CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
L1Analysis::L1AnalysisEvent Class Reference

#include <L1AnalysisEvent.h>

Public Member Functions

L1AnalysisEventDataFormatgetData ()
 
 L1AnalysisEvent (std::string puMCFile, std::string puMCHist, std::string puDataFile, std::string puDataHist, bool useAvgVtx, double maxWeight, edm::ConsumesCollector &&)
 
void Reset ()
 
void Set (const edm::Event &e, const edm::EDGetTokenT< edm::TriggerResults > &hlt_)
 
 ~L1AnalysisEvent ()
 

Private Attributes

bool doPUWeights_
 
L1Analysis::L1AnalysisEventDataFormat event_
 
bool fillHLT_
 
edm::LumiReWeighting lumiWeights_
 
double maxAllowedWeight_
 
edm::EDGetTokenT< std::vector< PileupSummaryInfo > > pileupSummaryInfoToken_
 
bool useAvgVtx_
 

Detailed Description

Definition at line 28 of file L1AnalysisEvent.h.

Constructor & Destructor Documentation

L1Analysis::L1AnalysisEvent::L1AnalysisEvent ( std::string  puMCFile,
std::string  puMCHist,
std::string  puDataFile,
std::string  puDataHist,
bool  useAvgVtx,
double  maxWeight,
edm::ConsumesCollector &&  iConsumes 
)

Definition at line 10 of file L1AnalysisEvent.cc.

References doPUWeights_, lumiWeights_, pileupSummaryInfoToken_, and trackingPlots::stat.

16  :
17  fillHLT_(true),
18  doPUWeights_(false),
19  useAvgVtx_(useAvgVtx),
20  maxAllowedWeight_(maxWeight),
21  lumiWeights_()
22 {
23 
24  pileupSummaryInfoToken_ = iConsumes.consumes<std::vector<PileupSummaryInfo>>(edm::InputTag("addPileupInfo"));
25  // check PU files exists, and reweight if they do
26  struct stat buf;
27  if ((stat(puMCFile.c_str(), &buf) != -1) && (stat(puDataFile.c_str(), &buf) != -1)) {
29  puDataFile,
30  puMCHist,
31  puDataHist);
32  doPUWeights_ = true;
33  }
34  else {
35  edm::LogWarning("L1Prompt") << "No PU reweighting inputs - not going to calculate weights"<<std::endl;
36  }
37 
38 
39 }
edm::EDGetTokenT< std::vector< PileupSummaryInfo > > pileupSummaryInfoToken_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::LumiReWeighting lumiWeights_
L1Analysis::L1AnalysisEvent::~L1AnalysisEvent ( )

Definition at line 41 of file L1AnalysisEvent.cc.

42 {
43 
44 }

Member Function Documentation

L1AnalysisEventDataFormat* L1Analysis::L1AnalysisEvent::getData ( void  )
inline

Definition at line 43 of file L1AnalysisEvent.h.

References event_.

43 {return &event_;}
L1Analysis::L1AnalysisEventDataFormat event_
void L1Analysis::L1AnalysisEvent::Reset ( void  )
inline
void L1Analysis::L1AnalysisEvent::Set ( const edm::Event e,
const edm::EDGetTokenT< edm::TriggerResults > &  hlt_ 
)

Definition at line 46 of file L1AnalysisEvent.cc.

References edm::HLTGlobalStatus::accept(), edm::EventBase::bunchCrossing(), L1Analysis::L1AnalysisEventDataFormat::bx, doPUWeights_, L1Analysis::L1AnalysisEventDataFormat::event, edm::EventID::event(), event_, edm::Event::eventAuxiliary(), edm::Event::getByLabel(), edm::Event::getByToken(), L1Analysis::L1AnalysisEventDataFormat::hlt, edm::EventBase::id(), edm::EventAuxiliary::isRealData(), edm::EDGetTokenT< T >::isUninitialized(), edm::HandleBase::isValid(), L1Analysis::L1AnalysisEventDataFormat::lumi, edm::EventBase::luminosityBlock(), lumiWeights_, maxAllowedWeight_, L1Analysis::L1AnalysisEventDataFormat::nPV, L1Analysis::L1AnalysisEventDataFormat::nPV_True, L1Analysis::L1AnalysisEventDataFormat::orbit, edm::EventBase::orbitNumber(), pileupSummaryInfoToken_, L1Analysis::L1AnalysisEventDataFormat::puWeight, L1Analysis::L1AnalysisEventDataFormat::run, edm::EventID::run(), edm::HLTGlobalStatus::size(), L1Analysis::L1AnalysisEventDataFormat::time, edm::EventBase::time(), edm::TriggerNames::triggerName(), edm::Event::triggerNames(), useAvgVtx_, edm::Timestamp::value(), mps_merge::weight, and edm::LumiReWeighting::weight().

Referenced by L1EventTreeProducer::analyze().

