File indexing completed on 2024-04-06 12:33:12
0001 #include <vector>
0002 #include <algorithm>
0003 #include "TMath.h"
0004 #include "macro/PlotHelpers.C"
0005
0006
0007
0008
0009 void SeedValHistoPublisher(const char* newFile = "NEW_FILE", const char* refFile = "REF_FILE") {
0010 cout << ">> Starting SeedValHistoPublisher(" << newFile << "," << refFile << ")..." << endl;
0011
0012
0013
0014 const char* dataType = "DATATYPE";
0015 const char* refLabel("REF_LABEL, REF_RELEASE REFSELECTION");
0016 const char* newLabel("NEW_LABEL, NEW_RELEASE NEWSELECTION");
0017
0018
0019
0020
0021 gROOT->SetBatch();
0022 gErrorIgnoreLevel = kWarning;
0023
0024 SetGlobalStyle();
0025
0026
0027 delete gROOT->GetListOfFiles()->FindObject(refFile);
0028 delete gROOT->GetListOfFiles()->FindObject(newFile);
0029
0030
0031 cout << ">> Openning file, moving to the right branch and getting sub-branches..." << endl;
0032
0033 cout << ">> Finding sources..." << endl;
0034 TFile* sfile = new TFile(newFile);
0035 TList* sl = getListOfBranches(dataType, sfile, "Seeds");
0036 if (!sl) {
0037 cout << "ERROR: Could not find keys!!!" << endl;
0038 cerr << "ERROR: Could not find keys!!!" << endl;
0039 return;
0040 }
0041 TDirectory* sdir = gDirectory;
0042 for (unsigned int i = 0; i < sl->GetEntries(); i++)
0043 cout << " + " << sl->At(i)->GetName() << endl;
0044
0045 cout << ">> Finding references..." << endl;
0046 TFile* rfile = new TFile(refFile);
0047 TList* rl = getListOfBranches(dataType, rfile, "Seeds");
0048 if (!rl) {
0049 cout << "ERROR: Could not find keys!!!" << endl;
0050 cerr << "ERROR: Could not find keys!!!" << endl;
0051 return;
0052 }
0053 TDirectory* rdir = gDirectory;
0054 for (unsigned int i = 0; i < sl->GetEntries(); i++)
0055 cout << " + " << sl->At(i)->GetName() << endl;
0056
0057
0058 cout << ">> Find out number of events for normalization..." << endl;
0059 TH1F *sevt, *revt;
0060 sdir->GetObject("RecoMuonV/RecoMuon_TrackAssoc/Muons/NMuon", sevt);
0061 rdir->GetObject("RecoMuonV/RecoMuon_TrackAssoc/Muons/NMuon", revt);
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075 cout << ">> Iterating over histograms and collections..." << endl;
0076 TIter iter_r(rl);
0077 TIter iter_s(sl);
0078 TKey* rKey = 0;
0079 TKey* sKey = 0;
0080 TString rcollname;
0081 TString scollname;
0082
0083 while ((rKey = (TKey*)iter_r())) {
0084 TString myName = rKey->GetName();
0085 #ifdef DEBUG
0086 cout << "DEBUG: Checking key " << myName << endl;
0087 #endif
0088 rcollname = myName;
0089 sKey = (TKey*)iter_s();
0090 if (!sKey)
0091 continue;
0092 scollname = sKey->GetName();
0093 if ((rcollname != scollname) && (rcollname + "FS" != scollname) && (rcollname != scollname + "FS")) {
0094 cerr << "ERROR: Different collection names, please check: " << rcollname << " : " << scollname << endl;
0095 cout << "ERROR: Different collection names, please check: " << rcollname << " : " << scollname << endl;
0096 continue;
0097 }
0098
0099
0100 cout << ">> Comparing plots in " << myName << "..." << endl;
0101 cerr << ">> Comparing plots in " << myName << "..." << endl;
0102 TString newDir("NEW_RELEASE/NEWSELECTION/NEW_LABEL/");
0103 newDir += myName;
0104 gSystem->mkdir(newDir, kTRUE);
0105
0106 bool logy[] = {false, true, false, true};
0107 bool doKolmo[] = {true, true, true, true};
0108 Double_t norm[] = {0., 0., 0., 0., 0., 0.};
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122 const char* plots1[] = {"seedEta_", "seedEtaErr_", "seedPhi_", "seedPhiErr_"};
0123 const char* plotsl1[] = {"seed #eta", "seed #eta error", "seed #phi", "seed #phi error"};
0124 Plot4Histograms(newDir + "/muonSeed1",
0125 rdir,
0126 sdir,
0127 rcollname,
0128 scollname,
0129 "Seeds1",
0130 "Seeds eta and phi",
0131 refLabel,
0132 newLabel,
0133 plots1,
0134 plotsl1,
0135 logy,
0136 doKolmo,
0137 norm);
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157
0158
0159
0160
0161 bool logy2[] = {false, true, false, true, false, true};
0162 bool doKolmo2[] = {true, true, true, true, true, true};
0163 const char* plots2[] = {
0164 "seedPt_", "seedPtErrOverPt_", "seedPz_", "seedPzErrOverPz_", "NumberOfRecHitsPerSeed_", "seedPErrOverP_"};
0165 const char* plotsl2[] = {"seed P_{T}",
0166 "seed P_{T} Err/P_{T}",
0167 "seed P_{Z}",
0168 "seed P_{Z} Err/P_{Z}",
0169 "Nr RecHits per seed",
0170 "seed P Err/P"};
0171 Plot6Histograms(newDir + "/muonSeed2",
0172 rdir,
0173 sdir,
0174 rcollname,
0175 scollname,
0176 "Seeds2",
0177 "Seeds momenta and hits",
0178 refLabel,
0179 newLabel,
0180 plots2,
0181 plotsl2,
0182 logy2,
0183 doKolmo2,
0184 norm);
0185
0186
0187 TString mergefile = "merged_seed.pdf";
0188 TString destfile = newDir + "/../" + myName + ".pdf";
0189 TString gscommand = "gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=" + mergefile + " " + newDir +
0190 "/muonSeed1.pdf " + newDir + "/muonSeed2.pdf ";
0191
0192 cout << ">> Merging partial pdfs to " << mergefile << "..." << endl;
0193 #ifdef DEBUG
0194 cout << "DEBUG: ...with command \"" << gscommand << "\"" << endl;
0195 #endif
0196 gSystem->Exec(gscommand);
0197 cout << ">> Moving " << mergefile << " to " << destfile << "..." << endl;
0198 gSystem->Rename(mergefile, destfile);
0199
0200 cout << ">> Deleting partial pdf files" << endl;
0201 gSystem->Exec("rm -r " + newDir + "/*.pdf");
0202 cout << " ... Done" << endl;
0203
0204 }
0205
0206 cout << ">> Removing the relval files from ROOT before closing..." << endl;
0207 gROOT->GetListOfFiles()->Remove(sfile);
0208 gROOT->GetListOfFiles()->Remove(rfile);
0209
0210 #ifdef DEBUG
0211 cout << "DEBUG: Exiting!" << endl;
0212 cerr << "DEBUG: Exiting!" << endl;
0213 #endif
0214 }