64 #include "TEfficiency.h" 68 #include "TGraphAsymmErrors.h" 74 #include "TObjString.h" 82 #define LOGPRINT edm::LogPrint("SiStripHitEffFromCalibTree") 103 std::unique_ptr<SiStripBadStrip> getNewObject()
override;
109 std::stringstream ssV[4][19],
110 int NBadComponent[4][19][4]);
111 void makeTKMap(
bool autoTagging);
112 void makeHotColdMaps();
114 void totalStatistics();
116 void makeSummaryVsBx();
117 void computeEff(vector<TH1F*>& vhfound, vector<TH1F*>& vhtotal,
string name);
118 void makeSummaryVsLumi();
119 void makeSummaryVsCM();
120 TString getLayerSideName(Long_t
k);
123 static constexpr
int siStripLayers_ = 22;
124 static constexpr
double nBxInAnOrbit_ = 3565;
168 map<pair<unsigned int, unsigned int>, array<double, 3> >
eventInfos;
174 map<unsigned int, pair<unsigned int, unsigned int> > modCounter[23];
192 int goodlayertotal[35];
193 int goodlayerfound[35];
194 int alllayertotal[35];
195 int alllayerfound[35];
240 ifstream badModules_file;
241 set<uint32_t> badModules_list;
244 uint32_t badmodule_detid;
245 int mods, fiber1, fiber2, fiber3;
246 if (badModules_file.is_open()) {
248 while (getline(badModules_file,
line)) {
249 if (badModules_file.eof())
252 ss >> badmodule_detid >>
mods >> fiber1 >> fiber2 >> fiber3;
253 if (badmodule_detid != 0 &&
mods == 1 && (fiber1 == 1 || fiber2 == 1 || fiber3 == 1))
254 badModules_list.insert(badmodule_detid);
256 badModules_file.close();
259 if (!badModules_list.empty())
260 LOGPRINT <<
"Remove additionnal bad modules from the analysis: ";
261 set<uint32_t>::iterator itBadMod;
262 for (
const auto& badMod : badModules_list) {
276 for (
int l = 0;
l < 35;
l++) {
283 TH1F* resolutionPlots[23];
284 for (Long_t ilayer = 0; ilayer < 23; ilayer++) {
287 resolutionPlots[ilayer] =
fs->
make<TH1F>(Form(
"resol_layer_%i", (
int)(ilayer)), lyrName.c_str(), 125, -125, 125);
288 resolutionPlots[ilayer]->GetXaxis()->SetTitle(
"trajX-clusX [strip unit]");
291 fs->
make<TH1F>(Form(
"layerfound_vsLumi_layer_%i", (
int)(ilayer)), lyrName.c_str(), 100, 0, 25000));
293 fs->
make<TH1F>(Form(
"layertotal_vsLumi_layer_%i", (
int)(ilayer)), lyrName.c_str(), 100, 0, 25000));
295 fs->
make<TH1F>(Form(
"layerfound_vsPU_layer_%i", (
int)(ilayer)), lyrName.c_str(), 45, 0, 90));
297 fs->
make<TH1F>(Form(
"layertotal_vsPU_layer_%i", (
int)(ilayer)), lyrName.c_str(), 45, 0, 90));
306 fs->
make<TH1F>(Form(
"layerfound_vsCM_layer_%i", (
int)(ilayer)), lyrName.c_str(), 20, 0, 400));
308 fs->
make<TH1F>(Form(
"layertotal_vsCM_layer_%i", (
int)(ilayer)), lyrName.c_str(), 20, 0, 400));
317 LOGPRINT <<
"A module is bad if the upper limit on the efficiency is < to the avg in the layer - " <<
threshold_ 318 <<
" and has at least " <<
nModsMin_ <<
" nModsMin.";
320 unsigned int run, evt,
bx{0};
325 LOGPRINT <<
"Loading file: " << calibTreeFileName;
326 TFile* CalibTreeFile = TFile::Open(calibTreeFileName.c_str(),
"READ");
329 bool foundEventInfos =
false;
331 CalibTreeFile->cd(
"eventInfo");
335 TTree* EventTree = (TTree*)(gDirectory->Get(
"tree"));
343 LOGPRINT <<
"Found event infos tree";
345 runLf = EventTree->GetLeaf(
"run");
346 evtLf = EventTree->GetLeaf(
"event");
348 BunchLf = EventTree->GetLeaf(
"bx");
349 InstLumiLf = EventTree->GetLeaf(
"instLumi");
350 PULf = EventTree->GetLeaf(
"PU");
352 int nevt = EventTree->GetEntries();
354 foundEventInfos =
true;
356 for (
int j = 0;
j <
nevt;
j++) {
357 EventTree->GetEntry(
j);
358 run = runLf->GetValue();
359 evt = evtLf->GetValue();
360 bx = BunchLf->GetValue();
362 PU = PULf->GetValue();
374 CalibTreeFile->cd(
"anEff");
375 calibTree_ = (TTree*)(gDirectory->Get(
"traj"));
379 TLeaf* BadLf =
calibTree_->GetLeaf(
"ModIsBad");
380 TLeaf* sistripLf =
calibTree_->GetLeaf(
"SiStripQualBad");
382 TLeaf* acceptLf =
calibTree_->GetLeaf(
"withinAcceptance");
383 TLeaf* layerLf =
calibTree_->GetLeaf(
"layer");
385 TLeaf* highPurityLf =
calibTree_->GetLeaf(
"highPurity");
389 TLeaf* ResXSigLf =
calibTree_->GetLeaf(
"ResXSig");
390 TLeaf* TrajLocXLf =
calibTree_->GetLeaf(
"TrajLocX");
391 TLeaf* TrajLocYLf =
calibTree_->GetLeaf(
"TrajLocY");
392 TLeaf* ClusterLocXLf =
calibTree_->GetLeaf(
"ClusterLocX");
396 TLeaf* CMLf =
nullptr;
401 LOGPRINT <<
"Successfully loaded analyze function with " <<
nevents <<
" events!\n";
403 map<pair<unsigned int, unsigned int>, array<double, 3> >::iterator itEventInfos;
404 map<pair<unsigned int, unsigned int>,
bool>::iterator itEventUsed;
409 run = (
unsigned int)runLf->GetValue();
410 evt = (
unsigned int)evtLf->GetValue();
411 unsigned int isBad = (
unsigned int)BadLf->GetValue();
412 unsigned int quality = (
unsigned int)sistripLf->GetValue();
413 unsigned int id = (
unsigned int)idLf->GetValue();
414 unsigned int accept = (
unsigned int)acceptLf->GetValue();
415 unsigned int layer_wheel = (
unsigned int)layerLf->GetValue();
416 unsigned int layer = layer_wheel;
419 layer = 10 + ((
id >> 9) & 0x3);
421 layer = 13 + ((
id >> 5) & 0x7);
425 double x = xLf->GetValue();
426 double y = yLf->GetValue();
427 double z = zLf->GetValue();
428 double resxsig = ResXSigLf->GetValue();
429 double TrajLocX = TrajLocXLf->GetValue();
430 double TrajLocY = TrajLocYLf->GetValue();
431 double ClusterLocX = ClusterLocXLf->GetValue();
435 bool badquality =
false;
441 if (!foundEventInfos) {
442 bx = (
unsigned int)BunchLf->GetValue();
443 if (InstLumiLf !=
nullptr)
446 PU = PULf->GetValue();
454 CM = CMLf->GetValue();
457 if (foundEventInfos) {
460 bx = itEventInfos->second[0];
462 PU = itEventInfos->second[2];
470 if (itEventUsed->second ==
false) {
474 itEventUsed->second =
true;
497 itBadMod = badModules_list.find(
id);
498 if (itBadMod != badModules_list.end())
504 bool badflag =
false;
511 if (isBad == 1 || resxsig >
resXSig_)
519 if (resxsig == 1000.0) {
522 stripTrajMid = TrajLocX / Pitch + nstrips / 2.0;
525 DetId ClusterDetId(
id);
530 stripTrajMid = TrajLocX / Pitch + nstrips / 2.0;
541 dynamic_cast<const TrapezoidalPlaneBounds*>(&(plane.bounds())));
542 std::array<const float, 4>
const&
parameters = (*trapezoidalBounds).parameters();
546 TrajLocXMid = TrajLocX / (1 + (htedge - hbedge) * TrajLocY / (htedge + hbedge) /
548 stripTrajMid = TrajLocXMid / Pitch + nstrips / 2.0;
552 if (!badquality &&
layer < 23) {
553 if (resxsig != 1000.0)
556 resolutionPlots[
layer]->Fill(1000);
562 float stripInAPV = 64.;
566 if (resxsig == 1000.0) {
577 tapv = (
int)stripTrajMid / 128;
579 stripInAPV = stripTrajMid - tapv * 128;
581 if (stripInAPV < stripsApvEdge_ || stripInAPV > 128 -
stripsApvEdge_)
589 if (badflag && !badquality) {
597 pair<unsigned int, unsigned int> newgoodpair(1, 1);
598 pair<unsigned int, unsigned int> newbadpair(1, 0);
600 map<unsigned int, pair<unsigned int, unsigned int> >::iterator it =
modCounter[
layer].find(
id);
608 ((*it).second.first)++;
610 ((*it).second.second)++;
640 if (((
id >> 13) & 0x3) == 1) {
644 }
else if (((
id >> 13) & 0x3) == 2) {
650 if (((
id >> 18) & 0x3) == 1) {
654 }
else if (((
id >> 18) & 0x3) == 2) {
667 if (((
id >> 13) & 0x3) == 1) {
671 }
else if (((
id >> 13) & 0x3) == 2) {
677 if (((
id >> 18) & 0x3) == 1) {
681 }
else if (((
id >> 18) & 0x3) == 2) {
704 int NTkBadComponent[4];
705 int NBadComponent[4][19][4];
709 std::stringstream ssV[4][19];
711 for (
int i = 0;
i < 4; ++
i) {
712 NTkBadComponent[
i] = 0;
713 for (
int j = 0;
j < 19; ++
j) {
715 for (
int k = 0;
k < 4; ++
k)
716 NBadComponent[
i][
j][
k] = 0;
722 for (
size_t i = 0;
i < BC.size(); ++
i) {
728 NTkBadComponent[0]++;
730 NTkBadComponent[1] += ((BC[
i].BadFibers >> 2) & 0
x1) + ((BC[
i].BadFibers >> 1) & 0
x1) + ((BC[
i].BadFibers) & 0
x1);
732 NTkBadComponent[2] += ((BC[
i].BadApvs >> 5) & 0
x1) + ((BC[
i].BadApvs >> 4) & 0
x1) + ((BC[
i].BadApvs >> 3) & 0
x1) +
733 ((BC[
i].BadApvs >> 2) & 0
x1) + ((BC[
i].BadApvs >> 1) & 0
x1) + ((BC[
i].BadApvs) & 0
x1);
754 component = tTopo.tidSide(BC[
i].detid) == 2 ? tTopo.tidWheel(BC[
i].detid) : tTopo.tidWheel(BC[
i].detid) + 3;
770 component = tTopo.tecSide(BC[
i].detid) == 2 ? tTopo.tecWheel(BC[
i].detid) : tTopo.tecWheel(BC[
i].detid) + 9;
778 float percentage = 0;
784 unsigned int detid = rp->detid;
789 if (
a.subdetId() == 3) {
792 }
else if (
a.subdetId() == 4) {
794 component = tTopo.tidSide(detid) == 2 ? tTopo.tidWheel(detid) : tTopo.tidWheel(detid) + 3;
795 }
else if (
a.subdetId() == 5) {
798 }
else if (
a.subdetId() == 6) {
800 component = tTopo.tecSide(detid) == 2 ? tTopo.tecWheel(detid) : tTopo.tecWheel(detid) + 9;
807 for (
int it = 0; it < sqrange.second - sqrange.first; it++) {
809 NTkBadComponent[3] +=
range;
810 NBadComponent[subdet][0][3] +=
range;
817 edm::LogError(
"SiStripQualityStatistics") <<
"PROBLEM detid " << detid <<
" value " << percentage << std::endl;
822 std::ostringstream
ss;
824 ss <<
"\n-----------------\nNew IOV starting from run " <<
e.id().run() <<
" event " <<
e.id().event()
825 <<
" lumiBlock " <<
e.luminosityBlock() <<
" time " <<
e.time().value() <<
"\n-----------------\n";
826 ss <<
"\n-----------------\nGlobal Info\n-----------------";
827 ss <<
"\nBadComponent \t Modules \tFibers " 828 "\tApvs\tStrips\n----------------------------------------------------------------";
829 ss <<
"\nTracker:\t\t" << NTkBadComponent[0] <<
"\t" << NTkBadComponent[1] <<
"\t" << NTkBadComponent[2] <<
"\t" 830 << NTkBadComponent[3];
831 ss <<
"\nTIB:\t\t\t" << NBadComponent[0][0][0] <<
"\t" << NBadComponent[0][0][1] <<
"\t" << NBadComponent[0][0][2]
832 <<
"\t" << NBadComponent[0][0][3];
833 ss <<
"\nTID:\t\t\t" << NBadComponent[1][0][0] <<
"\t" << NBadComponent[1][0][1] <<
"\t" << NBadComponent[1][0][2]
834 <<
"\t" << NBadComponent[1][0][3];
835 ss <<
"\nTOB:\t\t\t" << NBadComponent[2][0][0] <<
"\t" << NBadComponent[2][0][1] <<
"\t" << NBadComponent[2][0][2]
836 <<
"\t" << NBadComponent[2][0][3];
837 ss <<
"\nTEC:\t\t\t" << NBadComponent[3][0][0] <<
"\t" << NBadComponent[3][0][1] <<
"\t" << NBadComponent[3][0][2]
838 <<
"\t" << NBadComponent[3][0][3];
841 for (
int i = 1;
i < 5; ++
i)
842 ss <<
"\nTIB Layer " <<
i <<
" :\t\t" << NBadComponent[0][
i][0] <<
"\t" << NBadComponent[0][
i][1] <<
"\t" 843 << NBadComponent[0][
i][2] <<
"\t" << NBadComponent[0][
i][3];
845 for (
int i = 1;
i < 4; ++
i)
846 ss <<
"\nTID+ Disk " <<
i <<
" :\t\t" << NBadComponent[1][
i][0] <<
"\t" << NBadComponent[1][
i][1] <<
"\t" 847 << NBadComponent[1][
i][2] <<
"\t" << NBadComponent[1][
i][3];
848 for (
int i = 4;
i < 7; ++
i)
849 ss <<
"\nTID- Disk " <<
i - 3 <<
" :\t\t" << NBadComponent[1][
i][0] <<
"\t" << NBadComponent[1][
i][1] <<
"\t" 850 << NBadComponent[1][
i][2] <<
"\t" << NBadComponent[1][
i][3];
852 for (
int i = 1;
i < 7; ++
i)
853 ss <<
"\nTOB Layer " <<
i <<
" :\t\t" << NBadComponent[2][
i][0] <<
"\t" << NBadComponent[2][
i][1] <<
"\t" 854 << NBadComponent[2][
i][2] <<
"\t" << NBadComponent[2][
i][3];
856 for (
int i = 1;
i < 10; ++
i)
857 ss <<
"\nTEC+ Disk " <<
i <<
" :\t\t" << NBadComponent[3][
i][0] <<
"\t" << NBadComponent[3][
i][1] <<
"\t" 858 << NBadComponent[3][
i][2] <<
"\t" << NBadComponent[3][
i][3];
859 for (
int i = 10;
i < 19; ++
i)
860 ss <<
"\nTEC- Disk " <<
i - 9 <<
" :\t\t" << NBadComponent[3][
i][0] <<
"\t" << NBadComponent[3][
i][1] <<
"\t" 861 << NBadComponent[3][
i][2] <<
"\t" << NBadComponent[3][
i][3];
864 ss <<
"\n----------------------------------------------------------------\n\t\t Detid \tModules Fibers " 865 "Apvs\n----------------------------------------------------------------";
866 for (
int i = 1;
i < 5; ++
i)
867 ss <<
"\nTIB Layer " <<
i <<
" :" << ssV[0][
i].
str();
869 for (
int i = 1;
i < 4; ++
i)
870 ss <<
"\nTID+ Disk " <<
i <<
" :" << ssV[1][
i].
str();
871 for (
int i = 4;
i < 7; ++
i)
872 ss <<
"\nTID- Disk " <<
i - 3 <<
" :" << ssV[1][
i].
str();
874 for (
int i = 1;
i < 7; ++
i)
875 ss <<
"\nTOB Layer " <<
i <<
" :" << ssV[2][
i].
str();
877 for (
int i = 1;
i < 10; ++
i)
878 ss <<
"\nTEC+ Disk " <<
i <<
" :" << ssV[3][
i].
str();
879 for (
int i = 10;
i < 19; ++
i)
880 ss <<
"\nTEC- Disk " <<
i - 9 <<
" :" << ssV[3][
i].
str();
886 badModules.open(
"BadModules.log");
887 badModules <<
"\n----------------------------------------------------------------\n\t\t Detid \tModules Fibers " 888 "Apvs\n----------------------------------------------------------------";
889 for (
int i = 1;
i < 5; ++
i)
890 badModules <<
"\nTIB Layer " <<
i <<
" :" << ssV[0][
i].
str();
892 for (
int i = 1;
i < 4; ++
i)
893 badModules <<
"\nTID+ Disk " <<
i <<
" :" << ssV[1][
i].
str();
894 for (
int i = 4;
i < 7; ++
i)
895 badModules <<
"\nTID- Disk " <<
i - 3 <<
" :" << ssV[1][
i].
str();
897 for (
int i = 1;
i < 7; ++
i)
898 badModules <<
"\nTOB Layer " <<
i <<
" :" << ssV[2][
i].
str();
900 for (
int i = 1;
i < 10; ++
i)
901 badModules <<
"\nTEC+ Disk " <<
i <<
" :" << ssV[3][
i].
str();
902 for (
int i = 10;
i < 19; ++
i)
903 badModules <<
"\nTEC- Disk " <<
i - 9 <<
" :" << ssV[3][
i].
str();
908 LOGPRINT <<
"Entering hot cold map generation!\n";
909 TStyle* gStyle =
new TStyle(
"gStyle",
"myStyle");
911 gStyle->SetPalette(1);
912 gStyle->SetCanvasColor(kWhite);
913 gStyle->SetOptStat(0);
918 for (Long_t maplayer = 1; maplayer <=
siStripLayers_; maplayer++) {
920 if (maplayer > 0 && maplayer <= 4) {
922 temph2 =
fs->
make<TH2F>(Form(
"%s%i",
"TIB", (
int)(maplayer)),
"TIB", 100, -1, 361, 100, -100, 100);
923 temph2->GetXaxis()->SetTitle(
"Phi");
924 temph2->GetXaxis()->SetBinLabel(1, TString(
"360"));
925 temph2->GetXaxis()->SetBinLabel(50, TString(
"180"));
926 temph2->GetXaxis()->SetBinLabel(100, TString(
"0"));
927 temph2->GetYaxis()->SetTitle(
"Global Z");
928 temph2->SetOption(
"colz");
930 }
else if (maplayer > 4 && maplayer <= 10) {
932 temph2 =
fs->
make<TH2F>(Form(
"%s%i",
"TOB", (
int)(maplayer - 4)),
"TOB", 100, -1, 361, 100, -120, 120);
933 temph2->GetXaxis()->SetTitle(
"Phi");
934 temph2->GetXaxis()->SetBinLabel(1, TString(
"360"));
935 temph2->GetXaxis()->SetBinLabel(50, TString(
"180"));
936 temph2->GetXaxis()->SetBinLabel(100, TString(
"0"));
937 temph2->GetYaxis()->SetTitle(
"Global Z");
938 temph2->SetOption(
"colz");
940 }
else if (maplayer > 10 && maplayer <= 13) {
943 temph2 =
fs->
make<TH2F>(Form(
"%s%i",
"TID-", (
int)(maplayer - 10)),
"TID-", 100, -100, 100, 100, -100, 100);
944 temph2->GetXaxis()->SetTitle(
"Global Y");
945 temph2->GetXaxis()->SetBinLabel(1, TString(
"+Y"));
946 temph2->GetXaxis()->SetBinLabel(50, TString(
"0"));
947 temph2->GetXaxis()->SetBinLabel(100, TString(
"-Y"));
948 temph2->GetYaxis()->SetTitle(
"Global X");
949 temph2->GetYaxis()->SetBinLabel(1, TString(
"-X"));
950 temph2->GetYaxis()->SetBinLabel(50, TString(
"0"));
951 temph2->GetYaxis()->SetBinLabel(100, TString(
"+X"));
952 temph2->SetOption(
"colz");
954 temph2 =
fs->
make<TH2F>(Form(
"%s%i",
"TID+", (
int)(maplayer - 10)),
"TID+", 100, -100, 100, 100, -100, 100);
955 temph2->GetXaxis()->SetTitle(
"Global Y");
956 temph2->GetXaxis()->SetBinLabel(1, TString(
"+Y"));
957 temph2->GetXaxis()->SetBinLabel(50, TString(
"0"));
958 temph2->GetXaxis()->SetBinLabel(100, TString(
"-Y"));
959 temph2->GetYaxis()->SetTitle(
"Global X");
960 temph2->GetYaxis()->SetBinLabel(1, TString(
"-X"));
961 temph2->GetYaxis()->SetBinLabel(50, TString(
"0"));
962 temph2->GetYaxis()->SetBinLabel(100, TString(
"+X"));
963 temph2->SetOption(
"colz");
965 }
else if (maplayer > 13) {
968 temph2 =
fs->
make<TH2F>(Form(
"%s%i",
"TEC-", (
int)(maplayer - 13)),
"TEC-", 100, -120, 120, 100, -120, 120);
969 temph2->GetXaxis()->SetTitle(
"Global Y");
970 temph2->GetXaxis()->SetBinLabel(1, TString(
"+Y"));
971 temph2->GetXaxis()->SetBinLabel(50, TString(
"0"));
972 temph2->GetXaxis()->SetBinLabel(100, TString(
"-Y"));
973 temph2->GetYaxis()->SetTitle(
"Global X");
974 temph2->GetYaxis()->SetBinLabel(1, TString(
"-X"));
975 temph2->GetYaxis()->SetBinLabel(50, TString(
"0"));
976 temph2->GetYaxis()->SetBinLabel(100, TString(
"+X"));
977 temph2->SetOption(
"colz");
979 temph2 =
fs->
make<TH2F>(Form(
"%s%i",
"TEC+", (
int)(maplayer - 13)),
"TEC+", 100, -120, 120, 100, -120, 120);
980 temph2->GetXaxis()->SetTitle(
"Global Y");
981 temph2->GetXaxis()->SetBinLabel(1, TString(
"+Y"));
982 temph2->GetXaxis()->SetBinLabel(50, TString(
"0"));
983 temph2->GetXaxis()->SetBinLabel(100, TString(
"-Y"));
984 temph2->GetYaxis()->SetTitle(
"Global X");
985 temph2->GetYaxis()->SetBinLabel(1, TString(
"-X"));
986 temph2->GetYaxis()->SetBinLabel(50, TString(
"0"));
987 temph2->GetYaxis()->SetBinLabel(100, TString(
"+X"));
988 temph2->SetOption(
"colz");
996 vector<hit>::const_iterator iter;
997 for (iter =
hits[mylayer].begin(); iter !=
hits[mylayer].end(); iter++) {
1001 if (mylayer > 0 && mylayer <= 4) {
1003 float phi = ::calcPhi(iter->x, iter->y);
1005 }
else if (mylayer > 4 && mylayer <= 10) {
1007 float phi = ::calcPhi(iter->x, iter->y);
1009 }
else if (mylayer > 10 && mylayer <= 13) {
1012 int side = (((iter->id) >> 13) & 0x3);
1014 HotColdMaps[(mylayer - 1) + (mylayer - 11)]->Fill(-iter->y, iter->x, 1.);
1016 HotColdMaps[(mylayer - 1) + (mylayer - 10)]->Fill(-iter->y, iter->x, 1.);
1019 }
else if (mylayer > 13) {
1022 int side = (((iter->id) >> 18) & 0x3);
1024 HotColdMaps[(mylayer + 2) + (mylayer - 14)]->Fill(-iter->y, iter->x, 1.);
1026 HotColdMaps[(mylayer + 2) + (mylayer - 13)]->Fill(-iter->y, iter->x, 1.);
1032 LOGPRINT <<
"Finished HotCold Map Generation\n";
1036 LOGPRINT <<
"Entering TKMap generation!\n";
1038 TTree*
tree =
nullptr;
1039 unsigned int t_DetId, t_found, t_total;
1040 unsigned char t_layer;
1041 bool t_isTaggedIneff;
1045 tree->Branch(
"DetId", &t_DetId,
"DetId/i");
1046 tree->Branch(
"Layer", &t_layer,
"Layer/b");
1047 tree->Branch(
"FoundHits", &t_found,
"FoundHits/i");
1048 tree->Branch(
"AllHits", &t_total,
"AllHits/i");
1049 tree->Branch(
"IsTaggedIneff", &t_isTaggedIneff,
"IsTaggedIneff/O");
1050 tree->Branch(
"TagThreshold", &t_threshold,
"TagThreshold/F");
1059 double myeff, mynum, myden, myeff_up;
1060 double layer_min_eff = 0;
1068 fs->
make<TH1F>(Form(
"eff_layer%i",
int(
i)), Form(
"Module efficiency in layer %i",
int(
i)), 201, 0, 1.005);
1073 mynum = (double)((ih.second).second);
1074 myden = (double)((ih.second).first);
1076 myeff = mynum / myden;
1079 hEffInLayer->Fill(myeff);
1087 <<
" efficiency: " << myeff <<
" , " << mynum <<
"/" << myden;
1094 <<
" efficiency: " << myeff <<
" , " << mynum <<
"/" << myden;
1097 <<
" is under occupancy at " << myden;
1106 t_isTaggedIneff =
false;
1124 hEffInLayer->GetXaxis()->SetRange(3, hEffInLayer->GetNbinsX() + 1);
1126 hEffInLayer->GetMean() - 2.5 * hEffInLayer->GetRMS();
1127 if (
threshold_ > 2.5 * hEffInLayer->GetRMS())
1128 layer_min_eff = hEffInLayer->GetMean() -
threshold_;
1129 LOGPRINT <<
"Layer " <<
i <<
" threshold for bad modules: <" << layer_min_eff
1130 <<
" (layer mean: " << hEffInLayer->GetMean() <<
" rms: " << hEffInLayer->GetRMS() <<
")";
1132 hEffInLayer->GetXaxis()->SetRange(1, hEffInLayer->GetNbinsX() + 1);
1136 mynum = (double)((ih.second).second);
1137 myden = (double)((ih.second).first);
1139 myeff = mynum / myden;
1143 myeff_up = TEfficiency::Bayesian(myden, mynum, .99, 1, 1,
true);
1144 if ((myden >=
nModsMin_) && (myeff_up < layer_min_eff)) {
1148 t_isTaggedIneff =
true;
1152 t_isTaggedIneff =
false;
1154 if (myeff_up < layer_min_eff + 0.08)
1156 <<
" efficiency: " << myeff <<
" , " << mynum <<
"/" << myden <<
" , upper limit: " << myeff_up;
1159 <<
" layer " <<
i <<
" is under occupancy at " << myden;
1167 t_threshold = layer_min_eff;
1173 tkmap->
save(
true, 0, 0,
"SiStripHitEffTKMap.png");
1174 tkmapbad->
save(
true, 0, 0,
"SiStripHitEffTKMapBad.png");
1176 tkmapnum->
save(
true, 0, 0,
"SiStripHitEffTKMapNum.png");
1177 tkmapden->
save(
true, 0, 0,
"SiStripHitEffTKMapDen.png");
1178 LOGPRINT <<
"Finished TKMap Generation\n";
1180 LOGPRINT <<
"Modules efficiencies stored in tree\n";
1185 LOGPRINT <<
"Entering SQLite file generation!\n";
1186 std::vector<unsigned int> BadStripList;
1187 unsigned short NStrips;
1189 std::unique_ptr<SiStripQuality> pQuality = std::make_unique<SiStripQuality>(
detInfo_);
1197 LOGPRINT <<
"Number of strips module " << it.first <<
" is " << NStrips;
1198 BadStripList.push_back(pQuality->encode(0, NStrips, 0));
1200 id1 = (
unsigned int)it.first;
1201 LOGPRINT <<
"ID1 shoudl match list of modules above " <<
id1;
1205 BadStripList.clear();
1219 for (Long_t
i = 1;
i < 5;
i++) {
1234 if (
i >= 5 &&
i < 11) {
1238 if (
i >= 11 &&
i < 14) {
1248 LOGPRINT <<
"The total efficiency is " << double(totalfound) / double(totaltotal);
1249 LOGPRINT <<
" TIB: " << double(subdetfound[1]) / subdettotal[1] <<
" " << subdetfound[1] <<
"/" 1251 LOGPRINT <<
" TOB: " << double(subdetfound[2]) / subdettotal[2] <<
" " << subdetfound[2] <<
"/" 1253 LOGPRINT <<
" TID: " << double(subdetfound[3]) / subdettotal[3] <<
" " << subdetfound[3] <<
"/" 1255 LOGPRINT <<
" TEC: " << double(subdetfound[4]) / subdettotal[4] <<
" " << subdetfound[4] <<
"/" 1277 found->SetBinContent(0, -1);
1278 all->SetBinContent(0, 1);
1282 found->SetBinContent(
i, 1
e-6);
1283 all->SetBinContent(
i, 1);
1284 found2->SetBinContent(
i, 1
e-6);
1285 all2->SetBinContent(
i, 1);
1288 TCanvas* c7 =
new TCanvas(
"c7",
" test ", 10, 10, 800, 600);
1289 c7->SetFillColor(0);
1292 int nLayers_max =
nLayers + 1;
1295 for (Long_t
i = 1;
i < nLayers_max; ++
i) {
1312 for (Long_t
i = 11;
i < 14; ++
i) {
1327 LOGPRINT <<
"Fill only good modules layer " <<
i - 3
1349 TGraphAsymmErrors* gr =
fs->
make<TGraphAsymmErrors>(
nLayers + 1);
1350 gr->SetName(
"eff_good");
1353 TGraphAsymmErrors* gr2 =
fs->
make<TGraphAsymmErrors>(
nLayers + 1);
1354 gr2->SetName(
"eff_all");
1355 gr2->BayesDivide(found2, all2);
1358 gr->SetPointError(
j, 0., 0., gr->GetErrorYlow(
j), gr->GetErrorYhigh(
j));
1359 gr2->SetPointError(
j, 0., 0., gr2->GetErrorYlow(
j), gr2->GetErrorYhigh(
j));
1362 gr->GetXaxis()->SetLimits(0,
nLayers);
1363 gr->SetMarkerColor(2);
1364 gr->SetMarkerSize(1.2);
1365 gr->SetLineColor(2);
1366 gr->SetLineWidth(4);
1367 gr->SetMarkerStyle(20);
1369 gr->SetMaximum(1.001);
1370 gr->GetYaxis()->SetTitle(
"Efficiency");
1371 gStyle->SetTitleFillColor(0);
1372 gStyle->SetTitleBorderSize(0);
1375 gr2->GetXaxis()->SetLimits(0,
nLayers);
1376 gr2->SetMarkerColor(1);
1377 gr2->SetMarkerSize(1.2);
1378 gr2->SetLineColor(1);
1379 gr2->SetLineWidth(4);
1380 gr2->SetMarkerStyle(21);
1382 gr2->SetMaximum(1.001);
1383 gr2->GetYaxis()->SetTitle(
"Efficiency");
1402 gr->GetXaxis()->SetBinLabel(((
k + 1) * 100 + 2) / (
nLayers)-4,
label);
1403 gr2->GetXaxis()->SetBinLabel(((
k + 1) * 100 + 2) / (
nLayers)-4,
label);
1405 gr->GetXaxis()->SetBinLabel((
k + 1) * 100 / (
nLayers)-6,
label);
1406 gr2->GetXaxis()->SetBinLabel((
k + 1) * 100 / (
nLayers)-6,
label);
1410 gr->GetXaxis()->SetBinLabel((
k + 1) * 100 / (
nLayers)-4,
label);
1411 gr2->GetXaxis()->SetBinLabel((
k + 1) * 100 / (
nLayers)-4,
label);
1413 gr->GetXaxis()->SetBinLabel((
k + 1) * 100 / (
nLayers)-7,
label);
1414 gr2->GetXaxis()->SetBinLabel((
k + 1) * 100 / (
nLayers)-7,
label);
1420 gr->GetXaxis()->SetNdivisions(36);
1423 TPad*
overlay =
new TPad(
"overlay",
"", 0, 0, 1, 1);
1426 overlay->SetFrameFillStyle(4000);
1432 TLegend* leg =
new TLegend(0.70, 0.27, 0.88, 0.40);
1433 leg->AddEntry(gr,
"Good Modules",
"p");
1435 leg->AddEntry(gr2,
"All Modules",
"p");
1436 leg->SetTextSize(0.020);
1437 leg->SetFillColor(0);
1440 c7->SaveAs(
"Summary.png");
1441 c7->SaveAs(
"Summary.C");
1445 LOGPRINT <<
"Computing efficiency vs bx";
1451 for (
unsigned int ilayer = 1; ilayer <
nLayers; ilayer++) {
1458 layerfound_vsBX[ilayer]->SetBinContent(iterMapvsBx.first, iterMapvsBx.second[ilayer]);
1461 if (iterMapvsBx.second[ilayer] > 0) {
1462 layertotal_vsBX[ilayer]->SetBinContent(iterMapvsBx.first, iterMapvsBx.second[ilayer]);
1470 geff->SetName(Form(
"effVsBx_layer%i", ilayer));
1476 TGraphAsymmErrors* geff_avg =
fs->
make<TGraphAsymmErrors>();
1477 geff_avg->SetName(Form(
"effVsBxAvg_layer%i", ilayer));
1479 geff_avg->SetMarkerStyle(20);
1481 int previous_bx = -80;
1491 ibx = iterMapvsBx.first;
1492 delta_bx = ibx - previous_bx;
1497 geff_avg->SetPoint(ipt, sum_bx / nbx, eff);
1498 low = TEfficiency::Bayesian(
total,
found, .683, 1, 1,
false);
1499 up = TEfficiency::Bayesian(
total,
found, .683, 1, 1,
true);
1500 geff_avg->SetPointError(ipt, sum_bx / nbx - firstbx, previous_bx - sum_bx / nbx, eff -
low,
up - eff);
1518 geff_avg->SetPoint(ipt, sum_bx / nbx, eff);
1519 low = TEfficiency::Bayesian(
total,
found, .683, 1, 1,
false);
1520 up = TEfficiency::Bayesian(
total,
found, .683, 1, 1,
true);
1521 geff_avg->SetPointError(ipt, sum_bx / nbx - firstbx, previous_bx - sum_bx / nbx, eff -
low,
up - eff);
1533 for (
unsigned int ilayer = 1; ilayer <
nLayers; ilayer++) {
1534 hfound = vhfound[ilayer];
1535 htotal = vhtotal[ilayer];
1541 for (Long_t
i = 0;
i < hfound->GetNbinsX() + 1; ++
i) {
1542 if (hfound->GetBinContent(
i) == 0)
1543 hfound->SetBinContent(
i, 1
e-6);
1544 if (htotal->GetBinContent(
i) == 0)
1545 htotal->SetBinContent(
i, 1);
1548 TGraphAsymmErrors* geff =
fs->
make<TGraphAsymmErrors>(hfound->GetNbinsX());
1549 geff->SetName(Form(
"%s_layer%i",
name.c_str(), ilayer));
1550 geff->BayesDivide(hfound, htotal);
1551 if (
name ==
"effVsLumi")
1554 if (
name ==
"effVsPU")
1556 if (
name ==
"effVsCM")
1559 geff->SetMarkerStyle(20);
1564 LOGPRINT <<
"Computing efficiency vs lumi";
1575 unsigned int nLayersForAvg = 0;
1576 float layerLumi = 0;
1581 LOGPRINT <<
"Lumi summary: (avg over trajectory measurements)";
1582 for (
unsigned int ilayer = 1; ilayer <
nLayers; ilayer++) {
1586 if (layerLumi != 0 && layerPU != 0) {
1587 avgLumi += layerLumi;
1592 avgLumi /= nLayersForAvg;
1593 avgPU /= nLayersForAvg;
1594 LOGPRINT <<
"Avg conditions: lumi :" << avgLumi <<
" pu: " << avgPU;
1602 LOGPRINT <<
"Computing efficiency vs CM";
1607 TString layername =
"";
1608 TString ringlabel =
"D";
1611 if (
k > 0 &&
k < 5) {
1612 layername = TString(
"TIB L") +
k;
1613 }
else if (
k > 4 &&
k < 11) {
1614 layername = TString(
"TOB L") + (
k - 4);
1615 }
else if (
k > 10 &&
k < 14) {
1616 layername = TString(
"TID- ") + ringlabel + (
k - 10);
1617 }
else if (
k > 13 &&
k < 17) {
1618 layername = TString(
"TID+ ") + ringlabel + (
k - 13);
1620 layername = TString(
"TEC- ") + ringlabel + (
k - 16);
1622 layername = TString(
"TEC+ ") + ringlabel + (
k - 16 -
nTEClayers);
1631 auto obj = std::make_unique<SiStripBadStrip>();
1636 for (; rIter != rIterEnd; ++rIter) {
1639 if (!
obj->put(rIter->detid,
range))
1641 <<
"[SiStripHitEffFromCalibTree::getNewObject] detid already exists" << std::endl;
1677 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