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 Member Functions | Private Attributes
TrackParameterAnalyzer Class Reference

#include <Validation/RecoVertex/src/TrackParameterAnalyzer.cc>

Inheritance diagram for TrackParameterAnalyzer:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
 
virtual void beginJob ()
 
virtual void endJob ()
 
 TrackParameterAnalyzer (const edm::ParameterSet &)
 
 ~TrackParameterAnalyzer ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 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 (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

bool match (const ParameterVector &a, const ParameterVector &b)
 

Private Attributes

edm::EDGetTokenT
< edm::SimTrackContainer
edmSimTrackContainerToken_
 
edm::EDGetTokenT
< edm::SimVertexContainer
edmSimVertexContainerToken_
 
TH1 * h1_Beff_
 
TH1 * h1_par0_
 
TH1 * h1_par1_
 
TH1 * h1_par2_
 
TH1 * h1_par3_
 
TH1 * h1_par4_
 
TH1 * h1_pull0_
 
TH1 * h1_pull1_
 
TH1 * h1_pull2_
 
TH1 * h1_pull3_
 
TH1 * h1_pull4_
 
TH1 * h1_res0_
 
TH1 * h1_res1_
 
TH1 * h1_res2_
 
TH1 * h1_res3_
 
TH1 * h1_res4_
 
TH2 * h2_dvsphi_
 
std::string outputFile_
 
edm::EDGetTokenT
< reco::TrackCollection
recoTrackCollectionToken_
 
TFile * rootFile_
 
double simUnit_
 
bool verbose_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- 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)
 

Detailed Description

Description: <one line="" class="" summary>="">

Implementation: <Notes on="" implementation>="">

Definition at line 47 of file TrackParameterAnalyzer.h.

Constructor & Destructor Documentation

TrackParameterAnalyzer::TrackParameterAnalyzer ( const edm::ParameterSet iConfig)
explicit

Definition at line 36 of file TrackParameterAnalyzer.cc.

