CMS 3D CMS Logo

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

#include <MultiTrackValidator.h>

Inheritance diagram for MultiTrackValidator:
thread_unsafe::DQMEDAnalyzer MultiTrackValidatorBase edm::EDAnalyzer edm::EDConsumerBase MultiTrackValidatorGenPs

Public Member Functions

void analyze (const edm::Event &, const edm::EventSetup &)
 Method called once per event. More...
 
void bookHistograms (DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &)
 Method called to book the DQM histograms. More...
 
void endRun (edm::Run const &, edm::EventSetup const &)
 Method called at the end of the event loop. More...
 
 MultiTrackValidator (const edm::ParameterSet &pset)
 Constructor. More...
 
virtual ~MultiTrackValidator ()
 Destructor. More...
 
- Public Member Functions inherited from thread_unsafe::DQMEDAnalyzer
virtual void beginRun (edm::Run const &, edm::EventSetup const &) final
 
virtual void dqmBeginRun (edm::Run const &, edm::EventSetup const &)
 
 DQMEDAnalyzer (void)
 
- 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 ()
 

Protected Attributes

edm::InputTag assMapInput
 
edm::EDGetTokenT
< reco::RecoToSimCollection
associatormapRtS
 
edm::EDGetTokenT
< reco::SimToRecoCollection
associatormapStR
 
MTVHistoProducerAlgohistoProducerAlgo_
 
bool UseAssociators
 
- Protected Attributes inherited from MultiTrackValidatorBase
std::vector< const
TrackAssociatorBase * > 
associator
 
std::vector< std::string > associators
 
edm::EDGetTokenT< reco::BeamSpotbsSrc
 
bool ignoremissingtkcollection_
 
std::vector< edm::InputTaglabel
 
edm::EDGetTokenT< std::vector
< PileupSummaryInfo > > 
label_pileupinfo
 
edm::EDGetTokenT
< TrackingParticleCollection
label_tp_effic
 
edm::EDGetTokenT
< TrackingParticleCollection
label_tp_fake
 
edm::EDGetTokenT
< TrackingVertexCollection
label_tv
 
std::vector< edm::EDGetTokenT
< edm::View< reco::Track > > > 
labelToken
 
std::vector< edm::EDGetTokenT
< edm::View< TrajectorySeed > > > 
labelTokenSeed
 
edm::EDGetTokenT< reco::DeDxDatam_dEdx1Tag
 
edm::EDGetTokenT< reco::DeDxDatam_dEdx2Tag
 
std::string out
 
std::string parametersDefiner
 
std::string sim
 
bool skipHistoFit
 
edm::ESHandle< MagneticFieldtheMF
 

Private Attributes

edm::EDGetTokenT
< SimHitTPAssociationProducer::SimHitTPAssociationList
_simHitTpMapTag
 
CosmicTrackingParticleSelector cosmictpSelector
 
std::string dirName_
 
bool runStandalone
 
TrackingParticleSelector tpSelector
 
bool useGsf
 

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)
 
- Protected Member Functions inherited from MultiTrackValidatorBase
 MultiTrackValidatorBase (const edm::ParameterSet &pset, edm::ConsumesCollector &&iC, bool isSeed=false)
 Constructor. More...
 
virtual ~MultiTrackValidatorBase ()
 Destructor. More...
 

Detailed Description

Class that prodecs histrograms to validate Track Reconstruction performances

Author
cerati

Definition at line 15 of file MultiTrackValidator.h.

Constructor & Destructor Documentation

MultiTrackValidator::MultiTrackValidator ( const edm::ParameterSet pset)

Constructor.

Definition at line 42 of file MultiTrackValidator.cc.

References _simHitTpMapTag, assMapInput, associatormapRtS, associatormapStR, MultiTrackValidatorBase::associators, edm::EDConsumerBase::consumesCollector(), cosmictpSelector, dirName_, reco::get(), edm::ParameterSet::getParameter(), histoProducerAlgo_, MultiTrackValidatorBase::m_dEdx1Tag, MultiTrackValidatorBase::m_dEdx2Tag, runStandalone, AlCaHLTBitMon_QueryRunRegistry::string, tpSelector, UseAssociators, and useGsf.

