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::ProducerBase& mixMod,
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  mixMod.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
BranchAliasSetterT< ProductType > produces()
declare what type of product will make and with which optional label
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
EDGetTokenT< ProductType > mayConsume(edm::InputTag const &tag)
void finalizeEvent(edm::Event &e, edm::EventSetup const &c) override
void accumulate(edm::Event const &e, edm::EventSetup const &c) override
#define vend()
Definition: vmac.h:43
int iEvent
Definition: GenABIO.cc:224
PileupVertexAccumulator(const edm::ParameterSet &conf, edm::ProducerBase &mixMod, edm::ConsumesCollector &iC)
#define vbegin()
Definition: vmac.h:36
Namespace of DDCMS conversion namespace.
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:38
HLT enums.
bool getByLabel(edm::InputTag const &tag, edm::Handle< T > &result) const
void initializeEvent(edm::Event const &e, edm::EventSetup const &c) override
std::shared_ptr< cms::Exception > whyFailed() const
Definition: HandleBase.h:106
def move(src, dest)
Definition: eostools.py:511