37 static const float TGCChamberLowOccupancyCut = 1.0e-6;
38 static const float TGCChamberHighOccupancyCut = 0.005;
39 static const float TGCChannelOccupancyCut = 0.01;
40 static const float TGCChamberEfficiencyCut = 0.7;
41 static const float TGCChamberTimingCut = 0.95;
43 static const bool tgc_debug =
false;
48 std::vector< std::pair< std::string, float > > NoisyChambers;
49 std::vector< std::pair< std::string, float > > DeadChambers;
51 std::vector< std::pair< std::string, float > > NoisyChannels;
53 std::vector< std::pair< std::string, float > > LowEfficiencyChambers;
55 std::vector< std::pair< std::string, float > > ReadoutTimingChambers;
56 std::vector< std::pair< std::string, float > > TriggerTimingChambers;
83 std::vector< std::pair< std::string, float > >& noisychambers,
84 std::vector< std::pair< std::string, float > >& deadchambers) {
92 if (
mf.GetSize() < 1000.) {
106 TIter next_run(
mf.GetListOfKeys());
108 while ((key_run =
dynamic_cast<TKey*
> (next_run())) != 0) {
109 if (!key_run->IsFolder())
continue;
110 TString run_dir = key_run->GetName();
111 if (!run_dir.Contains(
"run"))
continue;
113 std::string run_dir2 = run_dir.Data();
117 TString tgc_dir = run_dir +
"/Muon/MuonRawDataMonitoring/TGC/";
119 TString tgc_global_dir = tgc_dir +
"Global/";
121 TString tgc_sub_dir[2] = {
122 tgc_dir +
"TGCEA/", tgc_dir +
"TGCEC/"
135 std::stringstream
ss;
138 TString schambertypesummary[2][4][6];
139 TH1F* chambertypesummary[2][4][6];
141 TString schambersummary[2][2];
142 TH1F* chambersummary[2][2];
144 std::string
type[17] = {
145 "_F_T1",
"_E4_T3",
"_E3_T6",
"_E2_T7",
"_E1_T8",
146 "_F_T2",
"_E5_T4",
"_E4_T6",
"_E3_T7",
"_E2_T8",
"_E1_T9",
147 "_F_T2",
"_E5_T5",
"_E4_T6",
"_E3_T7",
"_E2_T8",
"_E1_T9"
151 for (
int ws = 0; ws < 2; ws++) {
153 for (
int station = 0; station < 3; station++) {
154 for (
int eta = 0; eta < 6; eta++) {
155 if (eta == 5 && station == 0)
continue;
156 if (eta < 2 && station == 3)
continue;
159 ss <<
"Station" << station + 1 <<
type[ntype];
160 schambertypesummary[ws][station][eta] = tgc_dir +
"Global/Summary/"
161 +
"Summary_Of_Log10_" + sws[ws] +
"Occupancy_Per_Chamber_Type_" +
163 if (tgc_debug) std::cout << schambertypesummary[ws][station][eta] << std::endl;
165 chambertypesummary[ws][station][eta] = 0;
166 mf.get(schambertypesummary[ws][station][eta], chambertypesummary[ws][station][eta]);
167 if (!chambertypesummary[ws][station][eta]) {
178 for (
int ac = 0; ac < 2; ac++) {
179 schambersummary[ac][ws] = tgc_sub_dir[ac] +
"Summary/"
180 +
"Summary_Of_Log10_" + sws[ws] +
"Occupancy_Per_GasGap" + sac[ac];
181 if (tgc_debug) std::cout << schambersummary[ac][ws] << std::endl;
183 chambersummary[ac][ws] = 0;
184 mf.get(schambersummary[ac][ws], chambersummary[ac][ws]);
185 if (!chambersummary[ac][ws]) {
194 TString sentries = tgc_global_dir +
"Event_Counter";
197 mf.get(sentries, hentries);
203 double nentries = hentries->GetEntries();
206 for (
int ac = 0; ac < 2; ac++) {
207 for (
int ws = 0; ws < 2; ws++) {
211 TString sprof = tgc_sub_dir[ac] +
"Profile/" + sws[ws] +
"Profile_Map" + sac[ac];
212 TString soccu = tgc_sub_dir[ac] +
"Occupancy/" + sws[ws] +
"Occupancy_Map" + sac[ac];
215 mf.get(sprof, hprof);
222 mf.get(soccu, hoccu);
229 int nbinx = hprof->GetXaxis()->GetNbins();
230 int nbiny = hprof->GetYaxis()->GetNbins();
232 for (
int binx = 1; binx <= nbinx; binx++) {
233 for (
int biny = 1; biny <= nbiny; biny++) {
234 if (ws == 1 && (binx == 2 || binx == 9 || binx == 16 || binx == 23 || binx == 34))
continue;
236 if ((binx >= 33 && binx <= 43) &&
237 biny % 2 == 0)
continue;
238 if ((binx == 40 || binx == 41) &&
239 (biny == 19 || biny == 35 || biny == 43))
continue;
241 double num = hprof->GetBinContent(binx, biny);
247 eoccu = sqrt(occu * (1. - occu) / den);
249 hoccu->SetBinContent(binx, biny, occu);
250 hoccu->SetBinError(binx, biny, eoccu);
253 if (occu < min && occu > 1
e-8)
min = occu;
254 if (occu >
max)
max = occu;
260 if (chambersummary[ac][ws]) chambersummary[ac][ws]->Fill(log10(occu));
266 eta = (binx - 1) % 5;
267 }
else if (binx < 28) {
269 eta = (binx - 16) % 6;
270 }
else if (binx < 40) {
272 eta = (binx - 28) % 6;
275 eta = (binx - 40) % 2;
277 if (station < 3 && eta >= 0)
278 if (chambertypesummary[ws][station][eta]) chambertypesummary[ws][station][eta]->Fill(log10(occu));
281 if (occu > TGCChamberHighOccupancyCut) {
283 TString schamber = hprof->GetXaxis()->GetBinLabel(binx);
284 int sector = (biny - 1) / 4 + 1;
285 int phi = (biny - 1) % 4;
287 if (sector < 10)
ss <<
"0";
288 ss << sector <<
"phi" << phi;
289 if (tgc_debug) std::cout <<
"TGC noisy channel : " <<
ss.str() <<
" " << occu << std::endl;
291 std::pair<std::string, float>
p(
ss.str(), occu);
292 noisychambers.push_back(
p);
293 }
else if (occu < TGCChamberLowOccupancyCut) {
295 TString schamber = hprof->GetXaxis()->GetBinLabel(binx);
296 int sector = (biny - 1) / 4 + 1;
297 int phi = (biny - 1) % 4;
299 if (sector < 10)
ss <<
"0";
300 ss << sector <<
"phi" << phi;
301 if (tgc_debug) std::cout <<
"TGC low occupancy chamber : " <<
ss.str() <<
" " << occu << std::endl;
303 std::pair<std::string, float>
p(
ss.str(), occu);
304 deadchambers.push_back(
p);
309 hoccu->SetMinimum(
min * 0.95);
310 hoccu->SetMaximum(
max * 1.05);
312 TString occu_dir = tgc_sub_dir[ac] +
"Occupancy/";
313 TDirectory*
dir =
mf.GetDirectory(occu_dir);
317 hoccu->Write(
"", TObject::kOverwrite);
326 TString sum_dir = tgc_dir +
"Global/Summary";
327 TDirectory*
dir =
mf.GetDirectory(sum_dir);
331 for (
int ws = 0; ws < 2; ws++) {
332 for (
int station = 0; station < 3; station++) {
333 for (
int eta = 0; eta < 6; eta++) {
334 if (eta == 5 && station == 0)
continue;
335 if (eta < 2 && station == 3)
continue;
336 if (chambertypesummary[ws][station][eta]) chambertypesummary[ws][station][eta]->Write(
"",
337 TObject::kOverwrite);
347 for (
int ac = 0; ac < 2; ac++) {
349 sum_dir = tgc_sub_dir[ac] +
"Summary/";
350 dir =
mf.GetDirectory(sum_dir);
353 for (
int ws = 0; ws < 2; ws++) {
354 if (chambersummary[ac][ws]) chambersummary[ac][ws]->Write(
"", TObject::kOverwrite);
368 std::vector< std::pair< std::string,
369 float > >& loweffchambers) {
377 if (
mf.GetSize() < 1000.) {
391 TIter next_run(
mf.GetListOfKeys());
393 while ((key_run =
dynamic_cast<TKey*
> (next_run())) != 0) {
394 if (!key_run->IsFolder())
continue;
395 TString run_dir = key_run->GetName();
396 if (!run_dir.Contains(
"run"))
continue;
398 std::string run_dir2 = run_dir.Data();
402 TString tgc_dir = run_dir +
"/Muon/MuonRawDataMonitoring/TGC/";
404 TString tgc_sub_dir[2] = {
405 tgc_dir +
"TGCEA/", tgc_dir +
"TGCEC/"
415 std::stringstream
ss;
418 TString schambertypesummary[2][3][6];
419 TH1F* chambertypesummary[2][3][6];
421 TString schambersummary[2][2];
422 TH1F* chambersummary[2][2];
424 std::string
type[17] = {
425 "_F_T1",
"_E4_T3",
"_E3_T6",
"_E2_T7",
"_E1_T8",
426 "_F_T2",
"_E5_T4",
"_E4_T6",
"_E3_T7",
"_E2_T8",
"_E1_T9",
427 "_F_T2",
"_E5_T5",
"_E4_T6",
"_E3_T7",
"_E2_T8",
"_E1_T9"
431 for (
int ws = 0; ws < 2; ws++) {
433 for (
int station = 0; station < 3; station++) {
434 for (
int eta = 0; eta < 6; eta++) {
435 if (eta == 5 && station == 0)
continue;
436 if (eta < 2 && station == 3)
continue;
439 ss <<
"Station" << station + 1 <<
type[ntype];
440 schambertypesummary[ws][station][eta] = tgc_dir +
"Global/Summary/"
441 +
"Summary_Of_" + sws[ws] +
"Efficiency_Per_Chamber_Type_" +
443 if (tgc_debug) std::cout << schambertypesummary[ws][station][eta] << std::endl;
445 chambertypesummary[ws][station][eta] = 0;
446 mf.get(schambertypesummary[ws][station][eta], chambertypesummary[ws][station][eta]);
447 if (!chambertypesummary[ws][station][eta]) {
458 for (
int ac = 0; ac < 2; ac++) {
459 schambersummary[ac][ws] = tgc_sub_dir[ac] +
"Summary/"
460 +
"Summary_Of_" + sws[ws] +
"Efficiency_Per_GasGap" + sac[ac];
461 if (tgc_debug) std::cout << schambersummary[ac][ws] << std::endl;
463 chambersummary[ac][ws] = 0;
464 mf.get(schambersummary[ac][ws], chambersummary[ac][ws]);
465 if (!chambersummary[ac][ws]) {
473 for (
int ac = 0; ac < 2; ac++) {
474 for (
int ws = 0; ws < 2; ws++) {
475 TString seff = tgc_sub_dir[ac] +
"Efficiency/" + sws[ws] +
"Efficiency_Map" + sac[ac];
476 TString sden = tgc_sub_dir[ac] +
"Efficiency/NumDenom/" + sws[ws] +
"Efficiency_Map" + sac[ac] +
492 int nbinx = heff->GetXaxis()->GetNbins();
493 int nbiny = heff->GetYaxis()->GetNbins();
495 for (
int binx = 1; binx <= nbinx; binx++) {
496 for (
int biny = 1; biny <= nbiny; biny++) {
502 if ((binx >= 33 && binx <= 43) &&
503 biny % 2 == 0)
continue;
504 if ((binx == 40 || binx == 41) &&
505 (biny == 19 || biny == 35 || biny == 43))
continue;
508 double eff = heff->GetBinContent(binx, biny);
511 denom = hden->GetBinContent(binx, biny);
514 if (chambersummary[ac][ws])
515 if (
denom > 0) chambersummary[ac][ws]->Fill(
eff);
521 eta = (binx - 1) % 5;
522 }
else if (binx < 28) {
524 eta = (binx - 16) % 6;
525 }
else if (binx < 40) {
527 eta = (binx - 28) % 6;
530 eta = (binx - 40) % 2;
532 if (station < 3 && eta >= 0)
533 if (chambertypesummary[ws][station][eta])
534 if (
denom > 0) chambertypesummary[ws][station][eta]->Fill(
eff);
537 if (
eff < TGCChamberEfficiencyCut) {
539 TString schamber = heff->GetXaxis()->GetBinLabel(binx);
540 int sector = (biny - 1) / 4 + 1;
541 int phi = (biny - 1) % 4;
543 if (sector < 10)
ss <<
"0";
544 ss << sector <<
"phi" << phi;
546 if (tgc_debug) std::cout <<
"TGC low efficiency chamber : " <<
ss.str() <<
" " <<
eff << std::endl;
548 std::pair<std::string, float>
p(
ss.str(),
eff);
549 loweffchambers.push_back(
p);
554 TString eff_dir = tgc_sub_dir[ac] +
"Efficiency/";
555 TDirectory*
dir =
mf.GetDirectory(eff_dir);
559 heff->Write(
"", TObject::kOverwrite);
568 TString sum_dir = tgc_dir +
"Global/Summary";
569 TDirectory*
dir =
mf.GetDirectory(sum_dir);
574 for (
int ws = 0; ws < 2; ws++) {
575 for (
int station = 0; station < 3; station++) {
576 for (
int eta = 0; eta < 6; eta++) {
577 if (eta == 5 && station == 0)
continue;
578 if (eta < 2 && station == 3)
continue;
579 if (chambertypesummary[ws][station][eta]) chambertypesummary[ws][station][eta]->Write(
"",
580 TObject::kOverwrite);
590 for (
int ac = 0; ac < 2; ac++) {
592 sum_dir = tgc_sub_dir[ac] +
"Summary/";
593 dir =
mf.GetDirectory(sum_dir);
596 for (
int ws = 0; ws < 2; ws++) {
597 if (chambersummary[ac][ws]) chambersummary[ac][ws]->Write(
"", TObject::kOverwrite);
610 std::vector< std::pair< std::string, float > >& badrotimingchambers,
611 std::vector< std::pair< std::string, float > >& badtrgtimingchambers) {
619 if (
mf.GetSize() < 1000.) {
633 TIter next_run(
mf.GetListOfKeys());
635 while ((key_run =
dynamic_cast<TKey*
> (next_run())) != 0) {
636 if (!key_run->IsFolder())
continue;
637 TString run_dir = key_run->GetName();
638 if (!run_dir.Contains(
"run"))
continue;
640 std::string run_dir2 = run_dir.Data();
644 TString tgc_dir = run_dir +
"/Muon/MuonRawDataMonitoring/TGCLV1/";
646 TString tgc_sub_dir[2] = {
647 tgc_dir +
"TGCEA/", tgc_dir +
"TGCEC/"
654 TString ssllpt[2] = {
655 "SL_Timing",
"Low_Pt_Timing"
658 std::stringstream
ss;
660 TString schambertypesummary[6];
661 TH1F* chambertypesummary[6];
663 std::string
type[6] = {
664 "_F_T2",
"_E5_T5",
"_E4_T6",
"_E3_T7",
"_E2_T8",
"_E1_T9"
667 for (
int sllpt = 0; sllpt < 2; sllpt++) {
668 for (
int eta = 0; eta < 6; eta++) {
672 schambertypesummary[eta] = tgc_dir +
"Global/Summary/"
673 +
"Summary_Of_" + ssllpt[sllpt] +
"_Per_Chamber_Type" +
ss.str();
675 chambertypesummary[eta] = 0;
676 mf.get(schambertypesummary[eta], chambertypesummary[eta]);
677 if (!chambertypesummary[eta]) {
684 for (
int ac = 0; ac < 2; ac++) {
686 TString ssum = tgc_sub_dir[ac] +
"Summary/Summary_Of_" + ssllpt[sllpt] + sac[ac];
687 TString stmap = tgc_sub_dir[ac] + ssllpt[sllpt] +
"_Map" + sac[ac];
688 TString stfrac = tgc_sub_dir[ac] + ssllpt[sllpt] +
"_Fraction_Map" + sac[ac];
698 mf.get(stmap, htmap);
705 mf.get(stfrac, htfrac);
714 int nbinx = htmap->GetXaxis()->GetNbins();
715 int nbiny = htmap->GetYaxis()->GetNbins();
717 if (nbinx != 18 || nbiny != 48)
continue;
719 for (
int eta = 0; eta < 6; eta++) {
720 for (
int phi48 = 0; phi48 < 48; phi48++) {
721 if (eta == 5 && phi48 % 2 == 1)
continue;
723 float p = htmap->GetBinContent(eta + 1, phi48 + 1);
724 float c = htmap->GetBinContent(eta + 7, phi48 + 1);
725 float n = htmap->GetBinContent(eta + 13, phi48 + 1);
726 float tot =
p +
n +
c;
738 efp = sqrt(
fp * (1. -
fp) / tot);
740 efc = sqrt(fc * (1. - fc) / tot);
742 efn = sqrt(
fn * (1. -
fn) / tot);
745 htfrac->SetBinContent(eta + 1, phi48 + 1,
fp);
746 htfrac->SetBinContent(eta + 7, phi48 + 1, fc);
747 htfrac->SetBinContent(eta + 13, phi48 + 1,
fn);
748 htfrac->SetBinError(eta + 1, phi48 + 1, efp);
749 htfrac->SetBinError(eta + 7, phi48 + 1, efc);
750 htfrac->SetBinError(eta + 13, phi48 + 1, efn);
752 if (chambertypesummary[eta]) chambertypesummary[eta]->Fill(fc);
756 if (fc < TGCChamberTimingCut) {
759 ss << sac[ac] <<
"phi" << phi48 + 1 <<
"Eta" << eta;
761 if (tgc_debug) std::cout <<
"TGC " << ssllpt[sllpt] <<
" low current BCID fraction chamber : " <<
762 ss.str() <<
" " << fc << std::endl;
764 std::pair<std::string, float>
p(
ss.str(), fc);
766 badtrgtimingchambers.push_back(
p);
768 badrotimingchambers.push_back(
p);
775 TString timing_dir = tgc_sub_dir[ac];
776 TDirectory*
dir =
mf.GetDirectory(timing_dir);
780 htfrac->Write(
"", TObject::kOverwrite);
786 TString sum_dir = tgc_sub_dir[ac] +
"Summary/";
787 dir =
mf.GetDirectory(sum_dir);
791 hsum->Write(
"", TObject::kOverwrite);
799 TString sum_dir = tgc_dir +
"Global/Summary/";
800 TDirectory*
dir =
mf.GetDirectory(sum_dir);
804 for (
int eta = 0; eta < 6; eta++) {
805 if (chambertypesummary[eta]) chambertypesummary[eta]->Write(
"", TObject::kOverwrite);
818 std::vector< std::pair< std::string,
819 float > >& noisychannels) {
827 if (
mf.GetSize() < 1000.) {
841 TIter next_run(
mf.GetListOfKeys());
843 while ((key_run =
dynamic_cast<TKey*
> (next_run())) != 0) {
844 if (!key_run->IsFolder())
continue;
845 TString run_dir = key_run->GetName();
846 if (!run_dir.Contains(
"run"))
continue;
848 std::string run_dir2 = run_dir.Data();
852 TString tgc_dir = run_dir +
"/Muon/MuonRawDataMonitoring/TGC/";
854 TString tgc_global_dir = tgc_dir +
"Global/";
855 TString tgc_sub_dir[2] = {
856 tgc_dir +
"TGCEA/", tgc_dir +
"TGCEC/"
866 "1",
"2",
"3",
"4",
"5",
"6",
"7"
868 std::stringstream
ss;
871 TString sentries = tgc_global_dir +
"Event_Counter";
874 mf.get(sentries, hentries);
880 double nentries = hentries->GetEntries();
882 for (
int ac = 0; ac < 2; ac++) {
883 for (
int ws = 0; ws < 2; ws++) {
884 for (
int lay = 0; lay < 7; lay++) {
885 if (ws == 1 && lay == 1)
continue;
886 for (
int subsect = 1; subsect <= 48; subsect++) {
892 if (sector < 10)
ss <<
"0";
893 ss << sector <<
"_Layer" << slay[lay] <<
"_Phi" << phi4;
894 TString sprof = tgc_sub_dir[ac] +
"Profile/" + sws[ws] +
"Hit_Profile" + sac[ac] +
ss.str();
897 mf.get(sprof, hprof);
903 int nbin = hprof->GetXaxis()->GetNbins();
906 double num = hprof->GetBinContent(
bin);
909 if (occu > TGCChannelOccupancyCut) {
911 ss << hprof->GetName() <<
" " <<
bin;
912 if (tgc_debug) std::cout <<
"TGC noisy channel : " <<
ss.str() <<
" " << occu << std::endl;
914 std::pair<std::string, float>
p(
ss.str(), occu);
915 noisychannels.push_back(
p);
927 if (subsect % 2 == 1) {
931 }
else if (
bin <= 27) {
933 eta = (
bin - 16) % 6;
936 eta = (
bin - 28) % 6;
941 eta = (
bin - 1) % 4 + 1;
942 }
else if (
bin <= 22) {
944 eta = (
bin - 13) % 5 + 1;
947 eta = (
bin - 23) % 5 + 1;
954 sector = (subsect + 1) / 4 + 1;
955 if (sector > 12) sector = 1;
956 phi4 = (subsect + 1) % 4;
976 if (binx % 7 >= 1 && binx % 7 <= 3 && binx <= 28) {
977 layer = (binx - 1) % 7;
978 eta = 4 - (binx - 1) / 7;
980 }
else if (binx % 7 >= 4 && binx % 7 <= 5 && binx <= 28) {
981 layer = (binx - 1) % 7;
982 eta = 5 - (binx - 1) / 7;
984 }
else if ((binx - 1) % 7 >= 5 && binx <= 28) {
985 layer = (binx - 1) % 7;
986 eta = 5 - (binx - 1) / 7;
988 }
else if (binx > 28 && binx <= 30) {
989 layer = binx - 28 + 3 - 1;
992 }
else if (binx > 30 && binx <= 32) {
993 layer = binx - 28 + 3 - 1;
996 }
else if (binx > 32 && binx <= 35) {
997 layer = binx - 32 - 1;
1000 }
else if (binx > 35 && binx <= 37) {
1001 layer = binx - 32 - 1;
1004 }
else if (binx > 37 && binx <= 39) {
1005 layer = binx - 32 - 1;
1008 }
else if (binx > 39 && binx <= 41) {
1009 layer = binx - 32 - 1;
1012 }
else if (binx > 41 && binx <= 43) {
1013 layer = binx - 34 - 1;
1019 if (eta == 0) st -= 1;
1027 if (nwire == 0)
return 0;
1037 const int istationPhi) {
1040 if (istationName == 42) {
1043 if (istationEta == 1) {
1045 }
else if (istationEta == 2) {
1047 }
else if (istationEta == 3) {
1049 }
else if (istationEta == 4) {
1053 if (istationEta == 1) {
1055 }
else if (istationEta == 2) {
1057 }
else if (istationEta == 3) {
1059 }
else if (istationEta == 4) {
1063 }
else if (istationName == 41) {
1065 else if (
layer == 1) nWire = 104;
1066 }
else if (istationName == 44) {
1067 if (istationEta == 1) {
1069 }
else if (istationEta == 2) {
1071 }
else if (istationEta == 3) {
1073 }
else if (istationEta == 4) {
1075 }
else if (istationEta == 5) {
1078 }
else if (istationName == 43) {
1080 }
else if (istationName == 46) {
1081 if (istationEta == 1) {
1083 }
else if (istationEta == 2) {
1085 }
else if (istationEta == 3) {
1087 }
else if (istationEta == 4) {
1089 }
else if (istationEta == 5) {
1092 }
else if (istationName == 45) {
1094 }
else if (istationName == 48) {
1099 if (istationPhi == 2 || istationPhi == 11 || istationPhi == 13 || istationPhi == 14 || istationPhi == 15 ||
1100 istationPhi == 16 || istationPhi == 20 || istationPhi == 21) {
1107 }
else if (istationName == 47) {
1108 if (istationPhi == 2 || istationPhi == 5 || istationPhi == 8 || istationPhi == 11 || istationPhi == 14 ||
1109 istationPhi == 17 || istationPhi == 20 || istationPhi == 23) {
1125 h_funcs =
dynamic_cast<TList*
> (
h->GetListOfFunctions()->Clone());
1128 TIter iterE(h_funcs);
1130 h->GetListOfFunctions()->Add(*iterE);