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 Attributes
MultiTrackValidatorGenPs Class Reference

#include <MultiTrackValidatorGenPs.h>

Inheritance diagram for MultiTrackValidatorGenPs:
MultiTrackValidator DQMEDAnalyzer MultiTrackValidatorBase edm::stream::EDAnalyzer< edm::RunSummaryCache< dqmDetails::NoCache >, edm::LuminosityBlockSummaryCache< dqmDetails::NoCache > > edm::stream::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

void analyze (const edm::Event &, const edm::EventSetup &)
 Method called once per event. More...
 
 MultiTrackValidatorGenPs (const edm::ParameterSet &pset)
 Constructor. More...
 
virtual ~MultiTrackValidatorGenPs ()
 Destructor. More...
 
- Public Member Functions inherited from MultiTrackValidator
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 DQMEDAnalyzer
virtual void beginRun (edm::Run const &, edm::EventSetup const &) final
 
virtual void beginStream (edm::StreamID id) final
 
virtual void dqmBeginRun (edm::Run const &, edm::EventSetup const &)
 
 DQMEDAnalyzer (void)
 
virtual void endLuminosityBlockSummary (edm::LuminosityBlock const &, edm::EventSetup const &, dqmDetails::NoCache *) const final
 
virtual void endRunSummary (edm::Run const &, edm::EventSetup const &, dqmDetails::NoCache *) const final
 
uint32_t streamId () const
 
- Public Member Functions inherited from edm::stream::EDAnalyzer< edm::RunSummaryCache< dqmDetails::NoCache >, edm::LuminosityBlockSummaryCache< dqmDetails::NoCache > >
 EDAnalyzer ()=default
 
- Public Member Functions inherited from edm::stream::EDAnalyzerBase
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDAnalyzerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 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
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

GenParticleCustomSelector gpSelector
 
edm::EDGetTokenT
< reco::TrackToGenParticleAssociator
label_gen_associator
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDAnalyzer< edm::RunSummaryCache< dqmDetails::NoCache >, edm::LuminosityBlockSummaryCache< dqmDetails::NoCache > >
typedef CacheContexts< T...> CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T...> HasAbility
 
typedef
CacheTypes::LuminosityBlockCache 
LuminosityBlockCache
 
typedef
LuminosityBlockContextT
< LuminosityBlockCache,
RunCache, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDAnalyzerBase
typedef EDAnalyzerAdaptorBase ModuleType
 
- Static Public Member Functions inherited from DQMEDAnalyzer
static std::shared_ptr
< dqmDetails::NoCache
globalBeginLuminosityBlockSummary (edm::LuminosityBlock const &, edm::EventSetup const &, LuminosityBlockContext const *)
 
static std::shared_ptr
< dqmDetails::NoCache
globalBeginRunSummary (edm::Run const &, edm::EventSetup const &, RunContext const *)
 
static void globalEndLuminosityBlockSummary (edm::LuminosityBlock const &, edm::EventSetup const &, LuminosityBlockContext const *, dqmDetails::NoCache *)
 
static void globalEndRunSummary (edm::Run const &, edm::EventSetup const &, RunContext const *, dqmDetails::NoCache *)
 
- Static Public Member Functions inherited from edm::stream::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::stream::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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...
 
- Protected Attributes inherited from MultiTrackValidator
edm::InputTag assMapInput
 
edm::EDGetTokenT
< reco::RecoToSimCollection
associatormapRtS
 
edm::EDGetTokenT
< reco::SimToRecoCollection
associatormapStR
 
MTVHistoProducerAlgohistoProducerAlgo_
 
bool UseAssociators
 
- Protected Attributes inherited from MultiTrackValidatorBase
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
< edm::ValueMap
< reco::DeDxData > > 
m_dEdx1Tag
 
edm::EDGetTokenT
< edm::ValueMap
< reco::DeDxData > > 
m_dEdx2Tag
 
std::string out
 
std::string parametersDefiner
 