47 {
48 
49  event_.run = e.id().run();
50  event_.event = e.id().event();
51  event_.time = e.time().value();
52  event_.bx = e.bunchCrossing(); //overwritten by EVM info until fixed by fw
54  event_.orbit = e.orbitNumber(); //overwritten by EVM info until fixed by fw
55 
56 
57  if (!hlt_.isUninitialized()){
59  e.getByToken(hlt_,hltresults);
60  const edm::TriggerNames TrigNames_ = e.triggerNames(*hltresults);
61  const int ntrigs = hltresults->size();
62 
63  for (int itr=0; itr<ntrigs; itr++){
64  TString trigName=TrigNames_.triggerName(itr);
65  if (!hltresults->accept(itr)) continue;
66  event_.hlt.push_back(trigName);
67  }
68  }
69 
70  // do PU re-weighting for MC only
71  double weight = 1.;
72 
73  if (doPUWeights_ && (! e.eventAuxiliary().isRealData())) {
74 
76  e.getByLabel(edm::InputTag("addPileupInfo"), puInfo);
77 
78  if (puInfo.isValid()) {
79  std::vector<PileupSummaryInfo>::const_iterator pvi;
80 
81  float npv = -1;
82  for(pvi = puInfo->begin(); pvi != puInfo->end(); ++pvi) {
83 
84  int bx = pvi->getBunchCrossing();
85 
86  if(bx == 0) {
87  npv = useAvgVtx_ ? pvi->getTrueNumInteractions() :
88  pvi->getPU_NumInteractions();
89  continue;
90  }
91 
92  }
93 
94  weight = lumiWeights_.weight( npv );
95  if (maxAllowedWeight_ > 0. && weight > maxAllowedWeight_)
96  weight = maxAllowedWeight_;
97  }
98  }
99 
100  if (! e.eventAuxiliary().isRealData()){
101 
104  if (puInfo.isValid()) {
105  for(std::vector<PileupSummaryInfo>::const_iterator pvi=puInfo->begin();pvi!=puInfo->end();pvi++){
106  int bx = pvi->getBunchCrossing();
107  if (bx==0) {
108  event_.nPV = pvi->getPU_NumInteractions();
109  event_.nPV_True = pvi->getTrueNumInteractions();
110  }
111  }
112  }
113  }
114 
116 
117 }
RunNumber_t run() const
Definition: EventID.h:39
edm::EDGetTokenT< std::vector< PileupSummaryInfo > > pileupSummaryInfoToken_
EventNumber_t event() const
Definition: EventID.h:41
bool isRealData() const
virtual edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const
Definition: Event.cc:234
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
bool accept() const
Has at least one path accepted the event?
int bunchCrossing() const
Definition: EventBase.h:64
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:61
Definition: weight.py:1
unsigned int size() const
Get number of paths stored.
double weight(int npv)
int orbitNumber() const
Definition: EventBase.h:65
bool isValid() const
Definition: HandleBase.h:74
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:413
EventAuxiliary const & eventAuxiliary() const
Definition: Event.h:78
std::string const & triggerName(unsigned int index) const
Definition: TriggerNames.cc:27
edm::EventID id() const
Definition: EventBase.h:58
edm::LumiReWeighting lumiWeights_
bool isUninitialized() const
Definition: EDGetToken.h:73
L1Analysis::L1AnalysisEventDataFormat event_
TimeValue_t value() const
Definition: Timestamp.h:56
edm::Timestamp time() const
Definition: EventBase.h:59

Member Data Documentation

bool L1Analysis::L1AnalysisEvent::doPUWeights_
private

Definition at line 49 of file L1AnalysisEvent.h.

Referenced by L1AnalysisEvent(), and Set().

L1Analysis::L1AnalysisEventDataFormat L1Analysis::L1AnalysisEvent::event_
private

Definition at line 57 of file L1AnalysisEvent.h.

Referenced by getData(), Reset(), and Set().

bool L1Analysis::L1AnalysisEvent::fillHLT_
private

Definition at line 48 of file L1AnalysisEvent.h.

edm::LumiReWeighting L1Analysis::L1AnalysisEvent::lumiWeights_
private

Definition at line 54 of file L1AnalysisEvent.h.

Referenced by L1AnalysisEvent(), and Set().

double L1Analysis::L1AnalysisEvent::maxAllowedWeight_
private

Definition at line 52 of file L1AnalysisEvent.h.

Referenced by Set().

edm::EDGetTokenT<std::vector<PileupSummaryInfo> > L1Analysis::L1AnalysisEvent::pileupSummaryInfoToken_
private

Definition at line 56 of file L1AnalysisEvent.h.

Referenced by L1AnalysisEvent(), and Set().

bool L1Analysis::L1AnalysisEvent::useAvgVtx_
private

Definition at line 51 of file L1AnalysisEvent.h.

Referenced by Set().