Method called once per event.
107 edm::LogInfo(
"TrackValidator") <<
"\n====================================================" <<
"\n"
108 <<
"Analyzing new event" <<
"\n"
109 <<
"====================================================\n" <<
"\n";
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;}
136 event.getByToken(
bsSrc,recoBeamSpotHandle);
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];
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));
168 for (
unsigned int ww=0;ww<
associators.size();ww++){
173 for (
unsigned int www=0;www<
label.size();www++){
175 <<
label[www].process()<<
":"
176 <<
label[www].label()<<
":"
177 <<
label[www].instance()<<
" with "
184 if (seedCollection->size()==0) {
185 edm::LogInfo(
"TrackValidator") <<
"SeedCollection size = 0!" ;
190 LogTrace(
"TrackValidator") <<
"Calling associateRecoToSim method" <<
"\n";
193 LogTrace(
"TrackValidator") <<
"Calling associateSimToReco method" <<
"\n";
201 edm::LogVerbatim(
"TrackValidator") <<
"\n# of TrackingParticles: " << tPCeff.size() <<
"\n";
209 if (tp->charge()==0)
continue;
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());
222 if(tp->eventId().bunchCrossing() == 0) {
227 histoProducerAlgo_->fill_generic_simTrack_histos(momentumTP,vertexTP, tp->eventId().bunchCrossing());
230 std::vector<std::pair<edm::RefToBase<TrajectorySeed>,
double> > rt;
231 if(simRecColl.
find(tp) != simRecColl.
end()){
235 matchedSeedPointer = rt.begin()->first.get();
237 <<
" with pt=" <<
sqrt(tp->momentum().perp2())
238 <<
" associated with quality:" << rt.begin()->second <<
"\n";
242 <<
" with pt=" <<
sqrt(tp->momentum().perp2())
243 <<
" NOT associated to any TrajectorySeed" <<
"\n";
246 int nSimHits = tp->numberOfTrackerHits();
247 int nSimLayers = nLayers_tPCeff[tp];
248 int nSimPixelLayers = nPixelLayers_tPCeff[tp];
249 int nSimStripMonoAndStereoLayers = nStripMonoAndStereoLayers_tPCeff[tp];
253 if (matchedSeedPointer) {
258 if(!(tsAtClosestApproachSeed.isValid())){
259 edm::LogVerbatim(
"SeedValidator")<<
"TrajectoryStateClosestToBeamLine not valid";
263 tsAtClosestApproachSeed.trackStateAtPCA().position().y(),
264 tsAtClosestApproachSeed.trackStateAtPCA().position().z());
266 tsAtClosestApproachSeed.trackStateAtPCA().momentum().y(),
267 tsAtClosestApproachSeed.trackStateAtPCA().momentum().z());
270 matchedTrackPointer =
new reco::Track(0.,0., vSeed1, pSeed, 1, seedPerigeeErrors.covarianceMatrix());
275 histoProducerAlgo_->fill_recoAssociated_simTrack_histos(w,*tp,tp->momentum(),tp->vertex(),dxySim,dzSim,0,0,nSimHits,nSimLayers,nSimPixelLayers,nSimStripMonoAndStereoLayers,
279 if (matchedTrackPointer) asts++;
290 <<
label[www].process()<<
":"
291 <<
label[www].label()<<
":"
292 <<
label[www].instance()
293 <<
": " << seedCollection->size() <<
"\n";
307 if(!(tsAtClosestApproachSeed.isValid())){
308 edm::LogVerbatim(
"SeedValidator")<<
"TrajectoryStateClosestToBeamLine not valid";
312 tsAtClosestApproachSeed.trackStateAtPCA().position().y(),
313 tsAtClosestApproachSeed.trackStateAtPCA().position().z());
315 tsAtClosestApproachSeed.trackStateAtPCA().momentum().y(),
316 tsAtClosestApproachSeed.trackStateAtPCA().momentum().z());
321 reco::Track* trackFromSeed =
new reco::Track(0.,0., vSeed1, pSeed, 1, seedPerigeeErrors.covarianceMatrix());
324 bool isSigSimMatched(
false);
325 bool isSimMatched(
false);
326 bool isChargeMatched(
true);
327 int numAssocSeeds = 0;
329 double sharedFraction = 0.;
330 std::vector<std::pair<TrackingParticleRef, double> > tp;
332 tp = recSimColl[
seed];
335 nSimHits = tp[0].first->numberOfTrackerHits();
336 sharedFraction = tp[0].second;
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();
344 for (
unsigned int tp_ite=0;tp_ite<tp.size();++tp_ite){
347 isSigSimMatched =
true;
354 edm::LogVerbatim(
"SeedValidator") <<
"TrajectorySeed #" << rT <<
" associated with quality:" << tp.begin()->second <<
"\n";
357 edm::LogVerbatim(
"SeedValidator") <<
"TrajectorySeed #" << rT <<
" NOT associated to any TrackingParticle" <<
"\n";
362 isChargeMatched, numAssocSeeds,
364 nSimHits, sharedFraction,
dR);
368 if (tp.size()==0)
continue;
410 histoProducerAlgo_->fill_ResoAndPull_recoTrack_histos(w,momentumTP,vertexTP,tpr->charge(),
415 LogTrace(
"SeedValidator") <<
"exception found: " << e.
what() <<
"\n";
422 <<
"Total Associated (simToReco): " << ats <<
"\n"
423 <<
"Total Reconstructed: " << rT <<
"\n"
424 <<
"Total Associated (recoToSim): " << at <<
"\n"
425 <<
"Total Fakes: " << rT-at <<
"\n";
virtual char const * what() const
std::vector< edm::InputTag > associators
int event() const
get the contents of the subdetector field (should be protected?)
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)
const_iterator find(const key_type &k) const
find element with specified reference key
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
int bunchCrossing() const
get the detector field from this detid
FreeTrajectoryState const * freeState(bool withErrors=true) const
Cos< T >::type cos(const T &t)
math::XYZPoint Point
point in the space
edm::ESHandle< TransientTrackingRecHitBuilder > theTTRHBuilder
std::shared_ptr< TrackingRecHit const > RecHitPointer
std::string parametersDefiner
PTrajectoryStateOnDet const & startingState() const
T const * product() const
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
T const * product() 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
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
std::unique_ptr< MTVHistoProducerAlgoForTracker > histoProducerAlgo_
bool appendHits(const C &c, const TrackerTopology &ttopo)
append hit patterns from vector of hit references
tuple size
Write out results.
std::vector< edm::EDGetTokenT< reco::TrackToTrackingParticleAssociator > > associatorTokens