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
TrackerSeedValidator Class Reference

#include <TrackerSeedValidator.h>

Inheritance diagram for TrackerSeedValidator:
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 &) override
 Method called once per event. More...
 
void bookHistograms (DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
 Method called to book the DQM histograms. More...
 
 TrackerSeedValidator (const edm::ParameterSet &pset)
 Constructor. More...
 
virtual ~TrackerSeedValidator ()
 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
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 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 (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &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

std::vector< edm::EDGetTokenT
< reco::TrackToTrackingParticleAssociator > > 
associatorTokens
 
std::string builderName
 
CosmicTrackingParticleSelector cosmictpSelector
 
std::string dirName_
 
std::unique_ptr
< MTVHistoProducerAlgoForTracker
histoProducerAlgo_
 
edm::ESHandle
< TransientTrackingRecHitBuilder
theTTRHBuilder
 
TrackingParticleSelector tpSelector
 

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
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- 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::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 MultiTrackValidatorBase
std::vector< edm::InputTagassociators
 
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 parametersDefiner
 
std::vector< edm::EDGetTokenT
< std::vector< PSimHit > > > 
simHitTokens_
 

Detailed Description

Class that prodecs histrograms to validate Track Reconstruction performances

Author
cerati

Definition at line 18 of file TrackerSeedValidator.h.

Constructor & Destructor Documentation

TrackerSeedValidator::TrackerSeedValidator ( const edm::ParameterSet pset)

Constructor.

Definition at line 38 of file TrackerSeedValidator.cc.

References MultiTrackValidatorBase::associators, associatorTokens, builderName, dirName_, edm::ParameterSet::getParameter(), AlCaHLTBitMon_QueryRunRegistry::string, and tpSelector.

38  :
40  histoProducerAlgo_(std::make_unique<MTVHistoProducerAlgoForTracker>(pset.getParameter<ParameterSet>("histoProducerAlgoBlock"), consumesCollector())) {
41  dirName_ = pset.getParameter<std::string>("dirName");
42 
43  tpSelector = TrackingParticleSelector(pset.getParameter<double>("ptMinTP"),
44  pset.getParameter<double>("minRapidityTP"),
45  pset.getParameter<double>("maxRapidityTP"),
46  pset.getParameter<double>("tipTP"),
47  pset.getParameter<double>("lipTP"),
48  pset.getParameter<int>("minHitTP"),
49  pset.getParameter<bool>("signalOnlyTP"),
50  pset.getParameter<bool>("intimeOnlyTP"),
51  pset.getParameter<bool>("chargedOnlyTP"),
52  pset.getParameter<bool>("stableOnlyTP"),
53  pset.getParameter<std::vector<int> >("pdgIdTP"));
54 
55  builderName = pset.getParameter<std::string>("TTRHBuilder");
56 
57  for (auto const& associator: associators) {
58  associatorTokens.push_back(consumes<reco::TrackToTrackingParticleAssociator>(associator));
59  }
60 }
T getParameter(std::string const &) const
std::vector< edm::InputTag > associators
TrackingParticleSelector tpSelector
SingleObjectSelector< TrackingParticleCollection,::TrackingParticleSelector > TrackingParticleSelector
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
MultiTrackValidatorBase(const edm::ParameterSet &pset, edm::ConsumesCollector &&iC, bool isSeed=false)
Constructor.
std::unique_ptr< MTVHistoProducerAlgoForTracker > histoProducerAlgo_
std::vector< edm::EDGetTokenT< reco::TrackToTrackingParticleAssociator > > associatorTokens
TrackerSeedValidator::~TrackerSeedValidator ( )
virtual

Destructor.

Definition at line 62 of file TrackerSeedValidator.cc.

62 {}

Member Function Documentation

void TrackerSeedValidator::analyze ( const edm::Event event,
const edm::EventSetup setup 
)
overridevirtual

Method called once per event.

Implements edm::stream::EDAnalyzerBase.

Definition at line 105 of file TrackerSeedValidator.cc.

References reco::TrackBase::appendHits(), reco::TrackToTrackingParticleAssociator::associateRecoToSim(), reco::TrackToTrackingParticleAssociator::associateSimToReco(), MultiTrackValidatorBase::associators, associatorTokens, MultiTrackValidatorBase::bsSrc, builderName, EncodedEventId::bunchCrossing(), TrackingParticleNumberOfLayers::calculate(), LocalTrajectoryParameters::charge(), funct::cos(), PFRecoTauDiscriminationAgainstElectronDeadECAL_cfi::dR, alignCSCRings::e, edm::AssociationMap< Tag >::end(), EncodedEventId::event(), TrackingParticle::eventId(), edm::AssociationMap< Tag >::find(), plotBeamSpotDB::first, TrajectoryStateOnSurface::freeState(), PerigeeConversions::ftsToPerigeeError(), edm::EventSetup::get(), PileupSummaryInfo::getPU_NumInteractions(), histoProducerAlgo_, i, MultiTrackValidatorBase::label, MultiTrackValidatorBase::label_pileupinfo, MultiTrackValidatorBase::label_tp_effic, MultiTrackValidatorBase::label_tp_fake, MultiTrackValidatorBase::labelTokenSeed, LogTrace, PTrajectoryStateOnDet::parameters(), MultiTrackValidatorBase::parametersDefiner, reco::BeamSpot::position(), edm::Handle< T >::product(), edm::ESHandle< class >::product(), TrajectorySeed::recHits(), fileCollector::seed, MultiTrackValidatorBase::simHitTokens_, funct::sin(), findQualityFiles::size, mathSSE::sqrt(), TrajectorySeed::startingState(), theTTRHBuilder, tpSelector, trajectoryStateTransform::transientState(), w, and cms::Exception::what().

105  {
106 
107  edm::LogInfo("TrackValidator") << "\n====================================================" << "\n"
108  << "Analyzing new event" << "\n"
109  << "====================================================\n" << "\n";
110 
111  edm::ESHandle<ParametersDefinerForTP> parametersDefinerTP;
112  setup.get<TrackAssociatorRecord>().get(parametersDefiner,parametersDefinerTP);
113 
115  setup.get<TrackerTopologyRcd>().get(httopo);
116  const TrackerTopology& ttopo = *httopo;
117 
119  setup.get<TransientRecHitRecord>().get(builderName,theTTRHBuilder);
120 
122  setup.get<IdealMagneticFieldRecord>().get(theMF);
123 
124  edm::Handle<TrackingParticleCollection> TPCollectionHeff ;
125  event.getByToken(label_tp_effic,TPCollectionHeff);
126  const TrackingParticleCollection tPCeff = *(TPCollectionHeff.product());
127 
128  edm::Handle<TrackingParticleCollection> TPCollectionHfake ;
129  event.getByToken(label_tp_fake,TPCollectionHfake);
130  const TrackingParticleCollection tPCfake = *(TPCollectionHfake.product());
131 
132  if (tPCeff.size()==0) {edm::LogInfo("TrackValidator") << "TP Collection for efficiency studies has size = 0! Skipping Event." ; return;}
133  if (tPCfake.size()==0) {edm::LogInfo("TrackValidator") << "TP Collection for fake rate studies has size = 0! Skipping Event." ; return;}
134 
135  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
136  event.getByToken(bsSrc,recoBeamSpotHandle);
137  reco::BeamSpot bs = *recoBeamSpotHandle;
138 
140  event.getByToken(label_pileupinfo,puinfoH);
141  PileupSummaryInfo puinfo;
142 
143  for (unsigned int puinfo_ite=0;puinfo_ite<(*puinfoH).size();++puinfo_ite){
144  if ((*puinfoH)[puinfo_ite].getBunchCrossing()==0){
145  puinfo=(*puinfoH)[puinfo_ite];
146  break;
147  }
148  }
149 
150  // Calculate the number of 3D layers for TPs
151  //
152  // I would have preferred to produce the ValueMap to Event and read
153  // it from there, but there would have been quite some number of
154  // knock-on effects, and again the fact that we take two TP
155  // collections do not support Ref<TP>'s would have complicated that.
156  //
157  // In principle we could use the SimHitTPAssociationList read above
158  // for parametersDefinerIsCosmic_, but since we don't currently
159  // support Ref<TP>s, we can't in general use it since eff/fake TP
160  // collections can, in general, be different.
161  TrackingParticleNumberOfLayers tpNumberOfLayersAlgo(event, simHitTokens_);
162  auto nlayers_tPCeff_ptrs = tpNumberOfLayersAlgo.calculate(TPCollectionHeff, setup);
163  const auto& nLayers_tPCeff = *(std::get<TrackingParticleNumberOfLayers::nTrackerLayers>(nlayers_tPCeff_ptrs));
164  const auto& nPixelLayers_tPCeff = *(std::get<TrackingParticleNumberOfLayers::nPixelLayers>(nlayers_tPCeff_ptrs));
165  const auto& nStripMonoAndStereoLayers_tPCeff = *(std::get<TrackingParticleNumberOfLayers::nStripMonoAndStereoLayers>(nlayers_tPCeff_ptrs));
166 
167  int w=0;
168  for (unsigned int ww=0;ww<associators.size();ww++){
170  event.getByToken(associatorTokens[ww], theAssociator);
171  const reco::TrackToTrackingParticleAssociator *associator = theAssociator.product();
172 
173  for (unsigned int www=0;www<label.size();www++){
174  edm::LogVerbatim("TrackValidator") << "Analyzing "
175  << label[www].process()<<":"
176  << label[www].label()<<":"
177  << label[www].instance()<<" with "
178  << associators[ww] <<"\n";
179  //
180  //get collections from the event
181  //
182  edm::Handle<edm::View<TrajectorySeed> > seedCollection;
183  event.getByToken(labelTokenSeed[www], seedCollection);
184  if (seedCollection->size()==0) {
185  edm::LogInfo("TrackValidator") << "SeedCollection size = 0!" ;
186  continue;
187  }
188 
189  //associate seeds
190  LogTrace("TrackValidator") << "Calling associateRecoToSim method" << "\n";
191  reco::RecoToSimCollectionSeed recSimColl=associator->associateRecoToSim(seedCollection,
192  TPCollectionHfake);
193  LogTrace("TrackValidator") << "Calling associateSimToReco method" << "\n";
194  reco::SimToRecoCollectionSeed simRecColl=associator->associateSimToReco(seedCollection,
195  TPCollectionHeff);
196 
197  //
198  //fill simulation histograms
199  //compute number of seeds per eta interval
200  //
201  edm::LogVerbatim("TrackValidator") << "\n# of TrackingParticles: " << tPCeff.size() << "\n";
202  int ats(0); //This counter counts the number of simTracks that are "associated" to recoTracks
203  int st(0); //This counter counts the number of simulated tracks passing the MTV selection (i.e. tpSelector(tp) )
204  unsigned sts(0); //This counter counts the number of simTracks surviving the bunchcrossing cut
205  unsigned asts(0); //This counter counts the number of simTracks that are "associated" to recoTracks surviving the bunchcrossing cut
206  for (TrackingParticleCollection::size_type i=0; i<tPCeff.size(); i++){
207  TrackingParticleRef tp(TPCollectionHeff, i);
208 
209  if (tp->charge()==0) continue;
210 
211  if(! tpSelector(*tp)) continue;
212 
213  TrackingParticle::Vector momentumTP = tp->momentum();
214  TrackingParticle::Point vertexTP = tp->vertex();
215  //Calcualte the impact parameters w.r.t. PCA
216  TrackingParticle::Vector momentum = parametersDefinerTP->momentum(event,setup,tp);
217  TrackingParticle::Point vertex = parametersDefinerTP->vertex(event,setup,tp);
218  double dxySim = (-vertex.x()*sin(momentum.phi())+vertex.y()*cos(momentum.phi()));
219  double dzSim = vertex.z() - (vertex.x()*momentum.x()+vertex.y()*momentum.y())/sqrt(momentum.perp2())
220  * momentum.z()/sqrt(momentum.perp2());
221 
222  if(tp->eventId().bunchCrossing() == 0) {
223  st++;
224  }
225 
226  if(w == 0)
227  histoProducerAlgo_->fill_generic_simTrack_histos(momentumTP,vertexTP, tp->eventId().bunchCrossing());
228 
229  const TrajectorySeed* matchedSeedPointer=0;
230  std::vector<std::pair<edm::RefToBase<TrajectorySeed>, double> > rt;
231  if(simRecColl.find(tp) != simRecColl.end()){
232  rt = simRecColl[tp];
233  if (rt.size()!=0) {
234  ats++;
235  matchedSeedPointer = rt.begin()->first.get();
236  edm::LogVerbatim("TrackValidator") << "TrackingParticle #" << st
237  << " with pt=" << sqrt(tp->momentum().perp2())
238  << " associated with quality:" << rt.begin()->second <<"\n";
239  }
240  }else{
241  edm::LogVerbatim("TrackValidator") << "TrackingParticle #" << st
242  << " with pt=" << sqrt(tp->momentum().perp2())
243  << " NOT associated to any TrajectorySeed" << "\n";
244  }
245 
246  int nSimHits = tp->numberOfTrackerHits();
247  int nSimLayers = nLayers_tPCeff[tp];
248  int nSimPixelLayers = nPixelLayers_tPCeff[tp];
249  int nSimStripMonoAndStereoLayers = nStripMonoAndStereoLayers_tPCeff[tp];
250 
251  //fixme convert seed into track
252  reco::Track* matchedTrackPointer = 0;
253  if (matchedSeedPointer) {
254  TSCBLBuilderNoMaterial tscblBuilder;
255  TransientTrackingRecHit::RecHitPointer recHit = theTTRHBuilder->build(&*(matchedSeedPointer->recHits().second-1));
256  TrajectoryStateOnSurface state = trajectoryStateTransform::transientState( matchedSeedPointer->startingState(), recHit->surface(), theMF.product());
257  TrajectoryStateClosestToBeamLine tsAtClosestApproachSeed = tscblBuilder(*state.freeState(),bs);//as in TrackProducerAlgorithm
258  if(!(tsAtClosestApproachSeed.isValid())){
259  edm::LogVerbatim("SeedValidator")<<"TrajectoryStateClosestToBeamLine not valid";
260  continue;
261  }
262  const reco::TrackBase::Point vSeed1(tsAtClosestApproachSeed.trackStateAtPCA().position().x(),
263  tsAtClosestApproachSeed.trackStateAtPCA().position().y(),
264  tsAtClosestApproachSeed.trackStateAtPCA().position().z());
265  const reco::TrackBase::Vector pSeed(tsAtClosestApproachSeed.trackStateAtPCA().momentum().x(),
266  tsAtClosestApproachSeed.trackStateAtPCA().momentum().y(),
267  tsAtClosestApproachSeed.trackStateAtPCA().momentum().z());
268  //GlobalPoint vSeed(vSeed1.x()-bs.x0(),vSeed1.y()-bs.y0(),vSeed1.z()-bs.z0());
269  PerigeeTrajectoryError seedPerigeeErrors = PerigeeConversions::ftsToPerigeeError(tsAtClosestApproachSeed.trackStateAtPCA());
270  matchedTrackPointer = new reco::Track(0.,0., vSeed1, pSeed, 1, seedPerigeeErrors.covarianceMatrix());
271  matchedTrackPointer->appendHits(matchedSeedPointer->recHits().first,matchedSeedPointer->recHits().second, ttopo);
272  }
273 
274  double dR=0;//fixme: plots vs dR not implemented for now
275  histoProducerAlgo_->fill_recoAssociated_simTrack_histos(w,*tp,tp->momentum(),tp->vertex(),dxySim,dzSim,0,0,nSimHits,nSimLayers,nSimPixelLayers,nSimStripMonoAndStereoLayers,
276  matchedTrackPointer,puinfo.getPU_NumInteractions(),dR, nullptr);
277 
278  sts++;
279  if (matchedTrackPointer) asts++;
280 
281  } // End for (TrackingParticleCollection::size_type i=0; i<tPCeff.size(); i++){
282 
283  if(w == 0)
284  histoProducerAlgo_->fill_simTrackBased_histos(st);
285 
286  //
287  //fill reconstructed seed histograms
288  //
289  edm::LogVerbatim("TrackValidator") << "\n# of TrajectorySeeds with "
290  << label[www].process()<<":"
291  << label[www].label()<<":"
292  << label[www].instance()
293  << ": " << seedCollection->size() << "\n";
294  int sat(0); //This counter counts the number of recoTracks that are associated to SimTracks from Signal only
295  int at(0); //This counter counts the number of recoTracks that are associated to SimTracks
296  int rT(0); //This counter counts the number of recoTracks in general
297 
298  TSCBLBuilderNoMaterial tscblBuilder;
299  for(TrajectorySeedCollection::size_type i=0; i<seedCollection->size(); ++i){
300  edm::RefToBase<TrajectorySeed> seed(seedCollection, i);
301  rT++;
302 
303  //get parameters and errors from the seed state
304  TransientTrackingRecHit::RecHitPointer recHit = theTTRHBuilder->build(&*(seed->recHits().second-1));
305  TrajectoryStateOnSurface state = trajectoryStateTransform::transientState( seed->startingState(), recHit->surface(), theMF.product());
306  TrajectoryStateClosestToBeamLine tsAtClosestApproachSeed = tscblBuilder(*state.freeState(),bs);//as in TrackProducerAlgorithm
307  if(!(tsAtClosestApproachSeed.isValid())){
308  edm::LogVerbatim("SeedValidator")<<"TrajectoryStateClosestToBeamLine not valid";
309  continue;
310  }
311  const reco::TrackBase::Point vSeed1(tsAtClosestApproachSeed.trackStateAtPCA().position().x(),
312  tsAtClosestApproachSeed.trackStateAtPCA().position().y(),
313  tsAtClosestApproachSeed.trackStateAtPCA().position().z());
314  const reco::TrackBase::Vector pSeed(tsAtClosestApproachSeed.trackStateAtPCA().momentum().x(),
315  tsAtClosestApproachSeed.trackStateAtPCA().momentum().y(),
316  tsAtClosestApproachSeed.trackStateAtPCA().momentum().z());
317  //GlobalPoint vSeed(vSeed1.x()-bs.x0(),vSeed1.y()-bs.y0(),vSeed1.z()-bs.z0());
318  PerigeeTrajectoryError seedPerigeeErrors = PerigeeConversions::ftsToPerigeeError(tsAtClosestApproachSeed.trackStateAtPCA());
319 
320  //fixme
321  reco::Track* trackFromSeed = new reco::Track(0.,0., vSeed1, pSeed, 1, seedPerigeeErrors.covarianceMatrix());
322  trackFromSeed->appendHits(seed->recHits().first,seed->recHits().second, ttopo);
323 
324  bool isSigSimMatched(false);
325  bool isSimMatched(false);
326  bool isChargeMatched(true);
327  int numAssocSeeds = 0;
328  int nSimHits = 0;
329  double sharedFraction = 0.;
330  std::vector<std::pair<TrackingParticleRef, double> > tp;
331  if(recSimColl.find(seed) != recSimColl.end()) {
332  tp = recSimColl[seed];
333  if (tp.size()!=0) {
334 
335  nSimHits = tp[0].first->numberOfTrackerHits();
336  sharedFraction = tp[0].second;
337  isSimMatched = true;
338  if (tp[0].first->charge() != seed->startingState().parameters().charge()) isChargeMatched = false;
339  if(simRecColl.find(tp[0].first) != simRecColl.end()) numAssocSeeds = simRecColl[tp[0].first].size();
340  //std::cout << numAssocRecoTracks << std::endl;
341 
342  at++;
343 
344  for (unsigned int tp_ite=0;tp_ite<tp.size();++tp_ite){
345  TrackingParticle trackpart = *(tp[tp_ite].first);
346  if ((trackpart.eventId().event() == 0) && (trackpart.eventId().bunchCrossing() == 0)){
347  isSigSimMatched = true;
348  sat++;
349  break;
350  }
351  }
352 
353 
354  edm::LogVerbatim("SeedValidator") << "TrajectorySeed #" << rT << " associated with quality:" << tp.begin()->second <<"\n";
355  }
356  } else {
357  edm::LogVerbatim("SeedValidator") << "TrajectorySeed #" << rT << " NOT associated to any TrackingParticle" << "\n";
358  }
359 
360  double dR = 0.;//fixme: plots vs dR not implemented for now
361  histoProducerAlgo_->fill_generic_recoTrack_histos(w,*trackFromSeed,bs.position(), nullptr, isSimMatched,isSigSimMatched,
362  isChargeMatched, numAssocSeeds,
363  puinfo.getPU_NumInteractions(),
364  nSimHits, sharedFraction, dR);
365 
366  //Fill other histos
367  try{
368  if (tp.size()==0) continue;
369 
370  histoProducerAlgo_->fill_simAssociated_recoTrack_histos(w,*trackFromSeed);
371 
372  TrackingParticleRef tpr = tp.begin()->first;
373 
374  //compute tracking particle parameters at point of closest approach to the beamline
375  TrackingParticle::Vector momentumTP = parametersDefinerTP->momentum(event,setup,tpr);
376  TrackingParticle::Point vertexTP = parametersDefinerTP->vertex(event,setup,tpr);
377 
378  // LogTrace("SeedValidatorTEST") << "assocChi2=" << tp.begin()->second << "\n"
379  // << "" << "\n"
380  // << "ptREC=" << ptSeed << "\n"
381  // << "etaREC=" << etaSeed << "\n"
382  // << "qoverpREC=" << qoverpSeed << "\n"
383  // << "dxyREC=" << dxySeed << "\n"
384  // << "dzREC=" << dzSeed << "\n"
385  // << "thetaREC=" << thetaSeed << "\n"
386  // << "phiREC=" << phiSeed << "\n"
387  // << "" << "\n"
388  // << "qoverpError()=" << qoverpErrorSeed << "\n"
389  // << "dxyError()=" << dxyErrorSeed << "\n"
390  // << "dzError()=" << dzErrorSeed << "\n"
391  // << "thetaError()=" << lambdaErrorSeed << "\n"
392  // << "phiError()=" << phiErrorSeed << "\n"
393  // << "" << "\n"
394  // << "ptSIM=" << sqrt(assocTrack->momentum().perp2()) << "\n"
395  // << "etaSIM=" << assocTrack->momentum().Eta() << "\n"
396  // << "qoverpSIM=" << qoverpSim << "\n"
397  // << "dxySIM=" << dxySim << "\n"
398  // << "dzSIM=" << dzSim << "\n"
399  // << "thetaSIM=" << M_PI/2-lambdaSim << "\n"
400  // << "phiSIM=" << phiSim << "\n"
401  // << "" << "\n"
402  // << "contrib_Qoverp=" << contrib_Qoverp << "\n"
403  // << "contrib_dxy=" << contrib_dxy << "\n"
404  // << "contrib_dz=" << contrib_dz << "\n"
405  // << "contrib_theta=" << contrib_theta << "\n"
406  // << "contrib_phi=" << contrib_phi << "\n"
407  // << "" << "\n"
408  // <<"chi2PULL="<<contrib_Qoverp+contrib_dxy+contrib_dz+contrib_theta+contrib_phi<<"\n";
409 
410  histoProducerAlgo_->fill_ResoAndPull_recoTrack_histos(w,momentumTP,vertexTP,tpr->charge(),
411  *trackFromSeed,bs.position());
412 
413 
414  } catch (cms::Exception e){
415  LogTrace("SeedValidator") << "exception found: " << e.what() << "\n";
416  }
417  }// End of for(TrajectorySeedCollection::size_type i=0; i<seedCollection->size(); ++i)
418 
419  histoProducerAlgo_->fill_trackBased_histos(w,at,rT,st);
420 
421  edm::LogVerbatim("SeedValidator") << "Total Simulated: " << st << "\n"
422  << "Total Associated (simToReco): " << ats << "\n"
423  << "Total Reconstructed: " << rT << "\n"
424  << "Total Associated (recoToSim): " << at << "\n"
425  << "Total Fakes: " << rT-at << "\n";
426  w++;
427  }
428  }
429 }
virtual char const * what() const
Definition: Exception.cc:141
int i
Definition: DBlmapReader.cc:9
std::vector< edm::InputTag > associators
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
std::vector< TrackingParticle > TrackingParticleCollection
const_iterator end() const
last iterator over the map (read only)
edm::EDGetTokenT< TrackingParticleCollection > label_tp_effic
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
uint16_t size_type
TrackingParticleSelector tpSelector
edm::EDGetTokenT< reco::BeamSpot > bsSrc
math::XYZPointD Point
point in the space
std::vector< edm::InputTag > label
std::vector< edm::EDGetTokenT< edm::View< TrajectorySeed > > > labelTokenSeed
T sqrt(T t)
Definition: SSEVec.h:18
int bunchCrossing() const
get the detector field from this detid
FreeTrajectoryState const * freeState(bool withErrors=true) const
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
math::XYZPoint Point
point in the space
Definition: TrackBase.h:83
edm::ESHandle< TransientTrackingRecHitBuilder > theTTRHBuilder
#define LogTrace(id)
std::shared_ptr< TrackingRecHit const > RecHitPointer
PTrajectoryStateOnDet const & startingState() const
TrajectoryStateOnSurface transientState(const PTrajectoryStateOnDet &ts, const Surface *surface, const MagneticField *field)
T const * product() const
Definition: Handle.h:81
reco::RecoToSimCollection associateRecoToSim(const edm::Handle< edm::View< reco::Track > > &tCH, const edm::Handle< TrackingParticleCollection > &tPCH) const
compare reco to sim the handle of reco::Track and TrackingParticle collections
const T & get() const
Definition: EventSetup.h:56
T const * product() const
Definition: ESHandle.h:86
range recHits() const
const int getPU_NumInteractions() const
EncodedEventId eventId() const
Signal source, crossing number.
Monte Carlo truth information used for tracking validation.
PerigeeTrajectoryError ftsToPerigeeError(const FTS &originalFTS)
const Point & position() const
position
Definition: BeamSpot.h:62
reco::SimToRecoCollection associateSimToReco(const edm::Handle< edm::View< reco::Track > > &tCH, const edm::Handle< TrackingParticleCollection > &tPCH) const
compare reco to sim the handle of reco::Track and TrackingParticle collections
math::XYZVectorD Vector
point in the space
std::vector< edm::EDGetTokenT< std::vector< PSimHit > > > simHitTokens_
edm::EDGetTokenT< TrackingParticleCollection > label_tp_fake
math::XYZVector Vector
spatial vector
Definition: TrackBase.h:80
std::unique_ptr< MTVHistoProducerAlgoForTracker > histoProducerAlgo_
bool appendHits(const C &c, const TrackerTopology &ttopo)
append hit patterns from vector of hit references
Definition: TrackBase.h:480
tuple size
Write out results.
std::vector< edm::EDGetTokenT< reco::TrackToTrackingParticleAssociator > > associatorTokens
void TrackerSeedValidator::bookHistograms ( DQMStore::IBooker ibook,
edm::Run const &  ,
edm::EventSetup const &  setup 
)
overridevirtual

Method called to book the DQM histograms.

Implements DQMEDAnalyzer.

Definition at line 64 of file TrackerSeedValidator.cc.

References ecalcalib_dqm_sourceclient-live_cfg::algo, MultiTrackValidatorBase::associators, DQMStore::IBooker::cd(), TrackerOfflineValidation_Dqm_cff::dirName, dirName_, histoProducerAlgo_, edm::InputTag::instance(), edm::InputTag::label(), MultiTrackValidatorBase::label, edm::InputTag::process(), python.rootplot.root2matplotlib::replace(), and DQMStore::IBooker::setCurrentFolder().

64  {
65  {
66  ibook.cd();
67  ibook.setCurrentFolder(dirName_ + "simulation");
68 
69  //Booking histograms concerning with simulated tracks
70  histoProducerAlgo_->bookSimHistos(ibook);
71  }
72 
73  for (unsigned int ww=0;ww<associators.size();ww++){
74  for (unsigned int www=0;www<label.size();www++){
75 
76  ibook.cd();
77  InputTag algo = label[www];
78  string dirName=dirName_;
79  if (algo.process()!="")
80  dirName+=algo.process()+"_";
81  if(algo.label()!="")
82  dirName+=algo.label()+"_";
83  if(algo.instance()!="")
84  dirName+=algo.instance()+"_";
85  // if (dirName.find("Seeds")<dirName.length()){
86  // dirName.replace(dirName.find("Seeds"),6,"");
87  // }
88  string assoc= associators[ww].label();;
89  if (assoc.find("Track")<assoc.length()){
90  assoc.replace(assoc.find("Track"),5,"");
91  }
92  dirName+=assoc;
93  std::replace(dirName.begin(), dirName.end(), ':', '_');
94 
95  ibook.setCurrentFolder(dirName.c_str());
96 
97  //Booking histograms concerning with reconstructed tracks
98  histoProducerAlgo_->bookSimTrackHistos(ibook);
99  histoProducerAlgo_->bookRecoHistos(ibook);
100  }//end loop www
101  }// end loop ww
102 }
std::vector< edm::InputTag > associators
void cd(void)
Definition: DQMStore.cc:268
std::vector< edm::InputTag > label
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:276
std::string const & label() const
Definition: InputTag.h:36
std::string const & process() const
Definition: InputTag.h:40
std::string const & instance() const
Definition: InputTag.h:37
std::unique_ptr< MTVHistoProducerAlgoForTracker > histoProducerAlgo_

Member Data Documentation

std::vector<edm::EDGetTokenT<reco::TrackToTrackingParticleAssociator> > TrackerSeedValidator::associatorTokens
private

Definition at line 33 of file TrackerSeedValidator.h.

Referenced by analyze(), and TrackerSeedValidator().

std::string TrackerSeedValidator::builderName
private

Definition at line 35 of file TrackerSeedValidator.h.

Referenced by analyze(), and TrackerSeedValidator().

CosmicTrackingParticleSelector TrackerSeedValidator::cosmictpSelector
private

Definition at line 42 of file TrackerSeedValidator.h.

std::string TrackerSeedValidator::dirName_
private

Definition at line 37 of file TrackerSeedValidator.h.

Referenced by bookHistograms(), and TrackerSeedValidator().

std::unique_ptr<MTVHistoProducerAlgoForTracker> TrackerSeedValidator::histoProducerAlgo_
private

Definition at line 43 of file TrackerSeedValidator.h.

Referenced by analyze(), and bookHistograms().

edm::ESHandle<TransientTrackingRecHitBuilder> TrackerSeedValidator::theTTRHBuilder
private

Definition at line 36 of file TrackerSeedValidator.h.

Referenced by analyze().

TrackingParticleSelector TrackerSeedValidator::tpSelector
private

Definition at line 41 of file TrackerSeedValidator.h.

Referenced by analyze(), and TrackerSeedValidator().