CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
MCvsRecoVerticesAnalyzer Class Reference

#include <TrackingPFG/PileUp/src/MCvsRecoVerticesAnalyzer.cc>

Inheritance diagram for MCvsRecoVerticesAnalyzer:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 MCvsRecoVerticesAnalyzer (const edm::ParameterSet &)
 
 ~MCvsRecoVerticesAnalyzer ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
 
virtual void beginJob ()
 
virtual void beginRun (const edm::Run &, const edm::EventSetup &)
 
virtual void endJob ()
 
virtual void endRun (const edm::Run &, const edm::EventSetup &)
 

Private Attributes

edm::EDGetTokenT< double > m_doubleToken
 
TH1F * m_hclosestvtx
 
TH2F * m_hclosestvtxvsnpu
 
TH1F * m_hdeltazclose
 
TH2F * m_hdeltazclosevsnpu
 
TH1F * m_hdeltazfirst
 
TH2F * m_hdeltazfirstvsnpu
 
edm::EDGetTokenT
< edm::HepMCProduct
m_hepMCProductToken
 
const edm::ParameterSet m_histoParameters
 
TH2F * m_hrecovsmclumi2d
 
TProfile * m_hrecovsmclumiprof
 
TProfile * m_hrecovsmclumiweightedprof
 
TH2F * m_hrecovsmcnvtx2d
 
TProfile * m_hrecovsmcnvtxprof
 
TProfile * m_hrecovsmcnvtxweightedprof
 
edm::EDGetTokenT
< reco::VertexCollection
m_recoVertexCollectionToken
 
const bool m_useVisibleVertices
 
const bool m_useweight
 
edm::EDGetTokenT< std::vector
< PileupSummaryInfo > > 
m_vecPileupSummaryInfoToken
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Description: <one line="" class="" summary>="">

Implementation: <Notes on="" implementation>="">

Definition at line 59 of file MCvsRecoVerticesAnalyzer.cc.

Constructor & Destructor Documentation

MCvsRecoVerticesAnalyzer::MCvsRecoVerticesAnalyzer ( const edm::ParameterSet iConfig)
explicit

Definition at line 111 of file MCvsRecoVerticesAnalyzer.cc.

References edm::ParameterSet::getUntrackedParameter(), m_hclosestvtx, m_hclosestvtxvsnpu, m_hdeltazclose, m_hdeltazclosevsnpu, m_hdeltazfirst, m_hdeltazfirstvsnpu, m_histoParameters, m_hrecovsmclumi2d, m_hrecovsmclumiprof, m_hrecovsmclumiweightedprof, m_hrecovsmcnvtx2d, m_hrecovsmcnvtxprof, m_hrecovsmcnvtxweightedprof, m_useVisibleVertices, m_useweight, and TFileService::make().