43  //theExtractor = IsoDepositExtractorFactory::get()->create( extractorName, extractorPSet, consumesCollector());
44 
45  ParameterSet psetForHistoProducerAlgo = pset.getParameter<ParameterSet>("histoProducerAlgoBlock");
46  string histoProducerAlgoName = psetForHistoProducerAlgo.getParameter<string>("ComponentName");
47  histoProducerAlgo_ = MTVHistoProducerAlgoFactory::get()->create(histoProducerAlgoName ,psetForHistoProducerAlgo, consumesCollector());
48 
49  dirName_ = pset.getParameter<std::string>("dirName");
50  assMapInput = pset.getParameter< edm::InputTag >("associatormap");
51  associatormapStR = mayConsume<reco::SimToRecoCollection>(assMapInput);
52  associatormapRtS = mayConsume<reco::RecoToSimCollection>(assMapInput);
53  UseAssociators = pset.getParameter< bool >("UseAssociators");
54 
55  m_dEdx1Tag = mayConsume<reco::DeDxData>(pset.getParameter< edm::InputTag >("dEdx1Tag"));
56  m_dEdx2Tag = mayConsume<reco::DeDxData>(pset.getParameter< edm::InputTag >("dEdx2Tag"));
57 
58  tpSelector = TrackingParticleSelector(pset.getParameter<double>("ptMinTP"),
59  pset.getParameter<double>("minRapidityTP"),
60  pset.getParameter<double>("maxRapidityTP"),
61  pset.getParameter<double>("tipTP"),
62  pset.getParameter<double>("lipTP"),
63  pset.getParameter<int>("minHitTP"),
64  pset.getParameter<bool>("signalOnlyTP"),
65  pset.getParameter<bool>("chargedOnlyTP"),
66  pset.getParameter<bool>("stableOnlyTP"),
67  pset.getParameter<std::vector<int> >("pdgIdTP"));
68 
70  pset.getParameter<double>("minRapidityTP"),
71  pset.getParameter<double>("maxRapidityTP"),
72  pset.getParameter<double>("tipTP"),
73  pset.getParameter<double>("lipTP"),
74  pset.getParameter<int>("minHitTP"),
75  pset.getParameter<bool>("chargedOnlyTP"),
76  pset.getParameter<std::vector<int> >("pdgIdTP"));
77 
78  useGsf = pset.getParameter<bool>("useGsf");
79  runStandalone = pset.getParameter<bool>("runStandalone");
80 
81  _simHitTpMapTag = mayConsume<SimHitTPAssociationProducer::SimHitTPAssociationList>(pset.getParameter<edm::InputTag>("simHitTpMapTag"));
82 
83  if (!UseAssociators) {
84  associators.clear();
85  associators.push_back(assMapInput.label());
86  }
87 
88 }
T getParameter(std::string const &) const
edm::EDGetTokenT< SimHitTPAssociationProducer::SimHitTPAssociationList > _simHitTpMapTag
CosmicTrackingParticleSelector cosmictpSelector
edm::EDGetTokenT< reco::RecoToSimCollection > associatormapRtS
edm::EDGetTokenT< reco::SimToRecoCollection > associatormapStR
SingleObjectSelector< TrackingParticleCollection,::TrackingParticleSelector > TrackingParticleSelector
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
TrackingParticleSelector tpSelector
MultiTrackValidatorBase(const edm::ParameterSet &pset, edm::ConsumesCollector &&iC, bool isSeed=false)
Constructor.
edm::EDGetTokenT< reco::DeDxData > m_dEdx1Tag
ObjectSelector< CosmicTrackingParticleSelector > CosmicTrackingParticleSelector
MTVHistoProducerAlgo * histoProducerAlgo_
std::string const & label() const
Definition: InputTag.h:42
edm::EDGetTokenT< reco::DeDxData > m_dEdx2Tag
std::vector< std::string > associators
T get(const Candidate &c)
Definition: component.h:55
MultiTrackValidator::~MultiTrackValidator ( )
virtual

Destructor.

Definition at line 91 of file MultiTrackValidator.cc.

References histoProducerAlgo_.

91 {delete histoProducerAlgo_;}
MTVHistoProducerAlgo * histoProducerAlgo_

Member Function Documentation

void MultiTrackValidator::analyze ( const edm::Event event,
const edm::EventSetup setup 
)
virtual

Method called once per event.

Implements edm::EDAnalyzer.

Reimplemented in MultiTrackValidatorGenPs.

Definition at line 148 of file MultiTrackValidator.cc.

