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 
20 // system include files
21 #include <memory>
22 #include <set>
23 
24 // user include files
26 
33 
38 
39 // user include files
42 
45 
48 
51 
52 
53 //
54 // constants, enums and typedefs
55 //
56 
57 //
58 // static data member definitions
59 //
60 
61 //
62 // constructors and destructor
63 //
64 //using namespace std;
65 
66 
67 namespace cms
68 {
70  Mtag_(iConfig.getParameter<edm::InputTag>("vtxTag")),
71  fallbackMtag_(iConfig.getParameter<edm::InputTag>("vtxFallbackTag")),
72  saveVtxTimes_(iConfig.getParameter<bool>("saveVtxTimes"))
73  {
74  edm::LogInfo ("PixelDigitizer ") <<"Enter the Pixel Digitizer";
75 
76  const std::string alias ("PileupVertexAccum");
77 
78  mixMod.produces<PileupVertexContent>().setBranchAlias(alias);
79 
82  }
83 
85  }
86 
87 
88  //
89  // member functions
90  //
91 
92  void
94  // Make sure that the first crossing processed starts indexing the minbias events from zero.
95 
96  pT_Hats_.clear();
97  z_posns_.clear();
98  t_posns_.clear();
99  }
100 
101  void
103  // don't do anything for hard-scatter signal events
104  }
105 
106  void
108 
110  iEvent.getByLabel(Mtag_, MCevt);
111  if(MCevt.whyFailed()) {
112  iEvent.getByLabel(fallbackMtag_, MCevt);
113  }
114 
115  const HepMC::GenEvent *myGenEvent = MCevt->GetEvent();
116 
117  double pthat = myGenEvent->event_scale();
118  float pt_hat = float(pthat);
119 
120  pT_Hats_.push_back(pt_hat);
121 
122  HepMC::GenEvent::vertex_const_iterator viter;
123  HepMC::GenEvent::vertex_const_iterator vbegin = myGenEvent->vertices_begin();
124  HepMC::GenEvent::vertex_const_iterator vend = myGenEvent->vertices_end();
125 
126  // for production point, pick first vertex
127  viter=vbegin;
128 
129  if(viter!=vend){
130  // The origin vertex (turn it to cm's from GenEvent mm's)
131  HepMC::GenVertex* v = *viter;
132  float zpos = v->position().z()*0.1;
133 
134  z_posns_.push_back(zpos);
135 
136  if (saveVtxTimes_) {
137  float tpos = v->position().t()/299792458e-6; // turn from mm to ns
138  t_posns_.push_back(tpos);
139  }
140  }
141 
142  // delete myGenEvent;
143 
144  }
145 
146  // ------------ method called to produce write the data ------------
147  void
149 
150  std::unique_ptr<PileupVertexContent> PUVtxC(new PileupVertexContent(pT_Hats_, z_posns_, t_posns_));
151 
152  // write output to event
153  iEvent.put(std::move(PUVtxC));
154  }
155 
156 
157 }// end namespace cms::
158 
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:137
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:230
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