14 #include "CLHEP/Vector/LorentzVector.h"
37 : edmSimVertexContainerToken_( consumes<edm::
SimVertexContainer>( iConfig.getParameter<edm::InputTag>(
"simG4" ) ) )
38 , edmSimTrackContainerToken_( consumes<edm::
SimTrackContainer>( iConfig.getParameter<edm::InputTag>(
"simG4" ) ) )
39 , recoTrackCollectionToken_( consumes<
reco::
TrackCollection>( edm::InputTag( iConfig.getUntrackedParameter<std::
string>(
"recoTrackProducer" ) ) ) )
40 , outputFile_( iConfig.getUntrackedParameter<std::
string>(
"outputFile" ) )
42 , verbose_( iConfig.getUntrackedParameter<bool>(
"verbose",
false ) ) {
46 tversion = tversion.Remove(0,1);
47 tversion = tversion.Remove(tversion.Length()-1,tversion.Length());
70 std::cout <<
" TrackParameterAnalyzer::beginJob conversion from sim units to rec units is " <<
simUnit_ << std::endl;
73 h1_pull0_ =
new TH1F(
"pull0",
"pull q/p",100,-25.,25.);
74 h1_pull1_ =
new TH1F(
"pull1",
"pull lambda",100,-25.,25.);
75 h1_pull2_ =
new TH1F(
"pull2",
"pull phi ",100,-25.,25.);
76 h1_pull3_ =
new TH1F(
"pull3",
"pull dca ",100,-25.,25.);
77 h1_pull4_ =
new TH1F(
"pull4",
"pull zdca ",100,-25.,25.);
79 h1_res0_ =
new TH1F(
"res0",
"res q/p",100,-0.1,0.1);
80 h1_res1_ =
new TH1F(
"res1",
"res lambda",100,-0.1,0.1);
81 h1_res2_ =
new TH1F(
"res2",
"res phi ",100,-0.1,0.1);
82 h1_res3_ =
new TH1F(
"res3",
"res dca ",100,-0.1,0.1);
83 h1_res4_ =
new TH1F(
"res4",
"res zdca ",100,-0.1,0.1);
85 h1_Beff_ =
new TH1F(
"Beff",
"Beff",2000,-10.,10.);
87 h1_par0_ =
new TH1F(
"par0",
"q/p",100,-0.1,0.1);
90 h1_par3_ =
new TH1F(
"par3",
"dca ",100,-0.1,0.1);
91 h1_par4_ =
new TH1F(
"par4",
"zdca ",1000,-10.,10.);
121 double dtheta=
a(1)-
b(1);
122 double dphi =
a(2)-
b(2);
123 if (dphi>
M_PI){ dphi-=M_2_PI; }
else if(dphi<-
M_PI){dphi+=M_2_PI;}
124 return ( (fabs(dtheta)<0.02) && (fabs(dphi)<0.04) );
131 using CLHEP::HepLorentzVector;
136 const double fBfield=3.8;
141 std::cout <<
"SimVertex " << simVtcs->size() << std::endl;
142 for(edm::SimVertexContainer::const_iterator
v=simVtcs->begin();
143 v!=simVtcs->end(); ++
v){
145 << std::setw(10) << std::setprecision(4)
146 <<
v->position().x() <<
" "
147 <<
v->position().y() <<
" "
148 <<
v->position().z() <<
" "
149 <<
v->parentIndex() <<
" "
150 <<
v->noParent() <<
" "
160 std::vector<ParameterVector > tsim;
161 for(edm::SimTrackContainer::const_iterator
t=simTrks->begin();
162 t!=simTrks->end(); ++
t){
164 std::cout <<
"simtrk has no vertex" << std::endl;
168 HepLorentzVector
v((*simVtcs)[
t->vertIndex()].position().x(),
169 (*simVtcs)[
t->vertIndex()].position().y(),
170 (*simVtcs)[
t->vertIndex()].position().z(),
171 (*simVtcs)[
t->vertIndex()].position().e());
172 int pdgCode=
t->type();
176 std::cout <<
"funny particle skipped , code=" << pdgCode << std::endl;
179 if ((pdgCode==11)||(pdgCode==13)||(pdgCode==15)||(pdgCode==-211)||(pdgCode==-2212)||(pdgCode==321)){Q=-1;}
180 else if((pdgCode==-11)||(pdgCode==-13)||(pdgCode==-15)||(pdgCode==211)||(pdgCode==2212)||(pdgCode==321)){Q=1;}
184 HepLorentzVector
p(
t->momentum().x(),
t->momentum().y(),
t->momentum().z(),
t->momentum().e());
187 <<
" gen=" << std::setw( 4) <<
t->genpartIndex()
188 <<
" vtx=" << std::setw( 4) <<
t->vertIndex()
189 <<
" pdg=" << std::setw( 5) <<
t->type()
190 <<
" Q=" << std::setw( 3) << Q
191 <<
" pt=" << std::setw(6) <<
p.perp()
192 <<
" vx=" << std::setw(6) <<
v.x()
193 <<
" vy=" << std::setw(6) <<
v.y()
194 <<
" vz=" << std::setw(6) <<
v.z()
197 if ( (Q != 0) && (
p.perp()>0.1) ){
201 double kappa=-Q*0.002998*fBfield/
p.perp();
202 double D0=x0*
sin(
p.phi())-y0*
cos(
p.phi())-0.5*kappa*(x0*x0+y0*y0);
203 double q=
sqrt(1.-2.*kappa*D0);
204 double s0=(x0*
cos(
p.phi())+y0*
sin(
p.phi()))/
q;
206 if (fabs(kappa*s0)>0.001){
207 s1=asin(kappa*s0)/kappa;
209 double ks02=(kappa*s0)*(kappa*s0);
210 s1=s0*(1.+ks02/6.+3./40.*ks02*ks02+5./112.*
pow(ks02,3));
231 for(reco::TrackCollection::const_iterator
t=recTracks->begin();
232 t!=recTracks->end(); ++
t){
236 std::cout <<
"reco pars= " << p << std::endl;
239 for(std::vector<ParameterVector>::const_iterator
s=tsim.begin();
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Sin< T >::type sin(const T &t)
std::vector< Track > TrackCollection
collection of Tracks
TrackParameterAnalyzer(const edm::ParameterSet &)
math::Vector< dimension >::type ParameterVector
parameter vector
bool match(const ParameterVector &a, const ParameterVector &b)
edm::EDGetTokenT< edm::SimTrackContainer > edmSimTrackContainerToken_
Cos< T >::type cos(const T &t)
edm::EDGetTokenT< reco::TrackCollection > recoTrackCollectionToken_
virtual void analyze(const edm::Event &, const edm::EventSetup &)
std::string getReleaseVersion()
edm::EDGetTokenT< edm::SimVertexContainer > edmSimVertexContainerToken_
std::vector< SimVertex > SimVertexContainer
reco::TrackBase::ParameterVector ParameterVector
~TrackParameterAnalyzer()
volatile std::atomic< bool > shutdown_flag false
std::vector< SimTrack > SimTrackContainer
Power< A, B >::type pow(const A &a, const B &b)
math::Error< dimension >::type CovarianceMatrix
5 parameter covariance matrix