References _simHitTpMapTag, assMapInput, MultiTrackValidatorBase::associator, associatormapRtS, associatormapStR, MultiTrackValidatorBase::associators, asciidump::at, MultiTrackValidatorBase::bsSrc, EncodedEventId::bunchCrossing(), reco::TrackBase::charge(), edm::HandleBase::clear(), funct::cos(), cosmictpSelector, alignCSCRings::e, edm::AssociationMap< Tag >::end(), EncodedEventId::event(), TrackingParticle::eventId(), MTVHistoProducerAlgo::fill_dedx_recoTrack_histos(), MTVHistoProducerAlgo::fill_generic_recoTrack_histos(), MTVHistoProducerAlgo::fill_generic_simTrack_histos(), MTVHistoProducerAlgo::fill_recoAssociated_simTrack_histos(), MTVHistoProducerAlgo::fill_ResoAndPull_recoTrack_histos(), MTVHistoProducerAlgo::fill_simAssociated_recoTrack_histos(), MTVHistoProducerAlgo::fill_trackBased_histos(), edm::AssociationMap< Tag >::find(), first, edm::EventSetup::get(), edm::Ref< C, T, F >::get(), edm::Event::getByToken(), histoProducerAlgo_, i, MultiTrackValidatorBase::ignoremissingtkcollection_, CosmicTrackingParticleSelector::initEvent(), edm::InputTag::instance(), j, edm::InputTag::label(), MultiTrackValidatorBase::label, MultiTrackValidatorBase::label_pileupinfo, MultiTrackValidatorBase::label_tp_effic, MultiTrackValidatorBase::label_tp_fake, MultiTrackValidatorBase::label_tv, MultiTrackValidatorBase::labelToken, LogTrace, MultiTrackValidatorBase::m_dEdx1Tag, MultiTrackValidatorBase::m_dEdx2Tag, TrackingParticle::momentum(), TrackingParticle::numberOfTrackerHits(), MultiTrackValidatorBase::parametersDefiner, edm::InputTag::process(), edm::Handle< T >::product(), reco::TrackBase::pt(), dt_dqm_sourceclient_common_cff::reco, funct::sin(), findQualityFiles::size, mathSSE::sqrt(), tpSelector, UseAssociators, TrackingParticle::vertex(), w, and cms::Exception::what().

