test
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 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)
 
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_
 
bool useAvgVtx_
 

Detailed Description

Definition at line 25 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 
)

Definition at line 10 of file L1AnalysisEvent.cc.

References doPUWeights_, and lumiWeights_.

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

Definition at line 39 of file L1AnalysisEvent.cc.

40 {
41 
42 }

Member Function Documentation

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

Definition at line 39 of file L1AnalysisEvent.h.

References event_.

39 {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 44 of file L1AnalysisEvent.cc.

References edm::EventBase::bunchCrossing(), edm::EventID::event(), event_(), edm::Event::eventAuxiliary(), edm::Event::getByLabel(), edm::Event::getByToken(), edm::EventBase::id(), edm::EventAuxiliary::isRealData(), edm::EDGetTokenT< T >::isUninitialized(), edm::HandleBase::isValid(), edm::EventBase::luminosityBlock(), edm::EventBase::orbitNumber(), edm::EventID::run(), edm::EventBase::time(), edm::TriggerNames::triggerName(), edm::Event::triggerNames(), edm::Timestamp::value(), and puppiForMET_cff::weight.

Referenced by L1EventTreeProducer::analyze().

45 {
46 
47  event_.run = e.id().run();
48  event_.event = e.id().event();
49  event_.time = e.time().value();
50  event_.bx = e.bunchCrossing(); //overwritten by EVM info until fixed by fw
52  event_.orbit = e.orbitNumber(); //overwritten by EVM info until fixed by fw
53 
54 
55  if (!hlt_.isUninitialized()){
57  e.getByToken(hlt_,hltresults);
58  const edm::TriggerNames TrigNames_ = e.triggerNames(*hltresults);
59  const int ntrigs = hltresults->size();
60 
61  for (int itr=0; itr<ntrigs; itr++){
62  TString trigName=TrigNames_.triggerName(itr);
63  if (!hltresults->accept(itr)) continue;
64  event_.hlt.push_back(trigName);
65  }
66  }
67 
68  // do PU re-weighting for MC only
69  double weight = 1.;
70 
71  if (doPUWeights_ && (! e.eventAuxiliary().isRealData())) {
72 
74  e.getByLabel(edm::InputTag("addPileupInfo"), puInfo);
75 
76  if (puInfo.isValid()) {
77  std::vector<PileupSummaryInfo>::const_iterator pvi;
78 
79  float npv = -1;
80  for(pvi = puInfo->begin(); pvi != puInfo->end(); ++pvi) {
81 
82  int bx = pvi->getBunchCrossing();
83 
84  if(bx == 0) {
85  npv = useAvgVtx_ ? pvi->getTrueNumInteractions() :
86  pvi->getPU_NumInteractions();
87  continue;
88  }
89 
90  }
91 
92  weight = lumiWeights_.weight( npv );
93  if (maxAllowedWeight_ > 0. && weight > maxAllowedWeight_)
94  weight = maxAllowedWeight_;
95 
96  }
97 
98  }
99 
101 
102 
103 
104 
105 }
RunNumber_t run() const
Definition: EventID.h:39
EventNumber_t event() const
Definition: EventID.h:41
bool isRealData() const
virtual edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const
Definition: Event.cc:215
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
int bunchCrossing() const
Definition: EventBase.h:65
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:62
double weight(int npv)
int orbitNumber() const
Definition: EventBase.h:66
bool isValid() const
Definition: HandleBase.h:75
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:418
EventAuxiliary const & eventAuxiliary() const
Definition: Event.h:77
std::string const & triggerName(unsigned int index) const
Definition: TriggerNames.cc:27
edm::EventID id() const
Definition: EventBase.h:59
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:60

Member Data Documentation

bool L1Analysis::L1AnalysisEvent::doPUWeights_
private

Definition at line 45 of file L1AnalysisEvent.h.

Referenced by L1AnalysisEvent().

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

Definition at line 52 of file L1AnalysisEvent.h.

Referenced by getData(), and Reset().

bool L1Analysis::L1AnalysisEvent::fillHLT_
private

Definition at line 44 of file L1AnalysisEvent.h.

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

Definition at line 50 of file L1AnalysisEvent.h.

Referenced by L1AnalysisEvent().

double L1Analysis::L1AnalysisEvent::maxAllowedWeight_
private

Definition at line 48 of file L1AnalysisEvent.h.

bool L1Analysis::L1AnalysisEvent::useAvgVtx_
private

Definition at line 47 of file L1AnalysisEvent.h.