65 #include "TObjString.h" 76 #include "TGraphAsymmErrors.h" 79 #include "TEfficiency.h" 101 void algoEndJob()
override;
104 void makeTKMap(
bool autoTagging);
105 void makeHotColdMaps();
107 void totalStatistics();
109 void makeSummaryVsBx();
110 void ComputeEff(vector< TH1F* > &vhfound, vector< TH1F* > &vhtotal,
string name);
111 void makeSummaryVsLumi();
112 void makeSummaryVsCM();
113 TString GetLayerName(Long_t
k);
114 TString GetLayerSideName(Long_t k);
115 float calcPhi(
float x,
float y);
121 std::unique_ptr<SiStripBadStrip> getNewObject()
override;
153 map< pair< unsigned int, unsigned int>, array<double, 3> >
eventInfos;
157 map< unsigned int, pair< unsigned int, unsigned int> > modCounter[23];
173 int goodlayertotal[35];
174 int goodlayerfound[35];
175 int alllayertotal[35];
176 int alllayerfound[35];
182 FileInPath_(
"CalibTracker/SiStripCommon/data/SiStripDetInfo.dat")
208 if(_showRings) nTEClayers = 7;
237 ifstream badModules_file;
238 set<uint32_t> badModules_list;
241 uint32_t badmodule_detid;
242 int mods, fiber1, fiber2, fiber3;
243 if(badModules_file.is_open()) {
245 while ( getline (badModules_file,line) ) {
246 if(badModules_file.eof())
continue;
247 stringstream ss(line);
248 ss >> badmodule_detid >> mods >> fiber1 >> fiber2 >> fiber3;
249 if(badmodule_detid!=0 && mods==1 && (fiber1==1 || fiber2==1 || fiber3==1) )
250 badModules_list.insert(badmodule_detid);
252 badModules_file.close();
255 if(!badModules_list.empty())
cout<<
"Remove additionnal bad modules from the analysis: "<<endl;
256 set<uint32_t>::iterator itBadMod;
257 for (itBadMod=badModules_list.begin(); itBadMod!=badModules_list.end(); ++itBadMod)
258 cout<<
" "<<*itBadMod<<endl;
268 for(
int l=0;
l < 35;
l++) {
275 TH1F* resolutionPlots[23];
276 for(Long_t ilayer = 0; ilayer <23; ilayer++) {
277 resolutionPlots[ilayer] =
fs->
make<TH1F>(Form(
"resol_layer_%i",(
int)(ilayer)),
GetLayerName(ilayer),125,-125,125);
278 resolutionPlots[ilayer]->GetXaxis()->SetTitle(
"trajX-clusX [strip unit]");
294 else cout <<
"A module is bad if efficiency < the avg in layer - " <<
threshold <<
" and has at least " <<
nModsMin <<
" nModsMin." << endl;
297 unsigned int run, evt, bx;
307 bool foundEventInfos=
false;
309 CalibTreeFile->cd(
"eventInfo");
312 cout <<
"No event infos tree" << endl;
314 TTree* EventTree = (TTree*)(gDirectory->Get(
"tree"));
323 cout <<
"Found event infos tree" << endl;
325 runLf = EventTree->GetLeaf(
"run");
326 evtLf = EventTree->GetLeaf(
"event");
328 BunchLf = EventTree->GetLeaf(
"bx");
329 InstLumiLf = EventTree->GetLeaf(
"instLumi");
330 PULf = EventTree->GetLeaf(
"PU");
332 int nevt = EventTree->GetEntries();
333 if(nevt) foundEventInfos=
true;
335 for(
int j =0; j <
nevt; j++) {
336 EventTree->GetEntry(j);
337 run = runLf->GetValue();
338 evt = evtLf->GetValue();
339 bx = BunchLf->GetValue();
340 instLumi = InstLumiLf->GetValue();
341 PU = PULf->GetValue();
344 instLumiHisto->Fill(instLumi);
347 eventInfos[ make_pair(run, evt) ] = array<double, 3> {{ (double) bx, instLumi, PU}};
354 CalibTreeFile->cd(
"anEff");
355 CalibTree = (TTree*)(gDirectory->Get(
"traj"));
359 TLeaf* BadLf =
CalibTree->GetLeaf(
"ModIsBad");
360 TLeaf* sistripLf =
CalibTree->GetLeaf(
"SiStripQualBad");
362 TLeaf* acceptLf =
CalibTree->GetLeaf(
"withinAcceptance");
363 TLeaf* layerLf =
CalibTree->GetLeaf(
"layer");
365 TLeaf* highPurityLf =
CalibTree->GetLeaf(
"highPurity");
366 TLeaf* xLf =
CalibTree->GetLeaf(
"TrajGlbX");
367 TLeaf* yLf =
CalibTree->GetLeaf(
"TrajGlbY");
368 TLeaf* zLf =
CalibTree->GetLeaf(
"TrajGlbZ");
369 TLeaf* ResXSigLf =
CalibTree->GetLeaf(
"ResXSig");
370 TLeaf* TrajLocXLf =
CalibTree->GetLeaf(
"TrajLocX");
371 TLeaf* TrajLocYLf =
CalibTree->GetLeaf(
"TrajLocY");
372 TLeaf* ClusterLocXLf =
CalibTree->GetLeaf(
"ClusterLocX");
374 InstLumiLf =
CalibTree->GetLeaf(
"instLumi");
376 TLeaf* CMLf =
nullptr;
380 cout <<
"Successfully loaded analyze function with " << nevents <<
" events!\n";
383 map< pair< unsigned int, unsigned int>, array<double, 3> >::iterator itEventInfos;
387 for(
int j =0; j < nevents; j++) {
389 run = (
unsigned int)runLf->GetValue();
390 evt = (
unsigned int)evtLf->GetValue();
391 unsigned int isBad = (
unsigned int)BadLf->GetValue();
392 unsigned int quality = (
unsigned int)sistripLf->GetValue();
393 unsigned int id = (
unsigned int)idLf->GetValue();
394 unsigned int accept = (
unsigned int)acceptLf->GetValue();
395 unsigned int layer_wheel = (
unsigned int)layerLf->GetValue();
396 unsigned int layer = layer_wheel;
398 if(layer<14) layer = 10 + ((
id>>9)&0x3);
399 else layer = 13 + ((
id>>5)&0x7);
403 double x = xLf->GetValue();
404 double y = yLf->GetValue();
405 double z = zLf->GetValue();
406 double resxsig = ResXSigLf->GetValue();
407 double TrajLocX = TrajLocXLf->GetValue();
408 double TrajLocY = TrajLocYLf->GetValue();
409 double ClusterLocX = ClusterLocXLf->GetValue();
413 bool badquality =
false;
419 if(!foundEventInfos){
420 bx = (
unsigned int)BunchLf->GetValue();
421 if(InstLumiLf!=
nullptr) instLumi = InstLumiLf->GetValue();
422 if(PULf!=
nullptr) PU = PULf->GetValue();
425 if(
_useCM) CM = CMLf->GetValue();
431 itEventInfos =
eventInfos.find( make_pair(run, evt) );
433 bx = itEventInfos->second[0];
434 instLumi = itEventInfos->second[1];
435 PU = itEventInfos->second[2];
447 if(accept != 1)
continue;
449 if(quality == 1) badquality =
true;
452 if(!
_showTOB6TEC9 && (layer_wheel==10 || layer_wheel==22))
continue;
455 itBadMod = badModules_list.find(
id);
456 if(itBadMod!=badModules_list.end())
continue;
462 bool badflag =
false;
466 if(isBad == 1) badflag =
true;
469 if(isBad == 1 || resxsig >
_ResXSig) badflag =
true;
476 if (resxsig==1000.0) {
479 stripTrajMid = TrajLocX/Pitch + nstrips/2.0 ;
480 stripCluster = ClusterLocX/Pitch + nstrips/2.0 ;
483 DetId ClusterDetId(
id);
488 stripTrajMid = TrajLocX/Pitch + nstrips/2.0 ;
489 stripCluster = ClusterLocX/Pitch + nstrips/2.0 ;
498 const TrapezoidalPlaneBounds* trapezoidalBounds( dynamic_cast<const TrapezoidalPlaneBounds*>(&(plane.bounds())));
500 hbedge = parameters[0];
501 htedge = parameters[1];
502 hapoth = parameters[3];
503 TrajLocXMid = TrajLocX / (1 + (htedge-hbedge)*TrajLocY/(htedge+hbedge)/hapoth) ;
504 stripTrajMid = TrajLocXMid/Pitch + nstrips/2.0 ;
509 if(!badquality && layer<23) {
510 if(resxsig!=1000.0) resolutionPlots[layer]->Fill(stripTrajMid-stripCluster);
511 else resolutionPlots[layer]->Fill(1000);
518 float stripInAPV = 64.;
522 if(resxsig == 1000.0) {
530 tapv = (
int) stripTrajMid/128;
531 capv = (
int) stripCluster/128;
532 stripInAPV = stripTrajMid-tapv*128;
534 if(stripInAPV<_stripsApvEdge || stripInAPV>128-
_stripsApvEdge)
continue;
535 if(tapv != capv) badflag =
true;
542 if(badflag && !badquality) {
548 hits[layer].push_back(temphit);
550 pair<unsigned int, unsigned int> newgoodpair (1,1);
551 pair<unsigned int, unsigned int> newbadpair (1,0);
553 map< unsigned int, pair< unsigned int, unsigned int> >::iterator it =
modCounter[layer].find(
id);
560 ((*it).second.first)++;
561 if(!badflag) ((*it).second.second)++;
586 else if(layer > 10 && layer < 14) {
587 if( ((
id>>13)&0x3) == 1) {
591 else if( ((
id>>13)&0x3) == 2) {
596 else if(layer > 13 && layer <= 22) {
597 if( ((
id>>18)&0x3) == 1) {
601 else if( ((
id>>18)&0x3) == 2) {
612 else if(layer > 10 && layer < 14) {
613 if( ((
id>>13)&0x3) == 1) {
617 else if( ((
id>>13)&0x3) == 2) {
622 else if(layer > 13 && layer <= 22) {
623 if( ((
id>>18)&0x3) == 1) {
627 else if( ((
id>>18)&0x3) == 2) {
648 int NTkBadComponent[4];
649 int NBadComponent[4][19][4];
653 std::stringstream ssV[4][19];
655 for(
int i=0;
i<4;++
i){
656 NTkBadComponent[
i]=0;
657 for(
int j=0;j<19;++j){
660 NBadComponent[
i][j][
k]=0;
667 for (
size_t i=0;
i<BC.size();++
i){
674 NTkBadComponent[0]++;
676 NTkBadComponent[1]+= ( (BC[
i].BadFibers>>2)&0
x1 )+ ( (BC[
i].BadFibers>>1)&0
x1 ) + ( (BC[
i].BadFibers)&0
x1 );
678 NTkBadComponent[2]+= ( (BC[
i].BadApvs>>5)&0
x1 )+ ( (BC[
i].BadApvs>>4)&0
x1 ) + ( (BC[
i].BadApvs>>3)&0
x1 ) +
679 ( (BC[
i].BadApvs>>2)&0
x1 )+ ( (BC[
i].BadApvs>>1)&0
x1 ) + ( (BC[
i].BadApvs)&0
x1 );
731 unsigned int detid=rp->detid;
752 for(
int it=0;it<sqrange.second-sqrange.first;it++){
754 NTkBadComponent[3]+=range;
755 NBadComponent[subdet][0][3]+=range;
756 NBadComponent[subdet][component][3]+=range;
762 edm::LogError(
"SiStripQualityStatistics") <<
"PROBLEM detid " << detid <<
" value " << percentage<< std::endl;
768 cout <<
"\n-----------------\nNew IOV starting from run " << e.
id().
run() <<
" event " << e.
id().
event() <<
" lumiBlock " << e.
luminosityBlock() <<
" time " << e.
time().
value() <<
"\n-----------------\n";
769 cout <<
"\n-----------------\nGlobal Info\n-----------------";
770 cout <<
"\nBadComponent \t Modules \tFibers \tApvs\tStrips\n----------------------------------------------------------------";
771 cout <<
"\nTracker:\t\t"<<NTkBadComponent[0]<<
"\t"<<NTkBadComponent[1]<<
"\t"<<NTkBadComponent[2]<<
"\t"<<NTkBadComponent[3];
773 cout <<
"\nTIB:\t\t\t"<<NBadComponent[0][0][0]<<
"\t"<<NBadComponent[0][0][1]<<
"\t"<<NBadComponent[0][0][2]<<
"\t"<<NBadComponent[0][0][3];
774 cout <<
"\nTID:\t\t\t"<<NBadComponent[1][0][0]<<
"\t"<<NBadComponent[1][0][1]<<
"\t"<<NBadComponent[1][0][2]<<
"\t"<<NBadComponent[1][0][3];
775 cout <<
"\nTOB:\t\t\t"<<NBadComponent[2][0][0]<<
"\t"<<NBadComponent[2][0][1]<<
"\t"<<NBadComponent[2][0][2]<<
"\t"<<NBadComponent[2][0][3];
776 cout <<
"\nTEC:\t\t\t"<<NBadComponent[3][0][0]<<
"\t"<<NBadComponent[3][0][1]<<
"\t"<<NBadComponent[3][0][2]<<
"\t"<<NBadComponent[3][0][3];
779 for (
int i=1;
i<5;++
i)
780 cout <<
"\nTIB Layer " <<
i <<
" :\t\t"<<NBadComponent[0][
i][0]<<
"\t"<<NBadComponent[0][
i][1]<<
"\t"<<NBadComponent[0][
i][2]<<
"\t"<<NBadComponent[0][
i][3];
782 for (
int i=1;
i<4;++
i)
783 cout <<
"\nTID+ Disk " <<
i <<
" :\t\t"<<NBadComponent[1][
i][0]<<
"\t"<<NBadComponent[1][
i][1]<<
"\t"<<NBadComponent[1][
i][2]<<
"\t"<<NBadComponent[1][
i][3];
784 for (
int i=4;
i<7;++
i)
785 cout <<
"\nTID- Disk " <<
i-3 <<
" :\t\t"<<NBadComponent[1][
i][0]<<
"\t"<<NBadComponent[1][
i][1]<<
"\t"<<NBadComponent[1][
i][2]<<
"\t"<<NBadComponent[1][
i][3];
787 for (
int i=1;
i<7;++
i)
788 cout <<
"\nTOB Layer " <<
i <<
" :\t\t"<<NBadComponent[2][
i][0]<<
"\t"<<NBadComponent[2][
i][1]<<
"\t"<<NBadComponent[2][
i][2]<<
"\t"<<NBadComponent[2][
i][3];
790 for (
int i=1;
i<10;++
i)
791 cout <<
"\nTEC+ Disk " <<
i <<
" :\t\t"<<NBadComponent[3][
i][0]<<
"\t"<<NBadComponent[3][
i][1]<<
"\t"<<NBadComponent[3][
i][2]<<
"\t"<<NBadComponent[3][
i][3];
792 for (
int i=10;
i<19;++
i)
793 cout <<
"\nTEC- Disk " <<
i-9 <<
" :\t\t"<<NBadComponent[3][
i][0]<<
"\t"<<NBadComponent[3][
i][1]<<
"\t"<<NBadComponent[3][
i][2]<<
"\t"<<NBadComponent[3][
i][3];
796 cout <<
"\n----------------------------------------------------------------\n\t\t Detid \tModules Fibers Apvs\n----------------------------------------------------------------";
797 for (
int i=1;
i<5;++
i)
798 cout <<
"\nTIB Layer " <<
i <<
" :" << ssV[0][
i].
str();
800 for (
int i=1;
i<4;++
i)
801 cout <<
"\nTID+ Disk " <<
i <<
" :" << ssV[1][
i].
str();
802 for (
int i=4;
i<7;++
i)
803 cout <<
"\nTID- Disk " <<
i-3 <<
" :" << ssV[1][
i].
str();
805 for (
int i=1;
i<7;++
i)
806 cout <<
"\nTOB Layer " <<
i <<
" :" << ssV[2][
i].
str();
808 for (
int i=1;
i<10;++
i)
809 cout <<
"\nTEC+ Disk " <<
i <<
" :" << ssV[3][
i].
str();
810 for (
int i=10;
i<19;++
i)
811 cout <<
"\nTEC- Disk " <<
i-9 <<
" :" << ssV[3][
i].
str();
815 badModules.open(
"BadModules.log");
816 badModules <<
"\n----------------------------------------------------------------\n\t\t Detid \tModules Fibers Apvs\n----------------------------------------------------------------";
817 for (
int i=1;
i<5;++
i)
818 badModules <<
"\nTIB Layer " <<
i <<
" :" << ssV[0][
i].
str();
820 for (
int i=1;
i<4;++
i)
821 badModules <<
"\nTID+ Disk " <<
i <<
" :" << ssV[1][
i].
str();
822 for (
int i=4;
i<7;++
i)
823 badModules <<
"\nTID- Disk " <<
i-3 <<
" :" << ssV[1][
i].
str();
825 for (
int i=1;
i<7;++
i)
826 badModules <<
"\nTOB Layer " <<
i <<
" :" << ssV[2][
i].
str();
828 for (
int i=1;
i<10;++
i)
829 badModules <<
"\nTEC+ Disk " <<
i <<
" :" << ssV[3][
i].
str();
830 for (
int i=10;
i<19;++
i)
831 badModules <<
"\nTEC- Disk " <<
i-9 <<
" :" << ssV[3][
i].
str();
837 cout <<
"Entering hot cold map generation!\n";
838 TStyle* gStyle =
new TStyle(
"gStyle",
"myStyle");
840 gStyle->SetPalette(1);
841 gStyle->SetCanvasColor(kWhite);
842 gStyle->SetOptStat(0);
847 for(Long_t maplayer = 1; maplayer <=22; maplayer++) {
849 if(maplayer > 0 && maplayer <= 4) {
851 temph2 =
fs->
make<TH2F>(Form(
"%s%i",
"TIB",(
int)(maplayer)),
"TIB",100,-1,361,100,-100,100);
852 temph2->GetXaxis()->SetTitle(
"Phi");
853 temph2->GetXaxis()->SetBinLabel(1,TString(
"360"));
854 temph2->GetXaxis()->SetBinLabel(50,TString(
"180"));
855 temph2->GetXaxis()->SetBinLabel(100,TString(
"0"));
856 temph2->GetYaxis()->SetTitle(
"Global Z");
857 temph2->SetOption(
"colz");
860 else if(maplayer > 4 && maplayer <= 10) {
862 temph2 =
fs->
make<TH2F>(Form(
"%s%i",
"TOB",(
int)(maplayer-4)),
"TOB",100,-1,361,100,-120,120);
863 temph2->GetXaxis()->SetTitle(
"Phi");
864 temph2->GetXaxis()->SetBinLabel(1,TString(
"360"));
865 temph2->GetXaxis()->SetBinLabel(50,TString(
"180"));
866 temph2->GetXaxis()->SetBinLabel(100,TString(
"0"));
867 temph2->GetYaxis()->SetTitle(
"Global Z");
868 temph2->SetOption(
"colz");
871 else if(maplayer > 10 && maplayer <= 13) {
874 temph2 =
fs->
make<TH2F>(Form(
"%s%i",
"TID-",(
int)(maplayer-10)),
"TID-",100,-100,100,100,-100,100);
875 temph2->GetXaxis()->SetTitle(
"Global Y");
876 temph2->GetXaxis()->SetBinLabel(1,TString(
"+Y"));
877 temph2->GetXaxis()->SetBinLabel(50,TString(
"0"));
878 temph2->GetXaxis()->SetBinLabel(100,TString(
"-Y"));
879 temph2->GetYaxis()->SetTitle(
"Global X");
880 temph2->GetYaxis()->SetBinLabel(1,TString(
"-X"));
881 temph2->GetYaxis()->SetBinLabel(50,TString(
"0"));
882 temph2->GetYaxis()->SetBinLabel(100,TString(
"+X"));
883 temph2->SetOption(
"colz");
885 temph2 =
fs->
make<TH2F>(Form(
"%s%i",
"TID+",(
int)(maplayer-10)),
"TID+",100,-100,100,100,-100,100);
886 temph2->GetXaxis()->SetTitle(
"Global Y");
887 temph2->GetXaxis()->SetBinLabel(1,TString(
"+Y"));
888 temph2->GetXaxis()->SetBinLabel(50,TString(
"0"));
889 temph2->GetXaxis()->SetBinLabel(100,TString(
"-Y"));
890 temph2->GetYaxis()->SetTitle(
"Global X");
891 temph2->GetYaxis()->SetBinLabel(1,TString(
"-X"));
892 temph2->GetYaxis()->SetBinLabel(50,TString(
"0"));
893 temph2->GetYaxis()->SetBinLabel(100,TString(
"+X"));
894 temph2->SetOption(
"colz");
897 else if(maplayer > 13) {
900 temph2 =
fs->
make<TH2F>(Form(
"%s%i",
"TEC-",(
int)(maplayer-13)),
"TEC-",100,-120,120,100,-120,120);
901 temph2->GetXaxis()->SetTitle(
"Global Y");
902 temph2->GetXaxis()->SetBinLabel(1,TString(
"+Y"));
903 temph2->GetXaxis()->SetBinLabel(50,TString(
"0"));
904 temph2->GetXaxis()->SetBinLabel(100,TString(
"-Y"));
905 temph2->GetYaxis()->SetTitle(
"Global X");
906 temph2->GetYaxis()->SetBinLabel(1,TString(
"-X"));
907 temph2->GetYaxis()->SetBinLabel(50,TString(
"0"));
908 temph2->GetYaxis()->SetBinLabel(100,TString(
"+X"));
909 temph2->SetOption(
"colz");
911 temph2 =
fs->
make<TH2F>(Form(
"%s%i",
"TEC+",(
int)(maplayer-13)),
"TEC+",100,-120,120,100,-120,120);
912 temph2->GetXaxis()->SetTitle(
"Global Y");
913 temph2->GetXaxis()->SetBinLabel(1,TString(
"+Y"));
914 temph2->GetXaxis()->SetBinLabel(50,TString(
"0"));
915 temph2->GetXaxis()->SetBinLabel(100,TString(
"-Y"));
916 temph2->GetYaxis()->SetTitle(
"Global X");
917 temph2->GetYaxis()->SetBinLabel(1,TString(
"-X"));
918 temph2->GetYaxis()->SetBinLabel(50,TString(
"0"));
919 temph2->GetYaxis()->SetBinLabel(100,TString(
"+X"));
920 temph2->SetOption(
"colz");
924 for(Long_t mylayer = 1; mylayer <= 22; mylayer++) {
928 vector<hit>::const_iterator iter;
929 for(iter =
hits[mylayer].
begin(); iter !=
hits[mylayer].end(); iter++) {
933 if(mylayer > 0 && mylayer <= 4) {
936 HotColdMaps[mylayer - 1]->Fill(360.-phi,iter->z,1.);
938 else if(mylayer > 4 && mylayer <= 10) {
941 HotColdMaps[mylayer - 1]->Fill(360.-phi,iter->z,1.);
943 else if(mylayer > 10 && mylayer <= 13) {
946 int side = (((iter->id)>>13) & 0x3);
947 if(side == 1)
HotColdMaps[(mylayer - 1) + (mylayer - 11)]->Fill(-iter->y,iter->x,1.);
948 else if(side == 2)
HotColdMaps[(mylayer - 1) + (mylayer - 10)]->Fill(-iter->y,iter->x,1.);
952 else if(mylayer > 13) {
955 int side = (((iter->id)>>18) & 0x3);
956 if(side == 1)
HotColdMaps[(mylayer + 2) + (mylayer - 14)]->Fill(-iter->y,iter->x,1.);
957 else if(side == 2)
HotColdMaps[(mylayer + 2) + (mylayer - 13)]->Fill(-iter->y,iter->x,1.);
963 cout <<
"Finished HotCold Map Generation\n";
967 cout <<
"Entering TKMap generation!\n";
974 double myeff, mynum, myden;
977 for(Long_t
i = 1;
i <= 22;
i++) {
982 TH1F* hEffInLayer =
fs->
make<TH1F>(Form(
"eff_layer%i",
int(
i)),Form(
"Module efficiency in layer %i",
int(
i)), 201,0,1.005);
984 map<unsigned int, pair<unsigned int, unsigned int> >::const_iterator ih;
988 mynum = (double)(((*ih).second).second);
989 myden = (double)(((*ih).second).first);
990 if(myden>0) myeff = mynum/myden;
992 hEffInLayer->Fill(myeff);
999 cout <<
"Layer " <<
i <<
" ("<<
GetLayerName(
i) <<
") module " << (*ih).first <<
" efficiency: " << myeff <<
" , " << mynum <<
"/" << myden << endl;
1006 cout <<
"Layer " <<
i <<
" ("<<
GetLayerName(
i) <<
") module " << (*ih).first <<
" is under occupancy at " << myden << endl;
1013 tkmapnum->
fill((*ih).first,mynum);
1024 hEffInLayer->GetXaxis()->SetRange(3, hEffInLayer->GetNbinsX()+1);
1025 eff_limit = hEffInLayer->GetMean()-
threshold;
1026 cout <<
"Layer " <<
i <<
" threshold for bad modules: " << eff_limit << endl;
1027 hEffInLayer->GetXaxis()->SetRange(1, hEffInLayer->GetNbinsX()+1);
1032 mynum = (double)(((*ih).second).second);
1033 myden = (double)(((*ih).second).first);
1034 if(myden>0) myeff = mynum/myden;
1036 if ( (myden >=
nModsMin) && (myeff < eff_limit) ) {
1040 cout <<
"Layer " <<
i <<
" ("<<
GetLayerName(
i) <<
") module " << (*ih).first <<
" efficiency: " << myeff <<
" , " << mynum <<
"/" << myden << endl;
1047 cout <<
"Layer " <<
i <<
" ("<<
GetLayerName(
i) <<
") module " << (*ih).first <<
" layer " <<
i <<
" is under occupancy at " << myden << endl;
1055 tkmap->
save(
true, 0, 0,
"SiStripHitEffTKMap.png");
1056 tkmapbad->
save(
true, 0, 0,
"SiStripHitEffTKMapBad.png");
1058 tkmapnum->
save(
true, 0, 0,
"SiStripHitEffTKMapNum.png");
1059 tkmapden->
save(
true, 0, 0,
"SiStripHitEffTKMapDen.png");
1060 cout <<
"Finished TKMap Generation\n";
1066 cout <<
"Entering SQLite file generation!\n";
1067 std::vector<unsigned int> BadStripList;
1068 unsigned short NStrips;
1070 std::unique_ptr<SiStripQuality> pQuality = std::make_unique<SiStripQuality>();
1074 map< unsigned int, double >::const_iterator it;
1079 cout <<
"Number of strips module " << (*it).first <<
" is " << NStrips << endl;
1080 BadStripList.push_back(pQuality->encode(0,NStrips,0));
1082 id1=(
unsigned int)(*it).first;
1083 cout <<
"ID1 shoudl match list of modules above " << id1 << endl;
1087 BadStripList.clear();
1101 for(Long_t
i=1;
i<5;
i++) {subdetfound[
i]=0; subdettotal[
i]=0;}
1103 for(Long_t
i=1;
i<=22;
i++) {
1115 cout <<
"The total efficiency is " << double(totalfound)/double(totaltotal) << endl;
1116 cout <<
" TIB: " << double(subdetfound[1])/subdettotal[1] <<
" "<< subdetfound[1]<<
"/"<<subdettotal[1]<< endl;
1117 cout <<
" TOB: " << double(subdetfound[2])/subdettotal[2] <<
" "<< subdetfound[2]<<
"/"<<subdettotal[2]<< endl;
1118 cout <<
" TID: " << double(subdetfound[3])/subdettotal[3] <<
" "<< subdetfound[3]<<
"/"<<subdettotal[3]<< endl;
1119 cout <<
" TEC: " << double(subdetfound[4])/subdettotal[4] <<
" "<< subdetfound[4]<<
"/"<<subdettotal[4]<< endl;
1132 TH1F *
found =
fs->
make<TH1F>(
"found",
"found",nLayers+1,0,nLayers+1);
1133 TH1F *
all =
fs->
make<TH1F>(
"all",
"all",nLayers+1,0,nLayers+1);
1134 TH1F *found2 =
fs->
make<TH1F>(
"found2",
"found2",nLayers+1,0,nLayers+1);
1135 TH1F *all2 =
fs->
make<TH1F>(
"all2",
"all2",nLayers+1,0,nLayers+1);
1137 found->SetBinContent(0,-1);
1138 all->SetBinContent(0,1);
1141 for (Long_t
i=1;
i< nLayers+2; ++
i) {
1142 found->SetBinContent(
i,1
e-6);
1143 all->SetBinContent(
i,1);
1144 found2->SetBinContent(
i,1
e-6);
1145 all2->SetBinContent(
i,1);
1148 TCanvas *c7 =
new TCanvas(
"c7",
" test ",10,10,800,600);
1149 c7->SetFillColor(0);
1152 int nLayers_max=nLayers+1;
1154 for (Long_t
i=1;
i< nLayers_max; ++
i) {
1171 for (Long_t
i=11;
i< 14; ++
i) {
1203 TGraphAsymmErrors *gr =
fs->
make<TGraphAsymmErrors>(nLayers+1);
1204 gr->SetName(
"eff_good");
1205 gr->BayesDivide(found,all);
1207 TGraphAsymmErrors *gr2 =
fs->
make<TGraphAsymmErrors>(nLayers+1);
1208 gr2->SetName(
"eff_all");
1209 gr2->BayesDivide(found2,all2);
1211 for(
int j = 0; j<nLayers+1; j++){
1212 gr->SetPointError(j, 0., 0., gr->GetErrorYlow(j),gr->GetErrorYhigh(j) );
1213 gr2->SetPointError(j, 0., 0., gr2->GetErrorYlow(j),gr2->GetErrorYhigh(j) );
1216 gr->GetXaxis()->SetLimits(0,nLayers);
1217 gr->SetMarkerColor(2);
1218 gr->SetMarkerSize(1.2);
1219 gr->SetLineColor(2);
1220 gr->SetLineWidth(4);
1221 gr->SetMarkerStyle(20);
1223 gr->SetMaximum(1.001);
1224 gr->GetYaxis()->SetTitle(
"Efficiency");
1225 gStyle->SetTitleFillColor(0);
1226 gStyle->SetTitleBorderSize(0);
1229 gr2->GetXaxis()->SetLimits(0,nLayers);
1230 gr2->SetMarkerColor(1);
1231 gr2->SetMarkerSize(1.2);
1232 gr2->SetLineColor(1);
1233 gr2->SetLineWidth(4);
1234 gr2->SetMarkerStyle(21);
1236 gr2->SetMaximum(1.001);
1237 gr2->GetYaxis()->SetTitle(
"Efficiency");
1240 for ( Long_t
k=1;
k<nLayers+1;
k++) {
1251 gr->GetXaxis()->SetBinLabel(((
k+1)*100+2)/(nLayers)-4,label);
1252 gr2->GetXaxis()->SetBinLabel(((
k+1)*100+2)/(nLayers)-4,label);
1255 gr->GetXaxis()->SetBinLabel((
k+1)*100/(nLayers)-6,label);
1256 gr2->GetXaxis()->SetBinLabel((
k+1)*100/(nLayers)-6,label);
1261 gr->GetXaxis()->SetBinLabel((
k+1)*100/(nLayers)-4,label);
1262 gr2->GetXaxis()->SetBinLabel((
k+1)*100/(nLayers)-4,label);
1265 gr->GetXaxis()->SetBinLabel((
k+1)*100/(nLayers)-7,label);
1266 gr2->GetXaxis()->SetBinLabel((
k+1)*100/(nLayers)-7,label);
1272 gr->GetXaxis()->SetNdivisions(36);
1275 TPad *
overlay =
new TPad(
"overlay",
"",0,0,1,1);
1276 overlay->SetFillStyle(4000);
1277 overlay->SetFillColor(0);
1278 overlay->SetFrameFillStyle(4000);
1279 overlay->Draw(
"same");
1283 TLegend *
leg =
new TLegend(0.70,0.27,0.88,0.40);
1284 leg->AddEntry(gr,
"Good Modules",
"p");
1286 leg->SetTextSize(0.020);
1287 leg->SetFillColor(0);
1290 c7->SaveAs(
"Summary.png");
1295 cout<<
"Computing efficiency vs bx"<<endl;
1300 for(
unsigned int ilayer=1; ilayer<
nLayers; ilayer++) {
1301 TH1F *hfound =
fs->
make<TH1F>(Form(
"foundVsBx_layer%i", ilayer),Form(
"layer %i", ilayer),3565,0,3565);
1302 TH1F *htotal =
fs->
make<TH1F>(Form(
"totalVsBx_layer%i", ilayer),Form(
"layer %i", ilayer),3565,0,3565);
1304 for(
unsigned int ibx=0; ibx<3566; ibx++){
1305 hfound->SetBinContent(ibx, 1
e-6);
1306 htotal->SetBinContent(ibx, 1);
1308 map<unsigned int, vector<int> >::iterator iterMapvsBx;
1310 hfound->SetBinContent( iterMapvsBx->first, iterMapvsBx->second[ilayer]);
1312 if(iterMapvsBx->second[ilayer]>0) htotal->SetBinContent( iterMapvsBx->first, iterMapvsBx->second[ilayer]);
1317 TGraphAsymmErrors *geff =
fs->
make<TGraphAsymmErrors>(3564);
1318 geff->SetName(Form(
"effVsBx_layer%i", ilayer));
1319 geff->SetTitle(
"Hit Efficiency vs bx - "+
GetLayerName(ilayer));
1320 geff->BayesDivide(hfound,htotal);
1323 TGraphAsymmErrors *geff_avg =
fs->
make<TGraphAsymmErrors>();
1324 geff_avg->SetName(Form(
"effVsBxAvg_layer%i", ilayer));
1325 geff_avg->SetTitle(
"Hit Efficiency vs bx - "+
GetLayerName(ilayer));
1326 geff_avg->SetMarkerStyle(20);
1328 int previous_bx=-80;
1338 ibx=iterMapvsBx->first;
1339 delta_bx=ibx-previous_bx;
1342 eff=found/(
float)total;
1344 geff_avg->SetPoint(ipt, sum_bx/nbx, eff);
1345 low = TEfficiency::Bayesian(total, found, .683, 1, 1,
false);
1346 up = TEfficiency::Bayesian(total, found, .683, 1, 1,
true);
1347 geff_avg->SetPointError(ipt, sum_bx/nbx-firstbx, previous_bx-sum_bx/nbx, eff-low, up-eff);
1356 found+=hfound->GetBinContent(ibx);
1357 total+=htotal->GetBinContent(ibx);
1363 eff=found/(
float)total;
1365 geff_avg->SetPoint(ipt, sum_bx/nbx, eff);
1366 low = TEfficiency::Bayesian(total, found, .683, 1, 1,
false);
1367 up = TEfficiency::Bayesian(total, found, .683, 1, 1,
true);
1368 geff_avg->SetPointError(ipt, sum_bx/nbx-firstbx, previous_bx-sum_bx/nbx, eff-low, up-eff);
1375 TString layername=
"";
1376 TString ringlabel=
"D";
1379 layername = TString(
"TIB L") +
k;
1380 }
else if (k>4 && k<11) {
1381 layername = TString(
"TOB L")+(k-4);
1382 }
else if (k>10 && k<14) {
1383 layername = TString(
"TID ")+ringlabel+(k-10);
1385 layername = TString(
"TEC ")+ringlabel+(k-13);
1399 for(
unsigned int ilayer=1; ilayer<
nLayers; ilayer++) {
1401 hfound = vhfound[ilayer];
1402 htotal = vhtotal[ilayer];
1408 for (Long_t
i=0;
i< hfound->GetNbinsX()+1; ++
i) {
1409 if( hfound->GetBinContent(
i)==0) hfound->SetBinContent(
i,1
e-6);
1410 if( htotal->GetBinContent(
i)==0) htotal->SetBinContent(
i,1);
1413 TGraphAsymmErrors *geff =
fs->
make<TGraphAsymmErrors>(hfound->GetNbinsX());
1414 geff->SetName(Form(
"%s_layer%i", name.c_str(), ilayer));
1415 geff->BayesDivide(hfound, htotal);
1416 if(name==
"effVsLumi") geff->SetTitle(
"Hit Efficiency vs inst. lumi. - "+
GetLayerName(ilayer));
1417 if(name==
"effVsPU") geff->SetTitle(
"Hit Efficiency vs pileup - "+
GetLayerName(ilayer));
1418 if(name==
"effVsCM") geff->SetTitle(
"Hit Efficiency vs common Mode - "+
GetLayerName(ilayer));
1419 geff->SetMarkerStyle(20);
1426 cout<<
"Computing efficiency vs lumi"<<endl;
1436 unsigned int nLayersForAvg = 0;
1437 float layerLumi = 0;
1442 cout<<
"Lumi summary: (avg over trajectory measurements)"<<endl;
1443 for(
unsigned int ilayer=1; ilayer<
nLayers; ilayer++) {
1447 if(layerLumi!=0 && layerPU!=0) {
1453 avgLumi/=nLayersForAvg;
1454 avgPU/=nLayersForAvg;
1455 cout<<
"Avg conditions: lumi :"<<avgLumi<<
" pu: "<<avgPU<<endl;
1464 cout<<
"Computing efficiency vs CM"<<endl;
1470 TString layername=
"";
1471 TString ringlabel=
"D";
1474 layername = TString(
"TIB L") +
k;
1475 }
else if (k>4&&k<11) {
1476 layername = TString(
"TOB L")+(k-4);
1477 }
else if (k>10&&k<14) {
1478 layername = TString(
"TID- ")+ringlabel+(k-10);
1479 }
else if (k>13&&k<17) {
1480 layername = TString(
"TID+ ")+ringlabel+(k-13);
1482 layername = TString(
"TEC- ")+ringlabel+(k-16);
1484 layername = TString(
"TEC+ ")+ringlabel+(k-16-
nTEClayers);
1493 auto obj = std::make_unique<SiStripBadStrip>();
1498 for(;rIter!=rIterEnd;++rIter){
1500 if ( !
obj->put(rIter->detid,range) )
1501 edm::LogError(
"SiStripHitEffFromCalibTree")<<
"[SiStripHitEffFromCalibTree::getNewObject] detid already exists"<<std::endl;
1510 if((x>=0)&&(y>=0)) phi = atan(y/x);
1511 else if((x>=0)&&(y<=0)) phi = atan(y/x) + 2*
Pi;
1512 else if((x<=0)&&(y>=0)) phi = atan(y/x) +
Pi;
1513 else phi = atan(y/x) +
Pi;
1523 ssV[
i][component] <<
"\n\t\t " 1533 ssV[
i][component] <<
" \t " 1537 ssV[
i][component] <<
"x x " << ( (BC.
BadApvs>>2)&0
x1 ) <<
" " 1540 ssV[
i][component] << ( (BC.
BadApvs>>2)&0
x1 ) <<
" " 1543 << ( (BC.
BadApvs>>5)&0x1 ) <<
" ";
1548 NBadComponent[
i][component][2]+= ( (BC.
BadApvs>>5)&0x1 )+ ( (BC.
BadApvs>>4)&0x1 ) + ( (BC.
BadApvs>>3)&0x1 ) +
1556 NBadComponent[
i][0][0]++;
1557 NBadComponent[
i][component][0]++;
vector< TH2F * > HotColdMaps
T getParameter(std::string const &) const
EventNumber_t event() const
T getUntrackedParameter(std::string const &, T const &) const
vector< TH1F * > layerfound_vsPU
std::unique_ptr< SiStripBadStrip > getNewObject() override
const std::vector< BadComponent > & getBadComponentList() const
unsigned int tibLayer(const DetId &id) const
vector< TH1F * > layertotal_vsPU
virtual const std::array< const float, 4 > parameters() const
const std::pair< unsigned short, double > getNumberOfApvsAndStripLength(uint32_t detId) const
TString GetLayerSideName(Long_t k)
vector< TH1F * > layertotal_vsCM
edm::LuminosityBlockNumber_t luminosityBlock() const
const Bounds & bounds() const
unsigned int tidWheel(const DetId &id) const
T * make(const Args &...args) const
make new ROOT object
void SetBadComponents(int i, int component, SiStripQuality::BadComponent &BC, std::stringstream ssV[4][19], int NBadComponent[4][19][4])
Registry::const_iterator RegistryIterator
SiStripDetInfoFileReader * reader
SiStripQuality * quality_
unsigned int _spaceBetweenTrains
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
virtual const StripTopology & specificTopology() const
Returns a reference to the strip proxy topology.
const Plane & surface() const
The nominal surface of the GeomDet.
virtual float width() const =0
const TrackerGeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
def overlay(hists, ytitle, header, addon)
unsigned int _clusterMatchingMethod
#define DEFINE_FWK_MODULE(type)
float calcPhi(float x, float y)
RegistryIterator getRegistryVectorEnd() const
edm::Service< TFileService > fs
map< unsigned int, vector< int > > layerfound_perBx
unsigned int tidSide(const DetId &id) const
void ComputeEff(vector< TH1F * > &vhfound, vector< TH1F * > &vhtotal, string name)
void algoBeginJob(const edm::EventSetup &) override
void save(bool print_total=true, float minval=0., float maxval=0., std::string s="svgmap.svg", int width=1500, int height=800)
void compact(unsigned int &, std::vector< unsigned int > &)
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
edm::FileInPath FileInPath_
Abs< T >::type abs(const T &t)
void makeTKMap(bool autoTagging)
map< pair< unsigned int, unsigned int >, array< double, 3 > > eventInfos
map< unsigned int, pair< unsigned int, unsigned int > > modCounter[23]
~SiStripHitEffFromCalibTree() override
bool _autoIneffModTagging
void fillc(int idmod, int RGBcode)
ContainerIterator getDataVectorBegin() const
Detector identifier class for the strip tracker.
bool _showOnlyGoodModules
bool _useOnlyHighPurityTracks
virtual int nstrips() const =0
void algoEndJob() override
vector< TH1F * > layertotal_vsLumi
vector< TH1F * > layerfound_vsCM
RegistryIterator getRegistryVectorBegin() const
map< unsigned int, vector< int > > layertotal_perBx
void algoAnalyze(const edm::Event &e, const edm::EventSetup &c) override
TString GetLayerName(Long_t k)
std::pair< ContainerIterator, ContainerIterator > Range
std::string fullPath() const
vector< string > CalibTreeFilenames
map< unsigned int, double > BadModules
bool put(const uint32_t &detID, const InputVector &vect)
unsigned int tecWheel(const DetId &id) const
T const * product() const
TimeValue_t value() const
SiStripHitEffFromCalibTree(const edm::ParameterSet &)
edm::Timestamp time() const
void fill(int layer, int ring, int nmod, float x)
data decode(const unsigned int &value) const
unsigned int tobLayer(const DetId &id) const
vector< TH1F * > layerfound_vsLumi
unsigned int tecSide(const DetId &id) const