148  {
149  using namespace reco;
150 
151  edm::LogInfo("TrackValidator") << "\n====================================================" << "\n"
152  << "Analyzing new event" << "\n"
153  << "====================================================\n" << "\n";
154  edm::ESHandle<ParametersDefinerForTP> parametersDefinerTPHandle;
155  setup.get<TrackAssociatorRecord>().get(parametersDefiner,parametersDefinerTPHandle);
156  //Since we modify the object, we must clone it
157  auto parametersDefinerTP = parametersDefinerTPHandle->clone();
158 
159  edm::Handle<TrackingParticleCollection> TPCollectionHeff ;
160  event.getByToken(label_tp_effic,TPCollectionHeff);
161  const TrackingParticleCollection tPCeff = *(TPCollectionHeff.product());
162 
163  edm::Handle<TrackingParticleCollection> TPCollectionHfake ;
164  event.getByToken(label_tp_fake,TPCollectionHfake);
165  const TrackingParticleCollection tPCfake = *(TPCollectionHfake.product());
166 
167  if(parametersDefiner=="CosmicParametersDefinerForTP") {
169  //warning: make sure the TP collection used in the map is the same used in the MTV!
170  event.getByToken(_simHitTpMapTag,simHitsTPAssoc);
171  parametersDefinerTP->initEvent(simHitsTPAssoc);
172  cosmictpSelector.initEvent(simHitsTPAssoc);
173  }
174 
175  //if (tPCeff.size()==0) {edm::LogInfo("TrackValidator")
176  //<< "TP Collection for efficiency studies has size = 0! Skipping Event." ; return;}
177  //if (tPCfake.size()==0) {edm::LogInfo("TrackValidator")
178  //<< "TP Collection for fake rate studies has size = 0! Skipping Event." ; return;}
179 
180  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
181  event.getByToken(bsSrc,recoBeamSpotHandle);
182  reco::BeamSpot bs = *recoBeamSpotHandle;
183 
185  event.getByToken(label_pileupinfo,puinfoH);
186  PileupSummaryInfo puinfo;
187 
188  for (unsigned int puinfo_ite=0;puinfo_ite<(*puinfoH).size();++puinfo_ite){
189  if ((*puinfoH)[puinfo_ite].getBunchCrossing()==0){
190  puinfo=(*puinfoH)[puinfo_ite];
191  break;
192  }
193  }
194 
196  event.getByToken(label_tv,tvH);
197  TrackingVertexCollection tv = *tvH;
198 
199  int w=0; //counter counting the number of sets of histograms
200  for (unsigned int ww=0;ww<associators.size();ww++){
201  for (unsigned int www=0;www<label.size();www++){
202  //
203  //get collections from the event
204  //
205  edm::Handle<View<Track> > trackCollection;
206  if(!event.getByToken(labelToken[www], trackCollection)&&ignoremissingtkcollection_)continue;
207  //if (trackCollection->size()==0)
208  //edm::LogInfo("TrackValidator") << "TrackCollection size = 0!" ;
209  //continue;
210  //}
211  reco::RecoToSimCollection recSimColl;
212  reco::SimToRecoCollection simRecColl;
213  //associate tracks
214  if(UseAssociators){
215  edm::LogVerbatim("TrackValidator") << "Analyzing "
216  << label[www].process()<<":"
217  << label[www].label()<<":"
218  << label[www].instance()<<" with "
219  << associators[ww].c_str() <<"\n";
220 
221  LogTrace("TrackValidator") << "Calling associateRecoToSim method" << "\n";
222  recSimColl=associator[ww]->associateRecoToSim(trackCollection,
223  TPCollectionHfake,
224  &event,&setup);
225  LogTrace("TrackValidator") << "Calling associateSimToReco method" << "\n";
226  simRecColl=associator[ww]->associateSimToReco(trackCollection,
227  TPCollectionHeff,
228  &event,&setup);
229  }
230  else{
231  edm::LogVerbatim("TrackValidator") << "Analyzing "
232  << label[www].process()<<":"
233  << label[www].label()<<":"
234  << label[www].instance()<<" with "
235  << assMapInput.process()<<":"
236  << assMapInput.label()<<":"
237  << assMapInput.instance()<<"\n";
238 
239  Handle<reco::SimToRecoCollection > simtorecoCollectionH;
240  event.getByToken(associatormapStR,simtorecoCollectionH);
241  simRecColl= *(simtorecoCollectionH.product());
242 
243  Handle<reco::RecoToSimCollection > recotosimCollectionH;
244  event.getByToken(associatormapRtS,recotosimCollectionH);
245  recSimColl= *(recotosimCollectionH.product());
246  }
247 
248 
249 
250  // ########################################################
251  // fill simulation histograms (LOOP OVER TRACKINGPARTICLES)
252  // ########################################################
253 
254  //compute number of tracks per eta interval
255  //
256  edm::LogVerbatim("TrackValidator") << "\n# of TrackingParticles: " << tPCeff.size() << "\n";
257  int ats(0); //This counter counts the number of simTracks that are "associated" to recoTracks
258  int st(0); //This counter counts the number of simulated tracks passing the MTV selection (i.e. tpSelector(tp) )
259  unsigned sts(0); //This counter counts the number of simTracks surviving the bunchcrossing cut
260  unsigned asts(0); //This counter counts the number of simTracks that are "associated" to recoTracks surviving the bunchcrossing cut
261  for (TrackingParticleCollection::size_type i=0; i<tPCeff.size(); i++){ //loop over TPs collection for tracking efficiency
262  TrackingParticleRef tpr(TPCollectionHeff, i);
263  TrackingParticle* tp=const_cast<TrackingParticle*>(tpr.get());
264  TrackingParticle::Vector momentumTP;
265  TrackingParticle::Point vertexTP;
266  double dxySim(0);
267  double dzSim(0);
268 
269  //---------- THIS PART HAS TO BE CLEANED UP. THE PARAMETER DEFINER WAS NOT MEANT TO BE USED IN THIS WAY ----------
270  //If the TrackingParticle is collison like, get the momentum and vertex at production state
271  if(parametersDefiner=="LhcParametersDefinerForTP")
272  {
273  if(! tpSelector(*tp)) continue;
274  momentumTP = tp->momentum();
275  vertexTP = tp->vertex();
276  //Calcualte the impact parameters w.r.t. PCA
277  TrackingParticle::Vector momentum = parametersDefinerTP->momentum(event,setup,tpr);
278  TrackingParticle::Point vertex = parametersDefinerTP->vertex(event,setup,tpr);
279  dxySim = (-vertex.x()*sin(momentum.phi())+vertex.y()*cos(momentum.phi()));
280  dzSim = vertex.z() - (vertex.x()*momentum.x()+vertex.y()*momentum.y())/sqrt(momentum.perp2())
281  * momentum.z()/sqrt(momentum.perp2());
282  }
283  //If the TrackingParticle is comics, get the momentum and vertex at PCA
284  if(parametersDefiner=="CosmicParametersDefinerForTP")
285  {
286  if(! cosmictpSelector(tpr,&bs,event,setup)) continue;
287  momentumTP = parametersDefinerTP->momentum(event,setup,tpr);
288  vertexTP = parametersDefinerTP->vertex(event,setup,tpr);
289  dxySim = (-vertexTP.x()*sin(momentumTP.phi())+vertexTP.y()*cos(momentumTP.phi()));
290  dzSim = vertexTP.z() - (vertexTP.x()*momentumTP.x()+vertexTP.y()*momentumTP.y())/sqrt(momentumTP.perp2())
291  * momentumTP.z()/sqrt(momentumTP.perp2());
292  }
293  //---------- THE PART ABOVE HAS TO BE CLEANED UP. THE PARAMETER DEFINER WAS NOT MEANT TO BE USED IN THIS WAY ----------
294 
295  st++; //This counter counts the number of simulated tracks passing the MTV selection (i.e. tpSelector(tp) )
296 
297  // in the coming lines, histos are filled using as input
298  // - momentumTP
299  // - vertexTP
300  // - dxySim
301  // - dzSim
302 
304 
305 
306  // ##############################################
307  // fill RecoAssociated SimTracks' histograms
308  // ##############################################
309  // bool isRecoMatched(false); // UNUSED
310  const reco::Track* matchedTrackPointer=0;
311  std::vector<std::pair<RefToBase<Track>, double> > rt;
312  if(simRecColl.find(tpr) != simRecColl.end()){
313  rt = (std::vector<std::pair<RefToBase<Track>, double> >) simRecColl[tpr];
314  if (rt.size()!=0) {
315  ats++; //This counter counts the number of simTracks that have a recoTrack associated
316  // isRecoMatched = true; // UNUSED
317  matchedTrackPointer = rt.begin()->first.get();
318  edm::LogVerbatim("TrackValidator") << "TrackingParticle #" << st
319  << " with pt=" << sqrt(momentumTP.perp2())
320  << " associated with quality:" << rt.begin()->second <<"\n";
321  }
322  }else{
323  edm::LogVerbatim("TrackValidator")
324  << "TrackingParticle #" << st
325  << " with pt,eta,phi: "
326  << sqrt(momentumTP.perp2()) << " , "
327  << momentumTP.eta() << " , "
328  << momentumTP.phi() << " , "
329  << " NOT associated to any reco::Track" << "\n";
330  }
331 
332 
333 
334 
335  int nSimHits = tp->numberOfTrackerHits();
336 
337  double vtx_z_PU = vertexTP.z();
338  for (size_t j = 0; j < tv.size(); j++) {
339  if (tp->eventId().event() == tv[j].eventId().event()) {
340  vtx_z_PU = tv[j].position().z();
341  break;
342  }
343  }
344 
345  histoProducerAlgo_->fill_recoAssociated_simTrack_histos(w,*tp,momentumTP,vertexTP,dxySim,dzSim,nSimHits,matchedTrackPointer,puinfo.getPU_NumInteractions(), vtx_z_PU);
346  sts++;
347  if (matchedTrackPointer) asts++;
348 
349 
350 
351 
352  } // End for (TrackingParticleCollection::size_type i=0; i<tPCeff.size(); i++){
353 
354  //if (st!=0) h_tracksSIM[w]->Fill(st); // TO BE FIXED
355 
356 
357  // ##############################################
358  // fill recoTracks histograms (LOOP OVER TRACKS)
359  // ##############################################
360  edm::LogVerbatim("TrackValidator") << "\n# of reco::Tracks with "
361  << label[www].process()<<":"
362  << label[www].label()<<":"
363  << label[www].instance()
364  << ": " << trackCollection->size() << "\n";
365 
366  int sat(0); //This counter counts the number of recoTracks that are associated to SimTracks from Signal only
367  int at(0); //This counter counts the number of recoTracks that are associated to SimTracks
368  int rT(0); //This counter counts the number of recoTracks in general
369 
370 
371  // dE/dx
372  // at some point this could be generalized, with a vector of tags and a corresponding vector of Handles
373  // I'm writing the interface such to take vectors of ValueMaps
376  std::vector<edm::ValueMap<reco::DeDxData> > v_dEdx;
377  v_dEdx.clear();
378  //std::cout << "PIPPO: label is " << label[www] << std::endl;
379  if (label[www].label()=="generalTracks") {
380  try {
381  event.getByToken(m_dEdx1Tag, dEdx1Handle);
382  const edm::ValueMap<reco::DeDxData> dEdx1 = *dEdx1Handle.product();
383  event.getByToken(m_dEdx2Tag, dEdx2Handle);
384  const edm::ValueMap<reco::DeDxData> dEdx2 = *dEdx2Handle.product();
385  v_dEdx.push_back(dEdx1);
386  v_dEdx.push_back(dEdx2);
387  } catch (cms::Exception e){
388  LogTrace("TrackValidator") << "exception found: " << e.what() << "\n";
389  }
390  }
391  //end dE/dx
392 
393  for(View<Track>::size_type i=0; i<trackCollection->size(); ++i){
394 
395  RefToBase<Track> track(trackCollection, i);
396  rT++;
397 
398  bool isSigSimMatched(false);
399  bool isSimMatched(false);
400  bool isChargeMatched(true);
401  int numAssocRecoTracks = 0;
402  int tpbx = 0;
403  int nSimHits = 0;
404  double sharedFraction = 0.;
405  std::vector<std::pair<TrackingParticleRef, double> > tp;
406  if(recSimColl.find(track) != recSimColl.end()){
407  tp = recSimColl[track];
408  if (tp.size()!=0) {
409  nSimHits = tp[0].first->numberOfTrackerHits();
410  sharedFraction = tp[0].second;
411  isSimMatched = true;
412  if (tp[0].first->charge() != track->charge()) isChargeMatched = false;
413  if(simRecColl.find(tp[0].first) != simRecColl.end()) numAssocRecoTracks = simRecColl[tp[0].first].size();
414  //std::cout << numAssocRecoTracks << std::endl;
415  tpbx = tp[0].first->eventId().bunchCrossing();
416  at++;
417  for (unsigned int tp_ite=0;tp_ite<tp.size();++tp_ite){
418  TrackingParticle trackpart = *(tp[tp_ite].first);
419  if ((trackpart.eventId().event() == 0) && (trackpart.eventId().bunchCrossing() == 0)){
420  isSigSimMatched = true;
421  sat++;
422  break;
423  }
424  }
425  edm::LogVerbatim("TrackValidator") << "reco::Track #" << rT << " with pt=" << track->pt()
426  << " associated with quality:" << tp.begin()->second <<"\n";
427  }
428  } else {
429  edm::LogVerbatim("TrackValidator") << "reco::Track #" << rT << " with pt=" << track->pt()
430  << " NOT associated to any TrackingParticle" << "\n";
431  }
432 
433 
434  histoProducerAlgo_->fill_generic_recoTrack_histos(w,*track,bs.position(),isSimMatched,isSigSimMatched, isChargeMatched, numAssocRecoTracks, puinfo.getPU_NumInteractions(), tpbx, nSimHits, sharedFraction);
435 
436  // dE/dx
437  // reco::TrackRef track2 = reco::TrackRef( trackCollection, i );
438  if (v_dEdx.size() > 0) histoProducerAlgo_->fill_dedx_recoTrack_histos(w,track, v_dEdx);
439  //if (v_dEdx.size() > 0) histoProducerAlgo_->fill_dedx_recoTrack_histos(track2, v_dEdx);
440 
441 
442  //Fill other histos
443  //try{ //Is this really necessary ????
444 
445  if (tp.size()==0) continue;
446 
448 
449  TrackingParticleRef tpr = tp.begin()->first;
450 
451  /* TO BE FIXED LATER
452  if (associators[ww]=="TrackAssociatorByChi2"){
453  //association chi2
454  double assocChi2 = -tp.begin()->second;//in association map is stored -chi2
455  h_assochi2[www]->Fill(assocChi2);
456  h_assochi2_prob[www]->Fill(TMath::Prob((assocChi2)*5,5));
457  }
458  else if (associators[ww]=="quickTrackAssociatorByHits"){
459  double fraction = tp.begin()->second;
460  h_assocFraction[www]->Fill(fraction);
461  h_assocSharedHit[www]->Fill(fraction*track->numberOfValidHits());
462  }
463  */
464 
465 
466  //Get tracking particle parameters at point of closest approach to the beamline
467  TrackingParticle::Vector momentumTP = parametersDefinerTP->momentum(event,setup,tpr);
468  TrackingParticle::Point vertexTP = parametersDefinerTP->vertex(event,setup,tpr);
469  int chargeTP = tpr->charge();
470 
471  histoProducerAlgo_->fill_ResoAndPull_recoTrack_histos(w,momentumTP,vertexTP,chargeTP,
472  *track,bs.position());
473 
474 
475  //TO BE FIXED
476  //std::vector<PSimHit> simhits=tpr.get()->trackPSimHit(DetId::Tracker);
477  //nrecHit_vs_nsimHit_rec2sim[w]->Fill(track->numberOfValidHits(), (int)(simhits.end()-simhits.begin() ));
478 
479  /*
480  } // End of try{
481  catch (cms::Exception e){
482  LogTrace("TrackValidator") << "exception found: " << e.what() << "\n";
483  }
484  */
485 
486  } // End of for(View<Track>::size_type i=0; i<trackCollection->size(); ++i){
487 
489 
490  edm::LogVerbatim("TrackValidator") << "Total Simulated: " << st << "\n"
491  << "Total Associated (simToReco): " << ats << "\n"
492  << "Total Reconstructed: " << rT << "\n"
493  << "Total Associated (recoToSim): " << at << "\n"
494  << "Total Fakes: " << rT-at << "\n";
495 
496  w++;
497  } // End of for (unsigned int www=0;www<label.size();www++){
498  } //END of for (unsigned int ww=0;ww<associators.size();ww++){
499 
500 }
virtual char const * what() const
Definition: Exception.cc:141
int i
Definition: DBlmapReader.cc:9
edm::EDGetTokenT< SimHitTPAssociationProducer::SimHitTPAssociationList > _simHitTpMapTag
int event() const
get the contents of the subdetector field (should be protected?)
const double w
Definition: UKUtility.cc:23
edm::EDGetTokenT< std::vector< PileupSummaryInfo > > label_pileupinfo
CosmicTrackingParticleSelector cosmictpSelector
std::vector< TrackingParticle > TrackingParticleCollection
const_iterator end() const
last iterator over the map (read only)
edm::EDGetTokenT< TrackingParticleCollection > label_tp_effic
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
virtual void fill_dedx_recoTrack_histos(int count, edm::RefToBase< reco::Track > &trackref, const std::vector< edm::ValueMap< reco::DeDxData > > &v_dEdx)=0
Point vertex() const
Parent vertex position.
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
const_iterator find(const key_type &k) const
find element with specified reference key
std::vector< const TrackAssociatorBase * > associator
edm::EDGetTokenT< reco::RecoToSimCollection > associatormapRtS
virtual void fill_ResoAndPull_recoTrack_histos(int count, const TrackingParticle::Vector &momentumTP, const TrackingParticle::Point &vertexTP, int chargeTP, const reco::Track &track, const math::XYZPoint &bsPosition)=0
edm::EDGetTokenT< TrackingVertexCollection > label_tv
uint16_t size_type
edm::EDGetTokenT< reco::SimToRecoCollection > associatormapStR
edm::EDGetTokenT< reco::BeamSpot > bsSrc
math::XYZPointD Point
point in the space
virtual void fill_recoAssociated_simTrack_histos(int count, const TrackingParticle &tp, const TrackingParticle::Vector &momentumTP, const TrackingParticle::Point &vertexTP, double dxy, double dz, int nSimHits, const reco::Track *track, int numVertices, double vertz)=0
std::vector< edm::InputTag > label
T sqrt(T t)
Definition: SSEVec.h:48
virtual void fill_generic_recoTrack_histos(int count, const reco::Track &track, const math::XYZPoint &bsPosition, bool isMatched, bool isSigMatched, bool isChargeMatched, int numAssocRecoTracks, int numVertices, int tpbunchcrossing, int nSimHits, double sharedFraction)=0
int bunchCrossing() const
get the detector field from this detid
TrackingParticleSelector tpSelector
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
unsigned int size_type
Definition: View.h:85
int j
Definition: DBlmapReader.cc:9
void initEvent(edm::Handle< SimHitTPAssociationProducer::SimHitTPAssociationList > simHitsTPAssocToSet) const
edm::EDGetTokenT< reco::DeDxData > m_dEdx1Tag
bool first
Definition: L1TdeRCT.cc:75
#define LogTrace(id)
MTVHistoProducerAlgo * histoProducerAlgo_
virtual void fill_simAssociated_recoTrack_histos(int count, const reco::Track &track)=0
std::vector< TrackingVertex > TrackingVertexCollection
const T & get() const
Definition: EventSetup.h:55
virtual void fill_trackBased_histos(int count, int assTracks, int numRecoTracks, int numSimTracks)=0
T const * product() const
Definition: Handle.h:81
std::string const & label() const
Definition: InputTag.h:42
EncodedEventId eventId() const
Signal source, crossing number.
std::string const & process() const
Definition: InputTag.h:46
edm::EDGetTokenT< reco::DeDxData > m_dEdx2Tag
Vector momentum() const
spatial momentum vector
Monte Carlo truth information used for tracking validation.
std::vector< std::string > associators
int numberOfTrackerHits() const
The number of hits in the tracker. Hits on overlaps in the same layer count separately.
std::vector< edm::EDGetTokenT< edm::View< reco::Track > > > labelToken
math::XYZVectorD Vector
point in the space
virtual void fill_generic_simTrack_histos(int counter, const TrackingParticle::Vector &, const TrackingParticle::Point &vertex, int bx)=0
edm::EDGetTokenT< TrackingParticleCollection > label_tp_fake
std::string const & instance() const
Definition: InputTag.h:43
tuple size
Write out results.
list at
Definition: asciidump.py:428
void MultiTrackValidator::bookHistograms ( DQMStore::IBooker ibook,
edm::Run const &  ,
edm::EventSetup const &  setup 
)
virtual