112  : m_useweight( iConfig.getParameter< bool >( "useWeight" ) )
113  , m_useVisibleVertices( iConfig.getParameter< bool >( "useVisibleVertices" ) )
114  , m_histoParameters( iConfig.getUntrackedParameter< edm::ParameterSet >( "histoParameters", edm::ParameterSet() ) )
115  , m_doubleToken( consumes< double >( iConfig.getParameter< edm::InputTag >( "weightProduct" ) ) )
116  , m_vecPileupSummaryInfoToken( consumes< std::vector<PileupSummaryInfo> >( iConfig.getParameter< edm::InputTag >( "pileupSummaryCollection" ) ) )
117  , m_recoVertexCollectionToken( consumes< reco::VertexCollection >( iConfig.getParameter< edm::InputTag >( "pvCollection" ) ) )
118  , m_hepMCProductToken( consumes< edm::HepMCProduct >( iConfig.getParameter< edm::InputTag >( "mcTruthCollection" ) ) )
119 {
120  //now do what ever initialization is needed
121 
122  if(m_useVisibleVertices) edm::LogInfo("UseVisibleVertices") << "Only visible vertices will be used to compute Npileup";
123 
125 
126  m_hrecovsmcnvtx2d = tfserv->make<TH2F>("recovsmcnvtx2d","Number of reco vertices vs pileup interactions",60,-0.5,59.5,60,-0.5,59.5);
127  m_hrecovsmcnvtx2d->GetXaxis()->SetTitle("Pileup Interactions"); m_hrecovsmcnvtx2d->GetYaxis()->SetTitle("Reco Vertices");
128  m_hrecovsmcnvtxprof = tfserv->make<TProfile>("recovsmcnvtxprof","Mean number of reco vs pileup vertices",60,-0.5,59.5);
129  m_hrecovsmcnvtxprof->GetXaxis()->SetTitle("Pileup Interactions"); m_hrecovsmcnvtxprof->GetYaxis()->SetTitle("Reco Vertices");
130 
131  m_hrecovsmclumi2d = tfserv->make<TH2F>("recovsmclumi2d","Number of reco vertices vs ave pileup interactions",200,0.,50.,60,-0.5,59.5);
132  m_hrecovsmclumi2d->GetXaxis()->SetTitle("Average Pileup Interactions"); m_hrecovsmclumi2d->GetYaxis()->SetTitle("Reco Vertices");
133  m_hrecovsmclumiprof = tfserv->make<TProfile>("recovsmclumiprof","Mean number of reco vs ave pileup vertices",200,0.,50.);
134  m_hrecovsmclumiprof->GetXaxis()->SetTitle("Average Pileup Interactions"); m_hrecovsmclumiprof->GetYaxis()->SetTitle("Reco Vertices");
135 
136  if(m_useweight) {
137  m_hrecovsmcnvtxweightedprof = tfserv->make<TProfile>("recovsmcnvtxweightedprof","Mean number of reco vs pileup vertices (1-w) weight",60,-0.5,59.5);
138  m_hrecovsmcnvtxweightedprof->GetXaxis()->SetTitle("Pileup Interactions"); m_hrecovsmcnvtxweightedprof->GetYaxis()->SetTitle("Reco Vertices (1-w)");
139 
140  m_hrecovsmclumiweightedprof = tfserv->make<TProfile>("recovsmclumiweightedprof","Mean number of reco vs ave pileup vertices (1-w) weight",
141  200,0.,50.);
142  m_hrecovsmclumiweightedprof->GetXaxis()->SetTitle("Average Pileup Interactions");
143  m_hrecovsmclumiweightedprof->GetYaxis()->SetTitle("Reco Vertices (1-w)");
144  }
145 
146  m_hdeltazfirst = tfserv->make<TH1F>("deltazfirst","Reco-MC vertex z position (first vertex)",
147  m_histoParameters.getUntrackedParameter<unsigned int>("zBins",1000),
148  m_histoParameters.getUntrackedParameter<double>("zMin",-1.),
149  m_histoParameters.getUntrackedParameter<double>("zMax",1.));
150  m_hdeltazfirst->GetXaxis()->SetTitle("#Delta z (cm)"); m_hdeltazfirst->GetYaxis()->SetTitle("Events");
151 
152  m_hdeltazclose = tfserv->make<TH1F>("deltazclose","Reco-MC vertex z position (closest vertex)",
153  m_histoParameters.getUntrackedParameter<unsigned int>("zBins",1000),
154  m_histoParameters.getUntrackedParameter<double>("zMin",-1.),
155  m_histoParameters.getUntrackedParameter<double>("zMax",1.));
156  m_hdeltazclose->GetXaxis()->SetTitle("#Delta z (cm)"); m_hdeltazclose->GetYaxis()->SetTitle("Events");
157 
158  m_hclosestvtx = tfserv->make<TH1F>("closestvtx","Closest reco vtx ID",30,-0.5,29.5);
159  m_hclosestvtx->GetXaxis()->SetTitle("Vtx ID"); m_hclosestvtx->GetYaxis()->SetTitle("Events");
160 
161  m_hdeltazfirstvsnpu = tfserv->make<TH2F>("deltazfirstvsnpu","Reco-MC vertex z position (first vertex) vs Npileup",30,-0.5,29.5,
162  m_histoParameters.getUntrackedParameter<unsigned int>("zBins",1000),
163  m_histoParameters.getUntrackedParameter<double>("zMin",-1.),
164  m_histoParameters.getUntrackedParameter<double>("zMax",1.));
165  m_hdeltazfirstvsnpu->GetXaxis()->SetTitle("pileup Interactions"); m_hdeltazfirstvsnpu->GetYaxis()->SetTitle("#Delta z (cm)");
166 
167  m_hdeltazclosevsnpu = tfserv->make<TH2F>("deltazclosevsnpu","Reco-MC vertex z position (closest vertex) v Npileup",30,-0.5,29.5,
168  m_histoParameters.getUntrackedParameter<unsigned int>("zBins",1000),
169  m_histoParameters.getUntrackedParameter<double>("zMin",-1.),
170  m_histoParameters.getUntrackedParameter<double>("zMax",1.));
171  m_hdeltazclosevsnpu->GetXaxis()->SetTitle("Pileup Interactions"); m_hdeltazclosevsnpu->GetYaxis()->SetTitle("#Delta z (cm)");
172 
173  m_hclosestvtxvsnpu = tfserv->make<TH2F>("closestvtxvsnpu","Closest reco vtx ID vs Npileup",30,-0.5,29.5,30,-0.5,29.5);
174  m_hclosestvtxvsnpu->GetXaxis()->SetTitle("Pileup Interactions"); m_hclosestvtxvsnpu->GetYaxis()->SetTitle("Vtx ID");
175 
176 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< reco::VertexCollection > m_recoVertexCollectionToken
edm::EDGetTokenT< edm::HepMCProduct > m_hepMCProductToken
edm::EDGetTokenT< std::vector< PileupSummaryInfo > > m_vecPileupSummaryInfoToken
edm::EDGetTokenT< double > m_doubleToken
const edm::ParameterSet m_histoParameters
MCvsRecoVerticesAnalyzer::~MCvsRecoVerticesAnalyzer ( )

Definition at line 179 of file MCvsRecoVerticesAnalyzer.cc.

180 {
181 
182  // do anything here that needs to be done at desctruction time
183  // (e.g. close files, deallocate resources etc.)
184 
185 }

Member Function Documentation

void MCvsRecoVerticesAnalyzer::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Implements edm::EDAnalyzer.

Definition at line 194 of file MCvsRecoVerticesAnalyzer.cc.

References funct::abs(), edm::Event::getByToken(), m_doubleToken, m_hclosestvtx, m_hclosestvtxvsnpu, m_hdeltazclose, m_hdeltazclosevsnpu, m_hdeltazfirst, m_hdeltazfirstvsnpu, m_hepMCProductToken, m_hrecovsmclumi2d, m_hrecovsmclumiprof, m_hrecovsmclumiweightedprof, m_hrecovsmcnvtx2d, m_hrecovsmcnvtxprof, m_hrecovsmcnvtxweightedprof, m_recoVertexCollectionToken, m_useVisibleVertices, m_useweight, m_vecPileupSummaryInfoToken, histoStyle::weight, and detailsBasic3DVector::z.

195 {
196 
197  double weight = 1.;
198 
199  if(m_useweight) {
200  edm::Handle< double > weightprod;
201  iEvent.getByToken( m_doubleToken, weightprod );
202 
203  weight = *weightprod;
204 
205  }
206 
208  iEvent.getByToken( m_vecPileupSummaryInfoToken, pileupinfos );
209 
210  // look for the intime PileupSummaryInfo
211 
212  std::vector<PileupSummaryInfo>::const_iterator pileupinfo;
213 
214  for(pileupinfo = pileupinfos->begin(); pileupinfo != pileupinfos->end() ; ++pileupinfo) {
215 
216  if(pileupinfo->getBunchCrossing()==0) break;
217 
218  }
219 
220  //
221 
223  iEvent.getByToken( m_recoVertexCollectionToken, pvcoll );
224 
225 
226  //
227 
228  if(pileupinfo->getBunchCrossing()!=0) {
229 
230  edm::LogError("NoInTimePileUpInfo") << "Cannot find the in-time pileup info " << pileupinfo->getBunchCrossing();
231 
232  }
233  else {
234 
235  int npileup = pileupinfo->getPU_NumInteractions();
236 
237  if(m_useVisibleVertices) npileup = pileupinfo->getPU_zpositions().size();
238 
239  m_hrecovsmcnvtx2d->Fill(npileup,pvcoll->size(),weight);
240  m_hrecovsmcnvtxprof->Fill(npileup,pvcoll->size(),weight);
241 
242  m_hrecovsmclumi2d->Fill(pileupinfo->getTrueNumInteractions(),pvcoll->size(),weight);
243  m_hrecovsmclumiprof->Fill(pileupinfo->getTrueNumInteractions(),pvcoll->size(),weight);
244 
245  if(m_useweight) {
246  m_hrecovsmcnvtxweightedprof->Fill(npileup,pvcoll->size(),1.-weight);
247  m_hrecovsmclumiweightedprof->Fill(pileupinfo->getTrueNumInteractions(),pvcoll->size(),1.-weight);
248  }
249  //
250 
252  iEvent.getByToken( m_hepMCProductToken, EvtHandle );
253 
254  const HepMC::GenEvent* Evt = EvtHandle->GetEvent();
255 
256  // compute the difference between the main interaction vertex z position and the first vertex of the collection
257 
258  if(pvcoll->size() !=0) {
259  if(!(*pvcoll)[0].isFake()) {
260  // get the first vertex
261  if(Evt->vertices_begin() != Evt->vertices_end()) {
262  m_hdeltazfirst->Fill((*pvcoll)[0].z()-(*Evt->vertices_begin())->point3d().z()/10.,weight);
263  m_hdeltazfirstvsnpu->Fill(npileup,(*pvcoll)[0].z()-(*Evt->vertices_begin())->point3d().z()/10.,weight);
264  }
265  }
266  }
267 
268  // compute the difference between the main interaction vertex z position and the closest reco vertex
269 
270  double minabsdist = -1.;
271  double mindist = -999.;
272  int closestvtx = -1;
273 
274  for(unsigned int ivtx = 0 ; ivtx < pvcoll->size() ; ++ivtx) {
275 
276  if(closestvtx < 0 || minabsdist > std::abs((*pvcoll)[ivtx].z()-(*Evt->vertices_begin())->point3d().z()/10.)) {
277  mindist = (*pvcoll)[ivtx].z()-(*Evt->vertices_begin())->point3d().z()/10.;
278  closestvtx = ivtx;
279  minabsdist = std::abs(mindist);
280  }
281 
282  }
283  if(closestvtx >= 0) {
284  m_hdeltazclose->Fill(mindist,weight);
285  m_hdeltazclosevsnpu->Fill(npileup,mindist,weight);
286  m_hclosestvtx->Fill(closestvtx,weight);
287  m_hclosestvtxvsnpu->Fill(npileup,closestvtx,weight);
288  }
289 
290  }
291 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:446
float float float z
edm::EDGetTokenT< reco::VertexCollection > m_recoVertexCollectionToken
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
edm::EDGetTokenT< edm::HepMCProduct > m_hepMCProductToken
edm::EDGetTokenT< std::vector< PileupSummaryInfo > > m_vecPileupSummaryInfoToken
edm::EDGetTokenT< double > m_doubleToken
int weight
Definition: histoStyle.py:50
void MCvsRecoVerticesAnalyzer::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 307 of file MCvsRecoVerticesAnalyzer.cc.

308 {
309 }
void MCvsRecoVerticesAnalyzer::beginRun ( const edm::Run iRun,
const edm::EventSetup  
)
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 294 of file MCvsRecoVerticesAnalyzer.cc.

295 {
296 }
void MCvsRecoVerticesAnalyzer::endJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 313 of file MCvsRecoVerticesAnalyzer.cc.

314 {
315 }
void MCvsRecoVerticesAnalyzer::endRun ( const edm::Run iRun,
const edm::EventSetup  
)
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 299 of file MCvsRecoVerticesAnalyzer.cc.

300 {
301 }

Member Data Documentation

edm::EDGetTokenT< double > MCvsRecoVerticesAnalyzer::m_doubleToken
private

Definition at line 78 of file MCvsRecoVerticesAnalyzer.cc.

Referenced by analyze().

TH1F* MCvsRecoVerticesAnalyzer::m_hclosestvtx
private

Definition at line 91 of file MCvsRecoVerticesAnalyzer.cc.

Referenced by analyze(), and MCvsRecoVerticesAnalyzer().

TH2F* MCvsRecoVerticesAnalyzer::m_hclosestvtxvsnpu
private

Definition at line 95 of file MCvsRecoVerticesAnalyzer.cc.

Referenced by analyze(), and MCvsRecoVerticesAnalyzer().

TH1F* MCvsRecoVerticesAnalyzer::m_hdeltazclose
private

Definition at line 90 of file MCvsRecoVerticesAnalyzer.cc.

Referenced by analyze(), and MCvsRecoVerticesAnalyzer().

TH2F* MCvsRecoVerticesAnalyzer::m_hdeltazclosevsnpu
private

Definition at line 94 of file MCvsRecoVerticesAnalyzer.cc.

Referenced by analyze(), and MCvsRecoVerticesAnalyzer().

TH1F* MCvsRecoVerticesAnalyzer::m_hdeltazfirst
private

Definition at line 89 of file MCvsRecoVerticesAnalyzer.cc.

Referenced by analyze(), and MCvsRecoVerticesAnalyzer().

TH2F* MCvsRecoVerticesAnalyzer::m_hdeltazfirstvsnpu
private

Definition at line 93 of file MCvsRecoVerticesAnalyzer.cc.

Referenced by analyze(), and MCvsRecoVerticesAnalyzer().

edm::EDGetTokenT< edm::HepMCProduct > MCvsRecoVerticesAnalyzer::m_hepMCProductToken
private

Definition at line 81 of file MCvsRecoVerticesAnalyzer.cc.

Referenced by analyze().

const edm::ParameterSet MCvsRecoVerticesAnalyzer::m_histoParameters
private

Definition at line 77 of file MCvsRecoVerticesAnalyzer.cc.

Referenced by MCvsRecoVerticesAnalyzer().

TH2F* MCvsRecoVerticesAnalyzer::m_hrecovsmclumi2d
private

Definition at line 86 of file MCvsRecoVerticesAnalyzer.cc.

Referenced by analyze(), and MCvsRecoVerticesAnalyzer().

TProfile* MCvsRecoVerticesAnalyzer::m_hrecovsmclumiprof
private

Definition at line 87 of file MCvsRecoVerticesAnalyzer.cc.

Referenced by analyze(), and MCvsRecoVerticesAnalyzer().

TProfile* MCvsRecoVerticesAnalyzer::m_hrecovsmclumiweightedprof
private

Definition at line 88 of file MCvsRecoVerticesAnalyzer.cc.

Referenced by analyze(), and MCvsRecoVerticesAnalyzer().

TH2F* MCvsRecoVerticesAnalyzer::m_hrecovsmcnvtx2d
private

Definition at line 83 of file MCvsRecoVerticesAnalyzer.cc.

Referenced by analyze(), and MCvsRecoVerticesAnalyzer().

TProfile* MCvsRecoVerticesAnalyzer::m_hrecovsmcnvtxprof
private

Definition at line 84 of file MCvsRecoVerticesAnalyzer.cc.

Referenced by analyze(), and MCvsRecoVerticesAnalyzer().

TProfile* MCvsRecoVerticesAnalyzer::m_hrecovsmcnvtxweightedprof
private

Definition at line 85 of file MCvsRecoVerticesAnalyzer.cc.

Referenced by analyze(), and MCvsRecoVerticesAnalyzer().

edm::EDGetTokenT< reco::VertexCollection > MCvsRecoVerticesAnalyzer::m_recoVertexCollectionToken
private

Definition at line 80 of file MCvsRecoVerticesAnalyzer.cc.

Referenced by analyze().

const bool MCvsRecoVerticesAnalyzer::m_useVisibleVertices
private

Definition at line 76 of file MCvsRecoVerticesAnalyzer.cc.

Referenced by analyze(), and MCvsRecoVerticesAnalyzer().

const bool MCvsRecoVerticesAnalyzer::m_useweight
private

Definition at line 75 of file MCvsRecoVerticesAnalyzer.cc.

Referenced by analyze(), and MCvsRecoVerticesAnalyzer().

edm::EDGetTokenT< std::vector<PileupSummaryInfo> > MCvsRecoVerticesAnalyzer::m_vecPileupSummaryInfoToken
private

Definition at line 79 of file MCvsRecoVerticesAnalyzer.cc.

Referenced by analyze().