References edm::getReleaseVersion(), outputFile_, rootFile_, simUnit_, and AlCaHLTBitMon_QueryRunRegistry::string.

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" ) )
41  , simUnit_( 1.0 ) // starting from CMSSW_1_2_x, I think
42  , verbose_( iConfig.getUntrackedParameter<bool>( "verbose", false ) ) {
43  //now do whatever initialization is needed
44  // open output file to store histograms}
45  TString tversion(edm::getReleaseVersion());
46  tversion = tversion.Remove(0,1);
47  tversion = tversion.Remove(tversion.Length()-1,tversion.Length());
48  outputFile_ = std::string(tversion)+"_"+outputFile_;
49  rootFile_ = TFile::Open(outputFile_.c_str(),"RECREATE");
50  if ( (edm::getReleaseVersion()).find("CMSSW_1_1_",0)!=std::string::npos){
51  simUnit_=0.1; // for use in CMSSW_1_1_1 tutorial
52  }
53 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< edm::SimTrackContainer > edmSimTrackContainerToken_
edm::EDGetTokenT< reco::TrackCollection > recoTrackCollectionToken_
std::string getReleaseVersion()
edm::EDGetTokenT< edm::SimVertexContainer > edmSimVertexContainerToken_
TrackParameterAnalyzer::~TrackParameterAnalyzer ( )

Definition at line 56 of file TrackParameterAnalyzer.cc.

References rootFile_.

57 {
58 
59  // do anything here that needs to be done at destruction time
60  // (e.g. close files, deallocate resources etc.)
61  delete rootFile_;
62 }

Member Function Documentation

void TrackParameterAnalyzer::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
virtual

Implements edm::EDAnalyzer.

Definition at line 129 of file TrackParameterAnalyzer.cc.

References trackerHits::c, funct::cos(), gather_cfg::cout, edmSimTrackContainerToken_, edmSimVertexContainerToken_, edm::Event::getByToken(), h1_Beff_, h1_par0_, h1_par1_, h1_par2_, h1_par3_, h1_par4_, h1_pull0_, h1_pull1_, h1_pull2_, h1_pull3_, h1_pull4_, h1_res0_, h1_res1_, h1_res2_, h1_res3_, h1_res4_, h2_dvsphi_, reco::TrackBase::i_dsz, reco::TrackBase::i_dxy, reco::TrackBase::i_lambda, reco::TrackBase::i_phi, reco::TrackBase::i_qoverp, kappa, M_PI, match(), AlCaHLTBitMon_ParallelJobs::p, funct::pow(), lumiQueryAPI::q, recoTrackCollectionToken_, alignCSCRings::s, simUnit_, funct::sin(), mathSSE::sqrt(), edmStreamStallGrapher::t, findQualityFiles::v, and verbose_.

130 {
131  using CLHEP::HepLorentzVector;
132 
133  //edm::ESHandle<TransientTrackBuilder> theB;
134  //iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder",theB);
135  //double fBfield=((*theB).field()->inTesla(GlobalPoint(0.,0.,0.))).z();
136  const double fBfield=3.8;
137 
139  iEvent.getByToken( edmSimVertexContainerToken_, simVtcs );
140  if(verbose_){
141  std::cout << "SimVertex " << simVtcs->size() << std::endl;
142  for(edm::SimVertexContainer::const_iterator v=simVtcs->begin();
143  v!=simVtcs->end(); ++v){
144  std::cout << "simvtx "
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() << " "
151  << std::endl;
152  }
153  }
154 
155  // get the simulated tracks, extract perigee parameters
157  iEvent.getByToken( edmSimTrackContainerToken_, simTrks );
158 
159  if(verbose_){std::cout << "simtrks " << simTrks->size() << std::endl;}
160  std::vector<ParameterVector > tsim;
161  for(edm::SimTrackContainer::const_iterator t=simTrks->begin();
162  t!=simTrks->end(); ++t){
163  if (t->noVertex()){
164  std::cout << "simtrk has no vertex" << std::endl;
165  return;
166  }else{
167  // get the vertex position
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();
173 
174  if( pdgCode==-99 ){
175  // such entries cause crashes, no idea what they are
176  std::cout << "funny particle skipped , code=" << pdgCode << std::endl;
177  }else{
178  double Q=0; //double Q=HepPDT::theTable().getParticleData(pdgCode)->charge();
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;}
181  else {
182  std::cout << pdgCode << " " <<std::endl;
183  }
184  HepLorentzVector p(t->momentum().x(),t->momentum().y(),t->momentum().z(),t->momentum().e());
185  if(verbose_){
186  std::cout << "simtrk "
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()
195  << std::endl;
196  }
197  if ( (Q != 0) && (p.perp()>0.1) ){
198  double x0=v.x()*simUnit_;
199  double y0=v.y()*simUnit_;
200  double z0=v.z()*simUnit_;
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;
205  double s1;
206  if (fabs(kappa*s0)>0.001){
207  s1=asin(kappa*s0)/kappa;
208  }else{
209  double ks02=(kappa*s0)*(kappa*s0);
210  s1=s0*(1.+ks02/6.+3./40.*ks02*ks02+5./112.*pow(ks02,3));
211  }
212  ParameterVector par;
213  par[reco::TrackBase::i_qoverp] = Q/sqrt(p.perp2()+p.pz()*p.pz());
214  par[reco::TrackBase::i_lambda] = M_PI/2.-p.theta();
215  par[reco::TrackBase::i_phi] = p.phi()-asin(kappa*s0);
216  par[reco::TrackBase::i_dxy] = 2.*D0/(1.+q);
217  par[reco::TrackBase::i_dsz] = z0*sin(p.theta())-s1*cos(p.theta());
218  tsim.push_back(par);
219  }
220  }
221  }// has vertex
222  }//for loop
223 
224  // simtrack parameters are in now tsim
225  // loop over tracks and try to match them to simulated tracks
226 
227 
229  iEvent.getByToken( recoTrackCollectionToken_, recTracks );
230 
231  for(reco::TrackCollection::const_iterator t=recTracks->begin();
232  t!=recTracks->end(); ++t){
233  reco::TrackBase::ParameterVector p = t->parameters();
234  reco::TrackBase::CovarianceMatrix c = t->covariance();
235  if(verbose_){
236  std::cout << "reco pars= " << p << std::endl;
237  //std::cout << "z0=" << p(4) << std::endl;
238  }
239  for(std::vector<ParameterVector>::const_iterator s=tsim.begin();
240  s!=tsim.end(); ++s){
241  if (match(*s,p)){
242  //if(verbose_){ std::cout << "match found" << std::endl;}
243  h1_pull0_->Fill((p(0)-(*s)(0))/sqrt(c(0,0)));
244  h1_pull1_->Fill((p(1)-(*s)(1))/sqrt(c(1,1)));
245  h1_pull2_->Fill((p(2)-(*s)(2))/sqrt(c(2,2)));
246  h1_pull3_->Fill((p(3)-(*s)(3))/sqrt(c(3,3)));
247  h1_pull4_->Fill((p(4)-(*s)(4))/sqrt(c(4,4)));
248 
249  h1_res0_->Fill(p(0)-(*s)(0));
250  h1_res1_->Fill(p(1)-(*s)(1));
251  h1_res2_->Fill(p(2)-(*s)(2));
252  h1_res3_->Fill(p(3)-(*s)(3));
253  h1_res4_->Fill(p(4)-(*s)(4));
254 
255  h1_Beff_->Fill(p(0)/(*s)(0)*fBfield);
256  h2_dvsphi_->Fill(p(2),p(3));
257  h1_par0_->Fill(p(0));
258  h1_par1_->Fill(p(1));
259  h1_par2_->Fill(p(2));
260  h1_par3_->Fill(p(3));
261  h1_par4_->Fill(p(4));
262  }
263  }
264  }
265 
266 
267 
268 
269 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:446
Divides< arg, void > D0
Definition: Factorize.h:143
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
math::Vector< dimension >::type ParameterVector
parameter vector
Definition: TrackBase.h:73
bool match(const ParameterVector &a, const ParameterVector &b)
edm::EDGetTokenT< edm::SimTrackContainer > edmSimTrackContainerToken_
T sqrt(T t)
Definition: SSEVec.h:48
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
edm::EDGetTokenT< reco::TrackCollection > recoTrackCollectionToken_
#define M_PI
edm::EDGetTokenT< edm::SimVertexContainer > edmSimVertexContainerToken_
reco::TrackBase::ParameterVector ParameterVector
tuple cout
Definition: gather_cfg.py:121
static const G4double kappa
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
math::Error< dimension >::type CovarianceMatrix
5 parameter covariance matrix
Definition: TrackBase.h:76
void TrackParameterAnalyzer::beginJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 69 of file TrackParameterAnalyzer.cc.

References gather_cfg::cout, h1_Beff_, h1_par0_, h1_par1_, h1_par2_, h1_par3_, h1_par4_, h1_pull0_, h1_pull1_, h1_pull2_, h1_pull3_, h1_pull4_, h1_res0_, h1_res1_, h1_res2_, h1_res3_, h1_res4_, h2_dvsphi_, M_PI, rootFile_, and simUnit_.

69  {
70  std::cout << " TrackParameterAnalyzer::beginJob conversion from sim units to rec units is " << simUnit_ << std::endl;
71 
72  rootFile_->cd();
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.);
78 
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);
84 
85  h1_Beff_ = new TH1F("Beff", "Beff",2000,-10.,10.);
86  h2_dvsphi_ = new TH2F("dvsphi","dvsphi",360,-M_PI,M_PI,100,-0.1,0.1);
87  h1_par0_ = new TH1F("par0","q/p",100,-0.1,0.1);
88  h1_par1_ = new TH1F("par1","lambda",100, -M_PI/2.,M_PI/2.);
89  h1_par2_ = new TH1F("par2","phi ",100,-M_PI,M_PI);
90  h1_par3_ = new TH1F("par3","dca ",100,-0.1,0.1);
91  h1_par4_ = new TH1F("par4","zdca ",1000,-10.,10.);
92 }
#define M_PI
tuple cout
Definition: gather_cfg.py:121
void TrackParameterAnalyzer::endJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 95 of file TrackParameterAnalyzer.cc.