Method called to book the DQM histograms.

Implements thread_unsafe::DQMEDAnalyzer.

Definition at line 94 of file MultiTrackValidator.cc.

References MultiTrackValidatorBase::associator, MultiTrackValidatorBase::associators, MTVHistoProducerAlgo::bookRecoHistos(), MTVHistoProducerAlgo::bookRecoHistosForStandaloneRunning(), MTVHistoProducerAlgo::bookSimHistos(), DQMStore::IBooker::cd(), TrackerOfflineValidation_Dqm_cff::dirName, dirName_, edm::EventSetup::get(), histoProducerAlgo_, MTVHistoProducerAlgo::initialize(), edm::InputTag::instance(), edm::InputTag::label(), MultiTrackValidatorBase::label, edm::InputTag::process(), edm::ESHandle< class >::product(), python.rootplot.root2matplotlib::replace(), runStandalone, DQMStore::IBooker::setCurrentFolder(), UseAssociators, and w.

94  {
95 
96  //int j=0; //is This Necessary ???
97  for (unsigned int ww=0;ww<associators.size();ww++){
98  for (unsigned int www=0;www<label.size();www++){
99  ibook.cd();
100  InputTag algo = label[www];
101  string dirName=dirName_;
102  if (algo.process()!="")
103  dirName+=algo.process()+"_";
104  if(algo.label()!="")
105  dirName+=algo.label()+"_";
106  if(algo.instance()!="")
107  dirName+=algo.instance()+"_";
108  if (dirName.find("Tracks")<dirName.length()){
109  dirName.replace(dirName.find("Tracks"),6,"");
110  }
111  string assoc= associators[ww];
112  if (assoc.find("Track")<assoc.length()){
113  assoc.replace(assoc.find("Track"),5,"");
114  }
115  dirName+=assoc;
116  std::replace(dirName.begin(), dirName.end(), ':', '_');
117 
118  ibook.setCurrentFolder(dirName.c_str());
119 
120  // vector of vector initialization
121  histoProducerAlgo_->initialize(); //TO BE FIXED. I'D LIKE TO AVOID THIS CALL
122 
123  string subDirName = dirName + "/simulation";
124  ibook.setCurrentFolder(subDirName.c_str());
125 
126  //Booking histograms concerning with simulated tracks
128 
129  ibook.cd();
130  ibook.setCurrentFolder(dirName.c_str());
131 
132  //Booking histograms concerning with reconstructed tracks
135 
136  if (UseAssociators) {
138  for (unsigned int w=0;w<associators.size();w++) {
139  setup.get<TrackAssociatorRecord>().get(associators[w],theAssociator);
140  associator.push_back( theAssociator.product() );
141  }//end loop w
142  }
143  }//end loop www
144  }// end loop ww
145 }
const double w
Definition: UKUtility.cc:23
void cd(void)
Definition: DQMStore.cc:266
std::vector< const TrackAssociatorBase * > associator
virtual void bookRecoHistosForStandaloneRunning(DQMStore::IBooker &ibook)=0
std::vector< edm::InputTag > label
virtual void bookRecoHistos(DQMStore::IBooker &ibook)=0
virtual void initialize()=0
virtual void bookSimHistos(DQMStore::IBooker &ibook)=0
MTVHistoProducerAlgo * histoProducerAlgo_
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
T const * product() const
Definition: ESHandle.h:62
std::string const & label() const
Definition: InputTag.h:42
std::string const & process() const
Definition: InputTag.h:46
std::vector< std::string > associators
std::string const & instance() const
Definition: InputTag.h:43
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
void MultiTrackValidator::endRun ( edm::Run const &  ,
edm::EventSetup const &   
)
virtual

