Method called before the event loop.
234 using namespace reco;
236 edm::LogInfo(
"MuonTrackValidator") <<
"\n====================================================" <<
"\n" 237 <<
"Analyzing new event" <<
"\n" 238 <<
"====================================================\n" <<
"\n";
241 std::unique_ptr<ParametersDefinerForTP> Cosmic_parametersDefinerTP;
251 Cosmic_parametersDefinerTP = _Cosmic_parametersDefinerTP->
clone();
256 Cosmic_parametersDefinerTP->initEvent(simHitsTPAssoc);
275 std::vector<const reco::TrackToTrackingParticleAssociator*>
associator;
280 associator.push_back( theAssociator.
product() );
285 for (
unsigned int ww=0;ww<
associators.size();ww++){
286 for (
unsigned int www=0;www<
label.size();www++){
294 unsigned int trackCollectionSize = 0;
305 trackCollectionSize = trackCollection->size();
310 <<
label[www].process()<<
":" 311 <<
label[www].label()<<
":" 312 <<
label[www].instance()<<
" with " 315 LogTrace(
"MuonTrackValidator") <<
"Calling associateRecoToSim method" <<
"\n";
316 recSimColl=associator[ww]->associateRecoToSim(trackCollection,
318 LogTrace(
"MuonTrackValidator") <<
"Calling associateSimToReco method" <<
"\n";
319 simRecColl=associator[ww]->associateSimToReco(trackCollection,
324 <<
label[www].process()<<
":" 325 <<
label[www].label()<<
":" 326 <<
label[www].instance()<<
" with " 333 simRecColl= *(simtorecoCollectionH.
product());
337 recSimColl= *(recotosimCollectionH.
product());
346 edm::LogVerbatim(
"MuonTrackValidator") <<
"\n# of TrackingParticles: " << tPCeff.size() <<
"\n";
350 bool TP_is_matched =
false;
352 bool Quality05 =
false;
353 bool Quality075 =
false;
367 LogTrace(
"MuonTrackValidator") <<
"TrackingParticle "<<
i;
381 momentumTP = Cosmic_parametersDefinerTP->momentum(event,setup,tpr);
382 vertexTP = Cosmic_parametersDefinerTP->vertex(event,setup,tpr);
386 edm::LogVerbatim(
"MuonTrackValidator") <<
"--------------------Selected TrackingParticle #"<<tpr.key();
387 edm::LogVerbatim(
"MuonTrackValidator") <<
"momentumTP: pt = "<<
sqrt(momentumTP.perp2())<<
", pz = "<<momentumTP.z()
388 <<
", \t vertexTP: radius = "<<
sqrt(vertexTP.perp2())<<
", z = "<<vertexTP.z() <<
"\n";
395 std::vector<std::pair<RefToBase<Track>,
double> > rt;
396 if(simRecColl.
find(tpr) != simRecColl.
end()){
397 rt = (std::vector<std::pair<RefToBase<Track>,
double> >) simRecColl[tpr];
400 edm::LogVerbatim(
"MuonTrackValidator")<<
"-----------------------------associated Track #"<<assoc_recoTrack.
key();
401 TP_is_matched =
true;
403 quality = rt.begin()->second;
405 <<
" with pt=" <<
sqrt(momentumTP.perp2())
406 <<
" associated with quality:" << quality <<
"\n";
408 if (quality > 0.75) {
412 else if (quality > 0.5) {
419 <<
"TrackingParticle #" << tpr.key()
420 <<
" with pt,eta,phi: " 421 <<
sqrt(momentumTP.perp2()) <<
" , " 422 << momentumTP.eta() <<
" , " 423 << momentumTP.phi() <<
" , " 424 <<
" NOT associated to any reco::Track" <<
"\n";
439 else if (Quality05) {
459 else if (Quality05) {
479 else if (Quality05) {
529 nSimHits= tpr.get()->numberOfHits();
532 nSimHits= tpr.get()->numberOfHits() - tpr.get()->numberOfTrackerHits();
535 nSimHits=tpr.get()->numberOfTrackerHits();
539 edm::LogVerbatim(
"MuonTrackValidator") <<
"\t N simhits = "<< nSimHits<<
"\n";
556 <<
label[www].process()<<
":" 557 <<
label[www].label()<<
":" 558 <<
label[www].instance()
559 <<
": " << trackCollectionSize <<
"\n";
563 bool Track_is_matched =
false;
567 std::vector<std::pair<TrackingParticleRef, double> > tp;
572 edm::LogVerbatim(
"MuonTrackValidator")<<
"----------------------------------------Track #"<<
track.key();
575 tp = recSimColl[
track];
576 if (tp.size() != 0) {
577 tpr = tp.begin()->first;
579 if(simRecColl.
find(tpr) != simRecColl.
end()) {
580 std::vector<std::pair<RefToBase<Track>,
double> > track_checkback = simRecColl[tpr];
582 assoc_track_checkback = track_checkback.begin()->first;
584 if ( assoc_track_checkback.
key() ==
track.key() ) {
585 edm::LogVerbatim(
"MuonTrackValidator")<<
"------------------associated TrackingParticle #"<<tpr.
key();
586 Track_is_matched =
true;
588 double Purity = tp.begin()->second;
589 double Quality = track_checkback.begin()->second;
591 <<
" associated with quality:" << Purity <<
"\n";
598 if (!Track_is_matched)
600 <<
"reco::Track #" <<
track.key() <<
" with pt=" <<
track->pt() <<
" NOT associated to any TrackingParticle" <<
"\n";
605 tp = recSimColl[
track];
607 Track_is_matched =
true;
608 tpr = tp.begin()->first;
611 <<
" associated with quality:" << tp.begin()->second <<
"\n";
615 <<
" NOT associated to any TrackingParticle" <<
"\n";
624 if (Track_is_matched) {
634 if (Track_is_matched) {
644 if (Track_is_matched) {
654 if (Track_is_matched) {
664 if (Track_is_matched) {
684 if (! (Track_is_matched &&
tpSelector(*tpp)) )
continue;
686 momentumTP = Lhc_parametersDefinerTP->
momentum(event,setup,tpr) ;
687 vertexTP = Lhc_parametersDefinerTP->
vertex(event,setup,tpr);
692 if (! (Track_is_matched &&
cosmictpSelector(tpr,&bs,event,setup)) )
continue;
694 momentumTP = Cosmic_parametersDefinerTP->momentum(event,setup,tpr) ;
695 vertexTP = Cosmic_parametersDefinerTP->vertex(event,setup,tpr);
701 double assocChi2 = -tp.begin()->second;
705 else if (
associators[ww]==
"trackAssociatorByHits"){
706 double fraction = tp.begin()->second;
719 double ptSim =
sqrt(momentumTP.perp2());
720 double qoverpSim = tpr->charge()/
sqrt(momentumTP.x()*momentumTP.x()+momentumTP.y()*momentumTP.y()+momentumTP.z()*momentumTP.z());
721 double thetaSim = momentumTP.theta();
722 double lambdaSim =
M_PI/2-momentumTP.theta();
723 double phiSim = momentumTP.phi();
731 double qoverpErrorRec(0);
733 double ptErrorRec(0);
735 double lambdaErrorRec(0);
737 double phiErrorRec(0);
742 gsfTrack =
dynamic_cast<const GsfTrack*
>(&(*track));
743 if (gsfTrack==0)
edm::LogInfo(
"MuonTrackValidator") <<
"Trying to access mode for a non-GsfTrack";
748 getRecoMomentum(*gsfTrack, ptRec, ptErrorRec, qoverpRec, qoverpErrorRec,
749 lambdaRec,lambdaErrorRec, phiRec, phiErrorRec);
755 lambdaRec,lambdaErrorRec, phiRec, phiErrorRec);
758 double thetaRec =
track->theta();
759 double ptError = ptErrorRec;
760 double ptres = ptRec - ptSim;
761 double etares =
track->eta()-momentumTP.Eta();
765 double qoverpPull=(qoverpRec-qoverpSim)/qoverpErrorRec;
766 double thetaPull=(lambdaRec-lambdaSim)/lambdaErrorRec;
767 double phiDiff = phiRec - phiSim;
769 if (phiDiff >0.) phiDiff = phiDiff - 2.*
M_PI;
770 else phiDiff = phiDiff + 2.*
M_PI;
772 double phiPull=phiDiff/phiErrorRec;
773 double dxyPull=(dxyRec-dxySim)/
track->dxyError();
774 double dzPull=(dzRec-dzSim)/
track->dzError();
776 double contrib_Qoverp = ((qoverpRec-qoverpSim)/qoverpErrorRec)*((qoverpRec-qoverpSim)/qoverpErrorRec)/5;
777 double contrib_dxy = ((dxyRec-dxySim)/
track->dxyError())*((dxyRec-dxySim)/
track->dxyError())/5;
778 double contrib_dz = ((dzRec-dzSim)/
track->dzError())*((dzRec-dzSim)/
track->dzError())/5;
779 double contrib_theta = ((lambdaRec-lambdaSim)/lambdaErrorRec)*((lambdaRec-lambdaSim)/lambdaErrorRec)/5;
780 double contrib_phi = (phiDiff/phiErrorRec)*(phiDiff/phiErrorRec)/5;
782 edm::LogVerbatim(
"MuonTrackValidator") <<
"assocChi2=" << tp.begin()->second <<
"\n" 784 <<
"ptREC=" << ptRec <<
"\n" 785 <<
"etaREC=" <<
track->eta() <<
"\n" 786 <<
"qoverpREC=" << qoverpRec <<
"\n" 787 <<
"dxyREC=" << dxyRec <<
"\n" 788 <<
"dzREC=" << dzRec <<
"\n" 789 <<
"thetaREC=" <<
track->theta() <<
"\n" 790 <<
"phiREC=" << phiRec <<
"\n" 792 <<
"qoverpError()=" << qoverpErrorRec <<
"\n" 793 <<
"dxyError()=" <<
track->dxyError() <<
"\n" 794 <<
"dzError()=" <<
track->dzError() <<
"\n" 795 <<
"thetaError()=" << lambdaErrorRec <<
"\n" 796 <<
"phiError()=" << phiErrorRec <<
"\n" 798 <<
"ptSIM=" << ptSim <<
"\n" 799 <<
"etaSIM=" << momentumTP.Eta() <<
"\n" 800 <<
"qoverpSIM=" << qoverpSim <<
"\n" 801 <<
"dxySIM=" << dxySim <<
"\n" 802 <<
"dzSIM=" << dzSim <<
"\n" 803 <<
"thetaSIM=" <<
M_PI/2-lambdaSim <<
"\n" 804 <<
"phiSIM=" << phiSim <<
"\n" 806 <<
"contrib_Qoverp=" << contrib_Qoverp <<
"\n" 807 <<
"contrib_dxy=" << contrib_dxy <<
"\n" 808 <<
"contrib_dz=" << contrib_dz <<
"\n" 809 <<
"contrib_theta=" << contrib_theta <<
"\n" 810 <<
"contrib_phi=" << contrib_phi <<
"\n" 812 <<
"chi2PULL="<<contrib_Qoverp+contrib_dxy+contrib_dz+contrib_theta+contrib_phi<<
"\n";
820 h_pt[
w]->Fill(ptres/ptError);
868 nSimHits= tpr.
get()->numberOfHits();
871 nSimHits= tpr.
get()->numberOfHits() - tpr.
get()->numberOfTrackerHits();
874 nSimHits=tpr.
get()->numberOfTrackerHits();
884 <<
"Total Associated (simToReco): " << ats <<
"\n" 885 <<
"Total Reconstructed: " << rT <<
"\n" 886 <<
"Total Associated (recoToSim): " << at <<
"\n" 887 <<
"Total Fakes: " << rT-at <<
"\n";
std::vector< MonitorElement * > nrecHit_vs_nsimHit_sim2rec
std::vector< std::vector< int > > totASS_zpos
std::vector< MonitorElement * > h_PurityVsQuality
std::vector< std::vector< int > > totASSeta_Quality05
std::vector< std::vector< int > > totREC_phi
std::vector< MonitorElement * > etares_vs_eta
std::vector< MonitorElement * > nrecHit_vs_nsimHit_rec2sim
std::vector< MonitorElement * > ptres_vs_phi
std::vector< std::vector< int > > totASS2_hit
std::vector< edm::EDGetTokenT< edm::View< reco::Track > > > track_Collection_Token
std::vector< std::vector< int > > totRECpT
std::vector< TrackingParticle > TrackingParticleCollection
std::vector< std::vector< int > > totREC_dz
Vector momentum() const
spatial momentum vector
std::vector< MonitorElement * > nrec_vs_nsim
const_iterator end() const
last iterator over the map (read only)
std::vector< MonitorElement * > h_pullDz
std::vector< MonitorElement * > h_etaSIM
bool ignoremissingtkcollection_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
std::vector< MonitorElement * > h_fakes
std::vector< MonitorElement * > ptres_vs_eta
std::vector< MonitorElement * > cotThetares_vs_eta
virtual double getEta(double eta)
std::vector< MonitorElement * > h_eta
std::vector< MonitorElement * > phimean_vs_eta_phi
Sin< T >::type sin(const T &t)
std::vector< std::vector< int > > totASS_dz
const_iterator find(const key_type &k) const
find element with specified reference key
std::vector< std::vector< double > > etaintervals
std::vector< MonitorElement * > h_pt
std::vector< MonitorElement * > phires_vs_pt
std::vector< MonitorElement * > h_pullQoverp
std::string parametersDefiner
std::vector< MonitorElement * > h_assochi2_prob
std::vector< std::vector< int > > totSIM_zpos
std::vector< std::vector< int > > totASS2_dz
std::vector< MonitorElement * > cotThetares_vs_pt
std::vector< MonitorElement * > dxyres_vs_eta
std::vector< std::vector< int > > totASS_phi_Quality05
std::vector< MonitorElement * > dzres_vs_pt
key_type key() const
Accessor for product key.
std::vector< MonitorElement * > h_tracks
std::vector< MonitorElement * > dzres_vs_eta
void getRecoMomentum(const reco::Track &track, double &pt, double &ptError, double &qoverp, double &qoverpError, double &lambda, double &lambdaError, double &phi, double &phiError) const
retrieval of reconstructed momentum components from reco::Track (== mean values for GSF) ...
std::vector< std::vector< double > > dxyintervals
std::vector< MonitorElement * > nDThits_vs_eta
std::vector< std::vector< int > > totASS_phi
std::vector< MonitorElement * > thetapull_vs_phi
std::vector< std::vector< int > > totASS_dxy
edm::EDGetTokenT< SimHitTPAssociationProducer::SimHitTPAssociationList > _simHitTpMapTag
std::vector< MonitorElement * > h_assochi2
std::vector< MonitorElement * > chi2_vs_phi
std::vector< std::vector< int > > totSIM_dxy
std::vector< MonitorElement * > chi2_vs_nhits
math::XYZPointD Point
point in the space
std::vector< std::vector< int > > totASSeta_Quality075
std::vector< MonitorElement * > nhits_vs_eta
std::vector< MonitorElement * > phires_vs_phi
virtual double getPt(double pt)
CosmicTrackingParticleSelector cosmictpSelector
std::vector< MonitorElement * > nhits_vs_phi
std::vector< std::vector< int > > totASS2pT
std::vector< MonitorElement * > h_vertposSIM
edm::EDGetTokenT< TrackingParticleCollection > tp_fake_Token
std::vector< MonitorElement * > dxyres_vs_pt
std::vector< edm::InputTag > label
std::vector< MonitorElement * > h_assocSharedHit
std::vector< MonitorElement * > h_nchi2
std::vector< std::vector< double > > pTintervals
auto dz(const T_Vertex &vertex, const T_Momentum &momentum, const T_Point &point)
void post_insert()
post insert action
std::vector< std::vector< int > > totASS2eta
std::vector< std::vector< int > > totSIMpT
std::vector< std::vector< int > > totREC_dxy
std::vector< MonitorElement * > h_pullPhi
std::vector< std::vector< int > > totSIM_hit
std::vector< MonitorElement * > h_nchi2_prob
std::vector< MonitorElement * > ptpull_vs_eta
Cos< T >::type cos(const T &t)
std::vector< std::vector< int > > totASSpT
std::vector< MonitorElement * > dxypull_vs_eta
Abs< T >::type abs(const T &t)
std::vector< std::vector< int > > totASS_phi_Quality075
virtual TrackingParticle::Vector momentum(const edm::Event &iEvent, const edm::EventSetup &iSetup, const Charge ch, const Point &vtx, const LorentzVector &lv) const
void initEvent(edm::Handle< SimHitTPAssociationProducer::SimHitTPAssociationList > simHitsTPAssocToSet) const
std::vector< MonitorElement * > nME0hits_vs_eta
unsigned short numberOfValidHits() const
number of valid hits found
std::vector< MonitorElement * > h_pullTheta
std::vector< std::vector< int > > totSIM_vertpos
std::vector< std::vector< int > > totASSpT_Quality05
std::vector< std::vector< int > > totREC_hit
T const * get() const
Returns C++ pointer to the item.
std::vector< MonitorElement * > phipull_vs_eta
std::vector< std::vector< int > > totSIMeta
std::vector< std::vector< int > > totASS2_dxy
std::vector< MonitorElement * > thetapull_vs_eta
std::vector< MonitorElement * > h_charge
std::vector< MonitorElement * > ptmean_vs_eta_phi
std::vector< std::vector< int > > totASS2_phi
std::vector< std::vector< double > > phiintervals
edm::EDGetTokenT< reco::RecoToSimCollection > recoToSimCollection_Token
edm::EDGetTokenT< reco::SimToRecoCollection > simToRecoCollection_Token
std::vector< std::vector< int > > totASSpT_Quality075
std::vector< MonitorElement * > h_pullDxy
T const * product() const
std::vector< MonitorElement * > h_tracksSIM
std::vector< MonitorElement * > chi2_vs_eta
TrackingParticleSelector tpSelector
std::vector< std::vector< int > > totSIM_phi
Point vertex() const
Parent vertex position.
std::vector< MonitorElement * > h_hits
std::vector< MonitorElement * > h_losthits
std::vector< MonitorElement * > ptpull_vs_phi
std::vector< std::vector< double > > tmp
std::unique_ptr< ParametersDefinerForTP > clone() const override
auto dxy(const T_Vertex &vertex, const T_Momentum &momentum, const T_Point &point)
edm::InputTag associatormap
std::vector< std::vector< int > > totASSeta
std::vector< MonitorElement * > ptres_vs_pt
std::vector< std::vector< int > > totRECeta
std::vector< std::vector< double > > vertposintervals
std::vector< std::vector< double > > dzintervals
std::vector< MonitorElement * > phires_vs_eta
std::vector< MonitorElement * > h_ptSIM
Monte Carlo truth information used for tracking validation.
std::vector< std::vector< double > > zposintervals
const Point & position() const
position
std::vector< MonitorElement * > h_assocFraction
math::XYZVectorD Vector
point in the space
std::vector< std::vector< int > > totSIM_dz
std::vector< std::string > associators
bool BiDirectional_RecoToSim_association
std::vector< MonitorElement * > nlosthits_vs_eta
std::vector< MonitorElement * > dzpull_vs_eta
edm::EDGetTokenT< TrackingParticleCollection > tp_effic_Token
std::vector< MonitorElement * > nRPChits_vs_eta
std::vector< std::vector< int > > totASS_vertpos
std::vector< std::vector< int > > totASS_hit
std::vector< MonitorElement * > nGEMhits_vs_eta
std::vector< MonitorElement * > nCSChits_vs_eta
virtual TrackingParticle::Point vertex(const edm::Event &iEvent, const edm::EventSetup &iSetup, const Charge ch, const Point &vtx, const LorentzVector &lv) const
std::vector< MonitorElement * > phipull_vs_phi
edm::EDGetTokenT< reco::BeamSpot > bsSrc_Token