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 
34 
39 
40 // user include files
43 
46 
49 
52 
53 
54 //
55 // constants, enums and typedefs
56 //
57 
58 //
59 // static data member definitions
60 //
61 
62 //
63 // constructors and destructor
64 //
65 //using namespace std;
66 
67 
68 namespace cms
69 {
71  Mtag_(iConfig.getParameter<edm::InputTag>("vtxTag")),
72  fallbackMtag_(iConfig.getParameter<edm::InputTag>("vtxFallbackTag")),
73  saveVtxTimes_(iConfig.getParameter<bool>("saveVtxTimes"))
74  {
75  edm::LogInfo ("PixelDigitizer ") <<"Enter the Pixel Digitizer";
76 
77  const std::string alias ("PileupVertexAccum");
78 
79  mixMod.produces<PileupVertexContent>().setBranchAlias(alias);
80 
83  }
84 
86  }
87 
88 
89  //
90  // member functions
91  //
92 
93  void
95  // Make sure that the first crossing processed starts indexing the minbias events from zero.
96 
97  pT_Hats_.clear();
98  z_posns_.clear();
99  t_posns_.clear();
100  }
101 
102  void
104  // don't do anything for hard-scatter signal events
105  }
106 
107  void
109 
111  iEvent.getByLabel(Mtag_, MCevt);
112  if(MCevt.whyFailed()) {
113  iEvent.getByLabel(fallbackMtag_, MCevt);
114  }
115 
116  const HepMC::GenEvent *myGenEvent = MCevt->GetEvent();
117 
118  double pthat = myGenEvent->event_scale();
119  float pt_hat = float(pthat);
120 
121  pT_Hats_.push_back(pt_hat);
122 
123  HepMC::GenEvent::vertex_const_iterator viter;
124  HepMC::GenEvent::vertex_const_iterator vbegin = myGenEvent->vertices_begin();
125  HepMC::GenEvent::vertex_const_iterator vend = myGenEvent->vertices_end();
126 
127  // for production point, pick first vertex
128  viter=vbegin;
129 
130  if(viter!=vend){
131  // The origin vertex (turn it to cm's from GenEvent mm's)
132  HepMC::GenVertex* v = *viter;
133  float zpos = v->position().z()*0.1;
134 
135  z_posns_.push_back(zpos);
136 
137  if (saveVtxTimes_) {
138  float tpos = v->position().t()/299792458e-6; // turn from mm to ns
139  t_posns_.push_back(tpos);
140  }
141  }
142 
143  // delete myGenEvent;
144 
145  }
146 
147  // ------------ method called to produce write the data ------------
148  void
150 
151  std::unique_ptr<PileupVertexContent> PUVtxC(new PileupVertexContent(pT_Hats_, z_posns_, t_posns_));
152 
153  // write output to event
154  iEvent.put(std::move(PUVtxC));
155  }
156 
157 
158 }// end namespace cms::
159 
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
PileupVertexAccumulator(const edm::ParameterSet &conf, edm::stream::EDProducerBase &mixMod, edm::ConsumesCollector &iC)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
EDGetTokenT< ProductType > mayConsume(edm::InputTag const &tag)
virtual void finalizeEvent(edm::Event &e, edm::EventSetup const &c) override
virtual void accumulate(edm::Event const &e, edm::EventSetup const &c) override
#define vend()
Definition: vmac.h:41
int iEvent
Definition: GenABIO.cc:230
#define vbegin()
Definition: vmac.h:34
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:35
HLT enums.
bool getByLabel(edm::InputTag const &tag, edm::Handle< T > &result) const
virtual void initializeEvent(edm::Event const &e, edm::EventSetup const &c) override
std::shared_ptr< cms::Exception > whyFailed() const
Definition: HandleBase.h:110
def move(src, dest)
Definition: eostools.py:510