CMS 3D CMS Logo

GlobalHitsProdHistStripper.cc
Go to the documentation of this file.
1 
10 
12  : fName(""),
13  verbosity(0),
14  frequency(0),
15  vtxunit(0),
16  getAllProvenances(false),
17  printProvenanceInfo(false),
18  outputfile(""),
19  count(0) {
20  std::string MsgLoggerCat = "GlobalHitsProdHistStripper_GlobalHitsProdHistStripper";
21 
22  // get information from parameter set
23  fName = iPSet.getUntrackedParameter<std::string>("Name");
24  verbosity = iPSet.getUntrackedParameter<int>("Verbosity");
25  frequency = iPSet.getUntrackedParameter<int>("Frequency");
26  vtxunit = iPSet.getUntrackedParameter<int>("VtxUnit");
27  outputfile = iPSet.getParameter<std::string>("OutputFile");
28  doOutput = iPSet.getParameter<bool>("DoOutput");
29  edm::ParameterSet m_Prov = iPSet.getParameter<edm::ParameterSet>("ProvenanceLookup");
30  getAllProvenances = m_Prov.getUntrackedParameter<bool>("GetAllProvenances");
31  printProvenanceInfo = m_Prov.getUntrackedParameter<bool>("PrintProvenanceInfo");
32 
33  // use value of first digit to determine default output level (inclusive)
34  // 0 is none, 1 is basic, 2 is fill output, 3 is gather output
35  verbosity %= 10;
36 
37  // get dqm info
38  dbe = nullptr;
39  dbe = edm::Service<DQMStore>().operator->();
40 
41  // print out Parameter Set information being used
42  if (verbosity >= 0) {
43  edm::LogInfo(MsgLoggerCat) << "\n===============================\n"
44  << "Initialized as EDAnalyzer with parameter values:\n"
45  << " Name = " << fName << "\n"
46  << " Verbosity = " << verbosity << "\n"
47  << " Frequency = " << frequency << "\n"
48  << " VtxUnit = " << vtxunit << "\n"
49  << " OutputFile = " << outputfile << "\n"
50  << " DoOutput = " << doOutput << "\n"
51  << " GetProv = " << getAllProvenances << "\n"
52  << " PrintProv = " << printProvenanceInfo << "\n"
53  << "===============================\n";
54  }
55 }
56 
58  if (doOutput)
59  if (!outputfile.empty() && dbe)
61 }
62 
64 
66  std::string MsgLoggerCat = "GlobalHitsProdHistStripper_endJob";
67  if (verbosity >= 0)
68  edm::LogInfo(MsgLoggerCat) << "Terminating having processed " << count << " runs.";
69  return;
70 }
71 
73  std::string MsgLoggerCat = "GlobalHitsProdHistStripper_beginRun";
74  // keep track of number of runs processed
75  ++count;
76 
77  int nrun = iRun.run();
78 
79  if (verbosity > 0) {
80  edm::LogInfo(MsgLoggerCat) << "Processing run " << nrun << " (" << count << " runs total)";
81  } else if (verbosity == 0) {
82  if (nrun % frequency == 0 || count == 1) {
83  edm::LogInfo(MsgLoggerCat) << "Processing run " << nrun << " (" << count << " runs total)";
84  }
85  }
86 
87  if (getAllProvenances) {
88  std::vector<const edm::StableProvenance *> AllProv;
89  iRun.getAllStableProvenance(AllProv);
90 
91  if (verbosity >= 0)
92  edm::LogInfo(MsgLoggerCat) << "Number of Provenances = " << AllProv.size();
93 
94  if (printProvenanceInfo && (verbosity >= 0)) {
95  TString eventout("\nProvenance info:\n");
96 
97  for (unsigned int i = 0; i < AllProv.size(); ++i) {
98  eventout += "\n ******************************";
99  eventout += "\n Module : ";
100  eventout += AllProv[i]->moduleLabel();
101  eventout += "\n ProductID : ";
102  eventout += AllProv[i]->productID().id();
103  eventout += "\n ClassName : ";
104  eventout += AllProv[i]->className();
105  eventout += "\n InstanceName : ";
106  eventout += AllProv[i]->productInstanceName();
107  eventout += "\n BranchName : ";
108  eventout += AllProv[i]->branchName();
109  }
110  eventout += "\n ******************************\n";
111  edm::LogInfo(MsgLoggerCat) << eventout << "\n";
112  printProvenanceInfo = false;
113  }
114  getAllProvenances = false;
115  }
116 
117  return;
118 }
119 
121  std::string MsgLoggerCat = "GlobalHitsProdHistStripper_endRun";
122 
123  edm::Handle<TH1F> histogram1D;
124  std::vector<edm::Handle<TH1F>> allhistogram1D;
125  iRun.getManyByType(allhistogram1D);
126 
127  me.resize(allhistogram1D.size());
128 
129  for (uint i = 0; i < allhistogram1D.size(); ++i) {
130  histogram1D = allhistogram1D[i];
131  if (!histogram1D.isValid()) {
132  edm::LogWarning(MsgLoggerCat) << "Invalid histogram extracted from event.";
133  continue;
134  }
135 
136  me[i] = nullptr;
137 
138  /*
139  std::cout << "Extracting histogram: " << std::endl
140  << " Module : "
141  << (histogram1D.provenance()->branchDescription()).moduleLabel()
142  << std::endl
143  << " ProductID : "
144  <<
145  (histogram1D.provenance()->branchDescription()).productID().id()
146  << std::endl
147  << " ClassName : "
148  << (histogram1D.provenance()->branchDescription()).className()
149  << std::endl
150  << " InstanceName : "
151  <<
152  (histogram1D.provenance()->branchDescription()).productInstanceName()
153  << std::endl
154  << " BranchName : "
155  << (histogram1D.provenance()->branchDescription()).branchName()
156  << std::endl;
157  */
158 
159  if ((histogram1D.provenance()->branchDescription()).moduleLabel() != "globalhitsprodhist")
160  continue;
161 
162  std::string histname = histogram1D->GetName();
163 
164  std::string subhist1 = histname.substr(1, 5);
165  std::string subhist2 = histname.substr(1, 4);
166 
167  if (dbe) {
168  if (subhist1 == "CaloE" || subhist1 == "CaloP") {
169  dbe->setCurrentFolder("GlobalHitsV/ECal");
170  } else if (subhist1 == "CaloH") {
171  dbe->setCurrentFolder("GlobalHitsV/HCal");
172  } else if (subhist1 == "Geant" || subhist2 == "MCG4" || subhist1 == "MCRGP") {
173  dbe->setCurrentFolder("GlobalHitsV/MCGeant");
174  } else if (subhist2 == "Muon") {
175  dbe->setCurrentFolder("GlobalHitsV/Muon");
176  } else if (subhist1 == "Track") {
177  dbe->setCurrentFolder("GlobalHitsV/Tracker");
178  }
179 
180  me[i] = dbe->book1D(histname,
181  histogram1D->GetTitle(),
182  histogram1D->GetXaxis()->GetNbins(),
183  histogram1D->GetXaxis()->GetXmin(),
184  histogram1D->GetXaxis()->GetXmax());
185  me[i]->setAxisTitle(histogram1D->GetXaxis()->GetTitle(), 1);
186  me[i]->setAxisTitle(histogram1D->GetYaxis()->GetTitle(), 2);
187  }
188 
189  std::string mename = me[i]->getName();
190 
191  // std::cout << "Extracting histogram " << histname
192  // << " into MonitorElement " << mename
193  // << std::endl;
194 
195  for (Int_t x = 1; x <= histogram1D->GetXaxis()->GetNbins(); ++x) {
196  Double_t binx = histogram1D->GetBinCenter(x);
197  Double_t value = histogram1D->GetBinContent(x);
198  me[i]->Fill(binx, value);
199  }
200  }
201  return;
202 }
203 /*
204 if (iter != monitorElements.end()) {
205 
206  std::string mename = iter->second->getName();
207 
208  std::cout << "Extracting histogram " << histname
209  << " into MonitorElement " << mename
210  << std::endl;
211 
212  if (histname == "hGeantTrkE" || histname == "hGeantTrkPt") {
213  std::cout << "Information stored in histogram pointer:"
214  << std::endl;
215  std::cout << histname << ":" << std::endl;
216  std::cout << " Entries: " << histogram1D->GetEntries()
217  << std::endl;
218  std::cout << " Mean: " << histogram1D->GetMean() << std::endl;
219  std::cout << " RMS: " << histogram1D->GetRMS() << std::endl;
220  }
221 
222  for (Int_t x = 1; x <= histogram1D->GetXaxis()->GetNbins(); ++x) {
223  Double_t binx = histogram1D->GetBinCenter(x);
224  Double_t value = histogram1D->GetBinContent(x);
225  iter->second->Fill(binx,value);
226  }
227 
228  if (histname == "hGeantTrkE" || histname == "hGeantTrkPt") {
229  std::cout << "Information stored in monitor element:" << std::endl;
230  std::cout << mename << ":" << std::endl;
231  std::cout << " Entries: "
232  << iter->second->getEntries() << std::endl;
233  std::cout << " Mean: " << iter->second->getMean()
234  << std::endl;
235  std::cout << " RMS: " << iter->second->getRMS()
236  << std::endl;
237  }
238 } // find in map
239 } // loop through getManyByType
240 
241 return;
242 }
243 */
244 
HIPAlignmentAlgorithm_cfi.verbosity
verbosity
Definition: HIPAlignmentAlgorithm_cfi.py:7
writedatasetfile.outputfile
outputfile
Definition: writedatasetfile.py:27
GlobalHitsProdHistStripper::verbosity
int verbosity
Definition: GlobalHitsProdHistStripper.h:59
mps_fire.i
i
Definition: mps_fire.py:428
funct::false
false
Definition: Factorize.h:29
edm::Run
Definition: Run.h:45
GlobalHitsProdHistStripper::dbe
DQMStore * dbe
Definition: GlobalHitsProdHistStripper.h:65
edm::Run::getAllStableProvenance
void getAllStableProvenance(std::vector< StableProvenance const * > &provenances) const
Definition: Run.cc:33
GlobalHitsProdHistStripper::fName
std::string fName
Definition: GlobalHitsProdHistStripper.h:58
DQMStore.h
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
DDAxes::x
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
GlobalHitsProdHistStripper::count
unsigned int count
Definition: GlobalHitsProdHistStripper.h:156
edm::Handle
Definition: AssociativeIterator.h:50
parallelization.uint
uint
Definition: parallelization.py:124
edm::RunBase::run
RunNumber_t run() const
Definition: RunBase.h:40
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
MainPageGenerator.fName
fName
Definition: MainPageGenerator.py:301
GlobalHitsProdHistStripper::endRun
void endRun(const edm::Run &, const edm::EventSetup &) override
Definition: GlobalHitsProdHistStripper.cc:120
GlobalHitsProdHistStripper::getAllProvenances
bool getAllProvenances
Definition: GlobalHitsProdHistStripper.h:62
submitPVResolutionJobs.count
count
Definition: submitPVResolutionJobs.py:352
dqm::implementation::DQMStore::setCurrentFolder
void setCurrentFolder(std::string const &fullpath) override
Definition: DQMStore.h:569
edm::HandleBase::provenance
Provenance const * provenance() const
Definition: HandleBase.h:74
GlobalHitsProdHistStripper::beginRun
void beginRun(const edm::Run &, const edm::EventSetup &) override
Definition: GlobalHitsProdHistStripper.cc:72
dqm::implementation::DQMStore::save
DQM_DEPRECATED void save(std::string const &filename, std::string const &path="")
Definition: DQMStore.cc:761
GlobalHitsProdHistStripper::frequency
int frequency
Definition: GlobalHitsProdHistStripper.h:60
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
GlobalHitsProdHistStripper::me
std::vector< MonitorElement * > me
Definition: GlobalHitsProdHistStripper.h:71
GlobalHitsProdHistStripper::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: GlobalHitsProdHistStripper.cc:245
edm::ParameterSet
Definition: ParameterSet.h:47
GlobalHitsProdHistStripper::doOutput
bool doOutput
Definition: GlobalHitsProdHistStripper.h:67
edm::Service
Definition: Service.h:30
iEvent
int iEvent
Definition: GenABIO.cc:224
value
Definition: value.py:1
GlobalHitsProdHistStripper::printProvenanceInfo
bool printProvenanceInfo
Definition: GlobalHitsProdHistStripper.h:63
edm::EventSetup
Definition: EventSetup.h:57
GlobalHitsProdHistStripper::vtxunit
int vtxunit
Definition: GlobalHitsProdHistStripper.h:61
GlobalHitsProdHistStripper::beginJob
void beginJob(void) override
Definition: GlobalHitsProdHistStripper.cc:63
GlobalHitsProdHistStripper::GlobalHitsProdHistStripper
GlobalHitsProdHistStripper(const edm::ParameterSet &)
Definition: GlobalHitsProdHistStripper.cc:11
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
HerwigMaxPtPartonFilter_cfi.moduleLabel
moduleLabel
Definition: HerwigMaxPtPartonFilter_cfi.py:4
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::Event
Definition: Event.h:73
GlobalHitsProdHistStripper::~GlobalHitsProdHistStripper
~GlobalHitsProdHistStripper() override
Definition: GlobalHitsProdHistStripper.cc:57
GlobalHitsProdHistStripper::outputfile
std::string outputfile
Definition: GlobalHitsProdHistStripper.h:66
edm::Run::getManyByType
void getManyByType(std::vector< Handle< PROD >> &results) const
Definition: Run.h:362
dqm::implementation::IBooker::book1D
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
GlobalHitsProdHistStripper::endJob
void endJob() override
Definition: GlobalHitsProdHistStripper.cc:65
GlobalHitsProdHistStripper.h