65 #include "TObjString.h"
76 #include "TGraphAsymmErrors.h"
79 #include "TEfficiency.h"
101 void algoEndJob()
override;
103 void SetBadComponents(
int i,
106 std::stringstream ssV[4][19],
107 int NBadComponent[4][19][4]);
108 void makeTKMap(
bool autoTagging);
109 void makeHotColdMaps();
111 void totalStatistics();
113 void makeSummaryVsBx();
114 void ComputeEff(vector<TH1F*>& vhfound, vector<TH1F*>& vhtotal,
string name);
115 void makeSummaryVsLumi();
116 void makeSummaryVsCM();
117 TString GetLayerName(Long_t
k);
118 TString GetLayerSideName(Long_t k);
119 float calcPhi(
float x,
float y);
125 std::unique_ptr<SiStripBadStrip> getNewObject()
override;
160 map<pair<unsigned int, unsigned int>, array<double, 3> >
eventInfos;
162 vector<hit> hits[23];
164 map<unsigned int, pair<unsigned int, unsigned int> > modCounter[23];
180 int goodlayertotal[35];
181 int goodlayerfound[35];
182 int alllayertotal[35];
183 int alllayerfound[35];
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())
248 stringstream
ss(line);
249 ss >> badmodule_detid >> mods >> fiber1 >> fiber2 >> fiber3;
250 if (badmodule_detid != 0 && mods == 1 && (fiber1 == 1 || fiber2 == 1 || fiber3 == 1))
251 badModules_list.insert(badmodule_detid);
253 badModules_file.close();
256 if (!badModules_list.empty())
257 cout <<
"Remove additionnal bad modules from the analysis: " << endl;
258 set<uint32_t>::iterator itBadMod;
259 for (itBadMod = badModules_list.begin(); itBadMod != badModules_list.end(); ++itBadMod)
260 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] =
278 fs->
make<TH1F>(Form(
"resol_layer_%i", (
int)(ilayer)),
GetLayerName(ilayer), 125, -125, 125);
279 resolutionPlots[ilayer]->GetXaxis()->SetTitle(
"trajX-clusX [strip unit]");
282 fs->
make<TH1F>(Form(
"layerfound_vsLumi_layer_%i", (
int)(ilayer)),
GetLayerName(ilayer), 100, 0, 25000));
284 fs->
make<TH1F>(Form(
"layertotal_vsLumi_layer_%i", (
int)(ilayer)),
GetLayerName(ilayer), 100, 0, 25000));
286 fs->
make<TH1F>(Form(
"layerfound_vsPU_layer_%i", (
int)(ilayer)),
GetLayerName(ilayer), 45, 0, 90));
288 fs->
make<TH1F>(Form(
"layertotal_vsPU_layer_%i", (
int)(ilayer)),
GetLayerName(ilayer), 45, 0, 90));
292 fs->
make<TH1F>(Form(
"layerfound_vsCM_layer_%i", (
int)(ilayer)),
GetLayerName(ilayer), 20, 0, 400));
294 fs->
make<TH1F>(Form(
"layertotal_vsCM_layer_%i", (
int)(ilayer)),
GetLayerName(ilayer), 20, 0, 400));
301 cout <<
"A module is bad if efficiency < " <<
threshold <<
" and has at least " <<
nModsMin <<
" nModsMin." << endl;
303 cout <<
"A module is bad if efficiency < the avg in layer - " <<
threshold <<
" and has at least " <<
nModsMin
304 <<
" nModsMin." << endl;
306 unsigned int run, evt,
bx{0};
315 bool foundEventInfos =
false;
317 CalibTreeFile->cd(
"eventInfo");
319 cout <<
"No event infos tree" << endl;
321 TTree*
EventTree = (TTree*)(gDirectory->Get(
"tree"));
329 cout <<
"Found event infos tree" << endl;
331 runLf = EventTree->GetLeaf(
"run");
332 evtLf = EventTree->GetLeaf(
"event");
334 BunchLf = EventTree->GetLeaf(
"bx");
335 InstLumiLf = EventTree->GetLeaf(
"instLumi");
336 PULf = EventTree->GetLeaf(
"PU");
338 int nevt = EventTree->GetEntries();
340 foundEventInfos =
true;
342 for (
int j = 0;
j <
nevt;
j++) {
343 EventTree->GetEntry(
j);
344 run = runLf->GetValue();
345 evt = evtLf->GetValue();
346 bx = BunchLf->GetValue();
347 instLumi = InstLumiLf->GetValue();
348 PU = PULf->GetValue();
351 instLumiHisto->Fill(instLumi);
354 eventInfos[make_pair(run, evt)] = array<double, 3>{{(double)
bx, instLumi, PU}};
359 CalibTreeFile->cd(
"anEff");
360 CalibTree = (TTree*)(gDirectory->Get(
"traj"));
364 TLeaf* BadLf =
CalibTree->GetLeaf(
"ModIsBad");
365 TLeaf* sistripLf =
CalibTree->GetLeaf(
"SiStripQualBad");
367 TLeaf* acceptLf =
CalibTree->GetLeaf(
"withinAcceptance");
368 TLeaf* layerLf =
CalibTree->GetLeaf(
"layer");
370 TLeaf* highPurityLf =
CalibTree->GetLeaf(
"highPurity");
371 TLeaf* xLf =
CalibTree->GetLeaf(
"TrajGlbX");
372 TLeaf* yLf =
CalibTree->GetLeaf(
"TrajGlbY");
373 TLeaf* zLf =
CalibTree->GetLeaf(
"TrajGlbZ");
374 TLeaf* ResXSigLf =
CalibTree->GetLeaf(
"ResXSig");
375 TLeaf* TrajLocXLf =
CalibTree->GetLeaf(
"TrajLocX");
376 TLeaf* TrajLocYLf =
CalibTree->GetLeaf(
"TrajLocY");
377 TLeaf* ClusterLocXLf =
CalibTree->GetLeaf(
"ClusterLocX");
379 InstLumiLf =
CalibTree->GetLeaf(
"instLumi");
381 TLeaf* CMLf =
nullptr;
386 cout <<
"Successfully loaded analyze function with " << nevents <<
" events!\n";
388 map<pair<unsigned int, unsigned int>, array<double, 3> >::iterator itEventInfos;
393 run = (
unsigned int)runLf->GetValue();
394 evt = (
unsigned int)evtLf->GetValue();
395 unsigned int isBad = (
unsigned int)BadLf->GetValue();
396 unsigned int quality = (
unsigned int)sistripLf->GetValue();
397 unsigned int id = (
unsigned int)idLf->GetValue();
398 unsigned int accept = (
unsigned int)acceptLf->GetValue();
399 unsigned int layer_wheel = (
unsigned int)layerLf->GetValue();
400 unsigned int layer = layer_wheel;
403 layer = 10 + ((
id >> 9) & 0x3);
405 layer = 13 + ((
id >> 5) & 0x7);
408 bool highPurity = (bool)highPurityLf->GetValue();
409 double x = xLf->GetValue();
410 double y = yLf->GetValue();
411 double z = zLf->GetValue();
412 double resxsig = ResXSigLf->GetValue();
413 double TrajLocX = TrajLocXLf->GetValue();
414 double TrajLocY = TrajLocYLf->GetValue();
415 double ClusterLocX = ClusterLocXLf->GetValue();
419 bool badquality =
false;
425 if (!foundEventInfos) {
426 bx = (
unsigned int)BunchLf->GetValue();
427 if (InstLumiLf !=
nullptr)
428 instLumi = InstLumiLf->GetValue();
430 PU = PULf->GetValue();
434 CM = CMLf->GetValue();
437 if (foundEventInfos) {
438 itEventInfos =
eventInfos.find(make_pair(run, evt));
440 bx = itEventInfos->second[0];
441 instLumi = itEventInfos->second[1];
442 PU = itEventInfos->second[2];
461 if (!
_showTOB6TEC9 && (layer_wheel == 10 || layer_wheel == 22))
465 itBadMod = badModules_list.find(
id);
466 if (itBadMod != badModules_list.end())
472 bool badflag =
false;
479 if (isBad == 1 || resxsig >
_ResXSig)
487 if (resxsig == 1000.0) {
490 stripTrajMid = TrajLocX / Pitch + nstrips / 2.0;
491 stripCluster = ClusterLocX / Pitch + nstrips / 2.0;
493 DetId ClusterDetId(
id);
498 stripTrajMid = TrajLocX / Pitch + nstrips / 2.0;
499 stripCluster = ClusterLocX / Pitch + nstrips / 2.0;
509 dynamic_cast<const TrapezoidalPlaneBounds*>(&(plane.bounds())));
510 std::array<const float, 4>
const&
parameters = (*trapezoidalBounds).parameters();
511 hbedge = parameters[0];
512 htedge = parameters[1];
513 hapoth = parameters[3];
514 TrajLocXMid = TrajLocX / (1 + (htedge - hbedge) * TrajLocY / (htedge + hbedge) /
516 stripTrajMid = TrajLocXMid / Pitch + nstrips / 2.0;
520 if (!badquality && layer < 23) {
521 if (resxsig != 1000.0)
522 resolutionPlots[
layer]->Fill(stripTrajMid - stripCluster);
524 resolutionPlots[
layer]->Fill(1000);
530 float stripInAPV = 64.;
534 if (resxsig == 1000.0) {
545 tapv = (int)stripTrajMid / 128;
546 capv = (int)stripCluster / 128;
547 stripInAPV = stripTrajMid - tapv * 128;
549 if (stripInAPV < _stripsApvEdge || stripInAPV > 128 -
_stripsApvEdge)
557 if (badflag && !badquality) {
565 pair<unsigned int, unsigned int> newgoodpair(1, 1);
566 pair<unsigned int, unsigned int> newbadpair(1, 0);
568 map<unsigned int, pair<unsigned int, unsigned int> >::iterator it =
modCounter[
layer].find(
id);
576 ((*it).second.first)++;
578 ((*it).second.second)++;
607 }
else if (layer > 10 && layer < 14) {
608 if (((
id >> 13) & 0x3) == 1) {
612 }
else if (((
id >> 13) & 0x3) == 2) {
617 }
else if (layer > 13 && layer <= 22) {
618 if (((
id >> 18) & 0x3) == 1) {
622 }
else if (((
id >> 18) & 0x3) == 2) {
634 }
else if (layer > 10 && layer < 14) {
635 if (((
id >> 13) & 0x3) == 1) {
639 }
else if (((
id >> 13) & 0x3) == 2) {
644 }
else if (layer > 13 && layer <= 22) {
645 if (((
id >> 18) & 0x3) == 1) {
649 }
else if (((
id >> 18) & 0x3) == 2) {
672 int NTkBadComponent[4];
673 int NBadComponent[4][19][4];
677 std::stringstream ssV[4][19];
679 for (
int i = 0;
i < 4; ++
i) {
680 NTkBadComponent[
i] = 0;
681 for (
int j = 0;
j < 19; ++
j) {
683 for (
int k = 0;
k < 4; ++
k)
684 NBadComponent[
i][
j][
k] = 0;
690 for (
size_t i = 0;
i < BC.size(); ++
i) {
696 NTkBadComponent[0]++;
698 NTkBadComponent[1] += ((BC[
i].BadFibers >> 2) & 0x1) + ((BC[
i].BadFibers >> 1) & 0x1) + ((BC[
i].BadFibers) & 0x1);
700 NTkBadComponent[2] += ((BC[
i].BadApvs >> 5) & 0x1) + ((BC[
i].BadApvs >> 4) & 0x1) + ((BC[
i].BadApvs >> 3) & 0x1) +
701 ((BC[
i].BadApvs >> 2) & 0x1) + ((BC[
i].BadApvs >> 1) & 0x1) + ((BC[
i].BadApvs) & 0x1);
714 component = tTopo.tibLayer(BC[
i].detid);
722 component = tTopo.tidSide(BC[
i].detid) == 2 ? tTopo.tidWheel(BC[
i].detid) : tTopo.tidWheel(BC[
i].detid) + 3;
730 component = tTopo.tobLayer(BC[
i].detid);
738 component = tTopo.tecSide(BC[
i].detid) == 2 ? tTopo.tecWheel(BC[
i].detid) : tTopo.tecWheel(BC[
i].detid) + 9;
746 float percentage = 0;
752 unsigned int detid = rp->detid;
759 component = tTopo.tibLayer(detid);
762 component = tTopo.tidSide(detid) == 2 ? tTopo.tidWheel(detid) : tTopo.tidWheel(detid) + 3;
765 component = tTopo.tobLayer(detid);
768 component = tTopo.tecSide(detid) == 2 ? tTopo.tecWheel(detid) : tTopo.tecWheel(detid) + 9;
775 for (
int it = 0; it < sqrange.second - sqrange.first; it++) {
777 NTkBadComponent[3] +=
range;
778 NBadComponent[subdet][0][3] +=
range;
779 NBadComponent[subdet][component][3] +=
range;
785 edm::LogError(
"SiStripQualityStatistics") <<
"PROBLEM detid " << detid <<
" value " << percentage << std::endl;
791 cout <<
"\n-----------------\nNew IOV starting from run " << e.id().run() <<
" event " << e.id().event()
792 <<
" lumiBlock " << e.luminosityBlock() <<
" time " << e.time().value() <<
"\n-----------------\n";
793 cout <<
"\n-----------------\nGlobal Info\n-----------------";
794 cout <<
"\nBadComponent \t Modules \tFibers "
795 "\tApvs\tStrips\n----------------------------------------------------------------";
796 cout <<
"\nTracker:\t\t" << NTkBadComponent[0] <<
"\t" << NTkBadComponent[1] <<
"\t" << NTkBadComponent[2] <<
"\t"
797 << NTkBadComponent[3];
799 cout <<
"\nTIB:\t\t\t" << NBadComponent[0][0][0] <<
"\t" << NBadComponent[0][0][1] <<
"\t" << NBadComponent[0][0][2]
800 <<
"\t" << NBadComponent[0][0][3];
801 cout <<
"\nTID:\t\t\t" << NBadComponent[1][0][0] <<
"\t" << NBadComponent[1][0][1] <<
"\t" << NBadComponent[1][0][2]
802 <<
"\t" << NBadComponent[1][0][3];
803 cout <<
"\nTOB:\t\t\t" << NBadComponent[2][0][0] <<
"\t" << NBadComponent[2][0][1] <<
"\t" << NBadComponent[2][0][2]
804 <<
"\t" << NBadComponent[2][0][3];
805 cout <<
"\nTEC:\t\t\t" << NBadComponent[3][0][0] <<
"\t" << NBadComponent[3][0][1] <<
"\t" << NBadComponent[3][0][2]
806 <<
"\t" << NBadComponent[3][0][3];
809 for (
int i = 1;
i < 5; ++
i)
810 cout <<
"\nTIB Layer " <<
i <<
" :\t\t" << NBadComponent[0][
i][0] <<
"\t" << NBadComponent[0][
i][1] <<
"\t"
811 << NBadComponent[0][
i][2] <<
"\t" << NBadComponent[0][
i][3];
813 for (
int i = 1;
i < 4; ++
i)
814 cout <<
"\nTID+ Disk " <<
i <<
" :\t\t" << NBadComponent[1][
i][0] <<
"\t" << NBadComponent[1][
i][1] <<
"\t"
815 << NBadComponent[1][
i][2] <<
"\t" << NBadComponent[1][
i][3];
816 for (
int i = 4;
i < 7; ++
i)
817 cout <<
"\nTID- Disk " <<
i - 3 <<
" :\t\t" << NBadComponent[1][
i][0] <<
"\t" << NBadComponent[1][
i][1] <<
"\t"
818 << NBadComponent[1][
i][2] <<
"\t" << NBadComponent[1][
i][3];
820 for (
int i = 1;
i < 7; ++
i)
821 cout <<
"\nTOB Layer " <<
i <<
" :\t\t" << NBadComponent[2][
i][0] <<
"\t" << NBadComponent[2][
i][1] <<
"\t"
822 << NBadComponent[2][
i][2] <<
"\t" << NBadComponent[2][
i][3];
824 for (
int i = 1;
i < 10; ++
i)
825 cout <<
"\nTEC+ Disk " <<
i <<
" :\t\t" << NBadComponent[3][
i][0] <<
"\t" << NBadComponent[3][
i][1] <<
"\t"
826 << NBadComponent[3][
i][2] <<
"\t" << NBadComponent[3][
i][3];
827 for (
int i = 10;
i < 19; ++
i)
828 cout <<
"\nTEC- Disk " <<
i - 9 <<
" :\t\t" << NBadComponent[3][
i][0] <<
"\t" << NBadComponent[3][
i][1] <<
"\t"
829 << NBadComponent[3][
i][2] <<
"\t" << NBadComponent[3][
i][3];
832 cout <<
"\n----------------------------------------------------------------\n\t\t Detid \tModules Fibers "
833 "Apvs\n----------------------------------------------------------------";
834 for (
int i = 1;
i < 5; ++
i)
835 cout <<
"\nTIB Layer " <<
i <<
" :" << ssV[0][
i].
str();
837 for (
int i = 1;
i < 4; ++
i)
838 cout <<
"\nTID+ Disk " <<
i <<
" :" << ssV[1][
i].
str();
839 for (
int i = 4;
i < 7; ++
i)
840 cout <<
"\nTID- Disk " <<
i - 3 <<
" :" << ssV[1][
i].
str();
842 for (
int i = 1;
i < 7; ++
i)
843 cout <<
"\nTOB Layer " <<
i <<
" :" << ssV[2][
i].
str();
845 for (
int i = 1;
i < 10; ++
i)
846 cout <<
"\nTEC+ Disk " <<
i <<
" :" << ssV[3][
i].
str();
847 for (
int i = 10;
i < 19; ++
i)
848 cout <<
"\nTEC- Disk " <<
i - 9 <<
" :" << ssV[3][
i].
str();
852 badModules.open(
"BadModules.log");
853 badModules <<
"\n----------------------------------------------------------------\n\t\t Detid \tModules Fibers "
854 "Apvs\n----------------------------------------------------------------";
855 for (
int i = 1;
i < 5; ++
i)
856 badModules <<
"\nTIB Layer " <<
i <<
" :" << ssV[0][
i].
str();
858 for (
int i = 1;
i < 4; ++
i)
859 badModules <<
"\nTID+ Disk " <<
i <<
" :" << ssV[1][
i].
str();
860 for (
int i = 4;
i < 7; ++
i)
861 badModules <<
"\nTID- Disk " <<
i - 3 <<
" :" << ssV[1][
i].
str();
863 for (
int i = 1;
i < 7; ++
i)
864 badModules <<
"\nTOB Layer " <<
i <<
" :" << ssV[2][
i].
str();
866 for (
int i = 1;
i < 10; ++
i)
867 badModules <<
"\nTEC+ Disk " <<
i <<
" :" << ssV[3][
i].
str();
868 for (
int i = 10;
i < 19; ++
i)
869 badModules <<
"\nTEC- Disk " <<
i - 9 <<
" :" << ssV[3][
i].
str();
874 cout <<
"Entering hot cold map generation!\n";
875 TStyle* gStyle =
new TStyle(
"gStyle",
"myStyle");
877 gStyle->SetPalette(1);
878 gStyle->SetCanvasColor(kWhite);
879 gStyle->SetOptStat(0);
884 for (Long_t maplayer = 1; maplayer <= 22; maplayer++) {
886 if (maplayer > 0 && maplayer <= 4) {
888 temph2 =
fs->
make<TH2F>(Form(
"%s%i",
"TIB", (
int)(maplayer)),
"TIB", 100, -1, 361, 100, -100, 100);
889 temph2->GetXaxis()->SetTitle(
"Phi");
890 temph2->GetXaxis()->SetBinLabel(1, TString(
"360"));
891 temph2->GetXaxis()->SetBinLabel(50, TString(
"180"));
892 temph2->GetXaxis()->SetBinLabel(100, TString(
"0"));
893 temph2->GetYaxis()->SetTitle(
"Global Z");
894 temph2->SetOption(
"colz");
896 }
else if (maplayer > 4 && maplayer <= 10) {
898 temph2 =
fs->
make<TH2F>(Form(
"%s%i",
"TOB", (
int)(maplayer - 4)),
"TOB", 100, -1, 361, 100, -120, 120);
899 temph2->GetXaxis()->SetTitle(
"Phi");
900 temph2->GetXaxis()->SetBinLabel(1, TString(
"360"));
901 temph2->GetXaxis()->SetBinLabel(50, TString(
"180"));
902 temph2->GetXaxis()->SetBinLabel(100, TString(
"0"));
903 temph2->GetYaxis()->SetTitle(
"Global Z");
904 temph2->SetOption(
"colz");
906 }
else if (maplayer > 10 && maplayer <= 13) {
909 temph2 =
fs->
make<TH2F>(Form(
"%s%i",
"TID-", (
int)(maplayer - 10)),
"TID-", 100, -100, 100, 100, -100, 100);
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");
920 temph2 =
fs->
make<TH2F>(Form(
"%s%i",
"TID+", (
int)(maplayer - 10)),
"TID+", 100, -100, 100, 100, -100, 100);
921 temph2->GetXaxis()->SetTitle(
"Global Y");
922 temph2->GetXaxis()->SetBinLabel(1, TString(
"+Y"));
923 temph2->GetXaxis()->SetBinLabel(50, TString(
"0"));
924 temph2->GetXaxis()->SetBinLabel(100, TString(
"-Y"));
925 temph2->GetYaxis()->SetTitle(
"Global X");
926 temph2->GetYaxis()->SetBinLabel(1, TString(
"-X"));
927 temph2->GetYaxis()->SetBinLabel(50, TString(
"0"));
928 temph2->GetYaxis()->SetBinLabel(100, TString(
"+X"));
929 temph2->SetOption(
"colz");
931 }
else if (maplayer > 13) {
934 temph2 =
fs->
make<TH2F>(Form(
"%s%i",
"TEC-", (
int)(maplayer - 13)),
"TEC-", 100, -120, 120, 100, -120, 120);
935 temph2->GetXaxis()->SetTitle(
"Global Y");
936 temph2->GetXaxis()->SetBinLabel(1, TString(
"+Y"));
937 temph2->GetXaxis()->SetBinLabel(50, TString(
"0"));
938 temph2->GetXaxis()->SetBinLabel(100, TString(
"-Y"));
939 temph2->GetYaxis()->SetTitle(
"Global X");
940 temph2->GetYaxis()->SetBinLabel(1, TString(
"-X"));
941 temph2->GetYaxis()->SetBinLabel(50, TString(
"0"));
942 temph2->GetYaxis()->SetBinLabel(100, TString(
"+X"));
943 temph2->SetOption(
"colz");
945 temph2 =
fs->
make<TH2F>(Form(
"%s%i",
"TEC+", (
int)(maplayer - 13)),
"TEC+", 100, -120, 120, 100, -120, 120);
946 temph2->GetXaxis()->SetTitle(
"Global Y");
947 temph2->GetXaxis()->SetBinLabel(1, TString(
"+Y"));
948 temph2->GetXaxis()->SetBinLabel(50, TString(
"0"));
949 temph2->GetXaxis()->SetBinLabel(100, TString(
"-Y"));
950 temph2->GetYaxis()->SetTitle(
"Global X");
951 temph2->GetYaxis()->SetBinLabel(1, TString(
"-X"));
952 temph2->GetYaxis()->SetBinLabel(50, TString(
"0"));
953 temph2->GetYaxis()->SetBinLabel(100, TString(
"+X"));
954 temph2->SetOption(
"colz");
958 for (Long_t mylayer = 1; mylayer <= 22; mylayer++) {
962 vector<hit>::const_iterator iter;
963 for (iter =
hits[mylayer].
begin(); iter !=
hits[mylayer].end(); iter++) {
967 if (mylayer > 0 && mylayer <= 4) {
970 HotColdMaps[mylayer - 1]->Fill(360. - phi, iter->z, 1.);
971 }
else if (mylayer > 4 && mylayer <= 10) {
974 HotColdMaps[mylayer - 1]->Fill(360. - phi, iter->z, 1.);
975 }
else if (mylayer > 10 && mylayer <= 13) {
978 int side = (((iter->id) >> 13) & 0x3);
980 HotColdMaps[(mylayer - 1) + (mylayer - 11)]->Fill(-iter->y, iter->x, 1.);
982 HotColdMaps[(mylayer - 1) + (mylayer - 10)]->Fill(-iter->y, iter->x, 1.);
985 }
else if (mylayer > 13) {
988 int side = (((iter->id) >> 18) & 0x3);
990 HotColdMaps[(mylayer + 2) + (mylayer - 14)]->Fill(-iter->y, iter->x, 1.);
992 HotColdMaps[(mylayer + 2) + (mylayer - 13)]->Fill(-iter->y, iter->x, 1.);
998 cout <<
"Finished HotCold Map Generation\n";
1002 cout <<
"Entering TKMap generation!\n";
1009 double myeff, mynum, myden;
1010 double eff_limit = 0;
1012 for (Long_t
i = 1;
i <= 22;
i++) {
1018 fs->
make<TH1F>(Form(
"eff_layer%i",
int(
i)), Form(
"Module efficiency in layer %i",
int(
i)), 201, 0, 1.005);
1020 map<unsigned int, pair<unsigned int, unsigned int> >::const_iterator ih;
1024 mynum = (double)(((*ih).second).second);
1025 myden = (double)(((*ih).second).first);
1027 myeff = mynum / myden;
1030 hEffInLayer->Fill(myeff);
1037 cout <<
"Layer " <<
i <<
" (" <<
GetLayerName(
i) <<
") module " << (*ih).first <<
" efficiency: " << myeff
1038 <<
" , " << mynum <<
"/" << myden << endl;
1044 cout <<
"Layer " <<
i <<
" (" <<
GetLayerName(
i) <<
") module " << (*ih).first <<
" is under occupancy at "
1052 tkmapnum->
fill((*ih).first, mynum);
1062 hEffInLayer->GetXaxis()->SetRange(3, hEffInLayer->GetNbinsX() + 1);
1063 eff_limit = hEffInLayer->GetMean() -
threshold;
1064 cout <<
"Layer " <<
i <<
" threshold for bad modules: " << eff_limit << endl;
1065 hEffInLayer->GetXaxis()->SetRange(1, hEffInLayer->GetNbinsX() + 1);
1069 mynum = (double)(((*ih).second).second);
1070 myden = (double)(((*ih).second).first);
1072 myeff = mynum / myden;
1075 if ((myden >=
nModsMin) && (myeff < eff_limit)) {
1079 cout <<
"Layer " <<
i <<
" (" <<
GetLayerName(
i) <<
") module " << (*ih).first <<
" efficiency: " << myeff
1080 <<
" , " << mynum <<
"/" << myden << endl;
1086 cout <<
"Layer " <<
i <<
" (" <<
GetLayerName(
i) <<
") module " << (*ih).first <<
" layer " <<
i
1087 <<
" is under occupancy at " << myden << endl;
1092 tkmap->
save(
true, 0, 0,
"SiStripHitEffTKMap.png");
1093 tkmapbad->
save(
true, 0, 0,
"SiStripHitEffTKMapBad.png");
1095 tkmapnum->
save(
true, 0, 0,
"SiStripHitEffTKMapNum.png");
1096 tkmapden->
save(
true, 0, 0,
"SiStripHitEffTKMapDen.png");
1097 cout <<
"Finished TKMap Generation\n";
1102 cout <<
"Entering SQLite file generation!\n";
1103 std::vector<unsigned int> BadStripList;
1104 unsigned short NStrips;
1106 std::unique_ptr<SiStripQuality> pQuality = std::make_unique<SiStripQuality>(
_detInfo);
1110 map<unsigned int, double>::const_iterator it;
1115 cout <<
"Number of strips module " << (*it).first <<
" is " << NStrips << endl;
1116 BadStripList.push_back(pQuality->encode(0, NStrips, 0));
1118 id1 = (
unsigned int)(*it).first;
1119 cout <<
"ID1 shoudl match list of modules above " << id1 << endl;
1123 BadStripList.clear();
1137 for (Long_t
i = 1;
i < 5;
i++) {
1142 for (Long_t
i = 1;
i <= 22;
i++) {
1152 if (i >= 5 && i < 11) {
1156 if (i >= 11 && i < 14) {
1166 cout <<
"The total efficiency is " << double(totalfound) / double(totaltotal) << endl;
1167 cout <<
" TIB: " << double(subdetfound[1]) / subdettotal[1] <<
" " << subdetfound[1] <<
"/" << subdettotal[1]
1169 cout <<
" TOB: " << double(subdetfound[2]) / subdettotal[2] <<
" " << subdetfound[2] <<
"/" << subdettotal[2]
1171 cout <<
" TID: " << double(subdetfound[3]) / subdettotal[3] <<
" " << subdetfound[3] <<
"/" << subdettotal[3]
1173 cout <<
" TEC: " << double(subdetfound[4]) / subdettotal[4] <<
" " << subdetfound[4] <<
"/" << subdettotal[4]
1190 TH1F*
found =
fs->
make<TH1F>(
"found",
"found", nLayers + 1, 0, nLayers + 1);
1191 TH1F*
all =
fs->
make<TH1F>(
"all",
"all", nLayers + 1, 0, nLayers + 1);
1192 TH1F* found2 =
fs->
make<TH1F>(
"found2",
"found2", nLayers + 1, 0, nLayers + 1);
1193 TH1F* all2 =
fs->
make<TH1F>(
"all2",
"all2", nLayers + 1, 0, nLayers + 1);
1195 found->SetBinContent(0, -1);
1196 all->SetBinContent(0, 1);
1199 for (Long_t
i = 1;
i < nLayers + 2; ++
i) {
1200 found->SetBinContent(
i, 1e-6);
1201 all->SetBinContent(
i, 1);
1202 found2->SetBinContent(
i, 1e-6);
1203 all2->SetBinContent(
i, 1);
1206 TCanvas* c7 =
new TCanvas(
"c7",
" test ", 10, 10, 800, 600);
1207 c7->SetFillColor(0);
1210 int nLayers_max = nLayers + 1;
1213 for (Long_t
i = 1;
i < nLayers_max; ++
i) {
1231 for (Long_t
i = 11;
i < 14; ++
i) {
1246 cout <<
"Fill only good modules layer " <<
i - 3
1268 TGraphAsymmErrors* gr =
fs->
make<TGraphAsymmErrors>(nLayers + 1);
1269 gr->SetName(
"eff_good");
1270 gr->BayesDivide(found, all);
1272 TGraphAsymmErrors* gr2 =
fs->
make<TGraphAsymmErrors>(nLayers + 1);
1273 gr2->SetName(
"eff_all");
1274 gr2->BayesDivide(found2, all2);
1276 for (
int j = 0;
j < nLayers + 1;
j++) {
1277 gr->SetPointError(
j, 0., 0., gr->GetErrorYlow(
j), gr->GetErrorYhigh(
j));
1278 gr2->SetPointError(
j, 0., 0., gr2->GetErrorYlow(
j), gr2->GetErrorYhigh(
j));
1281 gr->GetXaxis()->SetLimits(0, nLayers);
1282 gr->SetMarkerColor(2);
1283 gr->SetMarkerSize(1.2);
1284 gr->SetLineColor(2);
1285 gr->SetLineWidth(4);
1286 gr->SetMarkerStyle(20);
1288 gr->SetMaximum(1.001);
1289 gr->GetYaxis()->SetTitle(
"Efficiency");
1290 gStyle->SetTitleFillColor(0);
1291 gStyle->SetTitleBorderSize(0);
1294 gr2->GetXaxis()->SetLimits(0, nLayers);
1295 gr2->SetMarkerColor(1);
1296 gr2->SetMarkerSize(1.2);
1297 gr2->SetLineColor(1);
1298 gr2->SetLineWidth(4);
1299 gr2->SetMarkerStyle(21);
1301 gr2->SetMaximum(1.001);
1302 gr2->GetYaxis()->SetTitle(
"Efficiency");
1305 for (Long_t
k = 1;
k < nLayers + 1;
k++) {
1321 gr->GetXaxis()->SetBinLabel(((
k + 1) * 100 + 2) / (nLayers)-4, label);
1322 gr2->GetXaxis()->SetBinLabel(((
k + 1) * 100 + 2) / (nLayers)-4, label);
1324 gr->GetXaxis()->SetBinLabel((
k + 1) * 100 / (nLayers)-6, label);
1325 gr2->GetXaxis()->SetBinLabel((
k + 1) * 100 / (nLayers)-6, label);
1329 gr->GetXaxis()->SetBinLabel((
k + 1) * 100 / (nLayers)-4, label);
1330 gr2->GetXaxis()->SetBinLabel((
k + 1) * 100 / (nLayers)-4, label);
1332 gr->GetXaxis()->SetBinLabel((
k + 1) * 100 / (nLayers)-7, label);
1333 gr2->GetXaxis()->SetBinLabel((
k + 1) * 100 / (nLayers)-7, label);
1339 gr->GetXaxis()->SetNdivisions(36);
1342 TPad*
overlay =
new TPad(
"overlay",
"", 0, 0, 1, 1);
1343 overlay->SetFillStyle(4000);
1344 overlay->SetFillColor(0);
1345 overlay->SetFrameFillStyle(4000);
1346 overlay->Draw(
"same");
1351 TLegend* leg =
new TLegend(0.70, 0.27, 0.88, 0.40);
1352 leg->AddEntry(gr,
"Good Modules",
"p");
1354 leg->AddEntry(gr2,
"All Modules",
"p");
1355 leg->SetTextSize(0.020);
1356 leg->SetFillColor(0);
1359 c7->SaveAs(
"Summary.png");
1363 cout <<
"Computing efficiency vs bx" << endl;
1365 unsigned int nLayers = 22;
1369 for (
unsigned int ilayer = 1; ilayer < nLayers; ilayer++) {
1370 TH1F* hfound =
fs->
make<TH1F>(Form(
"foundVsBx_layer%i", ilayer), Form(
"layer %i", ilayer), 3565, 0, 3565);
1371 TH1F* htotal =
fs->
make<TH1F>(Form(
"totalVsBx_layer%i", ilayer), Form(
"layer %i", ilayer), 3565, 0, 3565);
1373 for (
unsigned int ibx = 0; ibx < 3566; ibx++) {
1374 hfound->SetBinContent(ibx, 1e-6);
1375 htotal->SetBinContent(ibx, 1);
1377 map<unsigned int, vector<int> >::iterator iterMapvsBx;
1379 hfound->SetBinContent(iterMapvsBx->first, iterMapvsBx->second[ilayer]);
1381 if (iterMapvsBx->second[ilayer] > 0)
1382 htotal->SetBinContent(iterMapvsBx->first, iterMapvsBx->second[ilayer]);
1387 TGraphAsymmErrors* geff =
fs->
make<TGraphAsymmErrors>(3564);
1388 geff->SetName(Form(
"effVsBx_layer%i", ilayer));
1389 geff->SetTitle(
"Hit Efficiency vs bx - " +
GetLayerName(ilayer));
1390 geff->BayesDivide(hfound, htotal);
1393 TGraphAsymmErrors* geff_avg =
fs->
make<TGraphAsymmErrors>();
1394 geff_avg->SetName(Form(
"effVsBxAvg_layer%i", ilayer));
1395 geff_avg->SetTitle(
"Hit Efficiency vs bx - " +
GetLayerName(ilayer));
1396 geff_avg->SetMarkerStyle(20);
1398 int previous_bx = -80;
1408 ibx = iterMapvsBx->first;
1409 delta_bx = ibx - previous_bx;
1412 eff = found / (float)total;
1414 geff_avg->SetPoint(ipt, sum_bx / nbx, eff);
1415 low = TEfficiency::Bayesian(total, found, .683, 1, 1,
false);
1416 up = TEfficiency::Bayesian(total, found, .683, 1, 1,
true);
1417 geff_avg->SetPointError(ipt, sum_bx / nbx - firstbx, previous_bx - sum_bx / nbx, eff - low, up - eff);
1426 found += hfound->GetBinContent(ibx);
1427 total += htotal->GetBinContent(ibx);
1433 eff = found / (float)total;
1435 geff_avg->SetPoint(ipt, sum_bx / nbx, eff);
1436 low = TEfficiency::Bayesian(total, found, .683, 1, 1,
false);
1437 up = TEfficiency::Bayesian(total, found, .683, 1, 1,
true);
1438 geff_avg->SetPointError(ipt, sum_bx / nbx - firstbx, previous_bx - sum_bx / nbx, eff - low, up - eff);
1443 TString layername =
"";
1444 TString ringlabel =
"D";
1447 if (k > 0 && k < 5) {
1448 layername = TString(
"TIB L") +
k;
1449 }
else if (k > 4 && k < 11) {
1450 layername = TString(
"TOB L") + (k - 4);
1451 }
else if (k > 10 && k < 14) {
1452 layername = TString(
"TID ") + ringlabel + (k - 10);
1454 layername = TString(
"TEC ") + ringlabel + (k - 13);
1461 unsigned int nLayers = 22;
1468 for (
unsigned int ilayer = 1; ilayer < nLayers; ilayer++) {
1469 hfound = vhfound[ilayer];
1470 htotal = vhtotal[ilayer];
1476 for (Long_t
i = 0;
i < hfound->GetNbinsX() + 1; ++
i) {
1477 if (hfound->GetBinContent(
i) == 0)
1478 hfound->SetBinContent(
i, 1e-6);
1479 if (htotal->GetBinContent(
i) == 0)
1480 htotal->SetBinContent(
i, 1);
1483 TGraphAsymmErrors* geff =
fs->
make<TGraphAsymmErrors>(hfound->GetNbinsX());
1484 geff->SetName(Form(
"%s_layer%i", name.c_str(), ilayer));
1485 geff->BayesDivide(hfound, htotal);
1486 if (name ==
"effVsLumi")
1487 geff->SetTitle(
"Hit Efficiency vs inst. lumi. - " +
GetLayerName(ilayer));
1488 if (name ==
"effVsPU")
1489 geff->SetTitle(
"Hit Efficiency vs pileup - " +
GetLayerName(ilayer));
1490 if (name ==
"effVsCM")
1491 geff->SetTitle(
"Hit Efficiency vs common Mode - " +
GetLayerName(ilayer));
1492 geff->SetMarkerStyle(20);
1497 cout <<
"Computing efficiency vs lumi" << endl;
1499 if (instLumiHisto->GetEntries())
1500 cout <<
"Avg conditions (avg+/-rms): lumi :" << instLumiHisto->GetMean() <<
"+/-" << instLumiHisto->GetRMS()
1501 <<
" pu: " << PUHisto->GetMean() <<
"+/-" << PUHisto->GetRMS() << endl;
1505 unsigned int nLayers = 22;
1508 unsigned int nLayersForAvg = 0;
1509 float layerLumi = 0;
1514 cout <<
"Lumi summary: (avg over trajectory measurements)" << endl;
1515 for (
unsigned int ilayer = 1; ilayer < nLayers; ilayer++) {
1519 if (layerLumi != 0 && layerPU != 0) {
1520 avgLumi += layerLumi;
1525 avgLumi /= nLayersForAvg;
1526 avgPU /= nLayersForAvg;
1527 cout <<
"Avg conditions: lumi :" << avgLumi <<
" pu: " << avgPU << endl;
1535 cout <<
"Computing efficiency vs CM" << endl;
1540 TString layername =
"";
1541 TString ringlabel =
"D";
1544 if (k > 0 && k < 5) {
1545 layername = TString(
"TIB L") +
k;
1546 }
else if (k > 4 && k < 11) {
1547 layername = TString(
"TOB L") + (k - 4);
1548 }
else if (k > 10 && k < 14) {
1549 layername = TString(
"TID- ") + ringlabel + (k - 10);
1550 }
else if (k > 13 && k < 17) {
1551 layername = TString(
"TID+ ") + ringlabel + (k - 13);
1553 layername = TString(
"TEC- ") + ringlabel + (k - 16);
1555 layername = TString(
"TEC+ ") + ringlabel + (k - 16 -
nTEClayers);
1564 auto obj = std::make_unique<SiStripBadStrip>();
1569 for (; rIter != rIterEnd; ++rIter) {
1572 if (!
obj->put(rIter->detid,
range))
1574 <<
"[SiStripHitEffFromCalibTree::getNewObject] detid already exists" << std::endl;
1583 if ((x >= 0) && (y >= 0))
1585 else if ((x >= 0) && (y <= 0))
1586 phi = atan(y / x) + 2 *
Pi;
1587 else if ((x <= 0) && (y >= 0))
1588 phi = atan(y / x) +
Pi;
1590 phi = atan(y / x) +
Pi;
1591 phi = phi * 180.0 /
Pi;
1602 ssV[
i][component] <<
"x " << ((BC.
BadFibers >> 1) & 0x1);
1606 ssV[
i][component] <<
" \t " << ((BC.
BadApvs) & 0x1) <<
" " << ((BC.
BadApvs >> 1) & 0x1) <<
" ";
1608 ssV[
i][component] <<
"x x " << ((BC.
BadApvs >> 2) & 0x1) <<
" " << ((BC.
BadApvs >> 3) & 0x1);
1610 ssV[
i][component] << ((BC.
BadApvs >> 2) & 0x1) <<
" " << ((BC.
BadApvs >> 3) & 0x1) <<
" "
1611 << ((BC.
BadApvs >> 4) & 0x1) <<
" " << ((BC.
BadApvs >> 5) & 0x1) <<
" ";
1614 NBadComponent[
i][0][2] += ((BC.
BadApvs >> 5) & 0x1) + ((BC.
BadApvs >> 4) & 0x1) + ((BC.
BadApvs >> 3) & 0x1) +
1616 NBadComponent[
i][component][2] += ((BC.
BadApvs >> 5) & 0x1) + ((BC.
BadApvs >> 4) & 0x1) +
1622 NBadComponent[
i][component][1] +=
1626 NBadComponent[
i][0][0]++;
1627 NBadComponent[
i][component][0]++;
map< unsigned int, double > BadModules
vector< TH2F * > HotColdMaps
map< unsigned int, vector< int > > layertotal_perBx
virtual int nstrips() const =0
T getUntrackedParameter(std::string const &, T const &) const
const edm::EventSetup & c
std::unique_ptr< SiStripBadStrip > getNewObject() override
const std::vector< BadComponent > & getBadComponentList() const
vector< TH1F * > layerfound_vsCM
uint16_t *__restrict__ id
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > _tTopoToken
TString GetLayerSideName(Long_t k)
vector< TH1F * > layerfound_vsLumi
map< unsigned int, vector< int > > layerfound_perBx
static constexpr auto TID
#define DEFINE_FWK_MODULE(type)
uint32_t const *__restrict__ Quality * quality
const Bounds & bounds() 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
map< pair< unsigned int, unsigned int >, array< double, 3 > > eventInfos
Log< level::Error, false > LogError
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.
constexpr std::array< uint8_t, layerIndexSize > layer
const uint16_t range(const Frame &aFrame)
bool getData(T &iHolder) const
unsigned int _clusterMatchingMethod
float calcPhi(float x, float y)
RegistryIterator getRegistryVectorEnd() const
edm::Service< TFileService > fs
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)
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > _tkGeomToken
vector< TH1F * > layerfound_vsPU
const std::pair< unsigned short, double > getNumberOfApvsAndStripLength(uint32_t detId) const
void makeTKMap(bool autoTagging)
SiStripDetInfo read(std::string filePath)
static constexpr auto TOB
~SiStripHitEffFromCalibTree() override
bool _autoIneffModTagging
void fillc(int idmod, int RGBcode)
ContainerIterator getDataVectorBegin() const
Detector identifier class for the strip tracker.
bool _showOnlyGoodModules
bool _useOnlyHighPurityTracks
void algoEndJob() override
T getParameter(std::string const &) const
static constexpr auto TIB
RegistryIterator getRegistryVectorBegin() const
vector< TH1F * > layertotal_vsCM
void algoAnalyze(const edm::Event &e, const edm::EventSetup &c) override
TString GetLayerName(Long_t k)
std::pair< ContainerIterator, ContainerIterator > Range
vector< TH1F * > layertotal_vsPU
std::string fullPath() const
static constexpr char const *const kDefaultFile
vector< string > CalibTreeFilenames
bool put(const uint32_t &detID, const InputVector &vect)
virtual float width() const =0
SiStripHitEffFromCalibTree(const edm::ParameterSet &)
void fill(int layer, int ring, int nmod, float x)
static constexpr auto TEC
data decode(const unsigned int &value) const
vector< TH1F * > layertotal_vsLumi
map< unsigned int, pair< unsigned int, unsigned int > > modCounter[23]