11 #include "TDirectoryFile.h" 19 gROOT->SetStyle(
"Plain");
30 if (argv[3] && argv[4]){
31 stripmin=atoi(argv[3]);
32 stripmax=atoi(argv[4]);
38 TLegend
leg(0.1,0.7,0.2,0.9);
41 std::ifstream inmodules(modulelist);
46 if (!inmodules.good())
break;
48 hn=
"ClusterDigiPosition__det__" + detid;
50 TCanvas
c1(
"c1",
"c1",1600,900);
57 std::ifstream fileToCountLines(filelist);
58 std::size_t lines_count =0;
61 while (std::getline(fileToCountLines , line))
64 const float dim=lines_count;
66 std::ifstream filesin(filelist);
71 TH1D* trend=
new TH1D(
"trend",
"trend",
int(dim),0.5,dim+0.5);
72 trend->SetMarkerSize(3);
73 trend->SetMarkerStyle(8);
74 trend->SetMarkerColor(4);
77 trend->SetTitle(ttitle.c_str());
85 THStack *hs =
new THStack(
"hs",
"");
91 if (!filesin.good())
break;
93 std::string runNum= filename.substr(filename.find(
"run_")+4, 6);
96 fin=TFile::Open(filename.c_str());
98 if (!fin) {
std::cout <<
"Cannot open file " << filename.c_str() << std::endl;
102 TH1D* Events=(TH1D*)fin->Get(
"TotEvents");
104 double EvtNum=Events->GetBinContent(1);
106 TH1D*
histo=(TH1D*) fin->Get(hn.c_str());
108 if (!histo) {
std::cout <<
"Cannot open histo " << hn.c_str() << std::endl;
112 histo->SetDirectory(
nullptr);
113 histo->SetStats(kFALSE);
115 if (hn.find(
"Summary")==std::string::npos) histo->Scale(1/EvtNum);
117 double numberPerEvent;
118 if (stripmin==999 && stripmax==999) numberPerEvent=histo->Integral();
119 else numberPerEvent=histo->Integral(stripmin,stripmax);
122 if (max<=histo->GetBinContent(histo->GetMaximumBin())) max=histo->GetBinContent(histo->GetMaximumBin());
123 if (min>histo->GetBinContent(histo->GetMinimumBin())) min=histo->GetBinContent(histo->GetMinimumBin());
125 histo->SetLineColor(k+1);
126 histo->SetMarkerStyle(9);
127 histo->SetMarkerColor(k+1);
129 trend->SetBinContent(k+1,numberPerEvent);
130 trend->GetXaxis()->SetBinLabel(k+1,runNum.c_str());
132 leg.AddEntry(histo, runNum.c_str(),
"L");
139 if (min==0) min=1.e-6;
145 hs->SetTitle(hn.c_str());
155 l.DrawLine(128,min,128,max);
156 l.DrawLine(256,min,256,max);
157 l.DrawLine(384,min,384,max);
158 l.DrawLine(384,min,384,max);
159 l.DrawLine(512,min,512,max);
160 l.DrawLine(640,min,640,max);
164 c1.SaveAs(outname.c_str());
169 if (trend->GetMinimum()==0) mintrend=1.
e-4;
170 else mintrend=trend->GetMinimum();
172 trend->SetStats(kFALSE);
174 trend->GetYaxis()->SetRangeUser(mintrend*0.5,trend->GetMaximum()*2);
176 outname=hn+
"_Trend.png";
177 c1.SaveAs(outname.c_str());
int main(int argc, char *argv[])