std::string sim
 
bool skipHistoFit
 
edm::ESHandle< MagneticFieldtheMF
 

Detailed Description

Class that prodecs histrograms to validate Track Reconstruction performances

Author
cerati

Definition at line 14 of file MultiTrackValidatorGenPs.h.

Constructor & Destructor Documentation

MultiTrackValidatorGenPs::MultiTrackValidatorGenPs ( const edm::ParameterSet pset)

Constructor.

Definition at line 39 of file MultiTrackValidatorGenPs.cc.

References MultiTrackValidatorBase::associators, edm::ParameterSet::getParameter(), gpSelector, HLT_25ns14e33_v1_cff::InputTag, kTrackAssociatorByChi2(), label_gen_associator, mergeVDriftHistosByStation::name, and MultiTrackValidator::UseAssociators.

39  :MultiTrackValidator(pset){
40 
41  gpSelector = GenParticleCustomSelector(pset.getParameter<double>("ptMinGP"),
42  pset.getParameter<double>("minRapidityGP"),
43  pset.getParameter<double>("maxRapidityGP"),
44  pset.getParameter<double>("tipGP"),
45  pset.getParameter<double>("lipGP"),
46  pset.getParameter<bool>("chargedOnlyGP"),
47  pset.getParameter<int>("statusGP"),
48  pset.getParameter<std::vector<int> >("pdgIdGP"));
49 
50  if(UseAssociators) {
51  for(auto const& name: associators) {
53  label_gen_associator = consumes<reco::TrackToGenParticleAssociator>(edm::InputTag(name));
54  break;
55  }
56  }
57  }
58 
59 }
T getParameter(std::string const &) const
static const std::string kTrackAssociatorByChi2("trackAssociatorByChi2")
edm::EDGetTokenT< reco::TrackToGenParticleAssociator > label_gen_associator
GenParticleCustomSelector gpSelector
MultiTrackValidator(const edm::ParameterSet &pset)
Constructor.
std::vector< std::string > associators
SingleObjectSelector< GenParticleCollection,::GenParticleCustomSelector > GenParticleCustomSelector
MultiTrackValidatorGenPs::~MultiTrackValidatorGenPs ( )
virtual

Destructor.

Definition at line 61 of file MultiTrackValidatorGenPs.cc.

61 {}

Member Function Documentation

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

Method called once per event.

Reimplemented from MultiTrackValidator.

Definition at line 64 of file MultiTrackValidatorGenPs.cc.

References MultiTrackValidator::assMapInput, MultiTrackValidator::associatormapRtS, MultiTrackValidator::associatormapStR, asciidump::at, MultiTrackValidatorBase::bsSrc, reco::TrackBase::charge(), edm::HandleBase::clear(), reco::GenParticle::collisionId(), funct::cos(), PFRecoTauDiscriminationAgainstElectronDeadECAL_cfi::dR, alignCSCRings::e, edm::AssociationMap< Tag >::end(), 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(), plotBeamSpotDB::first, edm::EventSetup::get(), edm::Ref< C, T, F >::get(), edm::Event::getByToken(), gpSelector, MultiTrackValidator::histoProducerAlgo_, i, MultiTrackValidatorBase::ignoremissingtkcollection_, edm::InputTag::instance(), edm::EDGetTokenT< T >::isUninitialized(), kTrackAssociatorByChi2(), edm::InputTag::label(), MultiTrackValidatorBase::label, label_gen_associator, MultiTrackValidatorBase::label_pileupinfo, MultiTrackValidatorBase::label_tp_effic, MultiTrackValidatorBase::label_tp_fake, MultiTrackValidatorBase::labelToken, LogTrace, MultiTrackValidatorBase::m_dEdx1Tag, MultiTrackValidatorBase::m_dEdx2Tag, reco::LeafCandidate::momentum(), MultiTrackValidatorBase::parametersDefiner, edm::InputTag::process(), edm::Handle< T >::product(), reco::TrackBase::pt(), dt_dqm_sourceclient_common_cff::reco, mathSSE::return(), funct::sin(), findQualityFiles::size, mathSSE::sqrt(), HLT_25ns14e33_v3_cff::trackCollection, MultiTrackValidator::UseAssociators, reco::LeafCandidate::vertex(), w, and cms::Exception::what().

