CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
FFTJetPileupAnalyzer Class Reference

#include <RecoJets/JetAnalyzers/src/FFTJetPileupAnalyzer.cc>

Inheritance diagram for FFTJetPileupAnalyzer:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 FFTJetPileupAnalyzer (const edm::ParameterSet &)
 
 ~FFTJetPileupAnalyzer ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &) override
 
void analyzePileup (const std::vector< PileupSummaryInfo > &pInfo)
 
virtual void beginJob () override
 
virtual void endJob () override
 
 FFTJetPileupAnalyzer ()
 
 FFTJetPileupAnalyzer (const FFTJetPileupAnalyzer &)
 
FFTJetPileupAnalyzeroperator= (const FFTJetPileupAnalyzer &)
 

Private Attributes

bool collectFastJetRho
 
bool collectGridDensity
 
bool collectGrids
 
bool collectHistos
 
bool collectOOTPileup
 
bool collectPileup
 
bool collectSummaries
 
bool collectVertexInfo
 
unsigned long counter
 
double crazyEnergyCut
 
edm::InputTag fastJetRhoLabel
 
edm::InputTag fastJetSigmaLabel
 
edm::InputTag gridLabel
 
edm::InputTag histoLabel
 
TNtuple * nt
 
std::vector< float > ntupleData
 
std::string ntupleName
 
std::string ntupleTitle
 
std::string pileupLabel
 
edm::InputTag srcPVs
 
edm::InputTag summaryLabel
 
int totalNpu
 
int totalNPV
 
bool verbosePileupInfo
 
double vertexNdofCut
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Description: collects the info produced by FFTJetPileupProcessor and FFTJetPileupEstimator

Implementation: [Notes on implementation]

Definition at line 50 of file FFTJetPileupAnalyzer.cc.

Constructor & Destructor Documentation

FFTJetPileupAnalyzer::FFTJetPileupAnalyzer ( const edm::ParameterSet ps)
explicit

Definition at line 101 of file FFTJetPileupAnalyzer.cc.

111  init_param(bool, collectHistos),
114  init_param(bool, collectPileup),
116  init_param(bool, collectGrids),
120  init_param(double, vertexNdofCut),
121  init_param(double, crazyEnergyCut),
122  nt(0),
123  totalNpu(-1),
124  totalNPV(-1),
125  counter(0)
126 {
127 }
#define init_param(type, varname)
FFTJetPileupAnalyzer::~FFTJetPileupAnalyzer ( )

Definition at line 130 of file FFTJetPileupAnalyzer.cc.

131 {
132 }
FFTJetPileupAnalyzer::FFTJetPileupAnalyzer ( )
private
FFTJetPileupAnalyzer::FFTJetPileupAnalyzer ( const FFTJetPileupAnalyzer )
private

Member Function Documentation

void FFTJetPileupAnalyzer::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::EDAnalyzer.

Definition at line 251 of file FFTJetPileupAnalyzer.cc.

References analyzePileup(), collectFastJetRho, collectGridDensity, collectGrids, collectHistos, collectOOTPileup, collectPileup, collectSummaries, collectVertexInfo, filterCSVwithJSON::copy, counter, data, edm::EventID::event(), f, fastJetRhoLabel, fastJetSigmaLabel, TFileService::getBareDirectory(), edm::Event::getByLabel(), gridLabel, h, histoLabel, edm::EventBase::id(), input, M_PI, nt, ntupleData, pileupLabel, edm::EventID::run(), cond::runnumber, srcPVs, AlCaHLTBitMon_QueryRunRegistry::string, edmLumisInFiles::summary, summaryLabel, totalNpu, totalNPV, and vertexNdofCut.

