38 static const bool rno_debug =
false;
42 if (rno_debug) std::cout <<
"Start Pixel post-processing" << std::endl;
44 TFile*
infile = TFile::Open(inFilename.c_str(),
"UPDATE");
46 std::cerr <<
"--> PixelPostProcess: Input file not opened" << std::endl;
50 std::cerr <<
"--> PixelPostProcess: Input file " << inFilename <<
" cannot be opened" << std::endl;
53 if (
infile->GetSize() < 1000) {
54 std::cerr <<
"--> PixelPostProcess: Input file empty " << std::endl;
60 TIter next_run(
infile->GetListOfKeys());
62 key_run = (TKey*) next_run();
63 TDirectory* dir0 =
dynamic_cast<TDirectory*
> (key_run->ReadObj());
71 run_dir = dir0->GetName();
73 TString rno_dir = run_dir +
"/Pixel/Hits/";
74 TDirectory*
dir =
infile->GetDirectory(rno_dir);
76 std::cerr <<
"--> PixelPostProcess: directory " << rno_dir <<
" not found " << std::endl;
80 TString clus_dir = run_dir +
"/Pixel/Clusters/";
81 TDirectory* clusdir =
infile->GetDirectory(clus_dir);
83 std::cerr <<
"--> PixelPostProcess: directory " << clus_dir <<
" not found " << std::endl;
87 TString err_dir = run_dir +
"/Pixel/Errors/";
88 TDirectory* errdir =
infile->GetDirectory(err_dir);
90 std::cerr <<
"--> PixelPostProcess: directory " << err_dir <<
" not found " << std::endl;
94 TString status_dir = run_dir +
"/Pixel/Status/";
95 TDirectory* statusdir =
infile->GetDirectory(status_dir);
97 std::cerr <<
"--> PixelPostProcess: directory " << status_dir <<
" not found " << std::endl;
101 TString norm_histName = rno_dir +
"num_hits";
104 std::cerr <<
"--> PixelPostProcess: could not find normalisation histogram " << norm_histName << std::endl;
108 const static int nlayer = 8;
109 float nevents = h_norm->Integral(0, h_norm->GetNbinsX() + 1);
110 TString layerName[nlayer] = {
111 "IBL",
"B0",
"B1",
"B2",
"ECA",
"ECC",
"IBL2D",
"IBL3D"
113 float npixel[nlayer] = {
114 26880, 46080, 46080, 46080, 46080, 46080, 26880, 26880
116 float nmodule[nlayer] = {
117 280., 286., 494., 676., 144., 144., 168., 112.
120 const static int nerror = 5;
122 TString errorName[nerror] = {
123 "OpticalErrors_",
"SEUErrors_",
"SyncErrors_",
"TimeoutErrors_",
"TruncErrors_"
127 TH2F* h_occ_new[nlayer];
128 TH2F* h_clus[nlayer];
129 TH2F* h_clus_new[nlayer];
130 TH2F* h_err[nlayer][nerror];
131 TH2F* h_err_new[nlayer][nerror];
132 TH1F* h_disabled_per_lumi[nlayer];
133 TH1F* h_syncerr_per_lumi[nlayer];
134 TH1F* h_disabled_syncerr_per_lumi[nlayer];
136 for (
int i = 0;
i < nlayer;
i++) {
142 h_disabled_per_lumi[
i] = 0;
143 h_syncerr_per_lumi[
i] = 0;
144 h_disabled_syncerr_per_lumi[
i] = 0;
149 TString keyname =
"Occupancy_";
150 TString
histName = rno_dir + keyname + layerName[
i];
154 TString tmpname = keyname + layerName[
i] +
"_byPostProcess";
155 h_occ_new[
i] = (
TH2F*) h_occ[
i]->Clone(tmpname);
156 h_occ_new[
i]->Scale(1.0 / (
nevents * npixel[
i]));
160 if (h_occ_new[
i]) h_occ_new[
i]->Write();
165 keyname =
"Cluster_Occupancy_";
166 histName = clus_dir + keyname + layerName[
i];
170 TString tmpname = keyname + layerName[
i] +
"_byPostProcess";
171 h_clus_new[
i] = (
TH2F*) h_clus[
i]->Clone(tmpname);
172 h_clus_new[
i]->Scale(1.0 /
nevents);
175 if (h_clus_new[
i]) h_clus_new[
i]->Write();
179 for (
int j = 0; j < nerror; j++) {
184 keyname = errorName[j];
185 histName = err_dir + keyname + layerName[
i];
189 TString tmpname = keyname + layerName[
i] +
"_byPostProcess";
190 h_err_new[
i][j] = (
TH2F*) h_err[
i][j]->Clone(tmpname);
191 h_err_new[
i][j]->Scale(1.0 /
nevents);
195 if (h_err_new[
i][j]) h_err_new[
i][j]->Write();
199 keyname =
"SyncErrorsFrac_per_event_";
200 histName = err_dir + keyname + layerName[
i];
202 keyname =
"DisabledModules_per_lumi_";
203 histName = status_dir + keyname + layerName[
i];
206 if (h_disabled_per_lumi[
i] && h_syncerr_per_lumi[
i]) {
207 keyname =
"DisabledAndSyncErrorsModules_per_lumi_";
208 TString tmpname = keyname + layerName[
i] +
"_byPostProcess";
209 h_disabled_syncerr_per_lumi[
i] =
new TH1F(tmpname,
210 "Disable and Sync error per module per event;Lumi block;Avg. fraction per event", 2500, 0,
213 for (
int ibin = 0; ibin < 2500 + 1; ibin++) {
214 Double_t cont1 = h_disabled_per_lumi[
i]->GetBinContent(ibin) / nmodule[
i];
215 Double_t err1 = h_disabled_per_lumi[
i]->GetBinError(ibin) / nmodule[
i];
216 Double_t cont2 = h_syncerr_per_lumi[
i]->GetBinContent(ibin);
217 Double_t err2 = h_syncerr_per_lumi[
i]->GetBinError(ibin);
218 h_disabled_syncerr_per_lumi[
i]->SetBinContent(ibin, cont1 + cont2);
219 h_disabled_syncerr_per_lumi[
i]->SetBinError(ibin, err1 + err2);
223 if (h_disabled_syncerr_per_lumi[
i]) h_disabled_syncerr_per_lumi[
i]->Write();