Method called at the end of the event loop.

Reimplemented from edm::EDAnalyzer.

Definition at line 502 of file MultiTrackValidator.cc.

References MultiTrackValidatorBase::associators, MTVHistoProducerAlgo::fillHistosFromVectors(), MTVHistoProducerAlgo::fillProfileHistosFromVectors(), MTVHistoProducerAlgo::finalHistoFits(), histoProducerAlgo_, MultiTrackValidatorBase::label, runStandalone, MultiTrackValidatorBase::skipHistoFit, and w.

502  {
503  int w=0;
504  for (unsigned int ww=0;ww<associators.size();ww++){
505  for (unsigned int www=0;www<label.size();www++){
509  w++;
510  }
511  }
512  //if ( out.size() != 0 && dbe_ ) dbe_->save(out);
513 }
const double w
Definition: UKUtility.cc:23
std::vector< edm::InputTag > label
virtual void fillProfileHistosFromVectors(int counter)=0
virtual void finalHistoFits(int counter)=0
MTVHistoProducerAlgo * histoProducerAlgo_
virtual void fillHistosFromVectors(int counter)=0
std::vector< std::string > associators

Member Data Documentation

edm::EDGetTokenT<SimHitTPAssociationProducer::SimHitTPAssociationList> MultiTrackValidator::_simHitTpMapTag
private