253 {
254  ntupleData.clear();
255  ntupleData.push_back(counter);
256  totalNpu = -1;
257  totalNPV = -1;
258 
259  const long runnumber = iEvent.id().run();
260  const long eventnumber = iEvent.id().event();
261  ntupleData.push_back(runnumber);
262  ntupleData.push_back(eventnumber);
263 
264  // Get pileup information from the pile-up information module
266  {
268  if (iEvent.getByLabel(pileupLabel, puInfo))
269  analyzePileup(*puInfo);
270  else
271  {
272  if (collectPileup)
273  {
274  ntupleData.push_back(-1);
275  ntupleData.push_back(-1);
276  ntupleData.push_back(0.f);
277  ntupleData.push_back(0.f);
278  }
279  if (collectOOTPileup)
280  for (unsigned ibx = 0; ibx < 3; ++ibx)
281  {
282  ntupleData.push_back(-1);
283  ntupleData.push_back(0.f);
284  ntupleData.push_back(0.f);
285  }
286  }
287  }
288 
289  if (collectHistos)
290  {
292  iEvent.getByLabel(histoLabel, input);
293 
295  TH2D* copy = new TH2D(*input);
296 
297  std::ostringstream os;
298  os << copy->GetName() << '_' << counter << '_'
299  << totalNpu << '_' << runnumber << '_' << eventnumber;
300  const std::string& newname(os.str());
301  copy->SetNameTitle(newname.c_str(), newname.c_str());
302 
303  copy->SetDirectory(fs->getBareDirectory());
304  }
305 
306  if (collectSummaries)
307  {
309  iEvent.getByLabel(summaryLabel, summary);
310 
311  ntupleData.push_back(summary->uncalibratedQuantile());
312  ntupleData.push_back(summary->pileupRho());
313  ntupleData.push_back(summary->pileupRhoUncertainty());
314  ntupleData.push_back(summary->uncertaintyCode());
315  }
316 
317  if (collectFastJetRho)
318  {
319  edm::Handle<double> fjrho, fjsigma;
320  iEvent.getByLabel(fastJetRhoLabel, fjrho);
321  iEvent.getByLabel(fastJetSigmaLabel, fjsigma);
322 
323  ntupleData.push_back(*fjrho);
324  ntupleData.push_back(*fjsigma);
325  }
326 
327  if (collectGrids)
328  {
330  iEvent.getByLabel(gridLabel, input);
331 
332  // Make sure the input grid is reasonable
333  const double* data = input->data();
334  assert(data);
335  assert(input->phiBin0Edge() == 0.0);
336  const unsigned nEta = input->nEtaBins();
337  const unsigned nPhi = input->nPhiBins();
338 
339  // Generate a name for the output histogram
340  std::ostringstream os;
341  os << "FFTJetGrid_" << counter << '_'
342  << totalNpu << '_' << runnumber << '_' << eventnumber;
343  const std::string& newname(os.str());
344 
345  // Make a histogram and copy the grid data into it
347  TH2F* h = fs->make<TH2F>(newname.c_str(), newname.c_str(),
348  nEta, input->etaMin(), input->etaMax(),
349  nPhi, 0.0, 2.0*M_PI);
350  h->GetXaxis()->SetTitle("Eta");
351  h->GetYaxis()->SetTitle("Phi");
352  h->GetZaxis()->SetTitle("Transverse Energy");
353 
354  for (unsigned ieta=0; ieta<nEta; ++ieta)
355  for (unsigned iphi=0; iphi<nPhi; ++iphi)
356  h->SetBinContent(ieta+1U, iphi+1U, data[ieta*nPhi + iphi]);
357  }
358 
359  if (collectGridDensity)
360  {
362  iEvent.getByLabel(histoLabel, etSum);
363 
364  ntupleData.push_back(etSum->first);
365  ntupleData.push_back(etSum->second);
366  }
367 
368  if (collectVertexInfo)
369  {
371  iEvent.getByLabel(srcPVs, pvCollection);
372  totalNPV = 0;
373  if (!pvCollection->empty())
374  for (reco::VertexCollection::const_iterator pv = pvCollection->begin();
375  pv != pvCollection->end(); ++pv)
376  {
377  const double ndof = pv->ndof();
378  if (!pv->isFake() && ndof > vertexNdofCut)
379  ++totalNPV;
380  }
381  ntupleData.push_back(totalNPV);
382  }
383 
384  assert(ntupleData.size() == static_cast<unsigned>(nt->GetNvar()));
385  nt->Fill(&ntupleData[0]);
386 
387  ++counter;
388 }
RunNumber_t run() const
Definition: EventID.h:42
EventNumber_t event() const
Definition: EventID.h:44
void analyzePileup(const std::vector< PileupSummaryInfo > &pInfo)
static std::string const input
Definition: EdmProvDump.cc:44
TDirectory * getBareDirectory(const std::string &subdir="") const
Definition: TFileService.h:52
double f[11][100]
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
#define M_PI
Definition: BFit3D.cc:3
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
edm::EventID id() const
Definition: EventBase.h:56
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
std::vector< float > ntupleData
void FFTJetPileupAnalyzer::analyzePileup ( const std::vector< PileupSummaryInfo > &  pInfo)
private

Definition at line 138 of file FFTJetPileupAnalyzer.cc.

References collectOOTPileup, collectPileup, gather_cfg::cout, crazyEnergyCut, PileupSummaryInfo::getBunchCrossing(), PileupSummaryInfo::getPU_NumInteractions(), PileupSummaryInfo::getPU_sumpT_highpT(), PileupSummaryInfo::getPU_sumpT_lowpT(), customizeTrackingMonitorSeedNumber::idx, mix_2012_Summer_inTimeOnly_cff::npu, ntupleData, totalNpu, and verbosePileupInfo.

Referenced by analyze().

