65 #include "TObjString.h" 76 #include "TGraphAsymmErrors.h" 79 #include "TEfficiency.h" 99 void algoEndJob()
override;
102 void makeTKMap(
bool autoTagging);
103 void makeHotColdMaps();
105 void totalStatistics();
107 void makeSummaryVsBx();
108 void ComputeEff(vector< TH1F* > &vhfound, vector< TH1F* > &vhtotal,
string name);
109 void makeSummaryVsLumi();
110 void makeSummaryVsCM();
111 TString GetLayerName(Long_t
k);
112 TString GetLayerSideName(Long_t k);
113 float calcPhi(
float x,
float y);
151 map< pair< unsigned int, unsigned int>, array<double, 3> >
eventInfos;
155 map< unsigned int, pair< unsigned int, unsigned int> > modCounter[23];
171 int goodlayertotal[35];
172 int goodlayerfound[35];
173 int alllayertotal[35];
174 int alllayerfound[35];
180 FileInPath_(
"CalibTracker/SiStripCommon/data/SiStripDetInfo.dat")
206 if(_showRings) nTEClayers = 7;
235 ifstream badModules_file;
236 set<uint32_t> badModules_list;
239 uint32_t badmodule_detid;
240 int mods, fiber1, fiber2, fiber3;
241 if(badModules_file.is_open()) {
243 while ( getline (badModules_file,line) ) {
244 if(badModules_file.eof())
continue;
245 stringstream ss(line);
246 ss >> badmodule_detid >> mods >> fiber1 >> fiber2 >> fiber3;
247 if(badmodule_detid!=0 && mods==1 && (fiber1==1 || fiber2==1 || fiber3==1) )
248 badModules_list.insert(badmodule_detid);
250 badModules_file.close();
253 if(!badModules_list.empty())
cout<<
"Remove additionnal bad modules from the analysis: "<<endl;
254 set<uint32_t>::iterator itBadMod;
255 for (itBadMod=badModules_list.begin(); itBadMod!=badModules_list.end(); ++itBadMod)
256 cout<<
" "<<*itBadMod<<endl;
266 for(
int l=0;
l < 35;
l++) {
273 TH1F* resolutionPlots[23];
274 for(Long_t ilayer = 0; ilayer <23; ilayer++) {
275 resolutionPlots[ilayer] =
fs->
make<TH1F>(Form(
"resol_layer_%i",(
int)(ilayer)),
GetLayerName(ilayer),125,-125,125);
276 resolutionPlots[ilayer]->GetXaxis()->SetTitle(
"trajX-clusX [strip unit]");
292 else cout <<
"A module is bad if efficiency < the avg in layer - " <<
threshold <<
" and has at least " <<
nModsMin <<
" nModsMin." << endl;
295 unsigned int run, evt, bx;
305 bool foundEventInfos=
false;
307 CalibTreeFile->cd(
"eventInfo");
310 cout <<
"No event infos tree" << endl;
312 TTree* EventTree = (TTree*)(gDirectory->Get(
"tree"));
321 cout <<
"Found event infos tree" << endl;
323 runLf = EventTree->GetLeaf(
"run");
324 evtLf = EventTree->GetLeaf(
"event");
326 BunchLf = EventTree->GetLeaf(
"bx");
327 InstLumiLf = EventTree->GetLeaf(
"instLumi");
328 PULf = EventTree->GetLeaf(
"PU");
330 int nevt = EventTree->GetEntries();
331 if(nevt) foundEventInfos=
true;
333 for(
int j =0; j <
nevt; j++) {
334 EventTree->GetEntry(j);
335 run = runLf->GetValue();
336 evt = evtLf->GetValue();
337 bx = BunchLf->GetValue();
338 instLumi = InstLumiLf->GetValue();
339 PU = PULf->GetValue();
342 instLumiHisto->Fill(instLumi);
345 eventInfos[ make_pair(run, evt) ] = array<double, 3> {{ (double) bx, instLumi, PU}};
352 CalibTreeFile->cd(
"anEff");
353 CalibTree = (TTree*)(gDirectory->Get(
"traj"));
357 TLeaf* BadLf =
CalibTree->GetLeaf(
"ModIsBad");
358 TLeaf* sistripLf =
CalibTree->GetLeaf(
"SiStripQualBad");
360 TLeaf* acceptLf =
CalibTree->GetLeaf(
"withinAcceptance");
361 TLeaf* layerLf =
CalibTree->GetLeaf(
"layer");
363 TLeaf* highPurityLf =
CalibTree->GetLeaf(
"highPurity");
364 TLeaf* xLf =
CalibTree->GetLeaf(
"TrajGlbX");
365 TLeaf* yLf =
CalibTree->GetLeaf(
"TrajGlbY");
366 TLeaf* zLf =
CalibTree->GetLeaf(
"TrajGlbZ");
367 TLeaf* ResXSigLf =
CalibTree->GetLeaf(
"ResXSig");
368 TLeaf* TrajLocXLf =
CalibTree->GetLeaf(
"TrajLocX");
369 TLeaf* TrajLocYLf =
CalibTree->GetLeaf(
"TrajLocY");
370 TLeaf* ClusterLocXLf =
CalibTree->GetLeaf(
"ClusterLocX");
372 InstLumiLf =
CalibTree->GetLeaf(
"instLumi");
374 TLeaf* CMLf =
nullptr;
378 cout <<
"Successfully loaded analyze function with " << nevents <<
" events!\n";
381 map< pair< unsigned int, unsigned int>, array<double, 3> >::iterator itEventInfos;
385 for(
int j =0; j < nevents; j++) {
387 run = (
unsigned int)runLf->GetValue();
388 evt = (
unsigned int)evtLf->GetValue();
389 unsigned int isBad = (
unsigned int)BadLf->GetValue();
390 unsigned int quality = (
unsigned int)sistripLf->GetValue();
391 unsigned int id = (
unsigned int)idLf->GetValue();
392 unsigned int accept = (
unsigned int)acceptLf->GetValue();
393 unsigned int layer_wheel = (
unsigned int)layerLf->GetValue();
394 unsigned int layer = layer_wheel;
396 if(layer<14) layer = 10 + ((
id>>9)&0x3);
397 else layer = 13 + ((
id>>5)&0x7);
401 double x = xLf->GetValue();
402 double y = yLf->GetValue();
403 double z = zLf->GetValue();
404 double resxsig = ResXSigLf->GetValue();
405 double TrajLocX = TrajLocXLf->GetValue();
406 double TrajLocY = TrajLocYLf->GetValue();
407 double ClusterLocX = ClusterLocXLf->GetValue();
411 bool badquality =
false;
417 if(!foundEventInfos){
418 bx = (
unsigned int)BunchLf->GetValue();
419 if(InstLumiLf!=
nullptr) instLumi = InstLumiLf->GetValue();
420 if(PULf!=
nullptr) PU = PULf->GetValue();
423 if(
_useCM) CM = CMLf->GetValue();
429 itEventInfos =
eventInfos.find( make_pair(run, evt) );
431 bx = itEventInfos->second[0];
432 instLumi = itEventInfos->second[1];
433 PU = itEventInfos->second[2];
445 if(accept != 1)
continue;
447 if(quality == 1) badquality =
true;
450 if(!
_showTOB6TEC9 && (layer_wheel==10 || layer_wheel==22))
continue;
453 itBadMod = badModules_list.find(
id);
454 if(itBadMod!=badModules_list.end())
continue;
460 bool badflag =
false;
464 if(isBad == 1) badflag =
true;
467 if(isBad == 1 || resxsig >
_ResXSig) badflag =
true;
474 if (resxsig==1000.0) {
477 stripTrajMid = TrajLocX/Pitch + nstrips/2.0 ;
478 stripCluster = ClusterLocX/Pitch + nstrips/2.0 ;
481 DetId ClusterDetId(
id);
486 stripTrajMid = TrajLocX/Pitch + nstrips/2.0 ;
487 stripCluster = ClusterLocX/Pitch + nstrips/2.0 ;
496 const TrapezoidalPlaneBounds* trapezoidalBounds( dynamic_cast<const TrapezoidalPlaneBounds*>(&(plane.bounds())));
498 hbedge = parameters[0];
499 htedge = parameters[1];
500 hapoth = parameters[3];
501 TrajLocXMid = TrajLocX / (1 + (htedge-hbedge)*TrajLocY/(htedge+hbedge)/hapoth) ;
502 stripTrajMid = TrajLocXMid/Pitch + nstrips/2.0 ;
507 if(!badquality && layer<23) {
508 if(resxsig!=1000.0) resolutionPlots[layer]->Fill(stripTrajMid-stripCluster);
509 else resolutionPlots[layer]->Fill(1000);
516 float stripInAPV = 64.;
520 if(resxsig == 1000.0) {
528 tapv = (
int) stripTrajMid/128;
529 capv = (
int) stripCluster/128;
530 stripInAPV = stripTrajMid-tapv*128;
532 if(stripInAPV<_stripsApvEdge || stripInAPV>128-
_stripsApvEdge)
continue;
533 if(tapv != capv) badflag =
true;
540 if(badflag && !badquality) {
546 hits[layer].push_back(temphit);
548 pair<unsigned int, unsigned int> newgoodpair (1,1);
549 pair<unsigned int, unsigned int> newbadpair (1,0);
551 map< unsigned int, pair< unsigned int, unsigned int> >::iterator it =
modCounter[layer].find(
id);
558 ((*it).second.first)++;
559 if(!badflag) ((*it).second.second)++;
584 else if(layer > 10 && layer < 14) {
585 if( ((
id>>13)&0x3) == 1) {
589 else if( ((
id>>13)&0x3) == 2) {
594 else if(layer > 13 && layer <= 22) {
595 if( ((
id>>18)&0x3) == 1) {
599 else if( ((
id>>18)&0x3) == 2) {
610 else if(layer > 10 && layer < 14) {
611 if( ((
id>>13)&0x3) == 1) {
615 else if( ((
id>>13)&0x3) == 2) {
620 else if(layer > 13 && layer <= 22) {
621 if( ((
id>>18)&0x3) == 1) {
625 else if( ((
id>>18)&0x3) == 2) {
646 int NTkBadComponent[4];
647 int NBadComponent[4][19][4];
651 std::stringstream ssV[4][19];
653 for(
int i=0;
i<4;++
i){
654 NTkBadComponent[
i]=0;
655 for(
int j=0;j<19;++j){
658 NBadComponent[
i][j][
k]=0;
665 for (
size_t i=0;
i<BC.size();++
i){
672 NTkBadComponent[0]++;
674 NTkBadComponent[1]+= ( (BC[
i].BadFibers>>2)&0
x1 )+ ( (BC[
i].BadFibers>>1)&0
x1 ) + ( (BC[
i].BadFibers)&0
x1 );
676 NTkBadComponent[2]+= ( (BC[
i].BadApvs>>5)&0
x1 )+ ( (BC[
i].BadApvs>>4)&0
x1 ) + ( (BC[
i].BadApvs>>3)&0
x1 ) +
677 ( (BC[
i].BadApvs>>2)&0
x1 )+ ( (BC[
i].BadApvs>>1)&0
x1 ) + ( (BC[
i].BadApvs)&0
x1 );
729 unsigned int detid=rp->detid;
750 for(
int it=0;it<sqrange.second-sqrange.first;it++){
752 NTkBadComponent[3]+=range;
753 NBadComponent[subdet][0][3]+=range;
754 NBadComponent[subdet][component][3]+=range;
760 edm::LogError(
"SiStripQualityStatistics") <<
"PROBLEM detid " << detid <<
" value " << percentage<< std::endl;
766 cout <<
"\n-----------------\nNew IOV starting from run " << e.
id().
run() <<
" event " << e.
id().
event() <<
" lumiBlock " << e.
luminosityBlock() <<
" time " << e.
time().
value() <<
"\n-----------------\n";
767 cout <<
"\n-----------------\nGlobal Info\n-----------------";
768 cout <<
"\nBadComponent \t Modules \tFibers \tApvs\tStrips\n----------------------------------------------------------------";
769 cout <<
"\nTracker:\t\t"<<NTkBadComponent[0]<<
"\t"<<NTkBadComponent[1]<<
"\t"<<NTkBadComponent[2]<<
"\t"<<NTkBadComponent[3];
771 cout <<
"\nTIB:\t\t\t"<<NBadComponent[0][0][0]<<
"\t"<<NBadComponent[0][0][1]<<
"\t"<<NBadComponent[0][0][2]<<
"\t"<<NBadComponent[0][0][3];
772 cout <<
"\nTID:\t\t\t"<<NBadComponent[1][0][0]<<
"\t"<<NBadComponent[1][0][1]<<
"\t"<<NBadComponent[1][0][2]<<
"\t"<<NBadComponent[1][0][3];
773 cout <<
"\nTOB:\t\t\t"<<NBadComponent[2][0][0]<<
"\t"<<NBadComponent[2][0][1]<<
"\t"<<NBadComponent[2][0][2]<<
"\t"<<NBadComponent[2][0][3];
774 cout <<
"\nTEC:\t\t\t"<<NBadComponent[3][0][0]<<
"\t"<<NBadComponent[3][0][1]<<
"\t"<<NBadComponent[3][0][2]<<
"\t"<<NBadComponent[3][0][3];
777 for (
int i=1;
i<5;++
i)
778 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];
780 for (
int i=1;
i<4;++
i)
781 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];
782 for (
int i=4;
i<7;++
i)
783 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];
785 for (
int i=1;
i<7;++
i)
786 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];
788 for (
int i=1;
i<10;++
i)
789 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];
790 for (
int i=10;
i<19;++
i)
791 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];
794 cout <<
"\n----------------------------------------------------------------\n\t\t Detid \tModules Fibers Apvs\n----------------------------------------------------------------";
795 for (
int i=1;
i<5;++
i)
796 cout <<
"\nTIB Layer " <<
i <<
" :" << ssV[0][
i].
str();
798 for (
int i=1;
i<4;++
i)
799 cout <<
"\nTID+ Disk " <<
i <<
" :" << ssV[1][
i].
str();
800 for (
int i=4;
i<7;++
i)
801 cout <<
"\nTID- Disk " <<
i-3 <<
" :" << ssV[1][
i].
str();
803 for (
int i=1;
i<7;++
i)
804 cout <<
"\nTOB Layer " <<
i <<
" :" << ssV[2][
i].
str();
806 for (
int i=1;
i<10;++
i)
807 cout <<
"\nTEC+ Disk " <<
i <<
" :" << ssV[3][
i].
str();
808 for (
int i=10;
i<19;++
i)
809 cout <<
"\nTEC- Disk " <<
i-9 <<
" :" << ssV[3][
i].
str();
813 badModules.open(
"BadModules.log");
814 badModules <<
"\n----------------------------------------------------------------\n\t\t Detid \tModules Fibers Apvs\n----------------------------------------------------------------";
815 for (
int i=1;
i<5;++
i)
816 badModules <<
"\nTIB Layer " <<
i <<
" :" << ssV[0][
i].
str();
818 for (
int i=1;
i<4;++
i)
819 badModules <<
"\nTID+ Disk " <<
i <<
" :" << ssV[1][
i].
str();
820 for (
int i=4;
i<7;++
i)
821 badModules <<
"\nTID- Disk " <<
i-3 <<
" :" << ssV[1][
i].
str();
823 for (
int i=1;
i<7;++
i)
824 badModules <<
"\nTOB Layer " <<
i <<
" :" << ssV[2][
i].
str();
826 for (
int i=1;
i<10;++
i)
827 badModules <<
"\nTEC+ Disk " <<
i <<
" :" << ssV[3][
i].
str();
828 for (
int i=10;
i<19;++
i)
829 badModules <<
"\nTEC- Disk " <<
i-9 <<
" :" << ssV[3][
i].
str();
835 cout <<
"Entering hot cold map generation!\n";
836 TStyle* gStyle =
new TStyle(
"gStyle",
"myStyle");
838 gStyle->SetPalette(1);
839 gStyle->SetCanvasColor(kWhite);
840 gStyle->SetOptStat(0);
845 for(Long_t maplayer = 1; maplayer <=22; maplayer++) {
847 if(maplayer > 0 && maplayer <= 4) {
849 temph2 =
fs->
make<TH2F>(Form(
"%s%i",
"TIB",(
int)(maplayer)),
"TIB",100,-1,361,100,-100,100);
850 temph2->GetXaxis()->SetTitle(
"Phi");
851 temph2->GetXaxis()->SetBinLabel(1,TString(
"360"));
852 temph2->GetXaxis()->SetBinLabel(50,TString(
"180"));
853 temph2->GetXaxis()->SetBinLabel(100,TString(
"0"));
854 temph2->GetYaxis()->SetTitle(
"Global Z");
855 temph2->SetOption(
"colz");
858 else if(maplayer > 4 && maplayer <= 10) {
860 temph2 =
fs->
make<TH2F>(Form(
"%s%i",
"TOB",(
int)(maplayer-4)),
"TOB",100,-1,361,100,-120,120);
861 temph2->GetXaxis()->SetTitle(
"Phi");
862 temph2->GetXaxis()->SetBinLabel(1,TString(
"360"));
863 temph2->GetXaxis()->SetBinLabel(50,TString(
"180"));
864 temph2->GetXaxis()->SetBinLabel(100,TString(
"0"));
865 temph2->GetYaxis()->SetTitle(
"Global Z");
866 temph2->SetOption(
"colz");
869 else if(maplayer > 10 && maplayer <= 13) {
872 temph2 =
fs->
make<TH2F>(Form(
"%s%i",
"TID-",(
int)(maplayer-10)),
"TID-",100,-100,100,100,-100,100);
873 temph2->GetXaxis()->SetTitle(
"Global Y");
874 temph2->GetXaxis()->SetBinLabel(1,TString(
"+Y"));
875 temph2->GetXaxis()->SetBinLabel(50,TString(
"0"));
876 temph2->GetXaxis()->SetBinLabel(100,TString(
"-Y"));
877 temph2->GetYaxis()->SetTitle(
"Global X");
878 temph2->GetYaxis()->SetBinLabel(1,TString(
"-X"));
879 temph2->GetYaxis()->SetBinLabel(50,TString(
"0"));
880 temph2->GetYaxis()->SetBinLabel(100,TString(
"+X"));
881 temph2->SetOption(
"colz");
883 temph2 =
fs->
make<TH2F>(Form(
"%s%i",
"TID+",(
int)(maplayer-10)),
"TID+",100,-100,100,100,-100,100);
884 temph2->GetXaxis()->SetTitle(
"Global Y");
885 temph2->GetXaxis()->SetBinLabel(1,TString(
"+Y"));
886 temph2->GetXaxis()->SetBinLabel(50,TString(
"0"));
887 temph2->GetXaxis()->SetBinLabel(100,TString(
"-Y"));
888 temph2->GetYaxis()->SetTitle(
"Global X");
889 temph2->GetYaxis()->SetBinLabel(1,TString(
"-X"));
890 temph2->GetYaxis()->SetBinLabel(50,TString(
"0"));
891 temph2->GetYaxis()->SetBinLabel(100,TString(
"+X"));
892 temph2->SetOption(
"colz");
895 else if(maplayer > 13) {
898 temph2 =
fs->
make<TH2F>(Form(
"%s%i",
"TEC-",(
int)(maplayer-13)),
"TEC-",100,-120,120,100,-120,120);
899 temph2->GetXaxis()->SetTitle(
"Global Y");
900 temph2->GetXaxis()->SetBinLabel(1,TString(
"+Y"));
901 temph2->GetXaxis()->SetBinLabel(50,TString(
"0"));
902 temph2->GetXaxis()->SetBinLabel(100,TString(
"-Y"));
903 temph2->GetYaxis()->SetTitle(
"Global X");
904 temph2->GetYaxis()->SetBinLabel(1,TString(
"-X"));
905 temph2->GetYaxis()->SetBinLabel(50,TString(
"0"));
906 temph2->GetYaxis()->SetBinLabel(100,TString(
"+X"));
907 temph2->SetOption(
"colz");
909 temph2 =
fs->
make<TH2F>(Form(
"%s%i",
"TEC+",(
int)(maplayer-13)),
"TEC+",100,-120,120,100,-120,120);
910 temph2->GetXaxis()->SetTitle(
"Global Y");
911 temph2->GetXaxis()->SetBinLabel(1,TString(
"+Y"));
912 temph2->GetXaxis()->SetBinLabel(50,TString(
"0"));
913 temph2->GetXaxis()->SetBinLabel(100,TString(
"-Y"));
914 temph2->GetYaxis()->SetTitle(
"Global X");
915 temph2->GetYaxis()->SetBinLabel(1,TString(
"-X"));
916 temph2->GetYaxis()->SetBinLabel(50,TString(
"0"));
917 temph2->GetYaxis()->SetBinLabel(100,TString(
"+X"));
918 temph2->SetOption(
"colz");
922 for(Long_t mylayer = 1; mylayer <= 22; mylayer++) {
926 vector<hit>::const_iterator iter;
927 for(iter =
hits[mylayer].
begin(); iter !=
hits[mylayer].end(); iter++) {
931 if(mylayer > 0 && mylayer <= 4) {
934 HotColdMaps[mylayer - 1]->Fill(360.-phi,iter->z,1.);
936 else if(mylayer > 4 && mylayer <= 10) {
939 HotColdMaps[mylayer - 1]->Fill(360.-phi,iter->z,1.);
941 else if(mylayer > 10 && mylayer <= 13) {
944 int side = (((iter->id)>>13) & 0x3);
945 if(side == 1)
HotColdMaps[(mylayer - 1) + (mylayer - 11)]->Fill(-iter->y,iter->x,1.);
946 else if(side == 2)
HotColdMaps[(mylayer - 1) + (mylayer - 10)]->Fill(-iter->y,iter->x,1.);
950 else if(mylayer > 13) {
953 int side = (((iter->id)>>18) & 0x3);
954 if(side == 1)
HotColdMaps[(mylayer + 2) + (mylayer - 14)]->Fill(-iter->y,iter->x,1.);
955 else if(side == 2)
HotColdMaps[(mylayer + 2) + (mylayer - 13)]->Fill(-iter->y,iter->x,1.);
961 cout <<
"Finished HotCold Map Generation\n";
965 cout <<
"Entering TKMap generation!\n";
972 double myeff, mynum, myden;
975 for(Long_t
i = 1;
i <= 22;
i++) {
980 TH1F* hEffInLayer =
fs->
make<TH1F>(Form(
"eff_layer%i",
int(
i)),Form(
"Module efficiency in layer %i",
int(
i)), 201,0,1.005);
982 map<unsigned int, pair<unsigned int, unsigned int> >::const_iterator ih;
986 mynum = (double)(((*ih).second).second);
987 myden = (double)(((*ih).second).first);
988 if(myden>0) myeff = mynum/myden;
990 hEffInLayer->Fill(myeff);
997 cout <<
"Layer " <<
i <<
" ("<<
GetLayerName(
i) <<
") module " << (*ih).first <<
" efficiency: " << myeff <<
" , " << mynum <<
"/" << myden << endl;
1004 cout <<
"Layer " <<
i <<
" ("<<
GetLayerName(
i) <<
") module " << (*ih).first <<
" is under occupancy at " << myden << endl;
1011 tkmapnum->
fill((*ih).first,mynum);
1022 hEffInLayer->GetXaxis()->SetRange(3, hEffInLayer->GetNbinsX()+1);
1023 eff_limit = hEffInLayer->GetMean()-
threshold;
1024 cout <<
"Layer " <<
i <<
" threshold for bad modules: " << eff_limit << endl;
1025 hEffInLayer->GetXaxis()->SetRange(1, hEffInLayer->GetNbinsX()+1);
1030 mynum = (double)(((*ih).second).second);
1031 myden = (double)(((*ih).second).first);
1032 if(myden>0) myeff = mynum/myden;
1034 if ( (myden >=
nModsMin) && (myeff < eff_limit) ) {
1038 cout <<
"Layer " <<
i <<
" ("<<
GetLayerName(
i) <<
") module " << (*ih).first <<
" efficiency: " << myeff <<
" , " << mynum <<
"/" << myden << endl;
1045 cout <<
"Layer " <<
i <<
" ("<<
GetLayerName(
i) <<
") module " << (*ih).first <<
" layer " <<
i <<
" is under occupancy at " << myden << endl;
1053 tkmap->
save(
true, 0, 0,
"SiStripHitEffTKMap.png");
1054 tkmapbad->
save(
true, 0, 0,
"SiStripHitEffTKMapBad.png");
1056 tkmapnum->
save(
true, 0, 0,
"SiStripHitEffTKMapNum.png");
1057 tkmapden->
save(
true, 0, 0,
"SiStripHitEffTKMapDen.png");
1058 cout <<
"Finished TKMap Generation\n";
1064 cout <<
"Entering SQLite file generation!\n";
1065 std::vector<unsigned int> BadStripList;
1066 unsigned short NStrips;
1072 map< unsigned int, double >::const_iterator it;
1077 cout <<
"Number of strips module " << (*it).first <<
" is " << NStrips << endl;
1078 BadStripList.push_back(pQuality->
encode(0,NStrips,0));
1080 id1=(
unsigned int)(*it).first;
1081 cout <<
"ID1 shoudl match list of modules above " << id1 << endl;
1085 BadStripList.clear();
1099 for(Long_t
i=1;
i<5;
i++) {subdetfound[
i]=0; subdettotal[
i]=0;}
1101 for(Long_t
i=1;
i<=22;
i++) {
1113 cout <<
"The total efficiency is " << double(totalfound)/double(totaltotal) << endl;
1114 cout <<
" TIB: " << double(subdetfound[1])/subdettotal[1] <<
" "<< subdetfound[1]<<
"/"<<subdettotal[1]<< endl;
1115 cout <<
" TOB: " << double(subdetfound[2])/subdettotal[2] <<
" "<< subdetfound[2]<<
"/"<<subdettotal[2]<< endl;
1116 cout <<
" TID: " << double(subdetfound[3])/subdettotal[3] <<
" "<< subdetfound[3]<<
"/"<<subdettotal[3]<< endl;
1117 cout <<
" TEC: " << double(subdetfound[4])/subdettotal[4] <<
" "<< subdetfound[4]<<
"/"<<subdettotal[4]<< endl;
1130 TH1F *
found =
fs->
make<TH1F>(
"found",
"found",nLayers+1,0,nLayers+1);
1131 TH1F *
all =
fs->
make<TH1F>(
"all",
"all",nLayers+1,0,nLayers+1);
1132 TH1F *found2 =
fs->
make<TH1F>(
"found2",
"found2",nLayers+1,0,nLayers+1);
1133 TH1F *all2 =
fs->
make<TH1F>(
"all2",
"all2",nLayers+1,0,nLayers+1);
1135 found->SetBinContent(0,-1);
1136 all->SetBinContent(0,1);
1139 for (Long_t
i=1;
i< nLayers+2; ++
i) {
1140 found->SetBinContent(
i,1
e-6);
1141 all->SetBinContent(
i,1);
1142 found2->SetBinContent(
i,1
e-6);
1143 all2->SetBinContent(
i,1);
1146 TCanvas *c7 =
new TCanvas(
"c7",
" test ",10,10,800,600);
1147 c7->SetFillColor(0);
1150 int nLayers_max=nLayers+1;
1152 for (Long_t
i=1;
i< nLayers_max; ++
i) {
1169 for (Long_t
i=11;
i< 14; ++
i) {
1201 TGraphAsymmErrors *gr =
fs->
make<TGraphAsymmErrors>(nLayers+1);
1202 gr->SetName(
"eff_good");
1203 gr->BayesDivide(found,all);
1205 TGraphAsymmErrors *gr2 =
fs->
make<TGraphAsymmErrors>(nLayers+1);
1206 gr2->SetName(
"eff_all");
1207 gr2->BayesDivide(found2,all2);
1209 for(
int j = 0; j<nLayers+1; j++){
1210 gr->SetPointError(j, 0., 0., gr->GetErrorYlow(j),gr->GetErrorYhigh(j) );
1211 gr2->SetPointError(j, 0., 0., gr2->GetErrorYlow(j),gr2->GetErrorYhigh(j) );
1214 gr->GetXaxis()->SetLimits(0,nLayers);
1215 gr->SetMarkerColor(2);
1216 gr->SetMarkerSize(1.2);
1217 gr->SetLineColor(2);
1218 gr->SetLineWidth(4);
1219 gr->SetMarkerStyle(20);
1221 gr->SetMaximum(1.001);
1222 gr->GetYaxis()->SetTitle(
"Efficiency");
1223 gStyle->SetTitleFillColor(0);
1224 gStyle->SetTitleBorderSize(0);
1227 gr2->GetXaxis()->SetLimits(0,nLayers);
1228 gr2->SetMarkerColor(1);
1229 gr2->SetMarkerSize(1.2);
1230 gr2->SetLineColor(1);
1231 gr2->SetLineWidth(4);
1232 gr2->SetMarkerStyle(21);
1234 gr2->SetMaximum(1.001);
1235 gr2->GetYaxis()->SetTitle(
"Efficiency");
1238 for ( Long_t
k=1;
k<nLayers+1;
k++) {
1249 gr->GetXaxis()->SetBinLabel(((
k+1)*100+2)/(nLayers)-4,label);
1250 gr2->GetXaxis()->SetBinLabel(((
k+1)*100+2)/(nLayers)-4,label);
1253 gr->GetXaxis()->SetBinLabel((
k+1)*100/(nLayers)-6,label);
1254 gr2->GetXaxis()->SetBinLabel((
k+1)*100/(nLayers)-6,label);
1259 gr->GetXaxis()->SetBinLabel((
k+1)*100/(nLayers)-4,label);
1260 gr2->GetXaxis()->SetBinLabel((
k+1)*100/(nLayers)-4,label);
1263 gr->GetXaxis()->SetBinLabel((
k+1)*100/(nLayers)-7,label);
1264 gr2->GetXaxis()->SetBinLabel((
k+1)*100/(nLayers)-7,label);
1270 gr->GetXaxis()->SetNdivisions(36);
1273 TPad *
overlay =
new TPad(
"overlay",
"",0,0,1,1);
1274 overlay->SetFillStyle(4000);
1275 overlay->SetFillColor(0);
1276 overlay->SetFrameFillStyle(4000);
1277 overlay->Draw(
"same");
1281 TLegend *
leg =
new TLegend(0.70,0.27,0.88,0.40);
1282 leg->AddEntry(gr,
"Good Modules",
"p");
1284 leg->SetTextSize(0.020);
1285 leg->SetFillColor(0);
1288 c7->SaveAs(
"Summary.png");
1293 cout<<
"Computing efficiency vs bx"<<endl;
1298 for(
unsigned int ilayer=1; ilayer<
nLayers; ilayer++) {
1299 TH1F *hfound =
fs->
make<TH1F>(Form(
"foundVsBx_layer%i", ilayer),Form(
"layer %i", ilayer),3565,0,3565);
1300 TH1F *htotal =
fs->
make<TH1F>(Form(
"totalVsBx_layer%i", ilayer),Form(
"layer %i", ilayer),3565,0,3565);
1302 for(
unsigned int ibx=0; ibx<3566; ibx++){
1303 hfound->SetBinContent(ibx, 1
e-6);
1304 htotal->SetBinContent(ibx, 1);
1306 map<unsigned int, vector<int> >::iterator iterMapvsBx;
1308 hfound->SetBinContent( iterMapvsBx->first, iterMapvsBx->second[ilayer]);
1310 if(iterMapvsBx->second[ilayer]>0) htotal->SetBinContent( iterMapvsBx->first, iterMapvsBx->second[ilayer]);
1315 TGraphAsymmErrors *geff =
fs->
make<TGraphAsymmErrors>(3564);
1316 geff->SetName(Form(
"effVsBx_layer%i", ilayer));
1317 geff->SetTitle(
"Hit Efficiency vs bx - "+
GetLayerName(ilayer));
1318 geff->BayesDivide(hfound,htotal);
1321 TGraphAsymmErrors *geff_avg =
fs->
make<TGraphAsymmErrors>();
1322 geff_avg->SetName(Form(
"effVsBxAvg_layer%i", ilayer));
1323 geff_avg->SetTitle(
"Hit Efficiency vs bx - "+
GetLayerName(ilayer));
1324 geff_avg->SetMarkerStyle(20);
1326 int previous_bx=-80;
1336 ibx=iterMapvsBx->first;
1337 delta_bx=ibx-previous_bx;
1340 eff=found/(
float)total;
1342 geff_avg->SetPoint(ipt, sum_bx/nbx, eff);
1343 low = TEfficiency::Bayesian(total, found, .683, 1, 1,
false);
1344 up = TEfficiency::Bayesian(total, found, .683, 1, 1,
true);
1345 geff_avg->SetPointError(ipt, sum_bx/nbx-firstbx, previous_bx-sum_bx/nbx, eff-low, up-eff);
1354 found+=hfound->GetBinContent(ibx);
1355 total+=htotal->GetBinContent(ibx);
1361 eff=found/(
float)total;
1363 geff_avg->SetPoint(ipt, sum_bx/nbx, eff);
1364 low = TEfficiency::Bayesian(total, found, .683, 1, 1,
false);
1365 up = TEfficiency::Bayesian(total, found, .683, 1, 1,
true);
1366 geff_avg->SetPointError(ipt, sum_bx/nbx-firstbx, previous_bx-sum_bx/nbx, eff-low, up-eff);
1373 TString layername=
"";
1374 TString ringlabel=
"D";
1377 layername = TString(
"TIB L") +
k;
1378 }
else if (k>4 && k<11) {
1379 layername = TString(
"TOB L")+(k-4);
1380 }
else if (k>10 && k<14) {
1381 layername = TString(
"TID ")+ringlabel+(k-10);
1383 layername = TString(
"TEC ")+ringlabel+(k-13);
1397 for(
unsigned int ilayer=1; ilayer<
nLayers; ilayer++) {
1399 hfound = vhfound[ilayer];
1400 htotal = vhtotal[ilayer];
1406 for (Long_t
i=0;
i< hfound->GetNbinsX()+1; ++
i) {
1407 if( hfound->GetBinContent(
i)==0) hfound->SetBinContent(
i,1
e-6);
1408 if( htotal->GetBinContent(
i)==0) htotal->SetBinContent(
i,1);
1411 TGraphAsymmErrors *geff =
fs->
make<TGraphAsymmErrors>(hfound->GetNbinsX());
1412 geff->SetName(Form(
"%s_layer%i", name.c_str(), ilayer));
1413 geff->BayesDivide(hfound, htotal);
1414 if(name==
"effVsLumi") geff->SetTitle(
"Hit Efficiency vs inst. lumi. - "+
GetLayerName(ilayer));
1415 if(name==
"effVsPU") geff->SetTitle(
"Hit Efficiency vs pileup - "+
GetLayerName(ilayer));
1416 if(name==
"effVsCM") geff->SetTitle(
"Hit Efficiency vs common Mode - "+
GetLayerName(ilayer));
1417 geff->SetMarkerStyle(20);
1424 cout<<
"Computing efficiency vs lumi"<<endl;
1434 unsigned int nLayersForAvg = 0;
1435 float layerLumi = 0;
1440 cout<<
"Lumi summary: (avg over trajectory measurements)"<<endl;
1441 for(
unsigned int ilayer=1; ilayer<
nLayers; ilayer++) {
1445 if(layerLumi!=0 && layerPU!=0) {
1451 avgLumi/=nLayersForAvg;
1452 avgPU/=nLayersForAvg;
1453 cout<<
"Avg conditions: lumi :"<<avgLumi<<
" pu: "<<avgPU<<endl;
1462 cout<<
"Computing efficiency vs CM"<<endl;
1468 TString layername=
"";
1469 TString ringlabel=
"D";
1472 layername = TString(
"TIB L") +
k;
1473 }
else if (k>4&&k<11) {
1474 layername = TString(
"TOB L")+(k-4);
1475 }
else if (k>10&&k<14) {
1476 layername = TString(
"TID- ")+ringlabel+(k-10);
1477 }
else if (k>13&&k<17) {
1478 layername = TString(
"TID+ ")+ringlabel+(k-13);
1480 layername = TString(
"TEC- ")+ringlabel+(k-16);
1482 layername = TString(
"TEC+ ")+ringlabel+(k-16-
nTEClayers);
1496 for(;rIter!=rIterEnd;++rIter){
1498 if ( ! obj->
put(rIter->detid,range) )
1499 edm::LogError(
"SiStripHitEffFromCalibTree")<<
"[SiStripHitEffFromCalibTree::getNewObject] detid already exists"<<std::endl;
1508 if((x>=0)&&(y>=0)) phi = atan(y/x);
1509 else if((x>=0)&&(y<=0)) phi = atan(y/x) + 2*
Pi;
1510 else if((x<=0)&&(y>=0)) phi = atan(y/x) +
Pi;
1511 else phi = atan(y/x) +
Pi;
1521 ssV[
i][component] <<
"\n\t\t " 1531 ssV[
i][component] <<
" \t " 1535 ssV[
i][component] <<
"x x " << ( (BC.
BadApvs>>2)&0
x1 ) <<
" " 1538 ssV[
i][component] << ( (BC.
BadApvs>>2)&0
x1 ) <<
" " 1541 << ( (BC.
BadApvs>>5)&0x1 ) <<
" ";
1546 NBadComponent[
i][component][2]+= ( (BC.
BadApvs>>5)&0x1 )+ ( (BC.
BadApvs>>4)&0x1 ) + ( (BC.
BadApvs>>3)&0x1 ) +
1554 NBadComponent[
i][0][0]++;
1555 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
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)
#define DEFINE_FWK_MODULE(type)
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
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
SiStripBadStrip * getNewObject() override
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
unsigned int encode(const unsigned short &first, const unsigned short &NconsecutiveBadStrips, const unsigned short &flag=0)
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