64 #include "TEfficiency.h" 68 #include "TGraphAsymmErrors.h" 74 #include "TObjString.h" 82 #define LOGPRINT edm::LogPrint("SiStripHitEffFromCalibTree") 102 void algoEndJob()
override;
104 void SetBadComponents(
int i,
107 std::stringstream ssV[4][19],
108 int NBadComponent[4][19][4]);
109 void makeTKMap(
bool autoTagging);
110 void makeHotColdMaps();
112 void totalStatistics();
114 void makeSummaryVsBx();
115 void ComputeEff(vector<TH1F*>& vhfound, vector<TH1F*>& vhtotal,
string name);
116 void makeSummaryVsLumi();
117 void makeSummaryVsCM();
118 TString GetLayerSideName(Long_t
k);
121 static constexpr
int SiStripLayers = 22;
127 std::unique_ptr<SiStripBadStrip> getNewObject()
override;
162 map<pair<unsigned int, unsigned int>, array<double, 3> >
eventInfos;
166 map<unsigned int, pair<unsigned int, unsigned int> > modCounter[23];
182 int goodlayertotal[35];
183 int goodlayerfound[35];
184 int alllayertotal[35];
185 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())
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 LOGPRINT <<
"Remove additionnal bad modules from the analysis: ";
258 set<uint32_t>::iterator itBadMod;
259 for (itBadMod = badModules_list.begin(); itBadMod != badModules_list.end(); ++itBadMod)
268 for (
int l = 0;
l < 35;
l++) {
275 TH1F* resolutionPlots[23];
276 for (Long_t ilayer = 0; ilayer < 23; ilayer++) {
279 resolutionPlots[ilayer] =
fs->
make<TH1F>(Form(
"resol_layer_%i", (
int)(ilayer)), lyrName.c_str(), 125, -125, 125);
280 resolutionPlots[ilayer]->GetXaxis()->SetTitle(
"trajX-clusX [strip unit]");
283 fs->
make<TH1F>(Form(
"layerfound_vsLumi_layer_%i", (
int)(ilayer)), lyrName.c_str(), 100, 0, 25000));
285 fs->
make<TH1F>(Form(
"layertotal_vsLumi_layer_%i", (
int)(ilayer)), lyrName.c_str(), 100, 0, 25000));
287 fs->
make<TH1F>(Form(
"layerfound_vsPU_layer_%i", (
int)(ilayer)), lyrName.c_str(), 45, 0, 90));
289 fs->
make<TH1F>(Form(
"layertotal_vsPU_layer_%i", (
int)(ilayer)), lyrName.c_str(), 45, 0, 90));
293 fs->
make<TH1F>(Form(
"layerfound_vsCM_layer_%i", (
int)(ilayer)), lyrName.c_str(), 20, 0, 400));
295 fs->
make<TH1F>(Form(
"layertotal_vsCM_layer_%i", (
int)(ilayer)), lyrName.c_str(), 20, 0, 400));
304 LOGPRINT <<
"A module is bad if the upper limit on the efficiency is < to the avg in the layer - " <<
threshold 305 <<
" and has at least " <<
nModsMin <<
" nModsMin.";
307 unsigned int run, evt,
bx{0};
316 bool foundEventInfos =
false;
318 CalibTreeFile->cd(
"eventInfo");
322 TTree* EventTree = (TTree*)(gDirectory->Get(
"tree"));
330 LOGPRINT <<
"Found event infos tree";
332 runLf = EventTree->GetLeaf(
"run");
333 evtLf = EventTree->GetLeaf(
"event");
335 BunchLf = EventTree->GetLeaf(
"bx");
336 InstLumiLf = EventTree->GetLeaf(
"instLumi");
337 PULf = EventTree->GetLeaf(
"PU");
339 int nevt = EventTree->GetEntries();
341 foundEventInfos =
true;
343 for (
int j = 0;
j <
nevt;
j++) {
344 EventTree->GetEntry(
j);
345 run = runLf->GetValue();
346 evt = evtLf->GetValue();
347 bx = BunchLf->GetValue();
349 PU = PULf->GetValue();
360 CalibTreeFile->cd(
"anEff");
361 CalibTree = (TTree*)(gDirectory->Get(
"traj"));
365 TLeaf* BadLf =
CalibTree->GetLeaf(
"ModIsBad");
366 TLeaf* sistripLf =
CalibTree->GetLeaf(
"SiStripQualBad");
368 TLeaf* acceptLf =
CalibTree->GetLeaf(
"withinAcceptance");
369 TLeaf* layerLf =
CalibTree->GetLeaf(
"layer");
371 TLeaf* highPurityLf =
CalibTree->GetLeaf(
"highPurity");
372 TLeaf* xLf =
CalibTree->GetLeaf(
"TrajGlbX");
373 TLeaf* yLf =
CalibTree->GetLeaf(
"TrajGlbY");
374 TLeaf* zLf =
CalibTree->GetLeaf(
"TrajGlbZ");
375 TLeaf* ResXSigLf =
CalibTree->GetLeaf(
"ResXSig");
376 TLeaf* TrajLocXLf =
CalibTree->GetLeaf(
"TrajLocX");
377 TLeaf* TrajLocYLf =
CalibTree->GetLeaf(
"TrajLocY");
378 TLeaf* ClusterLocXLf =
CalibTree->GetLeaf(
"ClusterLocX");
380 InstLumiLf =
CalibTree->GetLeaf(
"instLumi");
382 TLeaf* CMLf =
nullptr;
387 LOGPRINT <<
"Successfully loaded analyze function with " <<
nevents <<
" events!\n";
389 map<pair<unsigned int, unsigned int>, array<double, 3> >::iterator itEventInfos;
394 run = (
unsigned int)runLf->GetValue();
395 evt = (
unsigned int)evtLf->GetValue();
396 unsigned int isBad = (
unsigned int)BadLf->GetValue();
397 unsigned int quality = (
unsigned int)sistripLf->GetValue();
398 unsigned int id = (
unsigned int)idLf->GetValue();
399 unsigned int accept = (
unsigned int)acceptLf->GetValue();
400 unsigned int layer_wheel = (
unsigned int)layerLf->GetValue();
401 unsigned int layer = layer_wheel;
404 layer = 10 + ((
id >> 9) & 0x3);
406 layer = 13 + ((
id >> 5) & 0x7);
410 double x = xLf->GetValue();
411 double y = yLf->GetValue();
412 double z = zLf->GetValue();
413 double resxsig = ResXSigLf->GetValue();
414 double TrajLocX = TrajLocXLf->GetValue();
415 double TrajLocY = TrajLocYLf->GetValue();
416 double ClusterLocX = ClusterLocXLf->GetValue();
420 bool badquality =
false;
426 if (!foundEventInfos) {
427 bx = (
unsigned int)BunchLf->GetValue();
428 if (InstLumiLf !=
nullptr)
431 PU = PULf->GetValue();
435 CM = CMLf->GetValue();
438 if (foundEventInfos) {
441 bx = itEventInfos->second[0];
443 PU = itEventInfos->second[2];
466 itBadMod = badModules_list.find(
id);
467 if (itBadMod != badModules_list.end())
473 bool badflag =
false;
480 if (isBad == 1 || resxsig >
_ResXSig)
488 if (resxsig == 1000.0) {
491 stripTrajMid = TrajLocX / Pitch + nstrips / 2.0;
494 DetId ClusterDetId(
id);
499 stripTrajMid = TrajLocX / Pitch + nstrips / 2.0;
510 dynamic_cast<const TrapezoidalPlaneBounds*>(&(plane.bounds())));
511 std::array<const float, 4>
const&
parameters = (*trapezoidalBounds).parameters();
515 TrajLocXMid = TrajLocX / (1 + (htedge - hbedge) * TrajLocY / (htedge + hbedge) /
517 stripTrajMid = TrajLocXMid / Pitch + nstrips / 2.0;
521 if (!badquality &&
layer < 23) {
522 if (resxsig != 1000.0)
525 resolutionPlots[
layer]->Fill(1000);
531 float stripInAPV = 64.;
535 if (resxsig == 1000.0) {
546 tapv = (
int)stripTrajMid / 128;
548 stripInAPV = stripTrajMid - tapv * 128;
550 if (stripInAPV < _stripsApvEdge || stripInAPV > 128 -
_stripsApvEdge)
558 if (badflag && !badquality) {
566 pair<unsigned int, unsigned int> newgoodpair(1, 1);
567 pair<unsigned int, unsigned int> newbadpair(1, 0);
569 map<unsigned int, pair<unsigned int, unsigned int> >::iterator it =
modCounter[
layer].find(
id);
577 ((*it).second.first)++;
579 ((*it).second.second)++;
609 if (((
id >> 13) & 0x3) == 1) {
613 }
else if (((
id >> 13) & 0x3) == 2) {
619 if (((
id >> 18) & 0x3) == 1) {
623 }
else if (((
id >> 18) & 0x3) == 2) {
636 if (((
id >> 13) & 0x3) == 1) {
640 }
else if (((
id >> 13) & 0x3) == 2) {
646 if (((
id >> 18) & 0x3) == 1) {
650 }
else if (((
id >> 18) & 0x3) == 2) {
673 int NTkBadComponent[4];
674 int NBadComponent[4][19][4];
678 std::stringstream ssV[4][19];
680 for (
int i = 0;
i < 4; ++
i) {
681 NTkBadComponent[
i] = 0;
682 for (
int j = 0;
j < 19; ++
j) {
684 for (
int k = 0;
k < 4; ++
k)
685 NBadComponent[
i][
j][
k] = 0;
691 for (
size_t i = 0;
i < BC.size(); ++
i) {
697 NTkBadComponent[0]++;
699 NTkBadComponent[1] += ((BC[
i].BadFibers >> 2) & 0
x1) + ((BC[
i].BadFibers >> 1) & 0
x1) + ((BC[
i].BadFibers) & 0
x1);
701 NTkBadComponent[2] += ((BC[
i].BadApvs >> 5) & 0
x1) + ((BC[
i].BadApvs >> 4) & 0
x1) + ((BC[
i].BadApvs >> 3) & 0
x1) +
702 ((BC[
i].BadApvs >> 2) & 0
x1) + ((BC[
i].BadApvs >> 1) & 0
x1) + ((BC[
i].BadApvs) & 0
x1);
723 component = tTopo.tidSide(BC[
i].detid) == 2 ? tTopo.tidWheel(BC[
i].detid) : tTopo.tidWheel(BC[
i].detid) + 3;
739 component = tTopo.tecSide(BC[
i].detid) == 2 ? tTopo.tecWheel(BC[
i].detid) : tTopo.tecWheel(BC[
i].detid) + 9;
747 float percentage = 0;
753 unsigned int detid = rp->detid;
758 if (
a.subdetId() == 3) {
761 }
else if (
a.subdetId() == 4) {
763 component = tTopo.tidSide(detid) == 2 ? tTopo.tidWheel(detid) : tTopo.tidWheel(detid) + 3;
764 }
else if (
a.subdetId() == 5) {
767 }
else if (
a.subdetId() == 6) {
769 component = tTopo.tecSide(detid) == 2 ? tTopo.tecWheel(detid) : tTopo.tecWheel(detid) + 9;
776 for (
int it = 0; it < sqrange.second - sqrange.first; it++) {
778 NTkBadComponent[3] +=
range;
779 NBadComponent[subdet][0][3] +=
range;
786 edm::LogError(
"SiStripQualityStatistics") <<
"PROBLEM detid " << detid <<
" value " << percentage << std::endl;
791 std::ostringstream
ss;
793 ss <<
"\n-----------------\nNew IOV starting from run " <<
e.id().run() <<
" event " <<
e.id().event()
794 <<
" lumiBlock " <<
e.luminosityBlock() <<
" time " <<
e.time().value() <<
"\n-----------------\n";
795 ss <<
"\n-----------------\nGlobal Info\n-----------------";
796 ss <<
"\nBadComponent \t Modules \tFibers " 797 "\tApvs\tStrips\n----------------------------------------------------------------";
798 ss <<
"\nTracker:\t\t" << NTkBadComponent[0] <<
"\t" << NTkBadComponent[1] <<
"\t" << NTkBadComponent[2] <<
"\t" 799 << NTkBadComponent[3];
800 ss <<
"\nTIB:\t\t\t" << NBadComponent[0][0][0] <<
"\t" << NBadComponent[0][0][1] <<
"\t" << NBadComponent[0][0][2]
801 <<
"\t" << NBadComponent[0][0][3];
802 ss <<
"\nTID:\t\t\t" << NBadComponent[1][0][0] <<
"\t" << NBadComponent[1][0][1] <<
"\t" << NBadComponent[1][0][2]
803 <<
"\t" << NBadComponent[1][0][3];
804 ss <<
"\nTOB:\t\t\t" << NBadComponent[2][0][0] <<
"\t" << NBadComponent[2][0][1] <<
"\t" << NBadComponent[2][0][2]
805 <<
"\t" << NBadComponent[2][0][3];
806 ss <<
"\nTEC:\t\t\t" << NBadComponent[3][0][0] <<
"\t" << NBadComponent[3][0][1] <<
"\t" << NBadComponent[3][0][2]
807 <<
"\t" << NBadComponent[3][0][3];
810 for (
int i = 1;
i < 5; ++
i)
811 ss <<
"\nTIB Layer " <<
i <<
" :\t\t" << NBadComponent[0][
i][0] <<
"\t" << NBadComponent[0][
i][1] <<
"\t" 812 << NBadComponent[0][
i][2] <<
"\t" << NBadComponent[0][
i][3];
814 for (
int i = 1;
i < 4; ++
i)
815 ss <<
"\nTID+ Disk " <<
i <<
" :\t\t" << NBadComponent[1][
i][0] <<
"\t" << NBadComponent[1][
i][1] <<
"\t" 816 << NBadComponent[1][
i][2] <<
"\t" << NBadComponent[1][
i][3];
817 for (
int i = 4;
i < 7; ++
i)
818 ss <<
"\nTID- Disk " <<
i - 3 <<
" :\t\t" << NBadComponent[1][
i][0] <<
"\t" << NBadComponent[1][
i][1] <<
"\t" 819 << NBadComponent[1][
i][2] <<
"\t" << NBadComponent[1][
i][3];
821 for (
int i = 1;
i < 7; ++
i)
822 ss <<
"\nTOB Layer " <<
i <<
" :\t\t" << NBadComponent[2][
i][0] <<
"\t" << NBadComponent[2][
i][1] <<
"\t" 823 << NBadComponent[2][
i][2] <<
"\t" << NBadComponent[2][
i][3];
825 for (
int i = 1;
i < 10; ++
i)
826 ss <<
"\nTEC+ Disk " <<
i <<
" :\t\t" << NBadComponent[3][
i][0] <<
"\t" << NBadComponent[3][
i][1] <<
"\t" 827 << NBadComponent[3][
i][2] <<
"\t" << NBadComponent[3][
i][3];
828 for (
int i = 10;
i < 19; ++
i)
829 ss <<
"\nTEC- Disk " <<
i - 9 <<
" :\t\t" << NBadComponent[3][
i][0] <<
"\t" << NBadComponent[3][
i][1] <<
"\t" 830 << NBadComponent[3][
i][2] <<
"\t" << NBadComponent[3][
i][3];
833 ss <<
"\n----------------------------------------------------------------\n\t\t Detid \tModules Fibers " 834 "Apvs\n----------------------------------------------------------------";
835 for (
int i = 1;
i < 5; ++
i)
836 ss <<
"\nTIB Layer " <<
i <<
" :" << ssV[0][
i].
str();
838 for (
int i = 1;
i < 4; ++
i)
839 ss <<
"\nTID+ Disk " <<
i <<
" :" << ssV[1][
i].
str();
840 for (
int i = 4;
i < 7; ++
i)
841 ss <<
"\nTID- Disk " <<
i - 3 <<
" :" << ssV[1][
i].
str();
843 for (
int i = 1;
i < 7; ++
i)
844 ss <<
"\nTOB Layer " <<
i <<
" :" << ssV[2][
i].
str();
846 for (
int i = 1;
i < 10; ++
i)
847 ss <<
"\nTEC+ Disk " <<
i <<
" :" << ssV[3][
i].
str();
848 for (
int i = 10;
i < 19; ++
i)
849 ss <<
"\nTEC- Disk " <<
i - 9 <<
" :" << ssV[3][
i].
str();
855 badModules.open(
"BadModules.log");
856 badModules <<
"\n----------------------------------------------------------------\n\t\t Detid \tModules Fibers " 857 "Apvs\n----------------------------------------------------------------";
858 for (
int i = 1;
i < 5; ++
i)
859 badModules <<
"\nTIB Layer " <<
i <<
" :" << ssV[0][
i].
str();
861 for (
int i = 1;
i < 4; ++
i)
862 badModules <<
"\nTID+ Disk " <<
i <<
" :" << ssV[1][
i].
str();
863 for (
int i = 4;
i < 7; ++
i)
864 badModules <<
"\nTID- Disk " <<
i - 3 <<
" :" << ssV[1][
i].
str();
866 for (
int i = 1;
i < 7; ++
i)
867 badModules <<
"\nTOB Layer " <<
i <<
" :" << ssV[2][
i].
str();
869 for (
int i = 1;
i < 10; ++
i)
870 badModules <<
"\nTEC+ Disk " <<
i <<
" :" << ssV[3][
i].
str();
871 for (
int i = 10;
i < 19; ++
i)
872 badModules <<
"\nTEC- Disk " <<
i - 9 <<
" :" << ssV[3][
i].
str();
877 LOGPRINT <<
"Entering hot cold map generation!\n";
878 TStyle* gStyle =
new TStyle(
"gStyle",
"myStyle");
880 gStyle->SetPalette(1);
881 gStyle->SetCanvasColor(kWhite);
882 gStyle->SetOptStat(0);
887 for (Long_t maplayer = 1; maplayer <=
SiStripLayers; maplayer++) {
889 if (maplayer > 0 && maplayer <= 4) {
891 temph2 =
fs->
make<TH2F>(Form(
"%s%i",
"TIB", (
int)(maplayer)),
"TIB", 100, -1, 361, 100, -100, 100);
892 temph2->GetXaxis()->SetTitle(
"Phi");
893 temph2->GetXaxis()->SetBinLabel(1, TString(
"360"));
894 temph2->GetXaxis()->SetBinLabel(50, TString(
"180"));
895 temph2->GetXaxis()->SetBinLabel(100, TString(
"0"));
896 temph2->GetYaxis()->SetTitle(
"Global Z");
897 temph2->SetOption(
"colz");
899 }
else if (maplayer > 4 && maplayer <= 10) {
901 temph2 =
fs->
make<TH2F>(Form(
"%s%i",
"TOB", (
int)(maplayer - 4)),
"TOB", 100, -1, 361, 100, -120, 120);
902 temph2->GetXaxis()->SetTitle(
"Phi");
903 temph2->GetXaxis()->SetBinLabel(1, TString(
"360"));
904 temph2->GetXaxis()->SetBinLabel(50, TString(
"180"));
905 temph2->GetXaxis()->SetBinLabel(100, TString(
"0"));
906 temph2->GetYaxis()->SetTitle(
"Global Z");
907 temph2->SetOption(
"colz");
909 }
else if (maplayer > 10 && maplayer <= 13) {
912 temph2 =
fs->
make<TH2F>(Form(
"%s%i",
"TID-", (
int)(maplayer - 10)),
"TID-", 100, -100, 100, 100, -100, 100);
913 temph2->GetXaxis()->SetTitle(
"Global Y");
914 temph2->GetXaxis()->SetBinLabel(1, TString(
"+Y"));
915 temph2->GetXaxis()->SetBinLabel(50, TString(
"0"));
916 temph2->GetXaxis()->SetBinLabel(100, TString(
"-Y"));
917 temph2->GetYaxis()->SetTitle(
"Global X");
918 temph2->GetYaxis()->SetBinLabel(1, TString(
"-X"));
919 temph2->GetYaxis()->SetBinLabel(50, TString(
"0"));
920 temph2->GetYaxis()->SetBinLabel(100, TString(
"+X"));
921 temph2->SetOption(
"colz");
923 temph2 =
fs->
make<TH2F>(Form(
"%s%i",
"TID+", (
int)(maplayer - 10)),
"TID+", 100, -100, 100, 100, -100, 100);
924 temph2->GetXaxis()->SetTitle(
"Global Y");
925 temph2->GetXaxis()->SetBinLabel(1, TString(
"+Y"));
926 temph2->GetXaxis()->SetBinLabel(50, TString(
"0"));
927 temph2->GetXaxis()->SetBinLabel(100, TString(
"-Y"));
928 temph2->GetYaxis()->SetTitle(
"Global X");
929 temph2->GetYaxis()->SetBinLabel(1, TString(
"-X"));
930 temph2->GetYaxis()->SetBinLabel(50, TString(
"0"));
931 temph2->GetYaxis()->SetBinLabel(100, TString(
"+X"));
932 temph2->SetOption(
"colz");
934 }
else if (maplayer > 13) {
937 temph2 =
fs->
make<TH2F>(Form(
"%s%i",
"TEC-", (
int)(maplayer - 13)),
"TEC-", 100, -120, 120, 100, -120, 120);
938 temph2->GetXaxis()->SetTitle(
"Global Y");
939 temph2->GetXaxis()->SetBinLabel(1, TString(
"+Y"));
940 temph2->GetXaxis()->SetBinLabel(50, TString(
"0"));
941 temph2->GetXaxis()->SetBinLabel(100, TString(
"-Y"));
942 temph2->GetYaxis()->SetTitle(
"Global X");
943 temph2->GetYaxis()->SetBinLabel(1, TString(
"-X"));
944 temph2->GetYaxis()->SetBinLabel(50, TString(
"0"));
945 temph2->GetYaxis()->SetBinLabel(100, TString(
"+X"));
946 temph2->SetOption(
"colz");
948 temph2 =
fs->
make<TH2F>(Form(
"%s%i",
"TEC+", (
int)(maplayer - 13)),
"TEC+", 100, -120, 120, 100, -120, 120);
949 temph2->GetXaxis()->SetTitle(
"Global Y");
950 temph2->GetXaxis()->SetBinLabel(1, TString(
"+Y"));
951 temph2->GetXaxis()->SetBinLabel(50, TString(
"0"));
952 temph2->GetXaxis()->SetBinLabel(100, TString(
"-Y"));
953 temph2->GetYaxis()->SetTitle(
"Global X");
954 temph2->GetYaxis()->SetBinLabel(1, TString(
"-X"));
955 temph2->GetYaxis()->SetBinLabel(50, TString(
"0"));
956 temph2->GetYaxis()->SetBinLabel(100, TString(
"+X"));
957 temph2->SetOption(
"colz");
961 for (Long_t mylayer = 1; mylayer <=
SiStripLayers; mylayer++) {
965 vector<hit>::const_iterator iter;
966 for (iter =
hits[mylayer].begin(); iter !=
hits[mylayer].end(); iter++) {
970 if (mylayer > 0 && mylayer <= 4) {
972 float phi = ::calcPhi(iter->x, iter->y);
974 }
else if (mylayer > 4 && mylayer <= 10) {
976 float phi = ::calcPhi(iter->x, iter->y);
978 }
else if (mylayer > 10 && mylayer <= 13) {
981 int side = (((iter->id) >> 13) & 0x3);
983 HotColdMaps[(mylayer - 1) + (mylayer - 11)]->Fill(-iter->y, iter->x, 1.);
985 HotColdMaps[(mylayer - 1) + (mylayer - 10)]->Fill(-iter->y, iter->x, 1.);
988 }
else if (mylayer > 13) {
991 int side = (((iter->id) >> 18) & 0x3);
993 HotColdMaps[(mylayer + 2) + (mylayer - 14)]->Fill(-iter->y, iter->x, 1.);
995 HotColdMaps[(mylayer + 2) + (mylayer - 13)]->Fill(-iter->y, iter->x, 1.);
1001 LOGPRINT <<
"Finished HotCold Map Generation\n";
1005 LOGPRINT <<
"Entering TKMap generation!\n";
1012 double myeff, mynum, myden, myeff_up;
1013 double layer_min_eff = 0;
1021 fs->
make<TH1F>(Form(
"eff_layer%i",
int(
i)), Form(
"Module efficiency in layer %i",
int(
i)), 201, 0, 1.005);
1023 map<unsigned int, pair<unsigned int, unsigned int> >::const_iterator ih;
1027 mynum = (double)(((*ih).second).second);
1028 myden = (double)(((*ih).second).first);
1030 myeff = mynum / myden;
1033 hEffInLayer->Fill(myeff);
1041 <<
" efficiency: " << myeff <<
" , " << mynum <<
"/" << myden;
1048 <<
" efficiency: " << myeff <<
" , " << mynum <<
"/" << myden;
1051 <<
" is under occupancy at " << myden;
1068 hEffInLayer->GetXaxis()->SetRange(3, hEffInLayer->GetNbinsX() + 1);
1070 hEffInLayer->GetMean() - 2.5 * hEffInLayer->GetRMS();
1071 if (
threshold > 2.5 * hEffInLayer->GetRMS())
1072 layer_min_eff = hEffInLayer->GetMean() -
threshold;
1073 LOGPRINT <<
"Layer " <<
i <<
" threshold for bad modules: <" << layer_min_eff
1074 <<
" (layer mean: " << hEffInLayer->GetMean() <<
" rms: " << hEffInLayer->GetRMS() <<
")";
1076 hEffInLayer->GetXaxis()->SetRange(1, hEffInLayer->GetNbinsX() + 1);
1080 mynum = (double)(((*ih).second).second);
1081 myden = (double)(((*ih).second).first);
1083 myeff = mynum / myden;
1087 myeff_up = TEfficiency::Bayesian(myden, mynum, .99, 1, 1,
true);
1088 if ((myden >=
nModsMin) && (myeff_up < layer_min_eff)) {
1096 if (myeff_up < layer_min_eff + 0.08)
1098 <<
" efficiency: " << myeff <<
" , " << mynum <<
"/" << myden <<
" , upper limit: " << myeff_up;
1101 <<
" layer " <<
i <<
" is under occupancy at " << myden;
1106 tkmap->
save(
true, 0, 0,
"SiStripHitEffTKMap.png");
1107 tkmapbad->
save(
true, 0, 0,
"SiStripHitEffTKMapBad.png");
1109 tkmapnum->
save(
true, 0, 0,
"SiStripHitEffTKMapNum.png");
1110 tkmapden->
save(
true, 0, 0,
"SiStripHitEffTKMapDen.png");
1111 LOGPRINT <<
"Finished TKMap Generation\n";
1116 LOGPRINT <<
"Entering SQLite file generation!\n";
1117 std::vector<unsigned int> BadStripList;
1118 unsigned short NStrips;
1120 std::unique_ptr<SiStripQuality> pQuality = std::make_unique<SiStripQuality>(
_detInfo);
1124 map<unsigned int, double>::const_iterator it;
1129 LOGPRINT <<
"Number of strips module " << (*it).first <<
" is " << NStrips;
1130 BadStripList.push_back(pQuality->encode(0, NStrips, 0));
1132 id1 = (
unsigned int)(*it).first;
1133 LOGPRINT <<
"ID1 shoudl match list of modules above " <<
id1;
1137 BadStripList.clear();
1151 for (Long_t
i = 1;
i < 5;
i++) {
1166 if (
i >= 5 &&
i < 11) {
1170 if (
i >= 11 &&
i < 14) {
1180 LOGPRINT <<
"The total efficiency is " << double(totalfound) / double(totaltotal);
1181 LOGPRINT <<
" TIB: " << double(subdetfound[1]) / subdettotal[1] <<
" " << subdetfound[1] <<
"/" 1183 LOGPRINT <<
" TOB: " << double(subdetfound[2]) / subdettotal[2] <<
" " << subdetfound[2] <<
"/" 1185 LOGPRINT <<
" TID: " << double(subdetfound[3]) / subdettotal[3] <<
" " << subdetfound[3] <<
"/" 1187 LOGPRINT <<
" TEC: " << double(subdetfound[4]) / subdettotal[4] <<
" " << subdetfound[4] <<
"/" 1209 found->SetBinContent(0, -1);
1210 all->SetBinContent(0, 1);
1214 found->SetBinContent(
i, 1
e-6);
1215 all->SetBinContent(
i, 1);
1216 found2->SetBinContent(
i, 1
e-6);
1217 all2->SetBinContent(
i, 1);
1220 TCanvas* c7 =
new TCanvas(
"c7",
" test ", 10, 10, 800, 600);
1221 c7->SetFillColor(0);
1224 int nLayers_max =
nLayers + 1;
1227 for (Long_t
i = 1;
i < nLayers_max; ++
i) {
1244 for (Long_t
i = 11;
i < 14; ++
i) {
1259 LOGPRINT <<
"Fill only good modules layer " <<
i - 3
1281 TGraphAsymmErrors* gr =
fs->
make<TGraphAsymmErrors>(
nLayers + 1);
1282 gr->SetName(
"eff_good");
1285 TGraphAsymmErrors* gr2 =
fs->
make<TGraphAsymmErrors>(
nLayers + 1);
1286 gr2->SetName(
"eff_all");
1287 gr2->BayesDivide(found2, all2);
1290 gr->SetPointError(
j, 0., 0., gr->GetErrorYlow(
j), gr->GetErrorYhigh(
j));
1291 gr2->SetPointError(
j, 0., 0., gr2->GetErrorYlow(
j), gr2->GetErrorYhigh(
j));
1294 gr->GetXaxis()->SetLimits(0,
nLayers);
1295 gr->SetMarkerColor(2);
1296 gr->SetMarkerSize(1.2);
1297 gr->SetLineColor(2);
1298 gr->SetLineWidth(4);
1299 gr->SetMarkerStyle(20);
1301 gr->SetMaximum(1.001);
1302 gr->GetYaxis()->SetTitle(
"Efficiency");
1303 gStyle->SetTitleFillColor(0);
1304 gStyle->SetTitleBorderSize(0);
1307 gr2->GetXaxis()->SetLimits(0,
nLayers);
1308 gr2->SetMarkerColor(1);
1309 gr2->SetMarkerSize(1.2);
1310 gr2->SetLineColor(1);
1311 gr2->SetLineWidth(4);
1312 gr2->SetMarkerStyle(21);
1314 gr2->SetMaximum(1.001);
1315 gr2->GetYaxis()->SetTitle(
"Efficiency");
1334 gr->GetXaxis()->SetBinLabel(((
k + 1) * 100 + 2) / (
nLayers)-4,
label);
1335 gr2->GetXaxis()->SetBinLabel(((
k + 1) * 100 + 2) / (
nLayers)-4,
label);
1337 gr->GetXaxis()->SetBinLabel((
k + 1) * 100 / (
nLayers)-6,
label);
1338 gr2->GetXaxis()->SetBinLabel((
k + 1) * 100 / (
nLayers)-6,
label);
1342 gr->GetXaxis()->SetBinLabel((
k + 1) * 100 / (
nLayers)-4,
label);
1343 gr2->GetXaxis()->SetBinLabel((
k + 1) * 100 / (
nLayers)-4,
label);
1345 gr->GetXaxis()->SetBinLabel((
k + 1) * 100 / (
nLayers)-7,
label);
1346 gr2->GetXaxis()->SetBinLabel((
k + 1) * 100 / (
nLayers)-7,
label);
1352 gr->GetXaxis()->SetNdivisions(36);
1355 TPad*
overlay =
new TPad(
"overlay",
"", 0, 0, 1, 1);
1358 overlay->SetFrameFillStyle(4000);
1364 TLegend* leg =
new TLegend(0.70, 0.27, 0.88, 0.40);
1365 leg->AddEntry(gr,
"Good Modules",
"p");
1367 leg->AddEntry(gr2,
"All Modules",
"p");
1368 leg->SetTextSize(0.020);
1369 leg->SetFillColor(0);
1372 c7->SaveAs(
"Summary.png");
1376 LOGPRINT <<
"Computing efficiency vs bx";
1382 for (
unsigned int ilayer = 1; ilayer <
nLayers; ilayer++) {
1383 TH1F* hfound =
fs->
make<TH1F>(Form(
"foundVsBx_layer%i", ilayer), Form(
"layer %i", ilayer), 3565, 0, 3565);
1384 TH1F* htotal =
fs->
make<TH1F>(Form(
"totalVsBx_layer%i", ilayer), Form(
"layer %i", ilayer), 3565, 0, 3565);
1386 for (
unsigned int ibx = 0; ibx < 3566; ibx++) {
1387 hfound->SetBinContent(ibx, 1
e-6);
1388 htotal->SetBinContent(ibx, 1);
1390 map<unsigned int, vector<int> >::iterator iterMapvsBx;
1392 hfound->SetBinContent(iterMapvsBx->first, iterMapvsBx->second[ilayer]);
1394 if (iterMapvsBx->second[ilayer] > 0)
1395 htotal->SetBinContent(iterMapvsBx->first, iterMapvsBx->second[ilayer]);
1400 TGraphAsymmErrors* geff =
fs->
make<TGraphAsymmErrors>(3564);
1401 geff->SetName(Form(
"effVsBx_layer%i", ilayer));
1403 geff->BayesDivide(hfound, htotal);
1406 TGraphAsymmErrors* geff_avg =
fs->
make<TGraphAsymmErrors>();
1407 geff_avg->SetName(Form(
"effVsBxAvg_layer%i", ilayer));
1409 geff_avg->SetMarkerStyle(20);
1411 int previous_bx = -80;
1421 ibx = iterMapvsBx->first;
1422 delta_bx = ibx - previous_bx;
1427 geff_avg->SetPoint(ipt, sum_bx / nbx, eff);
1428 low = TEfficiency::Bayesian(
total,
found, .683, 1, 1,
false);
1429 up = TEfficiency::Bayesian(
total,
found, .683, 1, 1,
true);
1430 geff_avg->SetPointError(ipt, sum_bx / nbx - firstbx, previous_bx - sum_bx / nbx, eff -
low,
up - eff);
1439 found += hfound->GetBinContent(ibx);
1440 total += htotal->GetBinContent(ibx);
1448 geff_avg->SetPoint(ipt, sum_bx / nbx, eff);
1449 low = TEfficiency::Bayesian(
total,
found, .683, 1, 1,
false);
1450 up = TEfficiency::Bayesian(
total,
found, .683, 1, 1,
true);
1451 geff_avg->SetPointError(ipt, sum_bx / nbx - firstbx, previous_bx - sum_bx / nbx, eff -
low,
up - eff);
1463 for (
unsigned int ilayer = 1; ilayer <
nLayers; ilayer++) {
1464 hfound = vhfound[ilayer];
1465 htotal = vhtotal[ilayer];
1471 for (Long_t
i = 0;
i < hfound->GetNbinsX() + 1; ++
i) {
1472 if (hfound->GetBinContent(
i) == 0)
1473 hfound->SetBinContent(
i, 1
e-6);
1474 if (htotal->GetBinContent(
i) == 0)
1475 htotal->SetBinContent(
i, 1);
1478 TGraphAsymmErrors* geff =
fs->
make<TGraphAsymmErrors>(hfound->GetNbinsX());
1479 geff->SetName(Form(
"%s_layer%i",
name.c_str(), ilayer));
1480 geff->BayesDivide(hfound, htotal);
1481 if (
name ==
"effVsLumi")
1484 if (
name ==
"effVsPU")
1486 if (
name ==
"effVsCM")
1489 geff->SetMarkerStyle(20);
1494 LOGPRINT <<
"Computing efficiency vs lumi";
1505 unsigned int nLayersForAvg = 0;
1506 float layerLumi = 0;
1511 LOGPRINT <<
"Lumi summary: (avg over trajectory measurements)";
1512 for (
unsigned int ilayer = 1; ilayer <
nLayers; ilayer++) {
1516 if (layerLumi != 0 && layerPU != 0) {
1517 avgLumi += layerLumi;
1522 avgLumi /= nLayersForAvg;
1523 avgPU /= nLayersForAvg;
1524 LOGPRINT <<
"Avg conditions: lumi :" << avgLumi <<
" pu: " << avgPU;
1532 LOGPRINT <<
"Computing efficiency vs CM";
1537 TString layername =
"";
1538 TString ringlabel =
"D";
1541 if (
k > 0 &&
k < 5) {
1542 layername = TString(
"TIB L") +
k;
1543 }
else if (
k > 4 &&
k < 11) {
1544 layername = TString(
"TOB L") + (
k - 4);
1545 }
else if (
k > 10 &&
k < 14) {
1546 layername = TString(
"TID- ") + ringlabel + (
k - 10);
1547 }
else if (
k > 13 &&
k < 17) {
1548 layername = TString(
"TID+ ") + ringlabel + (
k - 13);
1550 layername = TString(
"TEC- ") + ringlabel + (
k - 16);
1552 layername = TString(
"TEC+ ") + ringlabel + (
k - 16 -
nTEClayers);
1561 auto obj = std::make_unique<SiStripBadStrip>();
1566 for (; rIter != rIterEnd; ++rIter) {
1569 if (!
obj->put(rIter->detid,
range))
1571 <<
"[SiStripHitEffFromCalibTree::getNewObject] detid already exists" << std::endl;
1607 NBadComponent[
i][0][0]++;
map< unsigned int, double > BadModules
vector< TH2F * > HotColdMaps
map< unsigned int, vector< int > > layertotal_perBx
virtual int nstrips() const =0
ContainerIterator getDataVectorBegin() const
T getParameter(std::string const &) const
std::unique_ptr< SiStripBadStrip > getNewObject() override
vector< TH1F * > layerfound_vsCM
static constexpr int SiStripLayers
constexpr char const * layerName[numberOfLayers]
std::string fullPath() const
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)
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)
const std::vector< BadComponent > & getBadComponentList() const
constexpr std::array< uint8_t, layerIndexSize > layer
T getUntrackedParameter(std::string const &, T const &) const
def overlay(hists, ytitle, header, addon)
unsigned int _clusterMatchingMethod
edm::Service< TFileService > fs
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(uint32_t detid, std::vector< unsigned int > &)
virtual const StripTopology & specificTopology() const
Returns a reference to the strip proxy topology.
edm::FileInPath FileInPath_
Abs< T >::type abs(const T &t)
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > _tkGeomToken
vector< TH1F * > layerfound_vsPU
RegistryIterator getRegistryVectorEnd() const
void makeTKMap(bool autoTagging)
SiStripDetInfo read(std::string filePath)
static constexpr auto TOB
bool _autoIneffModTagging
void fillc(int idmod, int RGBcode)
Detector identifier class for the strip tracker.
bool _showOnlyGoodModules
const Plane & surface() const
The nominal surface of the GeomDet.
bool _useOnlyHighPurityTracks
const std::pair< unsigned short, double > getNumberOfApvsAndStripLength(uint32_t detId) const
void algoEndJob() override
static constexpr auto TIB
vector< TH1F * > layertotal_vsCM
void algoAnalyze(const edm::Event &e, const edm::EventSetup &c) override
std::pair< ContainerIterator, ContainerIterator > Range
vector< TH1F * > layertotal_vsPU
data decode(const unsigned int &value) const
T * make(const Args &...args) const
make new ROOT object
static constexpr char const *const kDefaultFile
vector< string > CalibTreeFilenames
void ComputeEff(vector< TH1F *> &vhfound, vector< TH1F *> &vhtotal, string name)
bool put(const uint32_t &detID, const InputVector &vect)
virtual float width() const =0
RegistryIterator getRegistryVectorBegin() const
SiStripHitEffFromCalibTree(const edm::ParameterSet &)
void fill(int layer, int ring, int nmod, float x)
static constexpr auto TEC
vector< TH1F * > layertotal_vsLumi
map< unsigned int, pair< unsigned int, unsigned int > > modCounter[23]
const Bounds & bounds() const