63 #include "TEfficiency.h" 67 #include "TGraphAsymmErrors.h" 73 #include "TObjString.h" 81 #define LOGPRINT edm::LogPrint("SiStripHitEffFromCalibTree") 102 std::unique_ptr<SiStripBadStrip> getNewObject()
override;
108 std::stringstream ssV[4][19],
109 int NBadComponent[4][19][4]);
110 void makeTKMap(
bool autoTagging);
111 void makeHotColdMaps();
113 void totalStatistics();
115 void makeSummaryVsBx();
116 void computeEff(vector<TH1F*>& vhfound, vector<TH1F*>& vhtotal,
string name);
117 void makeSummaryVsLumi();
118 void makeSummaryVsCM();
119 TString getLayerSideName(Long_t
k);
122 static constexpr
int siStripLayers_ = 22;
123 static constexpr
double nBxInAnOrbit_ = 3565;
167 map<pair<unsigned int, unsigned int>, array<double, 3> >
eventInfos;
173 map<unsigned int, pair<unsigned int, unsigned int> > modCounter[23];
191 int goodlayertotal[35];
192 int goodlayerfound[35];
193 int alllayertotal[35];
194 int alllayerfound[35];
239 ifstream badModules_file;
240 set<uint32_t> badModules_list;
243 uint32_t badmodule_detid;
244 int mods, fiber1, fiber2, fiber3;
245 if (badModules_file.is_open()) {
247 while (getline(badModules_file,
line)) {
248 if (badModules_file.eof())
251 ss >> badmodule_detid >>
mods >> fiber1 >> fiber2 >> fiber3;
252 if (badmodule_detid != 0 &&
mods == 1 && (fiber1 == 1 || fiber2 == 1 || fiber3 == 1))
253 badModules_list.insert(badmodule_detid);
255 badModules_file.close();
258 if (!badModules_list.empty())
259 LOGPRINT <<
"Remove additionnal bad modules from the analysis: ";
260 set<uint32_t>::iterator itBadMod;
261 for (
const auto& badMod : badModules_list) {
275 for (
int l = 0;
l < 35;
l++) {
282 TH1F* resolutionPlots[23];
283 for (Long_t ilayer = 0; ilayer < 23; ilayer++) {
286 resolutionPlots[ilayer] =
fs->
make<TH1F>(Form(
"resol_layer_%i", (
int)(ilayer)), lyrName.c_str(), 125, -125, 125);
287 resolutionPlots[ilayer]->GetXaxis()->SetTitle(
"trajX-clusX [strip unit]");
290 fs->
make<TH1F>(Form(
"layerfound_vsLumi_layer_%i", (
int)(ilayer)), lyrName.c_str(), 100, 0, 25000));
292 fs->
make<TH1F>(Form(
"layertotal_vsLumi_layer_%i", (
int)(ilayer)), lyrName.c_str(), 100, 0, 25000));
294 fs->
make<TH1F>(Form(
"layerfound_vsPU_layer_%i", (
int)(ilayer)), lyrName.c_str(), 45, 0, 90));
296 fs->
make<TH1F>(Form(
"layertotal_vsPU_layer_%i", (
int)(ilayer)), lyrName.c_str(), 45, 0, 90));
305 fs->
make<TH1F>(Form(
"layerfound_vsCM_layer_%i", (
int)(ilayer)), lyrName.c_str(), 20, 0, 400));
307 fs->
make<TH1F>(Form(
"layertotal_vsCM_layer_%i", (
int)(ilayer)), lyrName.c_str(), 20, 0, 400));
316 LOGPRINT <<
"A module is bad if the upper limit on the efficiency is < to the avg in the layer - " <<
threshold_ 317 <<
" and has at least " <<
nModsMin_ <<
" nModsMin.";
319 unsigned int run, evt,
bx{0};
324 LOGPRINT <<
"Loading file: " << calibTreeFileName;
325 TFile* CalibTreeFile = TFile::Open(calibTreeFileName.c_str(),
"READ");
328 bool foundEventInfos =
false;
330 CalibTreeFile->cd(
"eventInfo");
334 TTree* EventTree = (TTree*)(gDirectory->Get(
"tree"));
342 LOGPRINT <<
"Found event infos tree";
344 runLf = EventTree->GetLeaf(
"run");
345 evtLf = EventTree->GetLeaf(
"event");
347 BunchLf = EventTree->GetLeaf(
"bx");
348 InstLumiLf = EventTree->GetLeaf(
"instLumi");
349 PULf = EventTree->GetLeaf(
"PU");
351 int nevt = EventTree->GetEntries();
353 foundEventInfos =
true;
355 for (
int j = 0;
j <
nevt;
j++) {
356 EventTree->GetEntry(
j);
357 run = runLf->GetValue();
358 evt = evtLf->GetValue();
359 bx = BunchLf->GetValue();
361 PU = PULf->GetValue();
373 CalibTreeFile->cd(
"anEff");
374 calibTree_ = (TTree*)(gDirectory->Get(
"traj"));
378 TLeaf* BadLf =
calibTree_->GetLeaf(
"ModIsBad");
379 TLeaf* sistripLf =
calibTree_->GetLeaf(
"SiStripQualBad");
381 TLeaf* acceptLf =
calibTree_->GetLeaf(
"withinAcceptance");
382 TLeaf* layerLf =
calibTree_->GetLeaf(
"layer");
384 TLeaf* highPurityLf =
calibTree_->GetLeaf(
"highPurity");
388 TLeaf* ResXSigLf =
calibTree_->GetLeaf(
"ResXSig");
389 TLeaf* TrajLocXLf =
calibTree_->GetLeaf(
"TrajLocX");
390 TLeaf* TrajLocYLf =
calibTree_->GetLeaf(
"TrajLocY");
391 TLeaf* ClusterLocXLf =
calibTree_->GetLeaf(
"ClusterLocX");
395 TLeaf* CMLf =
nullptr;
400 LOGPRINT <<
"Successfully loaded analyze function with " <<
nevents <<
" events!\n";
402 map<pair<unsigned int, unsigned int>, array<double, 3> >::iterator itEventInfos;
403 map<pair<unsigned int, unsigned int>,
bool>::iterator itEventUsed;
408 run = (
unsigned int)runLf->GetValue();
409 evt = (
unsigned int)evtLf->GetValue();
410 unsigned int isBad = (
unsigned int)BadLf->GetValue();
411 unsigned int quality = (
unsigned int)sistripLf->GetValue();
412 unsigned int id = (
unsigned int)idLf->GetValue();
413 unsigned int accept = (
unsigned int)acceptLf->GetValue();
414 unsigned int layer_wheel = (
unsigned int)layerLf->GetValue();
415 unsigned int layer = layer_wheel;
418 layer = 10 + ((
id >> 9) & 0x3);
420 layer = 13 + ((
id >> 5) & 0x7);
424 double x = xLf->GetValue();
425 double y = yLf->GetValue();
426 double z = zLf->GetValue();
427 double resxsig = ResXSigLf->GetValue();
428 double TrajLocX = TrajLocXLf->GetValue();
429 double TrajLocY = TrajLocYLf->GetValue();
430 double ClusterLocX = ClusterLocXLf->GetValue();
434 bool badquality =
false;
440 if (!foundEventInfos) {
441 bx = (
unsigned int)BunchLf->GetValue();
442 if (InstLumiLf !=
nullptr)
445 PU = PULf->GetValue();
453 CM = CMLf->GetValue();
456 if (foundEventInfos) {
459 bx = itEventInfos->second[0];
461 PU = itEventInfos->second[2];
469 if (itEventUsed->second ==
false) {
473 itEventUsed->second =
true;
496 itBadMod = badModules_list.find(
id);
497 if (itBadMod != badModules_list.end())
503 bool badflag =
false;
510 if (isBad == 1 || resxsig >
resXSig_)
518 if (resxsig == 1000.0) {
521 stripTrajMid = TrajLocX / Pitch + nstrips / 2.0;
524 DetId ClusterDetId(
id);
529 stripTrajMid = TrajLocX / Pitch + nstrips / 2.0;
540 dynamic_cast<const TrapezoidalPlaneBounds*>(&(plane.bounds())));
541 std::array<const float, 4>
const&
parameters = (*trapezoidalBounds).parameters();
545 TrajLocXMid = TrajLocX / (1 + (htedge - hbedge) * TrajLocY / (htedge + hbedge) /
547 stripTrajMid = TrajLocXMid / Pitch + nstrips / 2.0;
551 if (!badquality &&
layer < 23) {
552 if (resxsig != 1000.0)
555 resolutionPlots[
layer]->Fill(1000);
561 float stripInAPV = 64.;
565 if (resxsig == 1000.0) {
576 tapv = (
int)stripTrajMid / 128;
578 stripInAPV = stripTrajMid - tapv * 128;
580 if (stripInAPV < stripsApvEdge_ || stripInAPV > 128 -
stripsApvEdge_)
588 if (badflag && !badquality) {
596 pair<unsigned int, unsigned int> newgoodpair(1, 1);
597 pair<unsigned int, unsigned int> newbadpair(1, 0);
599 map<unsigned int, pair<unsigned int, unsigned int> >::iterator it =
modCounter[
layer].find(
id);
607 ((*it).second.first)++;
609 ((*it).second.second)++;
639 if (((
id >> 13) & 0x3) == 1) {
643 }
else if (((
id >> 13) & 0x3) == 2) {
649 if (((
id >> 18) & 0x3) == 1) {
653 }
else if (((
id >> 18) & 0x3) == 2) {
666 if (((
id >> 13) & 0x3) == 1) {
670 }
else if (((
id >> 13) & 0x3) == 2) {
676 if (((
id >> 18) & 0x3) == 1) {
680 }
else if (((
id >> 18) & 0x3) == 2) {
703 int NTkBadComponent[4];
704 int NBadComponent[4][19][4];
708 std::stringstream ssV[4][19];
710 for (
int i = 0;
i < 4; ++
i) {
711 NTkBadComponent[
i] = 0;
712 for (
int j = 0;
j < 19; ++
j) {
714 for (
int k = 0;
k < 4; ++
k)
715 NBadComponent[
i][
j][
k] = 0;
721 for (
size_t i = 0;
i < BC.size(); ++
i) {
727 NTkBadComponent[0]++;
729 NTkBadComponent[1] += ((BC[
i].BadFibers >> 2) & 0
x1) + ((BC[
i].BadFibers >> 1) & 0
x1) + ((BC[
i].BadFibers) & 0
x1);
731 NTkBadComponent[2] += ((BC[
i].BadApvs >> 5) & 0
x1) + ((BC[
i].BadApvs >> 4) & 0
x1) + ((BC[
i].BadApvs >> 3) & 0
x1) +
732 ((BC[
i].BadApvs >> 2) & 0
x1) + ((BC[
i].BadApvs >> 1) & 0
x1) + ((BC[
i].BadApvs) & 0
x1);
753 component = tTopo.tidSide(BC[
i].detid) == 2 ? tTopo.tidWheel(BC[
i].detid) : tTopo.tidWheel(BC[
i].detid) + 3;
769 component = tTopo.tecSide(BC[
i].detid) == 2 ? tTopo.tecWheel(BC[
i].detid) : tTopo.tecWheel(BC[
i].detid) + 9;
777 float percentage = 0;
783 unsigned int detid = rp->detid;
788 if (
a.subdetId() == 3) {
791 }
else if (
a.subdetId() == 4) {
793 component = tTopo.tidSide(detid) == 2 ? tTopo.tidWheel(detid) : tTopo.tidWheel(detid) + 3;
794 }
else if (
a.subdetId() == 5) {
797 }
else if (
a.subdetId() == 6) {
799 component = tTopo.tecSide(detid) == 2 ? tTopo.tecWheel(detid) : tTopo.tecWheel(detid) + 9;
806 for (
int it = 0; it < sqrange.second - sqrange.first; it++) {
808 NTkBadComponent[3] +=
range;
809 NBadComponent[subdet][0][3] +=
range;
816 edm::LogError(
"SiStripQualityStatistics") <<
"PROBLEM detid " << detid <<
" value " << percentage << std::endl;
821 std::ostringstream
ss;
823 ss <<
"\n-----------------\nNew IOV starting from run " <<
e.id().run() <<
" event " <<
e.id().event()
824 <<
" lumiBlock " <<
e.luminosityBlock() <<
" time " <<
e.time().value() <<
"\n-----------------\n";
825 ss <<
"\n-----------------\nGlobal Info\n-----------------";
826 ss <<
"\nBadComponent \t Modules \tFibers " 827 "\tApvs\tStrips\n----------------------------------------------------------------";
828 ss <<
"\nTracker:\t\t" << NTkBadComponent[0] <<
"\t" << NTkBadComponent[1] <<
"\t" << NTkBadComponent[2] <<
"\t" 829 << NTkBadComponent[3];
830 ss <<
"\nTIB:\t\t\t" << NBadComponent[0][0][0] <<
"\t" << NBadComponent[0][0][1] <<
"\t" << NBadComponent[0][0][2]
831 <<
"\t" << NBadComponent[0][0][3];
832 ss <<
"\nTID:\t\t\t" << NBadComponent[1][0][0] <<
"\t" << NBadComponent[1][0][1] <<
"\t" << NBadComponent[1][0][2]
833 <<
"\t" << NBadComponent[1][0][3];
834 ss <<
"\nTOB:\t\t\t" << NBadComponent[2][0][0] <<
"\t" << NBadComponent[2][0][1] <<
"\t" << NBadComponent[2][0][2]
835 <<
"\t" << NBadComponent[2][0][3];
836 ss <<
"\nTEC:\t\t\t" << NBadComponent[3][0][0] <<
"\t" << NBadComponent[3][0][1] <<
"\t" << NBadComponent[3][0][2]
837 <<
"\t" << NBadComponent[3][0][3];
840 for (
int i = 1;
i < 5; ++
i)
841 ss <<
"\nTIB Layer " <<
i <<
" :\t\t" << NBadComponent[0][
i][0] <<
"\t" << NBadComponent[0][
i][1] <<
"\t" 842 << NBadComponent[0][
i][2] <<
"\t" << NBadComponent[0][
i][3];
844 for (
int i = 1;
i < 4; ++
i)
845 ss <<
"\nTID+ Disk " <<
i <<
" :\t\t" << NBadComponent[1][
i][0] <<
"\t" << NBadComponent[1][
i][1] <<
"\t" 846 << NBadComponent[1][
i][2] <<
"\t" << NBadComponent[1][
i][3];
847 for (
int i = 4;
i < 7; ++
i)
848 ss <<
"\nTID- Disk " <<
i - 3 <<
" :\t\t" << NBadComponent[1][
i][0] <<
"\t" << NBadComponent[1][
i][1] <<
"\t" 849 << NBadComponent[1][
i][2] <<
"\t" << NBadComponent[1][
i][3];
851 for (
int i = 1;
i < 7; ++
i)
852 ss <<
"\nTOB Layer " <<
i <<
" :\t\t" << NBadComponent[2][
i][0] <<
"\t" << NBadComponent[2][
i][1] <<
"\t" 853 << NBadComponent[2][
i][2] <<
"\t" << NBadComponent[2][
i][3];
855 for (
int i = 1;
i < 10; ++
i)
856 ss <<
"\nTEC+ Disk " <<
i <<
" :\t\t" << NBadComponent[3][
i][0] <<
"\t" << NBadComponent[3][
i][1] <<
"\t" 857 << NBadComponent[3][
i][2] <<
"\t" << NBadComponent[3][
i][3];
858 for (
int i = 10;
i < 19; ++
i)
859 ss <<
"\nTEC- Disk " <<
i - 9 <<
" :\t\t" << NBadComponent[3][
i][0] <<
"\t" << NBadComponent[3][
i][1] <<
"\t" 860 << NBadComponent[3][
i][2] <<
"\t" << NBadComponent[3][
i][3];
863 ss <<
"\n----------------------------------------------------------------\n\t\t Detid \tModules Fibers " 864 "Apvs\n----------------------------------------------------------------";
865 for (
int i = 1;
i < 5; ++
i)
866 ss <<
"\nTIB Layer " <<
i <<
" :" << ssV[0][
i].
str();
868 for (
int i = 1;
i < 4; ++
i)
869 ss <<
"\nTID+ Disk " <<
i <<
" :" << ssV[1][
i].
str();
870 for (
int i = 4;
i < 7; ++
i)
871 ss <<
"\nTID- Disk " <<
i - 3 <<
" :" << ssV[1][
i].
str();
873 for (
int i = 1;
i < 7; ++
i)
874 ss <<
"\nTOB Layer " <<
i <<
" :" << ssV[2][
i].
str();
876 for (
int i = 1;
i < 10; ++
i)
877 ss <<
"\nTEC+ Disk " <<
i <<
" :" << ssV[3][
i].
str();
878 for (
int i = 10;
i < 19; ++
i)
879 ss <<
"\nTEC- Disk " <<
i - 9 <<
" :" << ssV[3][
i].
str();
885 badModules.open(
"BadModules.log");
886 badModules <<
"\n----------------------------------------------------------------\n\t\t Detid \tModules Fibers " 887 "Apvs\n----------------------------------------------------------------";
888 for (
int i = 1;
i < 5; ++
i)
889 badModules <<
"\nTIB Layer " <<
i <<
" :" << ssV[0][
i].
str();
891 for (
int i = 1;
i < 4; ++
i)
892 badModules <<
"\nTID+ Disk " <<
i <<
" :" << ssV[1][
i].
str();
893 for (
int i = 4;
i < 7; ++
i)
894 badModules <<
"\nTID- Disk " <<
i - 3 <<
" :" << ssV[1][
i].
str();
896 for (
int i = 1;
i < 7; ++
i)
897 badModules <<
"\nTOB Layer " <<
i <<
" :" << ssV[2][
i].
str();
899 for (
int i = 1;
i < 10; ++
i)
900 badModules <<
"\nTEC+ Disk " <<
i <<
" :" << ssV[3][
i].
str();
901 for (
int i = 10;
i < 19; ++
i)
902 badModules <<
"\nTEC- Disk " <<
i - 9 <<
" :" << ssV[3][
i].
str();
907 LOGPRINT <<
"Entering hot cold map generation!\n";
908 TStyle* gStyle =
new TStyle(
"gStyle",
"myStyle");
910 gStyle->SetPalette(1);
911 gStyle->SetCanvasColor(kWhite);
912 gStyle->SetOptStat(0);
917 for (Long_t maplayer = 1; maplayer <=
siStripLayers_; maplayer++) {
919 if (maplayer > 0 && maplayer <= 4) {
921 temph2 =
fs->
make<TH2F>(Form(
"%s%i",
"TIB", (
int)(maplayer)),
"TIB", 100, -1, 361, 100, -100, 100);
922 temph2->GetXaxis()->SetTitle(
"Phi");
923 temph2->GetXaxis()->SetBinLabel(1, TString(
"360"));
924 temph2->GetXaxis()->SetBinLabel(50, TString(
"180"));
925 temph2->GetXaxis()->SetBinLabel(100, TString(
"0"));
926 temph2->GetYaxis()->SetTitle(
"Global Z");
927 temph2->SetOption(
"colz");
929 }
else if (maplayer > 4 && maplayer <= 10) {
931 temph2 =
fs->
make<TH2F>(Form(
"%s%i",
"TOB", (
int)(maplayer - 4)),
"TOB", 100, -1, 361, 100, -120, 120);
932 temph2->GetXaxis()->SetTitle(
"Phi");
933 temph2->GetXaxis()->SetBinLabel(1, TString(
"360"));
934 temph2->GetXaxis()->SetBinLabel(50, TString(
"180"));
935 temph2->GetXaxis()->SetBinLabel(100, TString(
"0"));
936 temph2->GetYaxis()->SetTitle(
"Global Z");
937 temph2->SetOption(
"colz");
939 }
else if (maplayer > 10 && maplayer <= 13) {
942 temph2 =
fs->
make<TH2F>(Form(
"%s%i",
"TID-", (
int)(maplayer - 10)),
"TID-", 100, -100, 100, 100, -100, 100);
943 temph2->GetXaxis()->SetTitle(
"Global Y");
944 temph2->GetXaxis()->SetBinLabel(1, TString(
"+Y"));
945 temph2->GetXaxis()->SetBinLabel(50, TString(
"0"));
946 temph2->GetXaxis()->SetBinLabel(100, TString(
"-Y"));
947 temph2->GetYaxis()->SetTitle(
"Global X");
948 temph2->GetYaxis()->SetBinLabel(1, TString(
"-X"));
949 temph2->GetYaxis()->SetBinLabel(50, TString(
"0"));
950 temph2->GetYaxis()->SetBinLabel(100, TString(
"+X"));
951 temph2->SetOption(
"colz");
953 temph2 =
fs->
make<TH2F>(Form(
"%s%i",
"TID+", (
int)(maplayer - 10)),
"TID+", 100, -100, 100, 100, -100, 100);
954 temph2->GetXaxis()->SetTitle(
"Global Y");
955 temph2->GetXaxis()->SetBinLabel(1, TString(
"+Y"));
956 temph2->GetXaxis()->SetBinLabel(50, TString(
"0"));
957 temph2->GetXaxis()->SetBinLabel(100, TString(
"-Y"));
958 temph2->GetYaxis()->SetTitle(
"Global X");
959 temph2->GetYaxis()->SetBinLabel(1, TString(
"-X"));
960 temph2->GetYaxis()->SetBinLabel(50, TString(
"0"));
961 temph2->GetYaxis()->SetBinLabel(100, TString(
"+X"));
962 temph2->SetOption(
"colz");
964 }
else if (maplayer > 13) {
967 temph2 =
fs->
make<TH2F>(Form(
"%s%i",
"TEC-", (
int)(maplayer - 13)),
"TEC-", 100, -120, 120, 100, -120, 120);
968 temph2->GetXaxis()->SetTitle(
"Global Y");
969 temph2->GetXaxis()->SetBinLabel(1, TString(
"+Y"));
970 temph2->GetXaxis()->SetBinLabel(50, TString(
"0"));
971 temph2->GetXaxis()->SetBinLabel(100, TString(
"-Y"));
972 temph2->GetYaxis()->SetTitle(
"Global X");
973 temph2->GetYaxis()->SetBinLabel(1, TString(
"-X"));
974 temph2->GetYaxis()->SetBinLabel(50, TString(
"0"));
975 temph2->GetYaxis()->SetBinLabel(100, TString(
"+X"));
976 temph2->SetOption(
"colz");
978 temph2 =
fs->
make<TH2F>(Form(
"%s%i",
"TEC+", (
int)(maplayer - 13)),
"TEC+", 100, -120, 120, 100, -120, 120);
979 temph2->GetXaxis()->SetTitle(
"Global Y");
980 temph2->GetXaxis()->SetBinLabel(1, TString(
"+Y"));
981 temph2->GetXaxis()->SetBinLabel(50, TString(
"0"));
982 temph2->GetXaxis()->SetBinLabel(100, TString(
"-Y"));
983 temph2->GetYaxis()->SetTitle(
"Global X");
984 temph2->GetYaxis()->SetBinLabel(1, TString(
"-X"));
985 temph2->GetYaxis()->SetBinLabel(50, TString(
"0"));
986 temph2->GetYaxis()->SetBinLabel(100, TString(
"+X"));
987 temph2->SetOption(
"colz");
995 vector<hit>::const_iterator iter;
996 for (iter =
hits[mylayer].begin(); iter !=
hits[mylayer].end(); iter++) {
1000 if (mylayer > 0 && mylayer <= 4) {
1002 float phi = ::calcPhi(iter->x, iter->y);
1004 }
else if (mylayer > 4 && mylayer <= 10) {
1006 float phi = ::calcPhi(iter->x, iter->y);
1008 }
else if (mylayer > 10 && mylayer <= 13) {
1011 int side = (((iter->id) >> 13) & 0x3);
1013 HotColdMaps[(mylayer - 1) + (mylayer - 11)]->Fill(-iter->y, iter->x, 1.);
1015 HotColdMaps[(mylayer - 1) + (mylayer - 10)]->Fill(-iter->y, iter->x, 1.);
1018 }
else if (mylayer > 13) {
1021 int side = (((iter->id) >> 18) & 0x3);
1023 HotColdMaps[(mylayer + 2) + (mylayer - 14)]->Fill(-iter->y, iter->x, 1.);
1025 HotColdMaps[(mylayer + 2) + (mylayer - 13)]->Fill(-iter->y, iter->x, 1.);
1031 LOGPRINT <<
"Finished HotCold Map Generation\n";
1035 LOGPRINT <<
"Entering TKMap generation!\n";
1037 TTree*
tree =
nullptr;
1038 unsigned int t_DetId, t_found, t_total;
1039 unsigned char t_layer;
1040 bool t_isTaggedIneff;
1044 tree->Branch(
"DetId", &t_DetId,
"DetId/i");
1045 tree->Branch(
"Layer", &t_layer,
"Layer/b");
1046 tree->Branch(
"FoundHits", &t_found,
"FoundHits/i");
1047 tree->Branch(
"AllHits", &t_total,
"AllHits/i");
1048 tree->Branch(
"IsTaggedIneff", &t_isTaggedIneff,
"IsTaggedIneff/O");
1049 tree->Branch(
"TagThreshold", &t_threshold,
"TagThreshold/F");
1058 double myeff, mynum, myden, myeff_up;
1059 double layer_min_eff = 0;
1067 fs->
make<TH1F>(Form(
"eff_layer%i",
int(
i)), Form(
"Module efficiency in layer %i",
int(
i)), 201, 0, 1.005);
1072 mynum = (double)((ih.second).second);
1073 myden = (double)((ih.second).first);
1075 myeff = mynum / myden;
1078 hEffInLayer->Fill(myeff);
1086 <<
" efficiency: " << myeff <<
" , " << mynum <<
"/" << myden;
1093 <<
" efficiency: " << myeff <<
" , " << mynum <<
"/" << myden;
1096 <<
" is under occupancy at " << myden;
1105 t_isTaggedIneff =
false;
1123 hEffInLayer->GetXaxis()->SetRange(3, hEffInLayer->GetNbinsX() + 1);
1125 hEffInLayer->GetMean() - 2.5 * hEffInLayer->GetRMS();
1126 if (
threshold_ > 2.5 * hEffInLayer->GetRMS())
1127 layer_min_eff = hEffInLayer->GetMean() -
threshold_;
1128 LOGPRINT <<
"Layer " <<
i <<
" threshold for bad modules: <" << layer_min_eff
1129 <<
" (layer mean: " << hEffInLayer->GetMean() <<
" rms: " << hEffInLayer->GetRMS() <<
")";
1131 hEffInLayer->GetXaxis()->SetRange(1, hEffInLayer->GetNbinsX() + 1);
1135 mynum = (double)((ih.second).second);
1136 myden = (double)((ih.second).first);
1138 myeff = mynum / myden;
1142 myeff_up = TEfficiency::Bayesian(myden, mynum, .99, 1, 1,
true);
1143 if ((myden >=
nModsMin_) && (myeff_up < layer_min_eff)) {
1147 t_isTaggedIneff =
true;
1151 t_isTaggedIneff =
false;
1153 if (myeff_up < layer_min_eff + 0.08)
1155 <<
" efficiency: " << myeff <<
" , " << mynum <<
"/" << myden <<
" , upper limit: " << myeff_up;
1158 <<
" layer " <<
i <<
" is under occupancy at " << myden;
1166 t_threshold = layer_min_eff;
1172 tkmap->
save(
true, 0, 0,
"SiStripHitEffTKMap.png");
1173 tkmapbad->
save(
true, 0, 0,
"SiStripHitEffTKMapBad.png");
1175 tkmapnum->
save(
true, 0, 0,
"SiStripHitEffTKMapNum.png");
1176 tkmapden->
save(
true, 0, 0,
"SiStripHitEffTKMapDen.png");
1177 LOGPRINT <<
"Finished TKMap Generation\n";
1179 LOGPRINT <<
"Modules efficiencies stored in tree\n";
1184 LOGPRINT <<
"Entering SQLite file generation!\n";
1185 std::vector<unsigned int> BadStripList;
1186 unsigned short NStrips;
1188 std::unique_ptr<SiStripQuality> pQuality = std::make_unique<SiStripQuality>(
detInfo_);
1196 LOGPRINT <<
"Number of strips module " << it.first <<
" is " << NStrips;
1197 BadStripList.push_back(pQuality->encode(0, NStrips, 0));
1199 id1 = (
unsigned int)it.first;
1200 LOGPRINT <<
"ID1 shoudl match list of modules above " <<
id1;
1204 BadStripList.clear();
1218 for (Long_t
i = 1;
i < 5;
i++) {
1233 if (
i >= 5 &&
i < 11) {
1237 if (
i >= 11 &&
i < 14) {
1247 LOGPRINT <<
"The total efficiency is " << double(totalfound) / double(totaltotal);
1248 LOGPRINT <<
" TIB: " << double(subdetfound[1]) / subdettotal[1] <<
" " << subdetfound[1] <<
"/" 1250 LOGPRINT <<
" TOB: " << double(subdetfound[2]) / subdettotal[2] <<
" " << subdetfound[2] <<
"/" 1252 LOGPRINT <<
" TID: " << double(subdetfound[3]) / subdettotal[3] <<
" " << subdetfound[3] <<
"/" 1254 LOGPRINT <<
" TEC: " << double(subdetfound[4]) / subdettotal[4] <<
" " << subdetfound[4] <<
"/" 1276 found->SetBinContent(0, -1);
1277 all->SetBinContent(0, 1);
1281 found->SetBinContent(
i, 1
e-6);
1282 all->SetBinContent(
i, 1);
1283 found2->SetBinContent(
i, 1
e-6);
1284 all2->SetBinContent(
i, 1);
1287 TCanvas* c7 =
new TCanvas(
"c7",
" test ", 10, 10, 800, 600);
1288 c7->SetFillColor(0);
1291 int nLayers_max =
nLayers + 1;
1294 for (Long_t
i = 1;
i < nLayers_max; ++
i) {
1311 for (Long_t
i = 11;
i < 14; ++
i) {
1326 LOGPRINT <<
"Fill only good modules layer " <<
i - 3
1348 TGraphAsymmErrors* gr =
fs->
make<TGraphAsymmErrors>(
nLayers + 1);
1349 gr->SetName(
"eff_good");
1352 TGraphAsymmErrors* gr2 =
fs->
make<TGraphAsymmErrors>(
nLayers + 1);
1353 gr2->SetName(
"eff_all");
1354 gr2->BayesDivide(found2, all2);
1357 gr->SetPointError(
j, 0., 0., gr->GetErrorYlow(
j), gr->GetErrorYhigh(
j));
1358 gr2->SetPointError(
j, 0., 0., gr2->GetErrorYlow(
j), gr2->GetErrorYhigh(
j));
1361 gr->GetXaxis()->SetLimits(0,
nLayers);
1362 gr->SetMarkerColor(2);
1363 gr->SetMarkerSize(1.2);
1364 gr->SetLineColor(2);
1365 gr->SetLineWidth(4);
1366 gr->SetMarkerStyle(20);
1368 gr->SetMaximum(1.001);
1369 gr->GetYaxis()->SetTitle(
"Efficiency");
1370 gStyle->SetTitleFillColor(0);
1371 gStyle->SetTitleBorderSize(0);
1374 gr2->GetXaxis()->SetLimits(0,
nLayers);
1375 gr2->SetMarkerColor(1);
1376 gr2->SetMarkerSize(1.2);
1377 gr2->SetLineColor(1);
1378 gr2->SetLineWidth(4);
1379 gr2->SetMarkerStyle(21);
1381 gr2->SetMaximum(1.001);
1382 gr2->GetYaxis()->SetTitle(
"Efficiency");
1401 gr->GetXaxis()->SetBinLabel(((
k + 1) * 100 + 2) / (
nLayers)-4,
label);
1402 gr2->GetXaxis()->SetBinLabel(((
k + 1) * 100 + 2) / (
nLayers)-4,
label);
1404 gr->GetXaxis()->SetBinLabel((
k + 1) * 100 / (
nLayers)-6,
label);
1405 gr2->GetXaxis()->SetBinLabel((
k + 1) * 100 / (
nLayers)-6,
label);
1409 gr->GetXaxis()->SetBinLabel((
k + 1) * 100 / (
nLayers)-4,
label);
1410 gr2->GetXaxis()->SetBinLabel((
k + 1) * 100 / (
nLayers)-4,
label);
1412 gr->GetXaxis()->SetBinLabel((
k + 1) * 100 / (
nLayers)-7,
label);
1413 gr2->GetXaxis()->SetBinLabel((
k + 1) * 100 / (
nLayers)-7,
label);
1419 gr->GetXaxis()->SetNdivisions(36);
1422 TPad*
overlay =
new TPad(
"overlay",
"", 0, 0, 1, 1);
1425 overlay->SetFrameFillStyle(4000);
1431 TLegend* leg =
new TLegend(0.70, 0.27, 0.88, 0.40);
1432 leg->AddEntry(gr,
"Good Modules",
"p");
1434 leg->AddEntry(gr2,
"All Modules",
"p");
1435 leg->SetTextSize(0.020);
1436 leg->SetFillColor(0);
1439 c7->SaveAs(
"Summary.png");
1440 c7->SaveAs(
"Summary.C");
1444 LOGPRINT <<
"Computing efficiency vs bx";
1450 for (
unsigned int ilayer = 1; ilayer <
nLayers; ilayer++) {
1457 layerfound_vsBX[ilayer]->SetBinContent(iterMapvsBx.first, iterMapvsBx.second[ilayer]);
1460 if (iterMapvsBx.second[ilayer] > 0) {
1461 layertotal_vsBX[ilayer]->SetBinContent(iterMapvsBx.first, iterMapvsBx.second[ilayer]);
1469 geff->SetName(Form(
"effVsBx_layer%i", ilayer));
1475 TGraphAsymmErrors* geff_avg =
fs->
make<TGraphAsymmErrors>();
1476 geff_avg->SetName(Form(
"effVsBxAvg_layer%i", ilayer));
1478 geff_avg->SetMarkerStyle(20);
1480 int previous_bx = -80;
1490 ibx = iterMapvsBx.first;
1491 delta_bx = ibx - previous_bx;
1496 geff_avg->SetPoint(ipt, sum_bx / nbx, eff);
1497 low = TEfficiency::Bayesian(
total,
found, .683, 1, 1,
false);
1498 up = TEfficiency::Bayesian(
total,
found, .683, 1, 1,
true);
1499 geff_avg->SetPointError(ipt, sum_bx / nbx - firstbx, previous_bx - sum_bx / nbx, eff -
low,
up - eff);
1517 geff_avg->SetPoint(ipt, sum_bx / nbx, eff);
1518 low = TEfficiency::Bayesian(
total,
found, .683, 1, 1,
false);
1519 up = TEfficiency::Bayesian(
total,
found, .683, 1, 1,
true);
1520 geff_avg->SetPointError(ipt, sum_bx / nbx - firstbx, previous_bx - sum_bx / nbx, eff -
low,
up - eff);
1532 for (
unsigned int ilayer = 1; ilayer <
nLayers; ilayer++) {
1533 hfound = vhfound[ilayer];
1534 htotal = vhtotal[ilayer];
1540 for (Long_t
i = 0;
i < hfound->GetNbinsX() + 1; ++
i) {
1541 if (hfound->GetBinContent(
i) == 0)
1542 hfound->SetBinContent(
i, 1
e-6);
1543 if (htotal->GetBinContent(
i) == 0)
1544 htotal->SetBinContent(
i, 1);
1547 TGraphAsymmErrors* geff =
fs->
make<TGraphAsymmErrors>(hfound->GetNbinsX());
1548 geff->SetName(Form(
"%s_layer%i",
name.c_str(), ilayer));
1549 geff->BayesDivide(hfound, htotal);
1550 if (
name ==
"effVsLumi")
1553 if (
name ==
"effVsPU")
1555 if (
name ==
"effVsCM")
1558 geff->SetMarkerStyle(20);
1563 LOGPRINT <<
"Computing efficiency vs lumi";
1574 unsigned int nLayersForAvg = 0;
1575 float layerLumi = 0;
1580 LOGPRINT <<
"Lumi summary: (avg over trajectory measurements)";
1581 for (
unsigned int ilayer = 1; ilayer <
nLayers; ilayer++) {
1585 if (layerLumi != 0 && layerPU != 0) {
1586 avgLumi += layerLumi;
1591 avgLumi /= nLayersForAvg;
1592 avgPU /= nLayersForAvg;
1593 LOGPRINT <<
"Avg conditions: lumi :" << avgLumi <<
" pu: " << avgPU;
1601 LOGPRINT <<
"Computing efficiency vs CM";
1606 TString layername =
"";
1607 TString ringlabel =
"D";
1610 if (
k > 0 &&
k < 5) {
1611 layername = TString(
"TIB L") +
k;
1612 }
else if (
k > 4 &&
k < 11) {
1613 layername = TString(
"TOB L") + (
k - 4);
1614 }
else if (
k > 10 &&
k < 14) {
1615 layername = TString(
"TID- ") + ringlabel + (
k - 10);
1616 }
else if (
k > 13 &&
k < 17) {
1617 layername = TString(
"TID+ ") + ringlabel + (
k - 13);
1619 layername = TString(
"TEC- ") + ringlabel + (
k - 16);
1621 layername = TString(
"TEC+ ") + ringlabel + (
k - 16 -
nTEClayers);
1630 auto obj = std::make_unique<SiStripBadStrip>();
1635 for (; rIter != rIterEnd; ++rIter) {
1638 if (!
obj->put(rIter->detid,
range))
1640 <<
"[SiStripHitEffFromCalibTree::getNewObject] detid already exists" << std::endl;
1676 NBadComponent[
i][0][0]++;
map< unsigned int, double > BadModules
vector< TH2F * > HotColdMaps
static const std::string kSharedResource
bool showOnlyGoodModules_
map< unsigned int, vector< int > > layertotal_perBx
virtual int nstrips() const =0
void setBadComponents(int i, int component, SiStripQuality::BadComponent &BC, std::stringstream ssV[4][19], int NBadComponent[4][19][4])
ContainerIterator getDataVectorBegin() const
T getParameter(std::string const &) const
std::unique_ptr< SiStripBadStrip > getNewObject() override
vector< TH1F * > layerfound_vsCM
std::string fullPath() const
edm::FileInPath fileInPath_
vector< TH1F * > layerfound_vsLumi
map< unsigned int, vector< int > > layerfound_perBx
static constexpr auto TID
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
Registry::const_iterator RegistryIterator
map< pair< unsigned int, unsigned int >, array< double, 3 > > eventInfos
Log< level::Error, false > LogError
SiStripQuality * quality_
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
static constexpr int siStripLayers_
const std::vector< BadComponent > & getBadComponentList() const
vector< TH1F * > layertotal_vsBX
bool autoIneffModTagging_
T getUntrackedParameter(std::string const &, T const &) const
def overlay(hists, ytitle, header, addon)
edm::Service< TFileService > fs
unsigned int clusterMatchingMethod_
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.
Abs< T >::type abs(const T &t)
vector< TH1F * > layerfound_vsPU
RegistryIterator getRegistryVectorEnd() const
#define DEFINE_FWK_MODULE(type)
void makeTKMap(bool autoTagging)
SiStripDetInfo read(std::string filePath)
static constexpr double nBxInAnOrbit_
vector< TH1F * > layerfound_vsBX
static constexpr auto TOB
void computeEff(vector< TH1F *> &vhfound, vector< TH1F *> &vhtotal, string name)
void fillc(int idmod, int RGBcode)
Detector identifier class for the strip tracker.
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > tkGeomToken_
void setBadComponents(int i, int component, const SiStripQuality::BadComponent &BC, int NBadComponent[4][19][4])
const Plane & surface() const
The nominal surface of the GeomDet.
const std::pair< unsigned short, double > getNumberOfApvsAndStripLength(uint32_t detId) const
unsigned int spaceBetweenTrains_
TH1F * instLumiHisto_cutOnTracks
static constexpr auto TIB
vector< TH1F * > layertotal_vsCM
void algoAnalyze(const edm::Event &e, const edm::EventSetup &c) override
TH1F * bxHisto_cutOnTracks
std::pair< ContainerIterator, ContainerIterator > Range
vector< TH1F * > layertotal_vsPU
vector< string > calibTreeFileNames_
data decode(const unsigned int &value) const
T * make(const Args &...args) const
make new ROOT object
static constexpr char const *const kDefaultFile
bool put(const uint32_t &detID, const InputVector &vect)
virtual float width() const =0
RegistryIterator getRegistryVectorBegin() const
TH1F * PUHisto_cutOnTracks
SiStripHitEffFromCalibTree(const edm::ParameterSet &)
void fill(int layer, int ring, int nmod, float x)
static constexpr auto TEC
map< pair< unsigned int, unsigned int >, bool > event_used
TString getLayerSideName(Long_t k)
vector< TH1F * > layertotal_vsLumi
map< unsigned int, pair< unsigned int, unsigned int > > modCounter[23]
bool useOnlyHighPurityTracks_
const Bounds & bounds() const