References h1_Beff_, h1_par0_, h1_par1_, h1_par2_, h1_par3_, h1_par4_, h1_pull0_, h1_pull1_, h1_pull2_, h1_pull3_, h1_pull4_, h1_res0_, h1_res1_, h1_res2_, h1_res3_, h1_res4_, h2_dvsphi_, and rootFile_.

95  {
96  rootFile_->cd();
97  h1_pull0_->Write();
98  h1_pull1_->Write();
99  h1_pull2_->Write();
100  h1_pull3_->Write();
101  h1_pull4_->Write();
102 
103  h1_res0_->Write();
104  h1_res1_->Write();
105  h1_res2_->Write();
106  h1_res3_->Write();
107  h1_res4_->Write();
108 
109  h1_Beff_->Write();
110  h2_dvsphi_->Write();
111  h1_par0_->Write();
112  h1_par1_->Write();
113  h1_par2_->Write();
114  h1_par3_->Write();
115  h1_par4_->Write();
116 }
bool TrackParameterAnalyzer::match ( const ParameterVector a,
const ParameterVector b 
)
private

Definition at line 119 of file TrackParameterAnalyzer.cc.

References a, b, and M_PI.

Referenced by analyze().

120  {
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) );
125 }
#define M_PI
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121

Member Data Documentation