64  {
65  using namespace reco;
66 
67  edm::LogInfo("TrackValidator") << "\n====================================================" << "\n"
68  << "Analyzing new event" << "\n"
69  << "====================================================\n" << "\n";
70 
71  edm::ESHandle<ParametersDefinerForTP> parametersDefinerTP;
72  setup.get<TrackAssociatorRecord>().get(parametersDefiner,parametersDefinerTP);
73 
74  edm::Handle<GenParticleCollection> TPCollectionHeff ;
75  event.getByToken(label_tp_effic,TPCollectionHeff);
76  const GenParticleCollection tPCeff = *(TPCollectionHeff.product());
77 
78  edm::Handle<GenParticleCollection> TPCollectionHfake ;
79  event.getByToken(label_tp_fake,TPCollectionHfake);
80  const GenParticleCollection tPCfake = *(TPCollectionHfake.product());
81 
82  //if (tPCeff.size()==0) {edm::LogInfo("TrackValidator")
83  //<< "TP Collection for efficiency studies has size = 0! Skipping Event." ; return;}
84  //if (tPCfake.size()==0) {edm::LogInfo("TrackValidator")
85  //<< "TP Collection for fake rate studies has size = 0! Skipping Event." ; return;}
86 
87  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
88  event.getByToken(bsSrc,recoBeamSpotHandle);
89  reco::BeamSpot bs = *recoBeamSpotHandle;
90 
92  event.getByToken(label_pileupinfo,puinfoH);
93  PileupSummaryInfo puinfo;
94 
95  for (unsigned int puinfo_ite=0;puinfo_ite<(*puinfoH).size();++puinfo_ite){
96  if ((*puinfoH)[puinfo_ite].getBunchCrossing()==0){
97  puinfo=(*puinfoH)[puinfo_ite];
98  break;
99  }
100  }
101 
102  const reco::TrackToGenParticleAssociator* trackGenAssociator =nullptr;
105  event.getByToken(label_gen_associator,trackGenAssociatorH);
106  trackGenAssociator = trackGenAssociatorH.product();
107  }
108 
109  if ( not trackGenAssociator) { return ; }
110 
111  int w=0; //counter counting the number of sets of histograms
112  for (unsigned int www=0;www<label.size();www++){
113  //
114  //get collections from the event
115  //
117  if(!event.getByToken(labelToken[www], trackCollection)&&ignoremissingtkcollection_)continue;
118  //if (trackCollection->size()==0)
119  //edm::LogInfo("TrackValidator") << "TrackCollection size = 0!" ;
120  //continue;
121  //}
122  reco::RecoToGenCollection recGenColl;
123  reco::GenToRecoCollection genRecColl;
124  //associate tracks
125  if(UseAssociators){
126  edm::LogVerbatim("TrackValidator") << "Analyzing "
127  << label[www].process()<<":"
128  << label[www].label()<<":"
129  << label[www].instance()<<" with "
130  << kTrackAssociatorByChi2 <<"\n";
131 
132  LogTrace("TrackValidator") << "Calling associateRecoToGen method" << "\n";
133  recGenColl=trackGenAssociator->associateRecoToGen(trackCollection,
134  TPCollectionHfake);
135  LogTrace("TrackValidator") << "Calling associateGenToReco method" << "\n";
136  genRecColl=trackGenAssociator->associateGenToReco(trackCollection,
137  TPCollectionHeff);
138  }
139  else{
140  edm::LogVerbatim("TrackValidator") << "Analyzing "
141  << label[www].process()<<":"
142  << label[www].label()<<":"
143  << label[www].instance()<<" with "
144  << assMapInput.process()<<":"
145  << assMapInput.label()<<":"
146  << assMapInput.instance()<<"\n";
147 
148  Handle<reco::GenToRecoCollection > gentorecoCollectionH;
149  event.getByToken(associatormapStR,gentorecoCollectionH);
150  genRecColl= *(gentorecoCollectionH.product());
151 
152  Handle<reco::RecoToGenCollection > recotogenCollectionH;
153  event.getByToken(associatormapRtS,recotogenCollectionH);
154  recGenColl= *(recotogenCollectionH.product());
155  }
156 
157 
158 
159  // ########################################################
160  // fill simulation histograms (LOOP OVER TRACKINGPARTICLES)
161  // ########################################################
162 
163  //compute number of tracks per eta interval
164  //
165  edm::LogVerbatim("TrackValidator") << "\n# of GenParticles: " << tPCeff.size() << "\n";
166  int ats(0); //This counter counts the number of simTracks that are "associated" to recoTracks
167  int st(0); //This counter counts the number of simulated tracks passing the MTV selection (i.e. tpSelector(tp) )
168  unsigned sts(0); //This counter counts the number of simTracks surviving the bunchcrossing cut
169  unsigned asts(0); //This counter counts the number of simTracks that are "associated" to recoTracks surviving the bunchcrossing cut
170  for (GenParticleCollection::size_type i=0; i<tPCeff.size(); i++){ //loop over TPs collection for tracking efficiency
171  GenParticleRef tpr(TPCollectionHeff, i);
172  GenParticle* tp=const_cast<GenParticle*>(tpr.get());
173  TrackingParticle::Vector momentumTP;
174  TrackingParticle::Point vertexTP;
175  double dxyGen(0);
176  double dzGen(0);
177 
178 
179  //---------- THIS PART HAS TO BE CLEANED UP. THE PARAMETER DEFINER WAS NOT MEANT TO BE USED IN THIS WAY ----------
180  //If the GenParticle is collison like, get the momentum and vertex at production state
181  if(parametersDefiner=="LhcParametersDefinerForTP")
182  {
183  //fixme this one shold be implemented
184  if(! gpSelector(*tp)) continue;
185  momentumTP = tp->momentum();
186  vertexTP = tp->vertex();
187  //Calcualte the impact parameters w.r.t. PCA
188  TrackingParticle::Vector momentum = parametersDefinerTP->momentum(event,setup,*tp);
189  TrackingParticle::Point vertex = parametersDefinerTP->vertex(event,setup,*tp);
190  dxyGen = (-vertex.x()*sin(momentum.phi())+vertex.y()*cos(momentum.phi()));
191  dzGen = vertex.z() - (vertex.x()*momentum.x()+vertex.y()*momentum.y())/sqrt(momentum.perp2())
192  * momentum.z()/sqrt(momentum.perp2());
193  }
194  //If the GenParticle is comics, get the momentum and vertex at PCA
195  if(parametersDefiner=="CosmicParametersDefinerForTP")
196  {
197  //if(! cosmictpSelector(*tp,&bs,event,setup)) continue;
198  momentumTP = parametersDefinerTP->momentum(event,setup,*tp);
199  vertexTP = parametersDefinerTP->vertex(event,setup,*tp);
200  dxyGen = (-vertexTP.x()*sin(momentumTP.phi())+vertexTP.y()*cos(momentumTP.phi()));
201  dzGen = vertexTP.z() - (vertexTP.x()*momentumTP.x()+vertexTP.y()*momentumTP.y())/sqrt(momentumTP.perp2())
202  * momentumTP.z()/sqrt(momentumTP.perp2());
203  }
204  //---------- THE PART ABOVE HAS TO BE CLEANED UP. THE PARAMETER DEFINER WAS NOT MEANT TO BE USED IN THIS WAY ----------
205 
206  st++; //This counter counts the number of simulated tracks passing the MTV selection (i.e. tpSelector(tp) )
207 
208  // in the coming lines, histos are filled using as input
209  // - momentumTP
210  // - vertexTP
211  // - dxyGen
212  // - dzGen
213 
214  histoProducerAlgo_->fill_generic_simTrack_histos(w,momentumTP,vertexTP, tp->collisionId());//fixme: check meaning of collisionId
215 
216 
217  // ##############################################
218  // fill RecoAssociated GenTracks' histograms
219  // ##############################################
220  // bool isRecoMatched(false); // UNUSED
221  const reco::Track* matchedTrackPointer=0;
222  std::vector<std::pair<RefToBase<Track>, double> > rt;
223  if(genRecColl.find(tpr) != genRecColl.end()){
224  rt = (std::vector<std::pair<RefToBase<Track>, double> >) genRecColl[tpr];
225  if (rt.size()!=0) {
226  ats++; //This counter counts the number of simTracks that have a recoTrack associated
227  // isRecoMatched = true; // UNUSED
228  matchedTrackPointer = rt.begin()->first.get();
229  edm::LogVerbatim("TrackValidator") << "GenParticle #" << st
230  << " with pt=" << sqrt(momentumTP.perp2())
231  << " associated with quality:" << rt.begin()->second <<"\n";
232  }
233  }else{
234  edm::LogVerbatim("TrackValidator")
235  << "GenParticle #" << st
236  << " with pt,eta,phi: "
237  << sqrt(momentumTP.perp2()) << " , "
238  << momentumTP.eta() << " , "
239  << momentumTP.phi() << " , "
240  << " NOT associated to any reco::Track" << "\n";
241  }
242 
243 
244 
245  int nSimHits = 0;
246  histoProducerAlgo_->fill_recoAssociated_simTrack_histos(w,*tp,momentumTP,vertexTP,dxyGen,dzGen,nSimHits,matchedTrackPointer,puinfo.getPU_NumInteractions());
247 
248  sts++;
249  if (matchedTrackPointer) asts++;
250 
251 
252 
253 
254  } // End for (GenParticleCollection::size_type i=0; i<tPCeff.size(); i++){
255 
256  //if (st!=0) h_tracksSIM[w]->Fill(st); // TO BE FIXED
257 
258 
259  // ##############################################
260  // fill recoTracks histograms (LOOP OVER TRACKS)
261  // ##############################################
262  edm::LogVerbatim("TrackValidator") << "\n# of reco::Tracks with "
263  << label[www].process()<<":"
264  << label[www].label()<<":"
265  << label[www].instance()
266  << ": " << trackCollection->size() << "\n";
267 
268  //int sat(0); //This counter counts the number of recoTracks that are associated to GenTracks from Signal only
269  int at(0); //This counter counts the number of recoTracks that are associated to GenTracks
270  int rT(0); //This counter counts the number of recoTracks in general
271 
272 
273  // dE/dx
274  // at some point this could be generalized, with a vector of tags and a corresponding vector of Handles
275  // I'm writing the interface such to take vectors of ValueMaps
278  std::vector<edm::ValueMap<reco::DeDxData> > v_dEdx;
279  v_dEdx.clear();
280  //std::cout << "PIPPO: label is " << label[www] << std::endl;
281  if (label[www].label()=="generalTracks") {
282  try {
283  event.getByToken(m_dEdx1Tag, dEdx1Handle);
284  const edm::ValueMap<reco::DeDxData> dEdx1 = *dEdx1Handle.product();
285  event.getByToken(m_dEdx2Tag, dEdx2Handle);
286  const edm::ValueMap<reco::DeDxData> dEdx2 = *dEdx2Handle.product();
287  v_dEdx.push_back(dEdx1);
288  v_dEdx.push_back(dEdx2);
289  } catch (cms::Exception e){
290  LogTrace("TrackValidator") << "exception found: " << e.what() << "\n";
291  }
292  }
293  //end dE/dx
294 
295  for(View<Track>::size_type i=0; i<trackCollection->size(); ++i){
296 
297  RefToBase<Track> track(trackCollection, i);
298  rT++;
299 
300  bool isSigGenMatched(false);
301  bool isGenMatched(false);
302  bool isChargeMatched(true);
303  int numAssocRecoTracks = 0;
304  int nSimHits = 0;
305  double sharedFraction = 0.;
306  std::vector<std::pair<GenParticleRef, double> > tp;
307  if(recGenColl.find(track) != recGenColl.end()){
308  tp = recGenColl[track];
309  if (tp.size()!=0) {
310  /*
311  std::vector<PSimHit> simhits=tp[0].first->trackPSimHit(DetId::Tracker);
312  nSimHits = simhits.end()-simhits.begin();
313  */
314  sharedFraction = tp[0].second;
315  isGenMatched = true;
316  if (tp[0].first->charge() != track->charge()) isChargeMatched = false;
317  if(genRecColl.find(tp[0].first) != genRecColl.end()) numAssocRecoTracks = genRecColl[tp[0].first].size();
318  //std::cout << numAssocRecoTracks << std::endl;
319  at++;
320  for (unsigned int tp_ite=0;tp_ite<tp.size();++tp_ite){
321  GenParticle trackpart = *(tp[tp_ite].first);
322  /*
323  if ((trackpart.eventId().event() == 0) && (trackpart.eventId().bunchCrossing() == 0)){
324  isSigGenMatched = true;
325  sat++;
326  break;
327  }
328  */
329  }
330  edm::LogVerbatim("TrackValidator") << "reco::Track #" << rT << " with pt=" << track->pt()
331  << " associated with quality:" << tp.begin()->second <<"\n";
332  }
333  } else {
334  edm::LogVerbatim("TrackValidator") << "reco::Track #" << rT << " with pt=" << track->pt()
335  << " NOT associated to any GenParticle" << "\n";
336  }
337 
338 
339  double dR=0;//fixme: plots vs dR not implemented for now
340  histoProducerAlgo_->fill_generic_recoTrack_histos(w,*track,bs.position(),isGenMatched,isSigGenMatched, isChargeMatched, numAssocRecoTracks, puinfo.getPU_NumInteractions(), nSimHits, sharedFraction,dR);
341 
342  // dE/dx
343  // reco::TrackRef track2 = reco::TrackRef( trackCollection, i );
344  if (v_dEdx.size() > 0) histoProducerAlgo_->fill_dedx_recoTrack_histos(w,track, v_dEdx);
345  //if (v_dEdx.size() > 0) histoProducerAlgo_->fill_dedx_recoTrack_histos(track2, v_dEdx);
346 
347 
348  //Fill other histos
349  //try{ //Is this really necessary ????
350 
351  if (tp.size()==0) continue;
352 
354 
355  GenParticleRef tpr = tp.begin()->first;
356 
357  /* TO BE FIXED LATER
358  if (associators[ww]=="TrackAssociatorByChi2"){
359  //association chi2
360  double assocChi2 = -tp.begin()->second;//in association map is stored -chi2
361  h_assochi2[www]->Fill(assocChi2);
362  h_assochi2_prob[www]->Fill(TMath::Prob((assocChi2)*5,5));
363  }
364  else if (associators[ww]=="quickTrackAssociatorByHits"){
365  double fraction = tp.begin()->second;
366  h_assocFraction[www]->Fill(fraction);
367  h_assocSharedHit[www]->Fill(fraction*track->numberOfValidHits());
368  }
369  */
370 
371 
372  //Get tracking particle parameters at point of closest approach to the beamline
373  TrackingParticle::Vector momentumTP = parametersDefinerTP->momentum(event,setup,*(tpr.get()));
374  TrackingParticle::Point vertexTP = parametersDefinerTP->vertex(event,setup,*(tpr.get()));
375  int chargeTP = tpr->charge();
376 
377  histoProducerAlgo_->fill_ResoAndPull_recoTrack_histos(w,momentumTP,vertexTP,chargeTP,
378  *track,bs.position());
379 
380 
381  //TO BE FIXED
382  //std::vector<PSimHit> simhits=tpr.get()->trackPSimHit(DetId::Tracker);
383  //nrecHit_vs_nsimHit_rec2sim[w]->Fill(track->numberOfValidHits(), (int)(simhits.end()-simhits.begin() ));
384 
385  /*
386  } // End of try{
387  catch (cms::Exception e){
388  LogTrace("TrackValidator") << "exception found: " << e.what() << "\n";
389  }
390  */
391 
392  } // End of for(View<Track>::size_type i=0; i<trackCollection->size(); ++i){
393 
395 
396  edm::LogVerbatim("TrackValidator") << "Total Simulated: " << st << "\n"
397  << "Total Associated (genToReco): " << ats << "\n"
398  << "Total Reconstructed: " << rT << "\n"
399  << "Total Associated (recoToGen): " << at << "\n"
400  << "Total Fakes: " << rT-at << "\n";
401 
402  w++;
403  } // End of for (unsigned int www=0;www<label.size();www++){
404 }
virtual char const * what() const
Definition: Exception.cc:141
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
unsigned int size_type
Definition: View.h:85
edm::EDGetTokenT< edm::ValueMap< reco::DeDxData > > m_dEdx1Tag
int i
Definition: DBlmapReader.cc:9
static const std::string kTrackAssociatorByChi2("trackAssociatorByChi2")
const double w
Definition: UKUtility.cc:23
edm::EDGetTokenT< std::vector< PileupSummaryInfo > > label_pileupinfo
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:449
virtual const Point & vertex() const
vertex position (overwritten by PF...)
virtual void fill_dedx_recoTrack_histos(int count, edm::RefToBase< reco::Track > &trackref, const std::vector< edm::ValueMap< reco::DeDxData > > &v_dEdx)=0
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
virtual Vector momentum() const
spatial momentum vector
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
int collisionId() const
Definition: GenParticle.h:39
uint16_t size_type
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 dR)=0
return((rh^lh)&mask)
edm::EDGetTokenT< reco::SimToRecoCollection > associatormapStR
edm::EDGetTokenT< reco::BeamSpot > bsSrc
math::XYZPointD Point
point in the space
edm::EDGetTokenT< reco::TrackToGenParticleAssociator > label_gen_associator
std::vector< edm::InputTag > label
GenParticleCustomSelector gpSelector
T sqrt(T t)
Definition: SSEVec.h:48
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:242
#define LogTrace(id)
MTVHistoProducerAlgo * histoProducerAlgo_
virtual void fill_simAssociated_recoTrack_histos(int count, const reco::Track &track)=0
T const * product() const
Definition: Handle.h:81
const T & get() const
Definition: EventSetup.h:55
virtual void fill_trackBased_histos(int count, int assTracks, int numRecoTracks, int numSimTracks)=0
std::string const & label() const
Definition: InputTag.h:42
std::string const & process() const
Definition: InputTag.h:46
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 nSimHits, double sharedFraction, double dR)=0
bool isUninitialized() const
Definition: EDGetToken.h:71
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.
edm::EDGetTokenT< edm::ValueMap< reco::DeDxData > > m_dEdx2Tag
list at
Definition: asciidump.py:428

Member Data Documentation

GenParticleCustomSelector MultiTrackValidatorGenPs::gpSelector
private

Definition at line 27 of file MultiTrackValidatorGenPs.h.

Referenced by analyze(), and MultiTrackValidatorGenPs().

edm::EDGetTokenT<reco::TrackToGenParticleAssociator> MultiTrackValidatorGenPs::label_gen_associator
private

Definition at line 28 of file MultiTrackValidatorGenPs.h.

Referenced by analyze(), and MultiTrackValidatorGenPs().