140 {
141  const unsigned nBx = info.size();
142  if (collectPileup)
143  ntupleData.push_back(static_cast<float>(nBx));
144 
145  double sumpt_Lo = 0.0, sumpt_Hi = 0.0;
146  totalNpu = 0;
147 
148  int npu_by_Bx[3] = {0,};
149  double sumpt_Lo_by_Bx[3] = {0.0,}, sumpt_Hi_by_Bx[3] = {0.0,};
150 
151  if (verbosePileupInfo)
152  std::cout << "\n**** Pileup info begin" << std::endl;
153 
154  bool isCrazy = false;
155  for (unsigned ibx = 0; ibx < nBx; ++ibx)
156  {
157  const PileupSummaryInfo& puInfo(info[ibx]);
158 
159  const int bx = puInfo.getBunchCrossing();
160  const int npu = puInfo.getPU_NumInteractions();
161  const std::vector<float>& lopt(puInfo.getPU_sumpT_lowpT());
162  const std::vector<float>& hipt(puInfo.getPU_sumpT_highpT());
163  const double losum = std::accumulate(lopt.begin(), lopt.end(), 0.0);
164  const double hisum = std::accumulate(hipt.begin(), hipt.end(), 0.0);
165 
166  if (losum >= crazyEnergyCut)
167  isCrazy = true;
168  if (hisum >= crazyEnergyCut)
169  isCrazy = true;
170 
171  totalNpu += npu;
172  sumpt_Lo += losum;
173  sumpt_Hi += hisum;
174 
175  const unsigned idx = bx < 0 ? 0U : (bx == 0 ? 1U : 2U);
176  npu_by_Bx[idx] += npu;
177  sumpt_Lo_by_Bx[idx] += losum;
178  sumpt_Hi_by_Bx[idx] += hisum;
179 
180  if (verbosePileupInfo)
181  std::cout << "ibx " << ibx << " bx " << bx
182  << " npu " << npu << " losum " << losum
183  << " hisum " << hisum
184  << std::endl;
185  }
186 
187  if (verbosePileupInfo)
188  std::cout << "**** Pileup info end\n" << std::endl;
189 
190  if (isCrazy)
191  {
192  totalNpu = -1;
193  sumpt_Lo = 0.0;
194  sumpt_Hi = 0.0;
195  for (unsigned ibx = 0; ibx < 3; ++ibx)
196  {
197  npu_by_Bx[ibx] = -1;
198  sumpt_Lo_by_Bx[ibx] = 0.0;
199  sumpt_Hi_by_Bx[ibx] = 0.0;
200  }
201  }
202 
203  if (collectPileup)
204  {
205  ntupleData.push_back(totalNpu);
206  ntupleData.push_back(sumpt_Lo);
207  ntupleData.push_back(sumpt_Hi);
208  }
209 
210  if (collectOOTPileup)
211  for (unsigned ibx = 0; ibx < 3; ++ibx)
212  {
213  ntupleData.push_back(npu_by_Bx[ibx]);
214  ntupleData.push_back(sumpt_Lo_by_Bx[ibx]);
215  ntupleData.push_back(sumpt_Hi_by_Bx[ibx]);
216  }
217 }
static const TGPicture * info(bool iBackgroundIsBlack)
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
tuple cout
Definition: gather_cfg.py:121
std::vector< float > ntupleData
void FFTJetPileupAnalyzer::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 221 of file FFTJetPileupAnalyzer.cc.

References collectFastJetRho, collectGridDensity, collectOOTPileup, collectPileup, collectSummaries, collectVertexInfo, TFileService::make(), nt, ntupleData, ntupleName, ntupleTitle, and AlCaHLTBitMon_QueryRunRegistry::string.

222 {
223  // Come up with the list of variables
224  std::string vars = "cnt:run:event";
225  if (collectPileup)
226  vars += ":nbx:npu:sumptLowCut:sumptHiCut";
227  if (collectOOTPileup)
228  {
229  vars += ":npu_negbx:sumptLowCut_negbx:sumptHiCut_negbx";
230  vars += ":npu_0bx:sumptLowCut_0bx:sumptHiCut_0bx";
231  vars += ":npu_posbx:sumptLowCut_posbx:sumptHiCut_posbx";
232  }
233  if (collectSummaries)
234  vars += ":estimate:pileup:uncert:uncertCode";
235  if (collectFastJetRho)
236  vars += ":fjrho:fjsigma";
237  if (collectGridDensity)
238  vars += ":gridEtDensity:gridEtDensityMixed";
239  if (collectVertexInfo)
240  vars += ":nPV";
241 
242  // Book the ntuple
244  nt = fs->make<TNtuple>(ntupleName.c_str(), ntupleTitle.c_str(),
245  vars.c_str());
246  ntupleData.reserve(nt->GetNvar());
247 }
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
std::vector< float > ntupleData
void FFTJetPileupAnalyzer::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 392 of file FFTJetPileupAnalyzer.cc.