edm::EDGetTokenT<edm::SimTrackContainer> TrackParameterAnalyzer::edmSimTrackContainerToken_
private

Definition at line 60 of file TrackParameterAnalyzer.h.

Referenced by analyze().

edm::EDGetTokenT<edm::SimVertexContainer> TrackParameterAnalyzer::edmSimVertexContainerToken_
private

Definition at line 59 of file TrackParameterAnalyzer.h.

Referenced by analyze().

TH1* TrackParameterAnalyzer::h1_Beff_
private

Definition at line 75 of file TrackParameterAnalyzer.h.

Referenced by analyze(), beginJob(), and endJob().

TH1* TrackParameterAnalyzer::h1_par0_
private

Definition at line 77 of file TrackParameterAnalyzer.h.

Referenced by analyze(), beginJob(), and endJob().

TH1* TrackParameterAnalyzer::h1_par1_
private

Definition at line 78 of file TrackParameterAnalyzer.h.

Referenced by analyze(), beginJob(), and endJob().

TH1* TrackParameterAnalyzer::h1_par2_
private

Definition at line 79 of file TrackParameterAnalyzer.h.

Referenced by analyze(), beginJob(), and endJob().

TH1* TrackParameterAnalyzer::h1_par3_
private

Definition at line 80 of file TrackParameterAnalyzer.h.

Referenced by analyze(), beginJob(), and endJob().

TH1* TrackParameterAnalyzer::h1_par4_
private

Definition at line 81 of file TrackParameterAnalyzer.h.

Referenced by analyze(), beginJob(), and endJob().

TH1* TrackParameterAnalyzer::h1_pull0_
private

Definition at line 65 of file TrackParameterAnalyzer.h.

Referenced by analyze(), beginJob(), and endJob().

TH1* TrackParameterAnalyzer::h1_pull1_
private

Definition at line 66 of file TrackParameterAnalyzer.h.

Referenced by analyze(), beginJob(), and endJob().

TH1* TrackParameterAnalyzer::h1_pull2_
private

Definition at line 67 of file TrackParameterAnalyzer.h.

Referenced by analyze(), beginJob(), and endJob().

TH1* TrackParameterAnalyzer::h1_pull3_
private

Definition at line 68 of file TrackParameterAnalyzer.h.

Referenced by analyze(), beginJob(), and endJob().

TH1* TrackParameterAnalyzer::h1_pull4_
private

Definition at line 69 of file TrackParameterAnalyzer.h.

Referenced by analyze(), beginJob(), and endJob().

TH1* TrackParameterAnalyzer::h1_res0_
private

Definition at line 70 of file TrackParameterAnalyzer.h.

Referenced by analyze(), beginJob(), and endJob().

TH1* TrackParameterAnalyzer::h1_res1_
private

Definition at line 71 of file TrackParameterAnalyzer.h.

Referenced by analyze(), beginJob(), and endJob().

TH1* TrackParameterAnalyzer::h1_res2_
private

Definition at line 72 of file TrackParameterAnalyzer.h.

Referenced by analyze(), beginJob(), and endJob().

TH1* TrackParameterAnalyzer::h1_res3_
private

Definition at line 73 of file TrackParameterAnalyzer.h.

Referenced by analyze(), beginJob(), and endJob().

TH1* TrackParameterAnalyzer::h1_res4_
private

Definition at line 74 of file TrackParameterAnalyzer.h.

Referenced by analyze(), beginJob(), and endJob().

TH2* TrackParameterAnalyzer::h2_dvsphi_
private

Definition at line 76 of file TrackParameterAnalyzer.h.

Referenced by analyze(), beginJob(), and endJob().

std::string TrackParameterAnalyzer::outputFile_
private

Definition at line 63 of file TrackParameterAnalyzer.h.

Referenced by TrackParameterAnalyzer().

edm::EDGetTokenT<reco::TrackCollection> TrackParameterAnalyzer::recoTrackCollectionToken_
private

Definition at line 61 of file TrackParameterAnalyzer.h.

Referenced by analyze().

TFile* TrackParameterAnalyzer::rootFile_
private
double TrackParameterAnalyzer::simUnit_
private

Definition at line 82 of file TrackParameterAnalyzer.h.

Referenced by analyze(), beginJob(), and TrackParameterAnalyzer().

bool TrackParameterAnalyzer::verbose_
private

Definition at line 83 of file TrackParameterAnalyzer.h.

Referenced by analyze().