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 27 of file L1AnalysisEvent.h.

Constructor & Destructor Documentation

◆ L1AnalysisEvent()

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.

17  : fillHLT_(true), doPUWeights_(false), useAvgVtx_(useAvgVtx), maxAllowedWeight_(maxWeight), lumiWeights_() {
18  pileupSummaryInfoToken_ = iConsumes.consumes<std::vector<PileupSummaryInfo>>(edm::InputTag("addPileupInfo"));
19  // check PU files exists, and reweight if they do
20  struct stat buf;
21  if ((stat(puMCFile.c_str(), &buf) != -1) && (stat(puDataFile.c_str(), &buf) != -1)) {
23  doPUWeights_ = true;
24  } else {
25  edm::LogWarning("L1Prompt") << "No PU reweighting inputs - not going to calculate weights" << std::endl;
26  }
27 }

References visDQMUpload::buf, doPUWeights_, HLT_FULL_cff::InputTag, lumiWeights_, pileupSummaryInfoToken_, l1EventTree_cfi::puDataFile, l1EventTree_cfi::puDataHist, l1EventTree_cfi::puMCFile, l1EventTree_cfi::puMCHist, and hgcalPlots::stat.

◆ ~L1AnalysisEvent()

L1Analysis::L1AnalysisEvent::~L1AnalysisEvent ( )

Definition at line 29 of file L1AnalysisEvent.cc.

29 {}

Member Function Documentation

◆ getData()

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

Definition at line 41 of file L1AnalysisEvent.h.

41 { return &event_; }

References event_.

Referenced by L1EventTreeProducer::L1EventTreeProducer().

◆ Reset()

void L1Analysis::L1AnalysisEvent::Reset ( )
inline

Definition at line 40 of file L1AnalysisEvent.h.

40 { event_.Reset(); }

References event_, and L1Analysis::L1AnalysisEventDataFormat::Reset().

Referenced by L1EventTreeProducer::analyze().

◆ Set()

void L1Analysis::L1AnalysisEvent::Set ( const edm::Event e,
const edm::EDGetTokenT< edm::TriggerResults > &  hlt_ 
)

Definition at line 31 of file L1AnalysisEvent.cc.

31  {
32  event_.run = e.id().run();
33  event_.event = e.id().event();
34  event_.time = e.time().value();
35  event_.bx = e.bunchCrossing(); //overwritten by EVM info until fixed by fw
36  event_.lumi = e.luminosityBlock();
37  event_.orbit = e.orbitNumber(); //overwritten by EVM info until fixed by fw
38 
39  if (!hlt_.isUninitialized()) {
41  e.getByToken(hlt_, hltresults);
42  const edm::TriggerNames& TrigNames_ = e.triggerNames(*hltresults);
43  const int ntrigs = hltresults->size();
44 
45  for (int itr = 0; itr < ntrigs; itr++) {
46  TString trigName = TrigNames_.triggerName(itr);
47  if (!hltresults->accept(itr))
48  continue;
49  event_.hlt.push_back(trigName);
50  }
51  }
52 
53  // do PU re-weighting for MC only
54  double weight = 1.;
55 
56  if (doPUWeights_ && (!e.eventAuxiliary().isRealData())) {
58  e.getByLabel(edm::InputTag("addPileupInfo"), puInfo);
59 
60  if (puInfo.isValid()) {
61  std::vector<PileupSummaryInfo>::const_iterator pvi;
62 
63  float npv = -1;
64  for (pvi = puInfo->begin(); pvi != puInfo->end(); ++pvi) {
65  int bx = pvi->getBunchCrossing();
66 
67  if (bx == 0) {
68  npv = useAvgVtx_ ? pvi->getTrueNumInteractions() : pvi->getPU_NumInteractions();
69  continue;
70  }
71  }
72 
73  weight = lumiWeights_.weight(npv);
76  }
77  }
78 
79  if (!e.eventAuxiliary().isRealData()) {
81  e.getByToken(pileupSummaryInfoToken_, puInfo);
82  if (puInfo.isValid()) {
83  for (std::vector<PileupSummaryInfo>::const_iterator pvi = puInfo->begin(); pvi != puInfo->end(); pvi++) {
84  int bx = pvi->getBunchCrossing();
85  if (bx == 0) {
86  event_.nPV = pvi->getPU_NumInteractions();
87  event_.nPV_True = pvi->getTrueNumInteractions();
88  }
89  }
90  }
91  }
92 
94 }

References l1GtPatternGenerator_cfi::bx, MillePedeFileConverter_cfg::e, event_(), HLTBitAnalyser_cfi::hltresults, edm::EDGetTokenT< T >::isUninitialized(), edm::HandleBase::isValid(), edm::TriggerNames::triggerName(), EgHLTOffTrigSelection_cfi::trigName, and mps_merge::weight.

Referenced by L1EventTreeProducer::analyze().

Member Data Documentation

◆ doPUWeights_

bool L1Analysis::L1AnalysisEvent::doPUWeights_
private

Definition at line 47 of file L1AnalysisEvent.h.

Referenced by L1AnalysisEvent().

◆ event_

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

Definition at line 55 of file L1AnalysisEvent.h.

Referenced by getData(), and Reset().

◆ fillHLT_

bool L1Analysis::L1AnalysisEvent::fillHLT_
private

