CMS 3D CMS Logo

PileupVertexAccumulator.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: PileupVertexAccumulator
4 // Class: PileupVertexAccumulator
5 //
13 //
14 // Original Author: Mike Hildreth - Notre Dame
15 // Created: Wed Jan 21 05:14:48 CET 2015
16 //
17 //
18 
19 // system include files
20 #include <memory>
21 #include <set>
22 
23 // user include files
25 
32 
37 
38 // user include files
41 
44 
47 
50 
51 //
52 // constants, enums and typedefs
53 //
54 
55 //
56 // static data member definitions
57 //
58 
59 //
60 // constructors and destructor
61 //
62 //using namespace std;
63 
64 namespace cms {
66  edm::ProducesCollector producesCollector,
68  : Mtag_(iConfig.getParameter<edm::InputTag>("vtxTag")),
69  fallbackMtag_(iConfig.getParameter<edm::InputTag>("vtxFallbackTag")),
70  saveVtxTimes_(iConfig.getParameter<bool>("saveVtxTimes")) {
71  edm::LogInfo("PixelDigitizer ") << "Enter the Pixel Digitizer";
72 
73  const std::string alias("PileupVertexAccum");
74 
75  producesCollector.produces<PileupVertexContent>().setBranchAlias(alias);
76 
79  }
80 
82 
83  //
84  // member functions
85  //
86 
88  // Make sure that the first crossing processed starts indexing the minbias events from zero.
89 
90  pT_Hats_.clear();
91  z_posns_.clear();
92  t_posns_.clear();
93  }
94 
96  // don't do anything for hard-scatter signal events
97  }
98 
100  edm::EventSetup const& iSetup,
101  edm::StreamID const& streamID) {
103  iEvent.getByLabel(Mtag_, MCevt);
104  if (MCevt.whyFailed()) {
105  iEvent.getByLabel(fallbackMtag_, MCevt);
106  }
107 
108  const HepMC::GenEvent* myGenEvent = MCevt->GetEvent();
109 
110  double pthat = myGenEvent->event_scale();
111  float pt_hat = float(pthat);
112 
113  pT_Hats_.push_back(pt_hat);
114 
115  HepMC::GenEvent::vertex_const_iterator viter;
116  HepMC::GenEvent::vertex_const_iterator vbegin = myGenEvent->vertices_begin();
117  HepMC::GenEvent::vertex_const_iterator vend = myGenEvent->vertices_end();
118 
119  // for production point, pick first vertex
120  viter = vbegin;
121 
122  if (viter != vend) {
123  // The origin vertex (turn it to cm's from GenEvent mm's)
124  HepMC::GenVertex* v = *viter;
125  float zpos = v->position().z() * 0.1;
126 
127  z_posns_.push_back(zpos);
128 
129  if (saveVtxTimes_) {
130  float tpos = v->position().t() / 299792458e-6; // turn from mm to ns
131  t_posns_.push_back(tpos);
132  }
133  }
134 
135  // delete myGenEvent;
136  }
137 
138  // ------------ method called to produce write the data ------------
140  std::unique_ptr<PileupVertexContent> PUVtxC(new PileupVertexContent(pT_Hats_, z_posns_, t_posns_));
141 
142  // write output to event
143  iEvent.put(std::move(PUVtxC));
144  }
145 
146 } // namespace cms
PileupVertexContent
Definition: PileupVertexContent.h:24
vend
#define vend()
Definition: vmac.h:43
edm::StreamID
Definition: StreamID.h:30
Handle.h
electrons_cff.bool
bool
Definition: electrons_cff.py:372
MessageLogger.h
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
ESHandle.h
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::LogInfo
Definition: MessageLogger.h:254
PileUpEventPrincipal
Definition: PileUpEventPrincipal.h:19
EDAnalyzer.h
vbegin
#define vbegin()
Definition: vmac.h:36
findQualityFiles.v
v
Definition: findQualityFiles.py:179
edm::Handle< edm::HepMCProduct >
GenRunInfoProduct.h
HepMC::GenEvent
Definition: hepmc_rootio.cc:9
cms::PileupVertexAccumulator::fallbackMtag_
edm::InputTag fallbackMtag_
Definition: PileupVertexAccumulator.h:59
cms::PileupVertexAccumulator::pT_Hats_
std::vector< float > pT_Hats_
Definition: PileupVertexAccumulator.h:55
MakerMacros.h
TrackerTopology.h
cms::PileupVertexAccumulator::t_posns_
std::vector< float > t_posns_
Definition: PileupVertexAccumulator.h:57
PileUpEventPrincipal.h
edm::ConsumesCollector::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: ConsumesCollector.h:49
edm::HandleBase::whyFailed
std::shared_ptr< cms::Exception > whyFailed() const
Definition: HandleBase.h:91
cms::PileupVertexAccumulator::saveVtxTimes_
bool saveVtxTimes_
Definition: PileupVertexAccumulator.h:60
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cms::PileupVertexAccumulator::Mtag_
edm::InputTag Mtag_
Definition: PileupVertexAccumulator.h:58
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
edm::ParameterSet
Definition: ParameterSet.h:36
GenEventInfoProduct.h
Event.h
edm::ConsumesCollector::mayConsume
EDGetTokenT< ProductType > mayConsume(edm::InputTag const &tag)
Definition: ConsumesCollector.h:61
cms::PileupVertexAccumulator::finalizeEvent
void finalizeEvent(edm::Event &e, edm::EventSetup const &c) override
Definition: PileupVertexAccumulator.cc:139
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::ProducesCollector::produces
ProductRegistryHelper::BranchAliasSetterT< ProductType > produces()
Definition: ProducesCollector.h:52
edm::EventSetup
Definition: EventSetup.h:57
edm::HepMCProduct::GetEvent
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:34
cms::PileupVertexAccumulator::initializeEvent
void initializeEvent(edm::Event const &e, edm::EventSetup const &c) override
Definition: PileupVertexAccumulator.cc:87
PileupVertexContent.h
cms::PileupVertexAccumulator::PileupVertexAccumulator
PileupVertexAccumulator(const edm::ParameterSet &conf, edm::ProducesCollector, edm::ConsumesCollector &iC)
Definition: PileupVertexAccumulator.cc:65
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::ProducesCollector
Definition: ProducesCollector.h:43
cms::PileupVertexAccumulator::~PileupVertexAccumulator
~PileupVertexAccumulator() override
Definition: PileupVertexAccumulator.cc:81
Frameworkfwd.h
SiStripOfflineCRack_cfg.alias
alias
Definition: SiStripOfflineCRack_cfg.py:129
EventSetup.h
Exception.h
ConsumesCollector.h
edm::HepMCProduct
Definition: HepMCProduct.h:18
ParameterSet.h
cms::PileupVertexAccumulator::accumulate
void accumulate(edm::Event const &e, edm::EventSetup const &c) override
Definition: PileupVertexAccumulator.cc:95
HepMCProduct.h
edm::Event
Definition: Event.h:73
PileupVertexAccumulator.h
StreamID.h
edm::ConsumesCollector
Definition: ConsumesCollector.h:39
cms::PileupVertexAccumulator::z_posns_
std::vector< float > z_posns_
Definition: PileupVertexAccumulator.h:56
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37