54 for (
int i=0;
i<2;
i++){
57 for (
int j=0;
j<2;
j++){
87 file_ =
new TFile(rootfile_.c_str(),
"RECREATE");
90 tree_eff =
new TTree(
"EffTracks",
"Efficiency Tracks Tree");
92 tree_eff->Branch(
"Run",&
irun,
"irun/i");
93 tree_eff->Branch(
"Event",&
ievt,
"ievt/i");
96 tree_eff->Branch(
"TrackID",&
trackType,
"trackType/i");
97 tree_eff->Branch(
"pt",&
pt,
"pt/F");
98 tree_eff->Branch(
"eta",&
eta,
"eta/F");
99 tree_eff->Branch(
"CotTheta",&
cottheta,
"cottheta/F");
100 tree_eff->Branch(
"phi",&
phi,
"phi/F");
101 tree_eff->Branch(
"d0",&
d0,
"d0/F");
102 tree_eff->Branch(
"z0",&
z0,
"z0/F");
103 tree_eff->Branch(
"nhit",&
nhit,
"nhit/i");
106 tree_eff->Branch(
"recpt",&
recpt,
"recpt/F");
107 tree_eff->Branch(
"receta",&
receta,
"receta/F");
108 tree_eff->Branch(
"CotRecTheta",&
reccottheta,
"reccottheta/F");
109 tree_eff->Branch(
"recphi",&
recphi,
"recphi/F");
110 tree_eff->Branch(
"recd0",&
recd0,
"recd0/F");
111 tree_eff->Branch(
"recz0",&
recz0,
"recz0/F");
112 tree_eff->Branch(
"nAssoc",&
nAssoc,
"nAssoc/i");
113 tree_eff->Branch(
"recnhit",&
recnhit,
"recnhit/i");
114 tree_eff->Branch(
"CHISQ",&
recchiq,
"recchiq/F");
116 tree_eff->Branch(
"reseta",&
reseta,
"reseta/F");
117 tree_eff->Branch(
"respt",&
respt,
"respt/F");
118 tree_eff->Branch(
"resd0",&
resd0,
"resd0/F");
119 tree_eff->Branch(
"resz0",&
resz0,
"resz0/F");
120 tree_eff->Branch(
"resphi",&
resphi,
"resphi/F");
121 tree_eff->Branch(
"rescottheta",&
rescottheta,
"rescottheta/F");
122 tree_eff->Branch(
"eff",&
eff,
"eff/F");
125 tree_eff->Branch(
"mzmu",&
mzmu,
"mzmu/F");
126 tree_eff->Branch(
"ptzmu",&
ptzmu,
"ptzmu/F");
127 tree_eff->Branch(
"pLzmu",&
pLzmu,
"pLzmu/F");
128 tree_eff->Branch(
"enezmu",&
enezmu,
"enezmu/F");
129 tree_eff->Branch(
"etazmu",&
etazmu,
"etazmu/F");
130 tree_eff->Branch(
"thetazmu",&
thetazmu,
"thetazmu/F");
131 tree_eff->Branch(
"phizmu",&
phizmu,
"phizmu/F");
132 tree_eff->Branch(
"yzmu",&
yzmu,
"yzmu/F");
133 tree_eff->Branch(
"mxptmu",&
mxptmu,
"mxptmu/F");
134 tree_eff->Branch(
"minptmu",&
minptmu,
"minptmu/F");
136 tree_eff->Branch(
"recmzmu",&
recmzmu,
"recmzmu/F");
137 tree_eff->Branch(
"recptzmu",&
recptzmu,
"recptzmu/F");
138 tree_eff->Branch(
"recpLzmu",&
recpLzmu,
"recpLzmu/F");
139 tree_eff->Branch(
"recenezmu",&
recenezmu,
"recenezmu/F");
140 tree_eff->Branch(
"recetazmu",&
recetazmu,
"recetazmu/F");
141 tree_eff->Branch(
"recthetazmu",&
recthetazmu,
"recthetazmu/F");
142 tree_eff->Branch(
"recphizmu",&
recphizmu,
"recphizmu/F");
143 tree_eff->Branch(
"recyzmu",&
recyzmu,
"recyzmu/F");
144 tree_eff->Branch(
"recmxptmu",&
recmxptmu,
"recmxptmu/F");
145 tree_eff->Branch(
"recminptmu",&
recminptmu,
"recminptmu/F");
150 tree_eff->Branch(
"chi2Associator",&
recchiq,
"recchiq/F");
154 tree_fake =
new TTree(
"FakeTracks",
"Fake Rate Tracks Tree");
221 <<
" events" << std::endl;
242 std::vector<const reco::TrackToTrackingParticleAssociator*> associatore;
248 associatore.push_back( theAssociator.
product() );
252 edm::LogInfo(
"Tracker Misalignment Validation") <<
"\n Starting!";
256 std::vector<int> indmu;
261 bool accepted =
false;
262 bool foundmuons=
false;
263 HepMC::GenEvent * myGenEvent =
new HepMC::GenEvent(*(evt->GetEvent()));
265 for ( HepMC::GenEvent::particle_iterator
p = myGenEvent->particles_begin();
p != myGenEvent->particles_end(); ++
p ) {
266 if ( !accepted && ( (*p)->pdg_id() == 23 ) && (*p)->status() == 3 ) {
268 for( HepMC::GenVertex::particle_iterator aDaughter=(*p)->end_vertex()->particles_begin(HepMC::descendants); aDaughter !=(*p)->end_vertex()->particles_end(HepMC::descendants);aDaughter++){
269 if (
abs((*aDaughter)->pdg_id())==13) {
271 if ((*aDaughter)->status()!=1 ) {
272 for( HepMC::GenVertex::particle_iterator byaDaughter=(*aDaughter)->end_vertex()->particles_begin(HepMC::descendants); byaDaughter !=(*aDaughter)->end_vertex()->particles_end(HepMC::descendants);byaDaughter++){
273 if ((*byaDaughter)->status()==1 &&
abs((*byaDaughter)->pdg_id())==13) {
274 indmu.push_back((*byaDaughter)->barcode());
275 std::cout <<
"Stable muon from Z with charge " << (*byaDaughter)->pdg_id() <<
" and index "<< (*byaDaughter)->barcode() << std::endl;
280 indmu.push_back((*aDaughter)->barcode());
281 std::cout <<
"Stable muon from Z with charge " << (*aDaughter)->pdg_id() <<
" and index "<< (*aDaughter)->barcode() << std::endl;
286 std::cout <<
"No muons from Z ...skip event" << std::endl;
292 std::cout <<
"No Z particles in the event ...skip event" << std::endl;
305 auto testGeomDet = trackerGeometry->detsTOB().front();
306 std::cout << testGeomDet->position() << std::endl;
319 for (
int i=0;
i<2;
i++){
320 for (
int j=0;
j<2;
j++){
346 for (
unsigned int ww=0;ww<
associators.size();ww++){
359 LogTrace(
"TrackValidator") <<
"Calling associateRecoToSim method" <<
"\n";
363 LogTrace(
"TrackValidator") <<
"Calling associateSimToReco method" <<
"\n";
375 std::cout <<
"Computing Efficiency" << std::endl;
377 edm::LogVerbatim(
"TrackValidator") <<
"\n# of TrackingParticles (before cuts): " << tPCeff.size() <<
"\n";
395 if (tp->charge()==0)
continue;
401 const SimTrack * simulatedTrack = &(*tp->g4Track_begin());
406 ftsAtProduction(
GlobalPoint(tp->vertex().x(),tp->vertex().y(),tp->vertex().z()),
426 std::cout <<
" TRACCIA SIM DI MUONI " << std::endl;
436 nhit=tp->matchedHit();
439 std::cout <<
"3) Before assoc: SimTrack of type = " << simulatedTrack->
type()
440 <<
" ,at eta = " <<
eta
441 <<
" ,with pt at vertex = " << simulatedTrack->
momentum().pt() <<
" GeV/c"
449 std::cout <<
" TRACK sim of muons from Z " << std::endl;
470 std::vector<std::pair<edm::RefToBase<reco::Track>,
double> > rt;
471 if(simRecColl.
find(tp) != simRecColl.
end()){
486 edm::LogVerbatim(
"TrackValidator") <<
"TrackingParticle #" << st <<
" with pt=" << t->
pt()
487 <<
" associated with quality:" << rt.begin()->second <<
"\n";
488 std::cout <<
"Reconstructed Track:" << t->
pt()<< std::endl;
490 std::cout <<
"\timpact parameter:d0: " << t->
d0()<< std::endl;
491 std::cout <<
"\timpact parameter:z0: " << t->
dz()<< std::endl;
492 std::cout <<
"\tAzimuthal angle of point of closest approach:" << t->
phi()<< std::endl;
510 std::cout <<
"5) After call to associator: the best match has "
512 <<
recchiq <<
", pt at vertex = "
513 <<
recpt <<
" GeV/c, "
514 <<
", recd0 = " <<
recd0
515 <<
", recz0= " <<
recz0
528 <<
" ,d0 residual=" <<
resd0
529 <<
" ,z0 residual=" <<
resz0
530 <<
" with eff=" <<
eff << std::endl;
535 std::cout <<
" TRACCIA RECO DI MUONI " << std::endl;
541 std::cout <<
" TRACCIA RECO DI ELETTRONI " << std::endl;
565 <<
" with pt=" <<
sqrt(tp->momentum().perp2())
566 <<
" NOT associated to any reco::Track" <<
"\n";
591 if (countpart[0]==2 &&
flag==0) {
593 (ene[0][0]+ene[0][1])*(ene[0][0]+ene[0][1])-
594 (px[0][0]+px[0][1])*(px[0][0]+px[0][1])-
595 (py[0][0]+py[0][1])*(py[0][0]+py[0][1])-
596 (pz[0][0]+pz[0][1])*(pz[0][0]+pz[0][1])
600 (px[0][0]+px[0][1])*(px[0][0]+px[0][1])+
601 (py[0][0]+py[0][1])*(py[0][0]+py[0][1])
604 pLzmu=pz[0][0]+pz[0][1];
605 enezmu=ene[0][0]+ene[0][1];
606 phizmu=atan2((py[0][0]+py[0][1]),(px[0][0]+px[0][1]));
629 (recene[0][0]+recene[0][1])*(recene[0][0]+recene[0][1])-
630 (recpx[0][0]+recpx[0][1])*(recpx[0][0]+recpx[0][1])-
631 (recpy[0][0]+recpy[0][1])*(recpy[0][0]+recpy[0][1])-
632 (recpz[0][0]+recpz[0][1])*(recpz[0][0]+recpz[0][1])
636 (recpx[0][0]+recpx[0][1])*(recpx[0][0]+recpx[0][1])+
637 (recpy[0][0]+recpy[0][1])*(recpy[0][0]+recpy[0][1])
642 recphizmu=atan2((recpy[0][0]+recpy[0][1]),(recpx[0][0]+recpx[0][1]));
672 std::cout <<
"Computing Fake Rate" << std::endl;
714 std::cout <<
"Track number "<<
i << std::endl ;
716 std::cout <<
"\timpact parameter:d0: " << track->
d0()<< std::endl;
717 std::cout <<
"\timpact parameter:z0: " << track->
dz()<< std::endl;
718 std::cout <<
"\tAzimuthal angle of point of closest approach:" << track->
phi()<< std::endl;
724 std::vector<std::pair<TrackingParticleRef, double> > tp;
727 if(recSimColl.
find(track) != recSimColl.
end()){
728 tp = recSimColl[track];
730 edm::LogVerbatim(
"TrackValidator") <<
"reco::Track #" << rT <<
" with pt=" << track->
pt()
731 <<
" associated with quality:" << tp.begin()->second <<
"\n";
735 const SimTrack * fakeassocTrack = &(*tpr->g4Track_begin());
740 ftsAtProduction(
GlobalPoint(tpr->vertex().x(),tpr->vertex().y(),tpr->vertex().z()),
767 std::cout <<
"4) After call to associator: the best SimTrack match is of type" << fakeassocTrack->
type()
770 <<
" ,with pt at vertex = " <<
fakept <<
" GeV/c"
771 <<
" ,d0 global = " <<
faked0
786 edm::LogVerbatim(
"TrackValidator") <<
"reco::Track #" << rT <<
" with pt=" << track->
pt()
787 <<
" NOT associated to any TrackingParticle" <<
"\n";
818 std::cout <<
"\t Misalignment analysis completed \n" << std::endl;
T getParameter(std::string const &) const
EventNumber_t event() const
T getUntrackedParameter(std::string const &, T const &) const
double d0() const
dxy parameter in perigee convention (d0 = -dxy)
std::vector< TrackingParticle > TrackingParticleCollection
const_iterator end() const
last iterator over the map (read only)
double normalizedChi2() const
chi-squared divided by n.d.o.f. (or chi-squared * 1e6 if n.d.o.f. is zero)
const FreeTrajectoryState & theState() const
double theta() const
polar angle
#define DEFINE_FWK_MODULE(type)
~ValidationMisalignedTracker()
Sin< T >::type sin(const T &t)
const_iterator find(const key_type &k) const
find element with specified reference key
Geom::Phi< T > phi() const
Global3DPoint GlobalPoint
double phi() const
azimuthal angle of momentum vector
const Vector & momentum() const
track momentum vector
virtual void analyze(const edm::Event &, const edm::EventSetup &) override
ValidationMisalignedTracker(const edm::ParameterSet &)
edm::InputTag label_tp_fake
virtual void endJob() override
double eta() const
pseudorapidity of momentum vector
double pt() const
track transverse momentum
int genpartIndex() const
index of the corresponding Generator particle in the Event container (-1 if no Genpart) ...
Cos< T >::type cos(const T &t)
Tan< T >::type tan(const T &t)
Abs< T >::type abs(const T &t)
unsigned short numberOfValidHits() const
number of valid hits found
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
GlobalVector momentum() const
std::vector< std::string > associators
double dz() const
dz parameter (= dsz/cos(lambda)). This is the track z0 w.r.t (0,0,0) only if the refPoint is close to...
std::vector< edm::InputTag > label
GlobalPoint position() const
T const * product() const
T const * product() const
int type() const
particle type (HEP PDT convension)
edm::InputTag label_tp_effic
const math::XYZTLorentzVectorD & momentum() const
std::string trackassociator
int charge() const
track electric charge
edm::ESHandle< MagneticField > theMF
std::vector< float > ptused
Global3DVector GlobalVector