Definition at line 50 of file MultiTrackValidator.h.

Referenced by analyze(), and MultiTrackValidator().

edm::InputTag MultiTrackValidator::assMapInput
protected
edm::EDGetTokenT<reco::RecoToSimCollection> MultiTrackValidator::associatormapRtS
protected
edm::EDGetTokenT<reco::SimToRecoCollection> MultiTrackValidator::associatormapStR
protected
CosmicTrackingParticleSelector MultiTrackValidator::cosmictpSelector
private

Definition at line 48 of file MultiTrackValidator.h.

Referenced by analyze(), and MultiTrackValidator().

std::string MultiTrackValidator::dirName_
private

Definition at line 41 of file MultiTrackValidator.h.

Referenced by bookHistograms(), and MultiTrackValidator().

MTVHistoProducerAlgo* MultiTrackValidator::histoProducerAlgo_
protected
bool MultiTrackValidator::runStandalone
private

Definition at line 44 of file MultiTrackValidator.h.

Referenced by bookHistograms(), endRun(), and MultiTrackValidator().

TrackingParticleSelector MultiTrackValidator::tpSelector
private

Definition at line 47 of file MultiTrackValidator.h.

Referenced by analyze(), and MultiTrackValidator().

bool MultiTrackValidator::UseAssociators
protected
bool MultiTrackValidator::useGsf
private

Definition at line 43 of file MultiTrackValidator.h.

Referenced by MultiTrackValidator().