14 #include <TDirectory.h>
21 #ifndef L1CALOPOSTPROCESSDEBUG
22 #define L1CALOPOSTPROCESSDEBUG false
32 if (
debug) std::cout <<
"--> L1CaloPostProcess: Begin L1Calo post-processing" << std::endl;
35 TFile*
f = TFile::Open(inFilename.c_str(),
"UPDATE");
38 if (
f == 0 || !
f->IsOpen()) {
39 std::cerr <<
"--> L1CaloPostProcess: Input file not opened" << std::endl;
46 std::cerr <<
"--> L1CaloPostProcess: Input file " << inFilename <<
" cannot be opened. " << std::endl;
52 if (
f->GetSize() < 1000.) {
53 std::cerr <<
"--> L1CaloPostProcess: Input file empty" << std::endl;
60 TIter next_run(
f->GetListOfKeys());
64 while ((key_run =
dynamic_cast<TKey*
>(next_run())) != 0) {
65 TObject* obj_run = key_run->ReadObj();
66 TDirectory* tdir_run =
dynamic_cast<TDirectory*
>(obj_run);
75 std::string runDirName(tdir_run->GetName());
76 if (
debug) std::cout <<
"Run_directory: " << runDirName << std::endl;
78 if (runDirName.find(
"run") == std::string::npos) {
84 TString stabilityDirName = runDirName +
"/L1Calo/PPM/Stability";
93 3., 3., 3., 6., 4., 2.
95 TString energies[6] = {
96 "10",
"20",
"30",
"50",
"100",
"200"
98 for (
int i = 0;
i < 3; ++
i) {
99 TString effDir = runDirName +
"/L1Calo/Reco/EmEfficiencies/ClusterRaw_"
100 + energies[
i] +
"GeV_EtaVsPhi";
101 TString nameDen =
"ClusterRaw_" + energies[
i] +
"GeV_Eta_vs_Phi";
102 TString nameEff = nameDen +
"_trig_Eff";
109 for (
int i = 3;
i < 6; ++
i) {
110 TString effDir = runDirName +
"/L1Calo/Reco/JetEfficiencies/JetEmScale_"
111 + energies[
i] +
"GeV_EtaVsPhi";
112 TString nameDen =
"JetEmScale_" + energies[
i] +
"GeV_Eta_vs_Phi";
113 TString nameEff = nameDen +
"_J_Eff_item";
114 TString nameEffF = nameDen +
"_FJ_J_Eff_item";
122 if (
debug) std::cout <<
"--> L1CaloPostProcess: finished L1Calo post-processing"
129 const TString& nameTag) {
130 TString nameData(
"ppm_em_2d_profile_etaPhi_adc_" + nameTag);
131 TString nameError(
"ppm_em_2d_etaPhi_adc_" + nameTag +
"RMS");
134 nameData =
"ppm_had_2d_profile_etaPhi_adc_" + nameTag;
135 nameError =
"ppm_had_2d_etaPhi_adc_" + nameTag +
"RMS";
142 const TString& nameData,
const TString& nameError) {
147 if (
debug) std::cout <<
"--> L1CaloPostProcess: directory "
148 <<
nameDir <<
" not found." << std::endl;
152 if (
debug) std::cout <<
"dir " <<
nameDir <<
" isn't there!" << std::endl;
159 if (
debug) std::cout <<
" histo " <<
p1.Data() <<
" is not in file "
160 <<
f->GetName() << std::endl;
163 TH1*
h1 = (TH1*) (
f->Get(
p1.Data()));
168 if (
debug) std::cout <<
" histo " <<
p2.Data() <<
" is not in file "
169 <<
f->GetName() << std::endl;
172 TH1* h2 = (TH1*) (
f->Get(
p2.Data()));
175 const int dim =
h1->GetDimension();
176 if (
dim != h2->GetDimension()) {
177 if (
debug) std::cout <<
"Histograms have different dimension" << std::endl;
180 if (
h1->GetNbinsX() != h2->GetNbinsX() ||
181 ((
dim == 2) && (
h1->GetNbinsY() != h2->GetNbinsY()))) {
182 if (
debug) std::cout <<
"Histograms have different number of bins" << std::endl;
188 int nbins =
h1->GetNbinsX() + 2;
196 h2->Write(
"", TObject::kOverwrite);
203 const TString& nameDen,
const TString& nameEff,
208 if (!(
f->GetDirectory(effDir))) {
209 if (
debug) std::cout <<
"--> L1CaloPostProcess: directory "
210 << effDir <<
" not found." << std::endl;
213 if (
f->cd(effDir.Data()) == 0) {
214 if (
debug) std::cout <<
"dir " << effDir <<
" isn't there!" << std::endl;
219 TString denPath = effDir +
"/denominator/" + nameDen;
220 TH1*
h1 = (TH1*) (
f->Get(denPath.Data()));
222 if (
debug) std::cout <<
" histo " << denPath <<
" is not in file "
223 <<
f->GetName() << std::endl;
226 if (
h1->GetDimension() != 2) {
227 if (
debug) std::cout <<
" histo " << denPath <<
" has unexpected dimension"
235 std::vector<TH1*> effVec;
237 TString effBase = effDir +
"/" + nameEff;
240 TString effPath = effBase +
str;
241 TH1* h2 = (TH1*) (
f->Get(effPath.Data()));
243 if (
debug) std::cout <<
" histo " << effPath <<
" is not in file "
244 <<
f->GetName() << std::endl;
247 if (h2->GetDimension() != 2) {
248 if (
debug) std::cout <<
" histo " << effPath <<
" has unexpected dimension"
252 if (
xbins != h2->GetNbinsX() ||
ybins != h2->GetNbinsY()) {
253 if (
debug) std::cout <<
" histos " << denPath <<
" and " << effPath
254 <<
" have different number of bins" << std::endl;
257 effVec.push_back(h2);
259 if (effVec.empty()) {
260 if (
debug) std::cout <<
"No valid histograms in " << effDir << std::endl;
267 for (
int x = 1 + binSkip;
x <=
xbins - binSkip; ++
x) {
271 for (iter = effVec.begin(); iter != iterEnd; ++iter) {
272 (*iter)->SetBinContent(
x,
y, 100.0);
279 for (iter = effVec.begin(); iter != iterEnd; ++iter) {
280 (*iter)->Write(
"", TObject::kOverwrite);
286 #undef L1CALOPOSTPROCESSDEBUG