Definition at line 46 of file L1AnalysisEvent.h.

◆ lumiWeights_

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

Definition at line 52 of file L1AnalysisEvent.h.

Referenced by L1AnalysisEvent().

◆ maxAllowedWeight_

double L1Analysis::L1AnalysisEvent::maxAllowedWeight_
private

Definition at line 50 of file L1AnalysisEvent.h.

◆ pileupSummaryInfoToken_

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

Definition at line 54 of file L1AnalysisEvent.h.

Referenced by L1AnalysisEvent().

◆ useAvgVtx_

bool L1Analysis::L1AnalysisEvent::useAvgVtx_
private

Definition at line 49 of file L1AnalysisEvent.h.

L1Analysis::L1AnalysisEventDataFormat::run
unsigned run
Definition: L1AnalysisEventDataFormat.h:30
L1Analysis::L1AnalysisEvent::pileupSummaryInfoToken_
edm::EDGetTokenT< std::vector< PileupSummaryInfo > > pileupSummaryInfoToken_
Definition: L1AnalysisEvent.h:54
HLTBitAnalyser_cfi.hltresults
hltresults
Definition: HLTBitAnalyser_cfi.py:13
L1Analysis::L1AnalysisEventDataFormat::Reset
void Reset()
Definition: L1AnalysisEventDataFormat.h:20
mps_merge.weight
weight
Definition: mps_merge.py:88
edm::LumiReWeighting::weight
double weight(int npv)
Definition: LumiReWeighting.cc:139
L1Analysis::L1AnalysisEventDataFormat::nPV_True
int nPV_True
Definition: L1AnalysisEventDataFormat.h:39
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89287
l1GtPatternGenerator_cfi.bx
bx
Definition: l1GtPatternGenerator_cfi.py:18
edm::EDGetTokenT::isUninitialized
constexpr bool isUninitialized() const noexcept
Definition: EDGetToken.h:99
L1Analysis::L1AnalysisEvent::useAvgVtx_
bool useAvgVtx_
Definition: L1AnalysisEvent.h:49
L1Analysis::L1AnalysisEventDataFormat::lumi
unsigned lumi
Definition: L1AnalysisEventDataFormat.h:32
l1EventTree_cfi.puDataHist
puDataHist
Definition: l1EventTree_cfi.py:8
L1Analysis::L1AnalysisEventDataFormat::nPV
int nPV
Definition: L1AnalysisEventDataFormat.h:38
edm::Handle< edm::TriggerResults >
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
L1Analysis::L1AnalysisEventDataFormat::hlt
std::vector< TString > hlt
Definition: L1AnalysisEventDataFormat.h:40
L1Analysis::L1AnalysisEventDataFormat::orbit
ULong64_t orbit
Definition: L1AnalysisEventDataFormat.h:35
hgcalPlots.stat
stat
Definition: hgcalPlots.py:1119
l1EventTree_cfi.useAvgVtx
useAvgVtx
Definition: l1EventTree_cfi.py:9
L1Analysis::L1AnalysisEventDataFormat::event
unsigned long long event
Definition: L1AnalysisEventDataFormat.h:31
edm::ConsumesCollector::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: ConsumesCollector.h:55
l1EventTree_cfi.puMCFile
puMCFile
Definition: l1EventTree_cfi.py:5
L1Analysis::L1AnalysisEvent::doPUWeights_
bool doPUWeights_
Definition: L1AnalysisEvent.h:47
EgHLTOffTrigSelection_cfi.trigName
trigName
Definition: EgHLTOffTrigSelection_cfi.py:8
L1Analysis::L1AnalysisEventDataFormat::time
ULong64_t time
Definition: L1AnalysisEventDataFormat.h:37
itr
std::vector< std::pair< float, float > >::iterator itr
Definition: HGCDigitizer.cc:29
visDQMUpload.buf
buf
Definition: visDQMUpload.py:154
edm::TriggerNames::triggerName
std::string const & triggerName(unsigned int index) const
Definition: TriggerNames.cc:22
L1Analysis::L1AnalysisEvent::fillHLT_
bool fillHLT_
Definition: L1AnalysisEvent.h:46
l1EventTree_cfi.puDataFile
puDataFile
Definition: l1EventTree_cfi.py:6
L1Analysis::L1AnalysisEventDataFormat::puWeight
double puWeight
Definition: L1AnalysisEventDataFormat.h:42
L1Analysis::L1AnalysisEvent::lumiWeights_
edm::LumiReWeighting lumiWeights_
Definition: L1AnalysisEvent.h:52
edm::TriggerNames
Definition: TriggerNames.h:55
L1Analysis::L1AnalysisEvent::maxAllowedWeight_
double maxAllowedWeight_
Definition: L1AnalysisEvent.h:50
L1Analysis::L1AnalysisEventDataFormat::bx
unsigned bx
Definition: L1AnalysisEventDataFormat.h:33
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
l1EventTree_cfi.puMCHist
puMCHist
Definition: l1EventTree_cfi.py:7
edm::LumiReWeighting
Definition: LumiReWeighting.h:105
L1Analysis::L1AnalysisEvent::event_
L1Analysis::L1AnalysisEventDataFormat event_
Definition: L1AnalysisEvent.h:55
edm::InputTag
Definition: InputTag.h:15
weight
Definition: weight.py:1
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37