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

Public Member Functions

 FFTJetPileupAnalyzer (const edm::ParameterSet &)
 
 ~FFTJetPileupAnalyzer ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

Private Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
 
void analyzePileup (const std::vector< PileupSummaryInfo > &pInfo)
 
virtual void beginJob ()
 
virtual void endJob ()
 
 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
 
typedef WorkerT< EDAnalyzerWorkerType
 
- 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::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

Detailed Description

Description: collects the info produced by FFTJetPileupProcessor and FFTJetPileupEstimator

Implementation: [Notes on implementation]

Definition at line 51 of file FFTJetPileupAnalyzer.cc.

Constructor & Destructor Documentation

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

Definition at line 102 of file FFTJetPileupAnalyzer.cc.

109  init_param(std::string, pileupLabel),
110  init_param(std::string, ntupleName),
111  init_param(std::string, ntupleTitle),
112  init_param(bool, collectHistos),
115  init_param(bool, collectPileup),
117  init_param(bool, collectGrids),
121  init_param(double, vertexNdofCut),
122  init_param(double, crazyEnergyCut),
123  nt(0),
124  totalNpu(-1),
125  totalNPV(-1),
126  counter(0)
127 {
128 }
#define init_param(type, varname)
FFTJetPileupAnalyzer::~FFTJetPileupAnalyzer ( )

Definition at line 131 of file FFTJetPileupAnalyzer.cc.

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

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 252 of file FFTJetPileupAnalyzer.cc.

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

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

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

Referenced by analyze().

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

Reimplemented from edm::EDAnalyzer.

Definition at line 222 of file FFTJetPileupAnalyzer.cc.

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

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

Reimplemented from edm::EDAnalyzer.

Definition at line 393 of file FFTJetPileupAnalyzer.cc.

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

Member Data Documentation

bool FFTJetPileupAnalyzer::collectFastJetRho
private

Definition at line 81 of file FFTJetPileupAnalyzer.cc.

Referenced by analyze(), and beginJob().

bool FFTJetPileupAnalyzer::collectGridDensity
private

Definition at line 85 of file FFTJetPileupAnalyzer.cc.

Referenced by analyze(), and beginJob().

bool FFTJetPileupAnalyzer::collectGrids
private

Definition at line 84 of file FFTJetPileupAnalyzer.cc.

Referenced by analyze().

bool FFTJetPileupAnalyzer::collectHistos
private

Definition at line 79 of file FFTJetPileupAnalyzer.cc.

Referenced by analyze().

bool FFTJetPileupAnalyzer::collectOOTPileup
private

Definition at line 83 of file FFTJetPileupAnalyzer.cc.

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

bool FFTJetPileupAnalyzer::collectPileup
private

Definition at line 82 of file FFTJetPileupAnalyzer.cc.

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

bool FFTJetPileupAnalyzer::collectSummaries
private

Definition at line 80 of file FFTJetPileupAnalyzer.cc.

Referenced by analyze(), and beginJob().

bool FFTJetPileupAnalyzer::collectVertexInfo
private

Definition at line 86 of file FFTJetPileupAnalyzer.cc.

Referenced by analyze(), and beginJob().

unsigned long FFTJetPileupAnalyzer::counter
private

Definition at line 96 of file FFTJetPileupAnalyzer.cc.

Referenced by analyze().

double FFTJetPileupAnalyzer::crazyEnergyCut
private

Definition at line 90 of file FFTJetPileupAnalyzer.cc.

Referenced by analyzePileup().

edm::InputTag FFTJetPileupAnalyzer::fastJetRhoLabel
private

Definition at line 72 of file FFTJetPileupAnalyzer.cc.

Referenced by analyze().

edm::InputTag FFTJetPileupAnalyzer::fastJetSigmaLabel
private

Definition at line 73 of file FFTJetPileupAnalyzer.cc.

Referenced by analyze().

edm::InputTag FFTJetPileupAnalyzer::gridLabel
private

Definition at line 74 of file FFTJetPileupAnalyzer.cc.

Referenced by analyze().

edm::InputTag FFTJetPileupAnalyzer::histoLabel
private

Definition at line 70 of file FFTJetPileupAnalyzer.cc.

Referenced by analyze().

TNtuple* FFTJetPileupAnalyzer::nt
private

Definition at line 93 of file FFTJetPileupAnalyzer.cc.

Referenced by analyze(), and beginJob().

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

Definition at line 92 of file FFTJetPileupAnalyzer.cc.

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

std::string FFTJetPileupAnalyzer::ntupleName
private

Definition at line 77 of file FFTJetPileupAnalyzer.cc.

Referenced by beginJob().

std::string FFTJetPileupAnalyzer::ntupleTitle
private

Definition at line 78 of file FFTJetPileupAnalyzer.cc.

Referenced by beginJob().

std::string FFTJetPileupAnalyzer::pileupLabel
private

Definition at line 76 of file FFTJetPileupAnalyzer.cc.

Referenced by analyze().

edm::InputTag FFTJetPileupAnalyzer::srcPVs
private

Definition at line 75 of file FFTJetPileupAnalyzer.cc.

Referenced by analyze().

edm::InputTag FFTJetPileupAnalyzer::summaryLabel
private

Definition at line 71 of file FFTJetPileupAnalyzer.cc.

Referenced by analyze().

int FFTJetPileupAnalyzer::totalNpu
private

Definition at line 94 of file FFTJetPileupAnalyzer.cc.

Referenced by analyze(), and analyzePileup().

int FFTJetPileupAnalyzer::totalNPV
private

Definition at line 95 of file FFTJetPileupAnalyzer.cc.

Referenced by analyze().

bool FFTJetPileupAnalyzer::verbosePileupInfo
private

Definition at line 87 of file FFTJetPileupAnalyzer.cc.

Referenced by analyzePileup().

double FFTJetPileupAnalyzer::vertexNdofCut
private

Definition at line 89 of file FFTJetPileupAnalyzer.cc.

Referenced by analyze().