66 #include "TObjString.h"
77 #include "TGraphAsymmErrors.h"
80 #include "TEfficiency.h"
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 GetLayerName(Long_t
k);
119 TString GetLayerSideName(Long_t
k);
120 float calcPhi(
float x,
float y);
126 std::unique_ptr<SiStripBadStrip> getNewObject()
override;
161 map<pair<unsigned int, unsigned int>, array<double, 3> >
eventInfos;
165 map<unsigned int, pair<unsigned int, unsigned int> > modCounter[23];
181 int goodlayertotal[35];
182 int goodlayerfound[35];
183 int alllayertotal[35];
184 int alllayerfound[35];
238 ifstream badModules_file;
239 set<uint32_t> badModules_list;
242 uint32_t badmodule_detid;
243 int mods, fiber1, fiber2, fiber3;
244 if (badModules_file.is_open()) {
246 while (getline(badModules_file,
line)) {
247 if (badModules_file.eof())
250 ss >> badmodule_detid >>
mods >> fiber1 >> fiber2 >> fiber3;
251 if (badmodule_detid != 0 &&
mods == 1 && (fiber1 == 1 || fiber2 == 1 || fiber3 == 1))
252 badModules_list.insert(badmodule_detid);
254 badModules_file.close();
257 if (!badModules_list.empty())
258 cout <<
"Remove additionnal bad modules from the analysis: " << endl;
259 set<uint32_t>::iterator itBadMod;
260 for (itBadMod = badModules_list.begin(); itBadMod != badModules_list.end(); ++itBadMod)
261 cout <<
" " << *itBadMod << endl;
269 for (
int l = 0;
l < 35;
l++) {
276 TH1F* resolutionPlots[23];
277 for (Long_t ilayer = 0; ilayer < 23; ilayer++) {
278 resolutionPlots[ilayer] =
279 fs->
make<TH1F>(Form(
"resol_layer_%i", (
int)(ilayer)),
GetLayerName(ilayer), 125, -125, 125);
280 resolutionPlots[ilayer]->GetXaxis()->SetTitle(
"trajX-clusX [strip unit]");
283 fs->
make<TH1F>(Form(
"layerfound_vsLumi_layer_%i", (
int)(ilayer)),
GetLayerName(ilayer), 100, 0, 25000));
285 fs->
make<TH1F>(Form(
"layertotal_vsLumi_layer_%i", (
int)(ilayer)),
GetLayerName(ilayer), 100, 0, 25000));
287 fs->
make<TH1F>(Form(
"layerfound_vsPU_layer_%i", (
int)(ilayer)),
GetLayerName(ilayer), 45, 0, 90));
289 fs->
make<TH1F>(Form(
"layertotal_vsPU_layer_%i", (
int)(ilayer)),
GetLayerName(ilayer), 45, 0, 90));
293 fs->
make<TH1F>(Form(
"layerfound_vsCM_layer_%i", (
int)(ilayer)),
GetLayerName(ilayer), 20, 0, 400));
295 fs->
make<TH1F>(Form(
"layertotal_vsCM_layer_%i", (
int)(ilayer)),
GetLayerName(ilayer), 20, 0, 400));
302 cout <<
"A module is bad if efficiency < " <<
threshold <<
" and has at least " <<
nModsMin <<
" nModsMin." << endl;
304 cout <<
"A module is bad if efficiency < the avg in layer - " <<
threshold <<
" and has at least " <<
nModsMin
305 <<
" nModsMin." << endl;
307 unsigned int run, evt,
bx{0};
316 bool foundEventInfos =
false;
318 CalibTreeFile->cd(
"eventInfo");
320 cout <<
"No event infos tree" << endl;
322 TTree* EventTree = (TTree*)(gDirectory->Get(
"tree"));
330 cout <<
"Found event infos tree" << endl;
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 cout <<
"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];
462 if (!
_showTOB6TEC9 && (layer_wheel == 10 || layer_wheel == 22))
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;
792 cout <<
"\n-----------------\nNew IOV starting from run " <<
e.id().run() <<
" event " <<
e.id().event()
793 <<
" lumiBlock " <<
e.luminosityBlock() <<
" time " <<
e.time().value() <<
"\n-----------------\n";
794 cout <<
"\n-----------------\nGlobal Info\n-----------------";
795 cout <<
"\nBadComponent \t Modules \tFibers "
796 "\tApvs\tStrips\n----------------------------------------------------------------";
797 cout <<
"\nTracker:\t\t" << NTkBadComponent[0] <<
"\t" << NTkBadComponent[1] <<
"\t" << NTkBadComponent[2] <<
"\t"
798 << NTkBadComponent[3];
800 cout <<
"\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 cout <<
"\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 cout <<
"\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 cout <<
"\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 cout <<
"\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 cout <<
"\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 cout <<
"\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 cout <<
"\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 cout <<
"\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 cout <<
"\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 cout <<
"\n----------------------------------------------------------------\n\t\t Detid \tModules Fibers "
834 "Apvs\n----------------------------------------------------------------";
835 for (
int i = 1;
i < 5; ++
i)
836 cout <<
"\nTIB Layer " <<
i <<
" :" << ssV[0][
i].
str();
838 for (
int i = 1;
i < 4; ++
i)
839 cout <<
"\nTID+ Disk " <<
i <<
" :" << ssV[1][
i].
str();
840 for (
int i = 4;
i < 7; ++
i)
841 cout <<
"\nTID- Disk " <<
i - 3 <<
" :" << ssV[1][
i].
str();
843 for (
int i = 1;
i < 7; ++
i)
844 cout <<
"\nTOB Layer " <<
i <<
" :" << ssV[2][
i].
str();
846 for (
int i = 1;
i < 10; ++
i)
847 cout <<
"\nTEC+ Disk " <<
i <<
" :" << ssV[3][
i].
str();
848 for (
int i = 10;
i < 19; ++
i)
849 cout <<
"\nTEC- Disk " <<
i - 9 <<
" :" << ssV[3][
i].
str();
853 badModules.open(
"BadModules.log");
854 badModules <<
"\n----------------------------------------------------------------\n\t\t Detid \tModules Fibers "
855 "Apvs\n----------------------------------------------------------------";
856 for (
int i = 1;
i < 5; ++
i)
857 badModules <<
"\nTIB Layer " <<
i <<
" :" << ssV[0][
i].
str();
859 for (
int i = 1;
i < 4; ++
i)
860 badModules <<
"\nTID+ Disk " <<
i <<
" :" << ssV[1][
i].
str();
861 for (
int i = 4;
i < 7; ++
i)
862 badModules <<
"\nTID- Disk " <<
i - 3 <<
" :" << ssV[1][
i].
str();
864 for (
int i = 1;
i < 7; ++
i)
865 badModules <<
"\nTOB Layer " <<
i <<
" :" << ssV[2][
i].
str();
867 for (
int i = 1;
i < 10; ++
i)
868 badModules <<
"\nTEC+ Disk " <<
i <<
" :" << ssV[3][
i].
str();
869 for (
int i = 10;
i < 19; ++
i)
870 badModules <<
"\nTEC- Disk " <<
i - 9 <<
" :" << ssV[3][
i].
str();
875 cout <<
"Entering hot cold map generation!\n";
876 TStyle* gStyle =
new TStyle(
"gStyle",
"myStyle");
878 gStyle->SetPalette(1);
879 gStyle->SetCanvasColor(kWhite);
880 gStyle->SetOptStat(0);
885 for (Long_t maplayer = 1; maplayer <= 22; maplayer++) {
887 if (maplayer > 0 && maplayer <= 4) {
889 temph2 =
fs->
make<TH2F>(Form(
"%s%i",
"TIB", (
int)(maplayer)),
"TIB", 100, -1, 361, 100, -100, 100);
890 temph2->GetXaxis()->SetTitle(
"Phi");
891 temph2->GetXaxis()->SetBinLabel(1, TString(
"360"));
892 temph2->GetXaxis()->SetBinLabel(50, TString(
"180"));
893 temph2->GetXaxis()->SetBinLabel(100, TString(
"0"));
894 temph2->GetYaxis()->SetTitle(
"Global Z");
895 temph2->SetOption(
"colz");
897 }
else if (maplayer > 4 && maplayer <= 10) {
899 temph2 =
fs->
make<TH2F>(Form(
"%s%i",
"TOB", (
int)(maplayer - 4)),
"TOB", 100, -1, 361, 100, -120, 120);
900 temph2->GetXaxis()->SetTitle(
"Phi");
901 temph2->GetXaxis()->SetBinLabel(1, TString(
"360"));
902 temph2->GetXaxis()->SetBinLabel(50, TString(
"180"));
903 temph2->GetXaxis()->SetBinLabel(100, TString(
"0"));
904 temph2->GetYaxis()->SetTitle(
"Global Z");
905 temph2->SetOption(
"colz");
907 }
else if (maplayer > 10 && maplayer <= 13) {
910 temph2 =
fs->
make<TH2F>(Form(
"%s%i",
"TID-", (
int)(maplayer - 10)),
"TID-", 100, -100, 100, 100, -100, 100);
911 temph2->GetXaxis()->SetTitle(
"Global Y");
912 temph2->GetXaxis()->SetBinLabel(1, TString(
"+Y"));
913 temph2->GetXaxis()->SetBinLabel(50, TString(
"0"));
914 temph2->GetXaxis()->SetBinLabel(100, TString(
"-Y"));
915 temph2->GetYaxis()->SetTitle(
"Global X");
916 temph2->GetYaxis()->SetBinLabel(1, TString(
"-X"));
917 temph2->GetYaxis()->SetBinLabel(50, TString(
"0"));
918 temph2->GetYaxis()->SetBinLabel(100, TString(
"+X"));
919 temph2->SetOption(
"colz");
921 temph2 =
fs->
make<TH2F>(Form(
"%s%i",
"TID+", (
int)(maplayer - 10)),
"TID+", 100, -100, 100, 100, -100, 100);
922 temph2->GetXaxis()->SetTitle(
"Global Y");
923 temph2->GetXaxis()->SetBinLabel(1, TString(
"+Y"));
924 temph2->GetXaxis()->SetBinLabel(50, TString(
"0"));
925 temph2->GetXaxis()->SetBinLabel(100, TString(
"-Y"));
926 temph2->GetYaxis()->SetTitle(
"Global X");
927 temph2->GetYaxis()->SetBinLabel(1, TString(
"-X"));
928 temph2->GetYaxis()->SetBinLabel(50, TString(
"0"));
929 temph2->GetYaxis()->SetBinLabel(100, TString(
"+X"));
930 temph2->SetOption(
"colz");
932 }
else if (maplayer > 13) {
935 temph2 =
fs->
make<TH2F>(Form(
"%s%i",
"TEC-", (
int)(maplayer - 13)),
"TEC-", 100, -120, 120, 100, -120, 120);
936 temph2->GetXaxis()->SetTitle(
"Global Y");
937 temph2->GetXaxis()->SetBinLabel(1, TString(
"+Y"));
938 temph2->GetXaxis()->SetBinLabel(50, TString(
"0"));
939 temph2->GetXaxis()->SetBinLabel(100, TString(
"-Y"));
940 temph2->GetYaxis()->SetTitle(
"Global X");
941 temph2->GetYaxis()->SetBinLabel(1, TString(
"-X"));
942 temph2->GetYaxis()->SetBinLabel(50, TString(
"0"));
943 temph2->GetYaxis()->SetBinLabel(100, TString(
"+X"));
944 temph2->SetOption(
"colz");
946 temph2 =
fs->
make<TH2F>(Form(
"%s%i",
"TEC+", (
int)(maplayer - 13)),
"TEC+", 100, -120, 120, 100, -120, 120);
947 temph2->GetXaxis()->SetTitle(
"Global Y");
948 temph2->GetXaxis()->SetBinLabel(1, TString(
"+Y"));
949 temph2->GetXaxis()->SetBinLabel(50, TString(
"0"));
950 temph2->GetXaxis()->SetBinLabel(100, TString(
"-Y"));
951 temph2->GetYaxis()->SetTitle(
"Global X");
952 temph2->GetYaxis()->SetBinLabel(1, TString(
"-X"));
953 temph2->GetYaxis()->SetBinLabel(50, TString(
"0"));
954 temph2->GetYaxis()->SetBinLabel(100, TString(
"+X"));
955 temph2->SetOption(
"colz");
959 for (Long_t mylayer = 1; mylayer <= 22; mylayer++) {
963 vector<hit>::const_iterator iter;
964 for (iter =
hits[mylayer].begin(); iter !=
hits[mylayer].end(); iter++) {
968 if (mylayer > 0 && mylayer <= 4) {
972 }
else if (mylayer > 4 && mylayer <= 10) {
976 }
else if (mylayer > 10 && mylayer <= 13) {
979 int side = (((iter->id) >> 13) & 0x3);
981 HotColdMaps[(mylayer - 1) + (mylayer - 11)]->Fill(-iter->y, iter->x, 1.);
983 HotColdMaps[(mylayer - 1) + (mylayer - 10)]->Fill(-iter->y, iter->x, 1.);
986 }
else if (mylayer > 13) {
989 int side = (((iter->id) >> 18) & 0x3);
991 HotColdMaps[(mylayer + 2) + (mylayer - 14)]->Fill(-iter->y, iter->x, 1.);
993 HotColdMaps[(mylayer + 2) + (mylayer - 13)]->Fill(-iter->y, iter->x, 1.);
999 cout <<
"Finished HotCold Map Generation\n";
1003 cout <<
"Entering TKMap generation!\n";
1010 double myeff, mynum, myden;
1011 double eff_limit = 0;
1013 for (Long_t
i = 1;
i <= 22;
i++) {
1019 fs->
make<TH1F>(Form(
"eff_layer%i",
int(
i)), Form(
"Module efficiency in layer %i",
int(
i)), 201, 0, 1.005);
1021 map<unsigned int, pair<unsigned int, unsigned int> >::const_iterator ih;
1025 mynum = (double)(((*ih).second).second);
1026 myden = (double)(((*ih).second).first);
1028 myeff = mynum / myden;
1031 hEffInLayer->Fill(myeff);
1038 cout <<
"Layer " <<
i <<
" (" <<
GetLayerName(
i) <<
") module " << (*ih).first <<
" efficiency: " << myeff
1039 <<
" , " << mynum <<
"/" << myden << endl;
1045 cout <<
"Layer " <<
i <<
" (" <<
GetLayerName(
i) <<
") module " << (*ih).first <<
" is under occupancy at "
1063 hEffInLayer->GetXaxis()->SetRange(3, hEffInLayer->GetNbinsX() + 1);
1064 eff_limit = hEffInLayer->GetMean() -
threshold;
1065 cout <<
"Layer " <<
i <<
" threshold for bad modules: " << eff_limit << endl;
1066 hEffInLayer->GetXaxis()->SetRange(1, hEffInLayer->GetNbinsX() + 1);
1070 mynum = (double)(((*ih).second).second);
1071 myden = (double)(((*ih).second).first);
1073 myeff = mynum / myden;
1076 if ((myden >=
nModsMin) && (myeff < eff_limit)) {
1080 cout <<
"Layer " <<
i <<
" (" <<
GetLayerName(
i) <<
") module " << (*ih).first <<
" efficiency: " << myeff
1081 <<
" , " << mynum <<
"/" << myden << endl;
1087 cout <<
"Layer " <<
i <<
" (" <<
GetLayerName(
i) <<
") module " << (*ih).first <<
" layer " <<
i
1088 <<
" is under occupancy at " << myden << endl;
1093 tkmap->
save(
true, 0, 0,
"SiStripHitEffTKMap.png");
1094 tkmapbad->
save(
true, 0, 0,
"SiStripHitEffTKMapBad.png");
1096 tkmapnum->
save(
true, 0, 0,
"SiStripHitEffTKMapNum.png");
1097 tkmapden->
save(
true, 0, 0,
"SiStripHitEffTKMapDen.png");
1098 cout <<
"Finished TKMap Generation\n";
1103 cout <<
"Entering SQLite file generation!\n";
1104 std::vector<unsigned int> BadStripList;
1105 unsigned short NStrips;
1107 std::unique_ptr<SiStripQuality> pQuality = std::make_unique<SiStripQuality>(
_detInfo);
1111 map<unsigned int, double>::const_iterator it;
1116 cout <<
"Number of strips module " << (*it).first <<
" is " << NStrips << endl;
1117 BadStripList.push_back(pQuality->encode(0, NStrips, 0));
1119 id1 = (
unsigned int)(*it).first;
1120 cout <<
"ID1 shoudl match list of modules above " <<
id1 << endl;
1124 BadStripList.clear();
1138 for (Long_t
i = 1;
i < 5;
i++) {
1143 for (Long_t
i = 1;
i <= 22;
i++) {
1153 if (
i >= 5 &&
i < 11) {
1157 if (
i >= 11 &&
i < 14) {
1167 cout <<
"The total efficiency is " << double(totalfound) / double(totaltotal) << endl;
1168 cout <<
" TIB: " << double(subdetfound[1]) / subdettotal[1] <<
" " << subdetfound[1] <<
"/" << subdettotal[1]
1170 cout <<
" TOB: " << double(subdetfound[2]) / subdettotal[2] <<
" " << subdetfound[2] <<
"/" << subdettotal[2]
1172 cout <<
" TID: " << double(subdetfound[3]) / subdettotal[3] <<
" " << subdetfound[3] <<
"/" << subdettotal[3]
1174 cout <<
" TEC: " << double(subdetfound[4]) / subdettotal[4] <<
" " << subdetfound[4] <<
"/" << subdettotal[4]
1196 found->SetBinContent(0, -1);
1197 all->SetBinContent(0, 1);
1201 found->SetBinContent(
i, 1
e-6);
1202 all->SetBinContent(
i, 1);
1203 found2->SetBinContent(
i, 1
e-6);
1204 all2->SetBinContent(
i, 1);
1207 TCanvas* c7 =
new TCanvas(
"c7",
" test ", 10, 10, 800, 600);
1208 c7->SetFillColor(0);
1211 int nLayers_max =
nLayers + 1;
1214 for (Long_t
i = 1;
i < nLayers_max; ++
i) {
1232 for (Long_t
i = 11;
i < 14; ++
i) {
1247 cout <<
"Fill only good modules layer " <<
i - 3
1269 TGraphAsymmErrors* gr =
fs->
make<TGraphAsymmErrors>(
nLayers + 1);
1270 gr->SetName(
"eff_good");
1273 TGraphAsymmErrors* gr2 =
fs->
make<TGraphAsymmErrors>(
nLayers + 1);
1274 gr2->SetName(
"eff_all");
1275 gr2->BayesDivide(found2, all2);
1278 gr->SetPointError(
j, 0., 0., gr->GetErrorYlow(
j), gr->GetErrorYhigh(
j));
1279 gr2->SetPointError(
j, 0., 0., gr2->GetErrorYlow(
j), gr2->GetErrorYhigh(
j));
1282 gr->GetXaxis()->SetLimits(0,
nLayers);
1283 gr->SetMarkerColor(2);
1284 gr->SetMarkerSize(1.2);
1285 gr->SetLineColor(2);
1286 gr->SetLineWidth(4);
1287 gr->SetMarkerStyle(20);
1289 gr->SetMaximum(1.001);
1290 gr->GetYaxis()->SetTitle(
"Efficiency");
1291 gStyle->SetTitleFillColor(0);
1292 gStyle->SetTitleBorderSize(0);
1295 gr2->GetXaxis()->SetLimits(0,
nLayers);
1296 gr2->SetMarkerColor(1);
1297 gr2->SetMarkerSize(1.2);
1298 gr2->SetLineColor(1);
1299 gr2->SetLineWidth(4);
1300 gr2->SetMarkerStyle(21);
1302 gr2->SetMaximum(1.001);
1303 gr2->GetYaxis()->SetTitle(
"Efficiency");
1322 gr->GetXaxis()->SetBinLabel(((
k + 1) * 100 + 2) / (
nLayers)-4,
label);
1323 gr2->GetXaxis()->SetBinLabel(((
k + 1) * 100 + 2) / (
nLayers)-4,
label);
1325 gr->GetXaxis()->SetBinLabel((
k + 1) * 100 / (
nLayers)-6,
label);
1326 gr2->GetXaxis()->SetBinLabel((
k + 1) * 100 / (
nLayers)-6,
label);
1330 gr->GetXaxis()->SetBinLabel((
k + 1) * 100 / (
nLayers)-4,
label);
1331 gr2->GetXaxis()->SetBinLabel((
k + 1) * 100 / (
nLayers)-4,
label);
1333 gr->GetXaxis()->SetBinLabel((
k + 1) * 100 / (
nLayers)-7,
label);
1334 gr2->GetXaxis()->SetBinLabel((
k + 1) * 100 / (
nLayers)-7,
label);
1340 gr->GetXaxis()->SetNdivisions(36);
1343 TPad*
overlay =
new TPad(
"overlay",
"", 0, 0, 1, 1);
1346 overlay->SetFrameFillStyle(4000);
1352 TLegend* leg =
new TLegend(0.70, 0.27, 0.88, 0.40);
1353 leg->AddEntry(gr,
"Good Modules",
"p");
1355 leg->AddEntry(gr2,
"All Modules",
"p");
1356 leg->SetTextSize(0.020);
1357 leg->SetFillColor(0);
1360 c7->SaveAs(
"Summary.png");
1364 cout <<
"Computing efficiency vs bx" << endl;
1370 for (
unsigned int ilayer = 1; ilayer <
nLayers; ilayer++) {
1371 TH1F* hfound =
fs->
make<TH1F>(Form(
"foundVsBx_layer%i", ilayer), Form(
"layer %i", ilayer), 3565, 0, 3565);
1372 TH1F* htotal =
fs->
make<TH1F>(Form(
"totalVsBx_layer%i", ilayer), Form(
"layer %i", ilayer), 3565, 0, 3565);
1374 for (
unsigned int ibx = 0; ibx < 3566; ibx++) {
1375 hfound->SetBinContent(ibx, 1
e-6);
1376 htotal->SetBinContent(ibx, 1);
1378 map<unsigned int, vector<int> >::iterator iterMapvsBx;
1380 hfound->SetBinContent(iterMapvsBx->first, iterMapvsBx->second[ilayer]);
1382 if (iterMapvsBx->second[ilayer] > 0)
1383 htotal->SetBinContent(iterMapvsBx->first, iterMapvsBx->second[ilayer]);
1388 TGraphAsymmErrors* geff =
fs->
make<TGraphAsymmErrors>(3564);
1389 geff->SetName(Form(
"effVsBx_layer%i", ilayer));
1390 geff->SetTitle(
"Hit Efficiency vs bx - " +
GetLayerName(ilayer));
1391 geff->BayesDivide(hfound, htotal);
1394 TGraphAsymmErrors* geff_avg =
fs->
make<TGraphAsymmErrors>();
1395 geff_avg->SetName(Form(
"effVsBxAvg_layer%i", ilayer));
1396 geff_avg->SetTitle(
"Hit Efficiency vs bx - " +
GetLayerName(ilayer));
1397 geff_avg->SetMarkerStyle(20);
1399 int previous_bx = -80;
1409 ibx = iterMapvsBx->first;
1410 delta_bx = ibx - previous_bx;
1415 geff_avg->SetPoint(ipt, sum_bx / nbx, eff);
1416 low = TEfficiency::Bayesian(
total,
found, .683, 1, 1,
false);
1417 up = TEfficiency::Bayesian(
total,
found, .683, 1, 1,
true);
1418 geff_avg->SetPointError(ipt, sum_bx / nbx - firstbx, previous_bx - sum_bx / nbx, eff -
low,
up - eff);
1427 found += hfound->GetBinContent(ibx);
1428 total += htotal->GetBinContent(ibx);
1436 geff_avg->SetPoint(ipt, sum_bx / nbx, eff);
1437 low = TEfficiency::Bayesian(
total,
found, .683, 1, 1,
false);
1438 up = TEfficiency::Bayesian(
total,
found, .683, 1, 1,
true);
1439 geff_avg->SetPointError(ipt, sum_bx / nbx - firstbx, previous_bx - sum_bx / nbx, eff -
low,
up - eff);
1444 TString layername =
"";
1445 TString ringlabel =
"D";
1448 if (
k > 0 &&
k < 5) {
1449 layername = TString(
"TIB L") +
k;
1450 }
else if (
k > 4 &&
k < 11) {
1451 layername = TString(
"TOB L") + (
k - 4);
1452 }
else if (
k > 10 &&
k < 14) {
1453 layername = TString(
"TID ") + ringlabel + (
k - 10);
1455 layername = TString(
"TEC ") + ringlabel + (
k - 13);
1469 for (
unsigned int ilayer = 1; ilayer <
nLayers; ilayer++) {
1470 hfound = vhfound[ilayer];
1471 htotal = vhtotal[ilayer];
1477 for (Long_t
i = 0;
i < hfound->GetNbinsX() + 1; ++
i) {
1478 if (hfound->GetBinContent(
i) == 0)
1479 hfound->SetBinContent(
i, 1
e-6);
1480 if (htotal->GetBinContent(
i) == 0)
1481 htotal->SetBinContent(
i, 1);
1484 TGraphAsymmErrors* geff =
fs->
make<TGraphAsymmErrors>(hfound->GetNbinsX());
1485 geff->SetName(Form(
"%s_layer%i",
name.c_str(), ilayer));
1486 geff->BayesDivide(hfound, htotal);
1487 if (
name ==
"effVsLumi")
1488 geff->SetTitle(
"Hit Efficiency vs inst. lumi. - " +
GetLayerName(ilayer));
1489 if (
name ==
"effVsPU")
1490 geff->SetTitle(
"Hit Efficiency vs pileup - " +
GetLayerName(ilayer));
1491 if (
name ==
"effVsCM")
1492 geff->SetTitle(
"Hit Efficiency vs common Mode - " +
GetLayerName(ilayer));
1493 geff->SetMarkerStyle(20);
1498 cout <<
"Computing efficiency vs lumi" << endl;
1502 <<
" pu: " <<
PUHisto->GetMean() <<
"+/-" <<
PUHisto->GetRMS() << endl;
1509 unsigned int nLayersForAvg = 0;
1510 float layerLumi = 0;
1515 cout <<
"Lumi summary: (avg over trajectory measurements)" << endl;
1516 for (
unsigned int ilayer = 1; ilayer <
nLayers; ilayer++) {
1520 if (layerLumi != 0 && layerPU != 0) {
1521 avgLumi += layerLumi;
1526 avgLumi /= nLayersForAvg;
1527 avgPU /= nLayersForAvg;
1528 cout <<
"Avg conditions: lumi :" << avgLumi <<
" pu: " << avgPU << endl;
1536 cout <<
"Computing efficiency vs CM" << endl;
1541 TString layername =
"";
1542 TString ringlabel =
"D";
1545 if (
k > 0 &&
k < 5) {
1546 layername = TString(
"TIB L") +
k;
1547 }
else if (
k > 4 &&
k < 11) {
1548 layername = TString(
"TOB L") + (
k - 4);
1549 }
else if (
k > 10 &&
k < 14) {
1550 layername = TString(
"TID- ") + ringlabel + (
k - 10);
1551 }
else if (
k > 13 &&
k < 17) {
1552 layername = TString(
"TID+ ") + ringlabel + (
k - 13);
1554 layername = TString(
"TEC- ") + ringlabel + (
k - 16);
1556 layername = TString(
"TEC+ ") + ringlabel + (
k - 16 -
nTEClayers);
1565 auto obj = std::make_unique<SiStripBadStrip>();
1570 for (; rIter != rIterEnd; ++rIter) {
1573 if (!
obj->put(rIter->detid,
range))
1575 <<
"[SiStripHitEffFromCalibTree::getNewObject] detid already exists" << std::endl;
1584 if ((
x >= 0) && (
y >= 0))
1586 else if ((
x >= 0) && (
y <= 0))
1588 else if ((
x <= 0) && (
y >= 0))
1627 NBadComponent[
i][0][0]++;