26 bool debugPrint =
false;
27 bool imagePrint =
false;
30 rootfilename =
argv[1];
31 modulelistname =
argv[2];
32 pnbits = atoi(
argv[3]);
37 std::cout <<
"Wrong number of parameters " <<
argc << std::endl;
41 if (debugPrint)
std::cout <<
"ready to go " << rootfilename <<
' ' << modulelistname << std::endl;
43 TFile*
rootfile = TFile::Open(rootfilename,
"READ");
45 std::cout <<
"Problems with input root file" << std::endl;
49 std::ifstream modulelist(modulelistname);
51 std::stringstream outrootfilename;
52 outrootfilename << prefix <<
"SummaryFile" << postfix <<
".root";
53 TFile* outrootfile = TFile::Open(outrootfilename.str().c_str(),
"RECREATE");
55 TH1D* th_summary =
nullptr;
56 Double_t TotalEvents = 0.0;
57 Double_t TotalDigis = 0.0;
59 TH1D* TotEvents=
new TH1D(
"TotEvents",
"TotEvents",1,0,1);
62 TDirectoryFile* tdir = (TDirectoryFile*) rootfile->FindObjectAny(
"AlCaReco");
63 TH1D*
hist = (TH1D*)tdir->FindObjectAny(
"TotalNumberOfCluster__TIB");
65 TotalEvents = hist->GetEntries();
66 TotEvents->SetBinContent(1,TotalEvents);
70 while (modulelist >> detid) {
71 if (debugPrint)
std::cout <<
" ready to go with detid " << detid <<
" " << pnbits << std::endl;
74 std::stringstream histoname;
76 if (debugPrint)
std::cout <<
" ready to go with histogram " << histoname.str() << std::endl;
77 TH1D* hist = (TH1D*)rootfile->FindObjectAny(histoname.str().c_str());
79 if (debugPrint)
std::cout << histoname.str() <<
" found!" << std::endl;
80 if (imagePrint)
printPlot(hist,prefix,postfix);
83 std::cout << histoname.str() <<
" NOT found..." << std::endl;
88 std::stringstream histoname;
90 if (debugPrint)
std::cout <<
" ready to go with histogram " << histoname.str() << std::endl;
91 TH1D* hist = (TH1D*)rootfile->FindObjectAny(histoname.str().c_str());
93 if (debugPrint)
std::cout << histoname.str() <<
" found!" << std::endl;
94 if (imagePrint)
printPlot(hist,prefix,postfix);
97 std::cout << histoname.str() <<
" NOT found..." << std::endl;
102 std::stringstream histoname;
104 std::string SummaryName=
"ClusterDigiPosition__det__Summary";
106 if (debugPrint)
std::cout <<
" ready to go with histogram " << histoname.str() << std::endl;
107 if (th_summary ==
nullptr) th_summary =
new TH1D(SummaryName.c_str(), SummaryName.c_str(), 768, 0.5, 768.5);
108 TH1D* hist = (TH1D*)rootfile->FindObjectAny(histoname.str().c_str());
110 if (debugPrint)
std::cout << histoname.str() <<
" found!" << hist->GetEntries() << std::endl;
111 for (
int i = 1;
i < hist->GetNbinsX()+1;
i++) {
112 th_summary->AddBinContent(
i, hist->GetBinContent(
i));
113 TotalDigis += hist->GetBinContent(
i);
115 hist->SetLineColor(2);
116 if (imagePrint)
printPlot(hist,prefix,postfix);
119 std::cout << histoname.str() <<
" NOT found..." << std::endl;
124 std::stringstream histoname;
126 if (debugPrint)
std::cout <<
" ready to go with histogram " << histoname.str() << std::endl;
127 TH1D* hist = (TH1D*)rootfile->FindObjectAny(histoname.str().c_str());
129 if (debugPrint)
std::cout << histoname.str() <<
" found!" << std::endl;
130 std::stringstream histoname_reorder;
132 TH1D* hist_reorder =
new TH1D(histoname_reorder.str().c_str(), histoname_reorder.str().c_str(),
133 hist->GetXaxis()->GetNbins(), hist->GetXaxis()->GetXmin(), hist->GetXaxis()->GetXmax());
134 for (
int i = 0;
i < hist_reorder->GetNbinsX();
i++) {
136 hist_reorder->SetBinContent(
i+1,hist->GetBinContent(chan));
139 hist_reorder->Write();
141 std::cout << histoname.str() <<
" NOT found..." << std::endl;
150 Double_t fac = 1.0/TotalEvents;
151 th_summary->Scale(fac);
152 std::cout <<
" Run Number " << run <<
" Events " << TotalEvents <<
" Total # of Digis " << TotalDigis <<
" Av. Digis " << TotalDigis*fac << std::endl;
153 th_summary->SetEntries(TotalDigis*fac);
160 outrootfile->Close();
void printPlot(TH1D *hist, char *prefix, char *postfix)
int getChannelNumber(int ival)
chan
lumi = TPaveText(lowX+0.38, lowY+0.061, lowX+0.45, lowY+0.161, "NDC") lumi.SetBorderSize( 0 ) lumi...