CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  {
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  }
99 
100  void
102  // don't do anything for hard-scatter signal events
103  }
104 
105  void
107 
109  iEvent.getByLabel(Mtag_, MCevt);
110  if(MCevt.whyFailed()) {
111  iEvent.getByLabel(fallbackMtag_, MCevt);
112  }
113 
114  const HepMC::GenEvent *myGenEvent = MCevt->GetEvent();
115 
116  double pthat = myGenEvent->event_scale();
117  float pt_hat = float(pthat);
118 
119  pT_Hats_.push_back(pt_hat);
120 
121  HepMC::GenEvent::vertex_const_iterator viter;
122  HepMC::GenEvent::vertex_const_iterator vbegin = myGenEvent->vertices_begin();
123  HepMC::GenEvent::vertex_const_iterator vend = myGenEvent->vertices_end();
124 
125  // for production point, pick first vertex
126  viter=vbegin;
127 
128  if(viter!=vend){
129  // The origin vertex (turn it to cm's from GenEvent mm's)
130  HepMC::GenVertex* v = *viter;
131  float zpos = v->position().z()*0.1;
132 
133  z_posns_.push_back(zpos);
134  }
135 
136  // delete myGenEvent;
137 
138  }
139 
140  // ------------ method called to produce write the data ------------
141  void
143 
144  std::auto_ptr<PileupVertexContent> PUVtxC(new PileupVertexContent(pT_Hats_, z_posns_));
145 
146  // write output to event
147  iEvent.put(PUVtxC);
148  }
149 
150 
151 }// end namespace cms::
152 
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
PileupVertexAccumulator(const edm::ParameterSet &conf, edm::stream::EDProducerBase &mixMod, edm::ConsumesCollector &iC)
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
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
#define vbegin()
Definition: vmac.h:34
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