Go to the documentation of this file.00001
00010 #include "Validation/GlobalHits/interface/GlobalHitsProdHistStripper.h"
00011 #include "DQMServices/Core/interface/DQMStore.h"
00012 #include "DQMServices/Core/interface/MonitorElement.h"
00013
00014 GlobalHitsProdHistStripper::GlobalHitsProdHistStripper(const
00015 edm::ParameterSet&
00016 iPSet)
00017 : fName(""), verbosity(0), frequency(0), vtxunit(0),
00018 getAllProvenances(false), printProvenanceInfo(false), outputfile(""),
00019 count(0)
00020 {
00021 std::string MsgLoggerCat =
00022 "GlobalHitsProdHistStripper_GlobalHitsProdHistStripper";
00023
00024
00025 fName = iPSet.getUntrackedParameter<std::string>("Name");
00026 verbosity = iPSet.getUntrackedParameter<int>("Verbosity");
00027 frequency = iPSet.getUntrackedParameter<int>("Frequency");
00028 vtxunit = iPSet.getUntrackedParameter<int>("VtxUnit");
00029 outputfile = iPSet.getParameter<std::string>("OutputFile");
00030 doOutput = iPSet.getParameter<bool>("DoOutput");
00031 edm::ParameterSet m_Prov =
00032 iPSet.getParameter<edm::ParameterSet>("ProvenanceLookup");
00033 getAllProvenances =
00034 m_Prov.getUntrackedParameter<bool>("GetAllProvenances");
00035 printProvenanceInfo =
00036 m_Prov.getUntrackedParameter<bool>("PrintProvenanceInfo");
00037
00038
00039
00040
00041 verbosity %= 10;
00042
00043
00044 dbe = 0;
00045 dbe = edm::Service<DQMStore>().operator->();
00046 if (dbe) {
00047 if (verbosity > 0 ) {
00048 dbe->setVerbose(1);
00049 } else {
00050 dbe->setVerbose(0);
00051 }
00052 }
00053
00054 if (dbe) {
00055 if (verbosity > 0 ) dbe->showDirStructure();
00056 }
00057
00058
00059 if (verbosity >= 0) {
00060 edm::LogInfo(MsgLoggerCat)
00061 << "\n===============================\n"
00062 << "Initialized as EDAnalyzer with parameter values:\n"
00063 << " Name = " << fName << "\n"
00064 << " Verbosity = " << verbosity << "\n"
00065 << " Frequency = " << frequency << "\n"
00066 << " VtxUnit = " << vtxunit << "\n"
00067 << " OutputFile = " << outputfile << "\n"
00068 << " DoOutput = " << doOutput << "\n"
00069 << " GetProv = " << getAllProvenances << "\n"
00070 << " PrintProv = " << printProvenanceInfo << "\n"
00071 << "===============================\n";
00072 }
00073
00074 }
00075
00076 GlobalHitsProdHistStripper::~GlobalHitsProdHistStripper()
00077 {
00078 if (doOutput)
00079 if (outputfile.size() != 0 && dbe) dbe->save(outputfile);
00080 }
00081
00082 void GlobalHitsProdHistStripper::beginJob( void )
00083 {
00084 return;
00085 }
00086
00087 void GlobalHitsProdHistStripper::endJob()
00088 {
00089 std::string MsgLoggerCat = "GlobalHitsProdHistStripper_endJob";
00090 if (verbosity >= 0)
00091 edm::LogInfo(MsgLoggerCat)
00092 << "Terminating having processed " << count << " runs.";
00093 return;
00094 }
00095
00096 void GlobalHitsProdHistStripper::beginRun(const edm::Run& iRun,
00097 const edm::EventSetup& iSetup)
00098 {
00099 std::string MsgLoggerCat = "GlobalHitsProdHistStripper_beginRun";
00100
00101 ++count;
00102
00103 int nrun = iRun.run();
00104
00105 if (verbosity > 0) {
00106 edm::LogInfo(MsgLoggerCat)
00107 << "Processing run " << nrun << " (" << count << " runs total)";
00108 } else if (verbosity == 0) {
00109 if (nrun%frequency == 0 || count == 1) {
00110 edm::LogInfo(MsgLoggerCat)
00111 << "Processing run " << nrun << " (" << count << " runs total)";
00112 }
00113 }
00114
00115 if (getAllProvenances) {
00116
00117 std::vector<const edm::Provenance*> AllProv;
00118 iRun.getAllProvenance(AllProv);
00119
00120 if (verbosity >= 0)
00121 edm::LogInfo(MsgLoggerCat)
00122 << "Number of Provenances = " << AllProv.size();
00123
00124 if (printProvenanceInfo && (verbosity >= 0)) {
00125 TString eventout("\nProvenance info:\n");
00126
00127 for (unsigned int i = 0; i < AllProv.size(); ++i) {
00128 eventout += "\n ******************************";
00129 eventout += "\n Module : ";
00130 eventout += AllProv[i]->moduleLabel();
00131 eventout += "\n ProductID : ";
00132 eventout += AllProv[i]->productID().id();
00133 eventout += "\n ClassName : ";
00134 eventout += AllProv[i]->className();
00135 eventout += "\n InstanceName : ";
00136 eventout += AllProv[i]->productInstanceName();
00137 eventout += "\n BranchName : ";
00138 eventout += AllProv[i]->branchName();
00139 }
00140 eventout += "\n ******************************\n";
00141 edm::LogInfo(MsgLoggerCat) << eventout << "\n";
00142 printProvenanceInfo = false;
00143 }
00144 getAllProvenances = false;
00145 }
00146
00147 return;
00148 }
00149
00150 void GlobalHitsProdHistStripper::endRun(const edm::Run& iRun,
00151 const edm::EventSetup& iSetup)
00152 {
00153 std::string MsgLoggerCat = "GlobalHitsProdHistStripper_endRun";
00154
00155 edm::Handle<TH1F> histogram1D;
00156 std::vector<edm::Handle<TH1F> > allhistogram1D;
00157 iRun.getManyByType(allhistogram1D);
00158
00159 me.resize(allhistogram1D.size());
00160
00161 for (uint i = 0; i < allhistogram1D.size(); ++i) {
00162 histogram1D = allhistogram1D[i];
00163 if(!histogram1D.isValid()) {
00164 edm::LogWarning(MsgLoggerCat)
00165 << "Invalid histogram extracted from event.";
00166 continue;
00167 }
00168
00169 me[i] = 0;
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190 if ((histogram1D.provenance()->product()).moduleLabel()
00191 != "globalhitsprodhist") continue;
00192
00193 std::string histname = histogram1D->GetName();
00194
00195 std::string subhist1 = histname.substr(1,5);
00196 std::string subhist2 = histname.substr(1,4);
00197
00198 if (dbe) {
00199 if (subhist1 == "CaloE" || subhist1 == "CaloP") {
00200 dbe->setCurrentFolder("GlobalHitsV/ECal");
00201 } else if (subhist1 == "CaloH") {
00202 dbe->setCurrentFolder("GlobalHitsV/HCal");
00203 } else if (subhist1 == "Geant" || subhist2 == "MCG4" ||
00204 subhist1 == "MCRGP") {
00205 dbe->setCurrentFolder("GlobalHitsV/MCGeant");
00206 } else if (subhist2 == "Muon") {
00207 dbe->setCurrentFolder("GlobalHitsV/Muon");
00208 } else if (subhist1 == "Track") {
00209 dbe->setCurrentFolder("GlobalHitsV/Tracker");
00210 }
00211
00212 me[i] = dbe->book1D(histname,histogram1D->GetTitle(),
00213 histogram1D->GetXaxis()->GetNbins(),
00214 histogram1D->GetXaxis()->GetXmin(),
00215 histogram1D->GetXaxis()->GetXmax());
00216 me[i]->setAxisTitle(histogram1D->GetXaxis()->GetTitle(),1);
00217 me[i]->setAxisTitle(histogram1D->GetYaxis()->GetTitle(),2);
00218
00219 }
00220
00221 std::string mename = me[i]->getName();
00222
00223
00224
00225
00226
00227 for (Int_t x = 1; x <= histogram1D->GetXaxis()->GetNbins(); ++x) {
00228 Double_t binx = histogram1D->GetBinCenter(x);
00229 Double_t value = histogram1D->GetBinContent(x);
00230 me[i]->Fill(binx,value);
00231 }
00232 }
00233 return;
00234 }
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277 void GlobalHitsProdHistStripper::analyze(const edm::Event& iEvent,
00278 const edm::EventSetup& iSetup)
00279 {
00280 return;
00281 }
00282
00283