393 {
394 }
FFTJetPileupAnalyzer& FFTJetPileupAnalyzer::operator= ( const FFTJetPileupAnalyzer )
private

Member Data Documentation

bool FFTJetPileupAnalyzer::collectFastJetRho
private

Definition at line 80 of file FFTJetPileupAnalyzer.cc.

Referenced by analyze(), and beginJob().

bool FFTJetPileupAnalyzer::collectGridDensity
private

Definition at line 84 of file FFTJetPileupAnalyzer.cc.

Referenced by analyze(), and beginJob().

bool FFTJetPileupAnalyzer::collectGrids
private

Definition at line 83 of file FFTJetPileupAnalyzer.cc.

Referenced by analyze().

bool FFTJetPileupAnalyzer::collectHistos
private

Definition at line 78 of file FFTJetPileupAnalyzer.cc.

Referenced by analyze().

bool FFTJetPileupAnalyzer::collectOOTPileup
private

Definition at line 82 of file FFTJetPileupAnalyzer.cc.

Referenced by analyze(), analyzePileup(), and beginJob().

bool FFTJetPileupAnalyzer::collectPileup
private

Definition at line 81 of file FFTJetPileupAnalyzer.cc.

Referenced by analyze(), analyzePileup(), and beginJob().

bool FFTJetPileupAnalyzer::collectSummaries
private

Definition at line 79 of file FFTJetPileupAnalyzer.cc.

Referenced by analyze(), and beginJob().

bool FFTJetPileupAnalyzer::collectVertexInfo
private

Definition at line 85 of file FFTJetPileupAnalyzer.cc.

Referenced by analyze(), and beginJob().

unsigned long FFTJetPileupAnalyzer::counter
private

Definition at line 95 of file FFTJetPileupAnalyzer.cc.

Referenced by analyze().

double FFTJetPileupAnalyzer::crazyEnergyCut
private

Definition at line 89 of file FFTJetPileupAnalyzer.cc.

Referenced by analyzePileup().

edm::InputTag FFTJetPileupAnalyzer::fastJetRhoLabel
private

Definition at line 71 of file FFTJetPileupAnalyzer.cc.

Referenced by analyze().

edm::InputTag FFTJetPileupAnalyzer::fastJetSigmaLabel
private

Definition at line 72 of file FFTJetPileupAnalyzer.cc.

Referenced by analyze().

edm::InputTag FFTJetPileupAnalyzer::gridLabel
private

Definition at line 73 of file FFTJetPileupAnalyzer.cc.

Referenced by analyze().

edm::InputTag FFTJetPileupAnalyzer::histoLabel
private

Definition at line 69 of file FFTJetPileupAnalyzer.cc.

Referenced by analyze().

TNtuple* FFTJetPileupAnalyzer::nt
private

Definition at line 92 of file FFTJetPileupAnalyzer.cc.

Referenced by analyze(), and beginJob().

std::vector<float> FFTJetPileupAnalyzer::ntupleData
private

Definition at line 91 of file FFTJetPileupAnalyzer.cc.

Referenced by analyze(), analyzePileup(), and beginJob().

std::string FFTJetPileupAnalyzer::ntupleName
private

Definition at line 76 of file FFTJetPileupAnalyzer.cc.

Referenced by beginJob().

std::string FFTJetPileupAnalyzer::ntupleTitle
private

Definition at line 77 of file FFTJetPileupAnalyzer.cc.

Referenced by beginJob().

std::string FFTJetPileupAnalyzer::pileupLabel
private

Definition at line 75 of file FFTJetPileupAnalyzer.cc.

Referenced by analyze().

edm::InputTag FFTJetPileupAnalyzer::srcPVs
private

Definition at line 74 of file FFTJetPileupAnalyzer.cc.

Referenced by analyze().

edm::InputTag FFTJetPileupAnalyzer::summaryLabel
private

Definition at line 70 of file FFTJetPileupAnalyzer.cc.

Referenced by analyze().

int FFTJetPileupAnalyzer::totalNpu
private

Definition at line 93 of file FFTJetPileupAnalyzer.cc.

Referenced by analyze(), and analyzePileup().

int FFTJetPileupAnalyzer::totalNPV
private

Definition at line 94 of file FFTJetPileupAnalyzer.cc.

Referenced by analyze().

bool FFTJetPileupAnalyzer::verbosePileupInfo
private

Definition at line 86 of file FFTJetPileupAnalyzer.cc.

Referenced by analyzePileup().

double FFTJetPileupAnalyzer::vertexNdofCut
private

Definition at line 88 of file FFTJetPileupAnalyzer.cc.

Referenced by analyze().