From 0f5e32ae982b75d105a9979bf152fe707ee30f7b Mon Sep 17 00:00:00 2001 From: Jaime Leon Date: Thu, 23 May 2019 15:33:18 +0200 Subject: [PATCH] Added chi2 implementation --- .../DTPhase2Trigger/interface/analtypedefs.h | 8 + .../src/MuonPathAnalyzerPerSL.cc | 47 ++-- .../DTPhase2Trigger/src/MuonPathAssociator.cc | 203 +++++++++++------- 3 files changed, 165 insertions(+), 93 deletions(-) diff --git a/L1Trigger/DTPhase2Trigger/interface/analtypedefs.h b/L1Trigger/DTPhase2Trigger/interface/analtypedefs.h index 444f248fb9d24..94089392783c0 100644 --- a/L1Trigger/DTPhase2Trigger/interface/analtypedefs.h +++ b/L1Trigger/DTPhase2Trigger/interface/analtypedefs.h @@ -25,20 +25,28 @@ struct metaPrimitive int quality; int wi1; int tdc1; + int lat1; int wi2; int tdc2; + int lat2; int wi3; int tdc3; + int lat3; int wi4; int tdc4; + int lat4; int wi5; int tdc5; + int lat5; int wi6; int tdc6; + int lat6; int wi7; int tdc7; + int lat7; int wi8; int tdc8; + int lat8; int index; }; typedef struct { diff --git a/L1Trigger/DTPhase2Trigger/src/MuonPathAnalyzerPerSL.cc b/L1Trigger/DTPhase2Trigger/src/MuonPathAnalyzerPerSL.cc index 6d53fc4660daa..4a2aac61a35e8 100644 --- a/L1Trigger/DTPhase2Trigger/src/MuonPathAnalyzerPerSL.cc +++ b/L1Trigger/DTPhase2Trigger/src/MuonPathAnalyzerPerSL.cc @@ -156,7 +156,7 @@ void MuonPathAnalyzerPerSL::analyze(MuonPath *inMPath,std::vector // Clonamos el objeto analizado. MuonPath *mPath = new MuonPath(inMPath); - + if (mPath->isAnalyzable()) { if(debug) std::cout<<"DTp2:analyze \t\t\t\t\t yes it is analyzable "<isAnalyzable()<getCellHorizontalLayout() ); @@ -165,12 +165,12 @@ void MuonPathAnalyzerPerSL::analyze(MuonPath *inMPath,std::vector if(debug) std::cout<<"DTp2:analyze \t\t\t\t\t no it is NOT analyzable "<isAnalyzable()<getPrimitive(0)); wi[0]=Prim0.getChannelId();tdc[0]=Prim0.getTDCTime(); DTPrimitive Prim1(mPath->getPrimitive(1)); wi[1]=Prim1.getChannelId();tdc[1]=Prim1.getTDCTime(); DTPrimitive Prim2(mPath->getPrimitive(2)); wi[2]=Prim2.getChannelId();tdc[2]=Prim2.getTDCTime(); DTPrimitive Prim3(mPath->getPrimitive(3)); wi[3]=Prim3.getChannelId();tdc[3]=Prim3.getTDCTime(); - for(int i=4;i<8;i++){wi[i]=-1;tdc[i]=-1;} + for(int i=4;i<8;i++){wi[i]=-1;tdc[i]=-1;lat[i]=-1;} DTWireId wireId(MuonPathSLId,2,1); @@ -191,6 +191,8 @@ void MuonPathAnalyzerPerSL::analyze(MuonPath *inMPath,std::vector double chi2_phiB=-1; double chi2_chi2=-1; int chi2_quality=-1; + int bestLat[8]; + for(int i=0;i<8;i++){bestLat[i]=-1;} for (int i = 0; i < totalNumValLateralities; i++) {//here if(debug) std::cout<<"DTp2:analyze \t\t\t\t\t laterality #- "< // Clonamos el objeto analizado. MuonPath *mpAux = new MuonPath(mPath); - + lat[0] = mpAux->getLateralComb()[0]; + lat[1] = mpAux->getLateralComb()[1]; + lat[2] = mpAux->getLateralComb()[2]; + lat[3] = mpAux->getLateralComb()[3]; + int idxHitNotValid = latQuality[i].invalidateHitIdx; if (idxHitNotValid >= 0) { delete mpAux->getPrimitive(idxHitNotValid); @@ -282,18 +288,19 @@ void MuonPathAnalyzerPerSL::analyze(MuonPath *inMPath,std::vector chi2_phiB=phiB; chi2_chi2=chi2; chi2_quality= mpAux->getQuality(); + for(int i=0;i<4;i++){bestLat[i]=lat[i];} } }else if(fabs(jm_tanPhi)<=tanPhiTh){//write the metaprimitive in case no HIGHQ or HIGHQGHOST and tanPhi range if(debug) std::cout<<"DTp2:analyze \t\t\t\t\t\t\t\t pushing back metaprimitive no HIGHQ or HIGHQGHOST"< if(chi2_jm_tanPhi!=999 and fabs(chi2_jm_tanPhi) dtdigis, double NewSlope=(PosSL1-PosSL3)/23.5; double MeanT0=(SL1metaPrimitive->t0+SL3metaPrimitive->t0)/2; double MeanPos=(PosSL3+PosSL1)/2; - double newChi2=(SL1metaPrimitive->chi2+SL3metaPrimitive->chi2)*0.5;//to be recalculated - int quality = 0; + //double newChi2=(SL1metaPrimitive->chi2+SL3metaPrimitive->chi2)*0.5;//to be recalculated + + DTSuperLayerId SLId1(SL1metaPrimitive->rawId); + DTSuperLayerId SLId3(SL3metaPrimitive->rawId); + + DTWireId wireId1(SLId1,2,1); + DTWireId wireId3(SLId3,2,1); + + double x1 = shiftinfo[wireId1.rawId()]+(42.*SL1metaPrimitive->wi1+21. + (21./386.74)*(SL1metaPrimitive->tdc1-MeanT0)*(-1+2*SL1metaPrimitive->lat1))/10; + double x2 = shiftinfo[wireId1.rawId()]+(42.*SL1metaPrimitive->wi2+(21./386.74)*(SL1metaPrimitive->tdc2-MeanT0)*(-1+2*SL1metaPrimitive->lat2))/10; + double x3 = shiftinfo[wireId1.rawId()]+(42.*SL1metaPrimitive->wi3+21. + (21./386.74)*(SL1metaPrimitive->tdc3-MeanT0)*(-1+2*SL1metaPrimitive->lat3))/10; + double x4 = shiftinfo[wireId1.rawId()]+(42.*SL1metaPrimitive->wi4+(21./386.74)*(SL1metaPrimitive->tdc4-MeanT0)*(-1+2*SL1metaPrimitive->lat4))/10; + double x5 = shiftinfo[wireId3.rawId()]+(42.*SL3metaPrimitive->wi1+21. + (21./386.74)*(SL3metaPrimitive->tdc1-MeanT0)*(-1+2*SL3metaPrimitive->lat1))/10; + double x6 = shiftinfo[wireId3.rawId()]+(42.*SL3metaPrimitive->wi2+(21./386.74)*(SL3metaPrimitive->tdc2-MeanT0)*(-1+2*SL3metaPrimitive->lat2))/10; + double x7 = shiftinfo[wireId3.rawId()]+(42.*SL3metaPrimitive->wi3+21. + (21./386.74)*(SL3metaPrimitive->tdc3-MeanT0)*(-1+2*SL3metaPrimitive->lat3))/10; + double x8 = shiftinfo[wireId3.rawId()]+(42.*SL3metaPrimitive->wi4+(21./386.74)*(SL3metaPrimitive->tdc4-MeanT0)*(-1+2*SL3metaPrimitive->lat4))/10; + + double x1reco = MeanPos+(23.5/2 - (1-2.5)*1.3)*NewSlope; + double x2reco = MeanPos+(23.5/2 - (2-2.5)*1.3)*NewSlope; + double x3reco = MeanPos+(23.5/2 - (3-2.5)*1.3)*NewSlope; + double x4reco = MeanPos+(23.5/2 - (4-2.5)*1.3)*NewSlope; + double x5reco = MeanPos+(-23.5/2 - (1-2.5)*1.3)*NewSlope; + double x6reco = MeanPos+(-23.5/2 - (2-2.5)*1.3)*NewSlope; + double x7reco = MeanPos+(-23.5/2 - (3-2.5)*1.3)*NewSlope; + double x8reco = MeanPos+(-23.5/2 - (4-2.5)*1.3)*NewSlope; + + double newChi2 = (x1reco-x1)*(x1reco-x1)+(x2reco-x2)*(x2reco-x2)+(x3reco-x3)*(x3reco-x3)+(x4reco-x4)*(x4reco-x4)+(x5reco-x5)*(x5reco-x5)+(x6reco-x6)*(x6reco-x6)+(x7reco-x7)*(x7reco-x7)+(x8reco-x8)*(x8reco-x8); + + int quality = 0; if(SL3metaPrimitive->quality <= 2 and SL1metaPrimitive->quality <=2) quality=6; if((SL3metaPrimitive->quality >= 3 && SL1metaPrimitive->quality <=2) @@ -131,14 +158,14 @@ void MuonPathAssociator::correlateMPaths(edm::Handle dtdigis, double phiB=hasPosRF(ChId.wheel(),ChId.sector()) ? psi-phi :-psi-phi ; outMPaths.push_back(metaPrimitive({ChId.rawId(),MeanT0,MeanPos,NewSlope,phi,phiB,newChi2,quality, - SL1metaPrimitive->wi1,SL1metaPrimitive->tdc1, - SL1metaPrimitive->wi2,SL1metaPrimitive->tdc2, - SL1metaPrimitive->wi3,SL1metaPrimitive->tdc3, - SL1metaPrimitive->wi4,SL1metaPrimitive->tdc4, - SL3metaPrimitive->wi1,SL3metaPrimitive->tdc1, - SL3metaPrimitive->wi2,SL3metaPrimitive->tdc2, - SL3metaPrimitive->wi3,SL3metaPrimitive->tdc3, - SL3metaPrimitive->wi4,SL3metaPrimitive->tdc4, + SL1metaPrimitive->wi1,SL1metaPrimitive->tdc1,SL1metaPrimitive->lat1, + SL1metaPrimitive->wi2,SL1metaPrimitive->tdc2,SL1metaPrimitive->lat2, + SL1metaPrimitive->wi3,SL1metaPrimitive->tdc3,SL1metaPrimitive->lat3, + SL1metaPrimitive->wi4,SL1metaPrimitive->tdc4,SL1metaPrimitive->lat4, + SL3metaPrimitive->wi1,SL3metaPrimitive->tdc1,SL1metaPrimitive->lat5, + SL3metaPrimitive->wi2,SL3metaPrimitive->tdc2,SL1metaPrimitive->lat6, + SL3metaPrimitive->wi3,SL3metaPrimitive->tdc3,SL1metaPrimitive->lat7, + SL3metaPrimitive->wi4,SL3metaPrimitive->tdc4,SL1metaPrimitive->lat8, -1 })); at_least_one_correlation=true; @@ -148,12 +175,16 @@ void MuonPathAssociator::correlateMPaths(edm::Handle dtdigis, if(at_least_one_correlation==false){//no correlation was found, trying with pairs of two digis in the other SL int matched_digis=0; double minx=minx_match_2digis; + double min2x=minx_match_2digis; int best_tdc=-1; int next_tdc=-1; int best_wire=-1; int next_wire=-1; int best_layer=-1; int next_layer=-1; + int best_lat=-1; + int next_lat=-1; + int lat=-1; for (auto dtLayerId_It=dtdigis->begin(); dtLayerId_It!=dtdigis->end(); ++dtLayerId_It){ const DTLayerId dtLId = (*dtLayerId_It).first; @@ -169,16 +200,29 @@ void MuonPathAssociator::correlateMPaths(edm::Handle dtdigis, DTWireId wireId(dtLId,(*digiIt).wire()); int x_wire = shiftinfo[wireId.rawId()]+((*digiIt).time()-SL1metaPrimitive->t0)*0.00543; int x_wire_left = shiftinfo[wireId.rawId()]-((*digiIt).time()-SL1metaPrimitive->t0)*0.00543; - if(fabs(x_inSL3-x_wire)>fabs(x_inSL3-x_wire_left)) x_wire=x_wire_left; //choose the closest laterality + lat=1; + if(fabs(x_inSL3-x_wire)>fabs(x_inSL3-x_wire_left)){ + x_wire=x_wire_left; //choose the closest laterality + lat=0; + } if(fabs(x_inSL3-x_wire)=minx)&&(fabs(x_inSL3-x_wire) dtdigis, int new_quality=7; if(SL1metaPrimitive->quality<=2) new_quality=5; - int wi1=-1;int tdc1=-1; - int wi2=-1;int tdc2=-1; - int wi3=-1;int tdc3=-1; - int wi4=-1;int tdc4=-1; - - if(next_layer==1) {wi1=next_wire; tdc1=next_tdc; } - if(next_layer==2) {wi2=next_wire; tdc2=next_tdc; } - if(next_layer==3) {wi3=next_wire; tdc3=next_tdc; } - if(next_layer==4) {wi4=next_wire; tdc4=next_tdc; } - - if(best_layer==1) {wi1=best_wire; tdc1=best_tdc; } - if(best_layer==2) {wi2=best_wire; tdc2=best_tdc; } - if(best_layer==3) {wi3=best_wire; tdc3=best_tdc; } - if(best_layer==4) {wi4=best_wire; tdc4=best_tdc; } + int wi1=-1;int tdc1=-1;int lat1=-1; + int wi2=-1;int tdc2=-1;int lat2=-1; + int wi3=-1;int tdc3=-1;int lat3=-1; + int wi4=-1;int tdc4=-1;int lat4=-1; + if(next_layer==1) {wi1=next_wire; tdc1=next_tdc; lat1=next_lat;} + if(next_layer==2) {wi2=next_wire; tdc2=next_tdc; lat2=next_lat;} + if(next_layer==3) {wi3=next_wire; tdc3=next_tdc; lat3=next_lat;} + if(next_layer==4) {wi4=next_wire; tdc4=next_tdc; lat4=next_lat;} + if(best_layer==1) {wi1=best_wire; tdc1=best_tdc; lat1=best_lat;} + if(best_layer==2) {wi2=best_wire; tdc2=best_tdc; lat2=best_lat;} + if(best_layer==3) {wi3=best_wire; tdc3=best_tdc; lat3=best_lat;} + if(best_layer==4) {wi4=best_wire; tdc4=best_tdc; lat4=best_lat;} outMPaths.push_back(metaPrimitive({ChId.rawId(),SL1metaPrimitive->t0,SL1metaPrimitive->x,SL1metaPrimitive->tanPhi,SL1metaPrimitive->phi,SL1metaPrimitive->phiB,SL1metaPrimitive->chi2, new_quality, - SL1metaPrimitive->wi1,SL1metaPrimitive->tdc1, - SL1metaPrimitive->wi2,SL1metaPrimitive->tdc2, - SL1metaPrimitive->wi3,SL1metaPrimitive->tdc3, - SL1metaPrimitive->wi4,SL1metaPrimitive->tdc4, - wi1,tdc1, - wi2,tdc2, - wi3,tdc3, - wi4,tdc4, + SL1metaPrimitive->wi1,SL1metaPrimitive->tdc1,SL1metaPrimitive->lat1, + SL1metaPrimitive->wi2,SL1metaPrimitive->tdc2,SL1metaPrimitive->lat2, + SL1metaPrimitive->wi3,SL1metaPrimitive->tdc3,SL1metaPrimitive->lat3, + SL1metaPrimitive->wi4,SL1metaPrimitive->tdc4,SL1metaPrimitive->lat4, + wi1,tdc1,lat1, + wi2,tdc2,lat2, + wi3,tdc3,lat3, + wi4,tdc4,lat4, -1 })); at_least_one_correlation=true; @@ -237,12 +279,16 @@ void MuonPathAssociator::correlateMPaths(edm::Handle dtdigis, int matched_digis=0; double minx=minx_match_2digis; + double min2x=minx_match_2digis; int best_tdc=-1; int next_tdc=-1; int best_wire=-1; int next_wire=-1; int best_layer=-1; int next_layer=-1; + int best_lat=-1; + int next_lat=-1; + int lat=-1; for (auto dtLayerId_It=dtdigis->begin(); dtLayerId_It!=dtdigis->end(); ++dtLayerId_It){ const DTLayerId dtLId = (*dtLayerId_It).first; @@ -258,16 +304,29 @@ void MuonPathAssociator::correlateMPaths(edm::Handle dtdigis, DTWireId wireId(dtLId,(*digiIt).wire()); int x_wire = shiftinfo[wireId.rawId()]+((*digiIt).time()-SL3metaPrimitive->t0)*0.00543; int x_wire_left = shiftinfo[wireId.rawId()]-((*digiIt).time()-SL3metaPrimitive->t0)*0.00543; - if(fabs(x_inSL1-x_wire)>fabs(x_inSL1-x_wire_left)) x_wire=x_wire_left; //choose the closest laterality + lat=1; + if(fabs(x_inSL1-x_wire)>fabs(x_inSL1-x_wire_left)){ + x_wire=x_wire_left; //choose the closest laterality + lat=0; + } if(fabs(x_inSL1-x_wire)=minx)&&(fabs(x_inSL1-x_wire dtdigis, int new_quality=7; if(SL3metaPrimitive->quality<=2) new_quality=5; - int wi1=-1;int tdc1=-1; - int wi2=-1;int tdc2=-1; - int wi3=-1;int tdc3=-1; - int wi4=-1;int tdc4=-1; - - if(next_layer==1) {wi1=next_wire; tdc1=next_tdc; } - if(next_layer==2) {wi2=next_wire; tdc2=next_tdc; } - if(next_layer==3) {wi3=next_wire; tdc3=next_tdc; } - if(next_layer==4) {wi4=next_wire; tdc4=next_tdc; } - - if(best_layer==1) {wi1=best_wire; tdc1=best_tdc; } - if(best_layer==2) {wi2=best_wire; tdc2=best_tdc; } - if(best_layer==3) {wi3=best_wire; tdc3=best_tdc; } - if(best_layer==4) {wi4=best_wire; tdc4=best_tdc; } + int wi1=-1;int tdc1=-1;int lat1=-1; + int wi2=-1;int tdc2=-1;int lat2=-1; + int wi3=-1;int tdc3=-1;int lat3=-1; + int wi4=-1;int tdc4=-1;int lat4=-1; + if(next_layer==1) {wi1=next_wire; tdc1=next_tdc; lat1=next_lat;} + if(next_layer==2) {wi2=next_wire; tdc2=next_tdc; lat2=next_lat;} + if(next_layer==3) {wi3=next_wire; tdc3=next_tdc; lat3=next_lat;} + if(next_layer==4) {wi4=next_wire; tdc4=next_tdc; lat4=next_lat;} - + if(best_layer==1) {wi1=best_wire; tdc1=best_tdc; lat1=best_lat;} + if(best_layer==2) {wi2=best_wire; tdc2=best_tdc; lat2=best_lat;} + if(best_layer==3) {wi3=best_wire; tdc3=best_tdc; lat3=best_lat;} + if(best_layer==4) {wi4=best_wire; tdc4=best_tdc; lat4=best_lat;} + outMPaths.push_back(metaPrimitive({ChId.rawId(),SL3metaPrimitive->t0,SL3metaPrimitive->x,SL3metaPrimitive->tanPhi,SL3metaPrimitive->phi,SL3metaPrimitive->phiB,SL3metaPrimitive->chi2, new_quality, - wi1,tdc1, - wi2,tdc2, - wi3,tdc3, - wi4,tdc4, - SL3metaPrimitive->wi1,SL3metaPrimitive->tdc1, - SL3metaPrimitive->wi2,SL3metaPrimitive->tdc2, - SL3metaPrimitive->wi3,SL3metaPrimitive->tdc3, - SL3metaPrimitive->wi4,SL3metaPrimitive->tdc4, + wi1,tdc1,lat1, + wi2,tdc2,lat2, + wi3,tdc3,lat3, + wi4,tdc4,lat4, + SL3metaPrimitive->wi1,SL3metaPrimitive->tdc1,SL3metaPrimitive->lat1, + SL3metaPrimitive->wi2,SL3metaPrimitive->tdc2,SL3metaPrimitive->lat2, + SL3metaPrimitive->wi3,SL3metaPrimitive->tdc3,SL3metaPrimitive->lat3, + SL3metaPrimitive->wi4,SL3metaPrimitive->tdc4,SL3metaPrimitive->lat4, -1 })); at_least_one_correlation=true; @@ -319,14 +376,14 @@ void MuonPathAssociator::correlateMPaths(edm::Handle dtdigis, DTSuperLayerId SLId(SL1metaPrimitive->rawId); DTChamberId(SLId.wheel(),SLId.station(),SLId.sector()); outMPaths.push_back(metaPrimitive({ChId.rawId(),SL1metaPrimitive->t0,SL1metaPrimitive->x,SL1metaPrimitive->tanPhi,SL1metaPrimitive->phi,SL1metaPrimitive->phiB,SL1metaPrimitive->chi2,SL1metaPrimitive->quality, - SL1metaPrimitive->wi1,SL1metaPrimitive->tdc1, - SL1metaPrimitive->wi2,SL1metaPrimitive->tdc2, - SL1metaPrimitive->wi3,SL1metaPrimitive->tdc3, - SL1metaPrimitive->wi4,SL1metaPrimitive->tdc4, - -1,-1, - -1,-1, - -1,-1, - -1,-1, + SL1metaPrimitive->wi1,SL1metaPrimitive->tdc1,SL1metaPrimitive->lat1, + SL1metaPrimitive->wi2,SL1metaPrimitive->tdc2,SL1metaPrimitive->lat2, + SL1metaPrimitive->wi3,SL1metaPrimitive->tdc3,SL1metaPrimitive->lat3, + SL1metaPrimitive->wi4,SL1metaPrimitive->tdc4,SL1metaPrimitive->lat4, + -1,-1,-1, + -1,-1,-1, + -1,-1,-1, + -1,-1,-1, -1 })); } @@ -334,14 +391,14 @@ void MuonPathAssociator::correlateMPaths(edm::Handle dtdigis, DTSuperLayerId SLId(SL3metaPrimitive->rawId); DTChamberId(SLId.wheel(),SLId.station(),SLId.sector()); outMPaths.push_back(metaPrimitive({ChId.rawId(),SL3metaPrimitive->t0,SL3metaPrimitive->x,SL3metaPrimitive->tanPhi,SL3metaPrimitive->phi,SL3metaPrimitive->phiB,SL3metaPrimitive->chi2,SL3metaPrimitive->quality, - -1,-1, - -1,-1, - -1,-1, - -1,-1, - SL3metaPrimitive->wi1,SL3metaPrimitive->tdc1, - SL3metaPrimitive->wi2,SL3metaPrimitive->tdc2, - SL3metaPrimitive->wi3,SL3metaPrimitive->tdc3, - SL3metaPrimitive->wi4,SL3metaPrimitive->tdc4, + -1,-1,-1, + -1,-1,-1, + -1,-1,-1, + -1,-1,-1, + SL3metaPrimitive->wi1,SL3metaPrimitive->tdc1,SL3metaPrimitive->lat1, + SL3metaPrimitive->wi2,SL3metaPrimitive->tdc2,SL3metaPrimitive->lat2, + SL3metaPrimitive->wi3,SL3metaPrimitive->tdc3,SL3metaPrimitive->lat3, + SL3metaPrimitive->wi4,SL3metaPrimitive->tdc4,SL3metaPrimitive->lat4, -1 })); }