#include <RecoVertex/KineExample/src/KineExample.cc>
Public Member Functions | |
virtual void | analyze (const edm::Event &, const edm::EventSetup &) |
virtual void | beginJob (edm::EventSetup const &) |
virtual void | endJob () |
KineExample (const edm::ParameterSet &) | |
~KineExample () | |
Private Member Functions | |
TrackingVertex | getSimVertex (const edm::Event &iEvent) const |
void | printout (const RefCountedKinematicTree &myTree) const |
void | printout (const RefCountedKinematicParticle &myParticle) const |
void | printout (const RefCountedKinematicVertex &myVertex) const |
Private Attributes | |
TrackAssociatorByChi2 * | associatorForParamAtPca |
edm::ParameterSet | kvfPSet |
std::string | outputFile_ |
edm::ParameterSet | theConfig |
std::string | trackLabel_ |
Description: steers tracker primary vertex reconstruction and storage.
Implementation: <Notes on="" implementation>="">
Definition at line 46 of file KineExample.h.
KineExample::KineExample | ( | const edm::ParameterSet & | iConfig | ) | [explicit] |
Definition at line 36 of file KineExample.cc.
References edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), kvfPSet, outputFile_, and trackLabel_.
00037 : theConfig(iConfig) 00038 { 00039 trackLabel_ = iConfig.getParameter<std::string>("TrackLabel"); 00040 outputFile_ = iConfig.getUntrackedParameter<std::string>("outputFile"); 00041 kvfPSet = iConfig.getParameter<edm::ParameterSet>("KVFParameters"); 00042 // rootFile_ = TFile::Open(outputFile_.c_str(),"RECREATE"); 00043 edm::LogInfo("RecoVertex/KineExample") 00044 << "Initializing KVF TEST analyser - Output file: " << outputFile_ <<"\n"; 00045 }
KineExample::~KineExample | ( | ) |
void KineExample::analyze | ( | const edm::Event & | iEvent, | |
const edm::EventSetup & | iSetup | |||
) | [virtual] |
Implements edm::EDAnalyzer.
Definition at line 70 of file KineExample.cc.
References GenMuonPlsPt100GeV_cfg::cout, lat::endl(), KinematicConstrainedVertexFitter::fit(), KinematicParticleVertexFitter::fit(), KinematicParticleFitter::fit(), edm::EventSetup::get(), edm::Event::getByLabel(), edm::Event::id(), edm::Handle< T >::isValid(), KinematicParticleFactoryFromTransientTrack::particle(), TransientVertex::position(), printout(), trackLabel_, and KalmanVertexFitter::vertex().
00071 { 00072 00073 edm::LogInfo("RecoVertex/KineExample") 00074 << "Reconstructing event number: " << iEvent.id() << "\n"; 00075 00076 // get RECO tracks from the event 00077 // `tks` can be used as a ptr to a reco::TrackCollection 00078 edm::Handle<reco::TrackCollection> tks; 00079 iEvent.getByLabel(trackLabel_, tks); 00080 if (!tks.isValid()) { 00081 cout 00082 << "Exception during event number: " << iEvent.id() 00083 << "\n"; 00084 } else { 00085 00086 edm::LogInfo("RecoVertex/KineExample") 00087 << "Found: " << (*tks).size() << " reconstructed tracks" << "\n"; 00088 cout << "got " << (*tks).size() << " tracks " << endl; 00089 00090 // Transform Track to TransientTrack 00091 00092 //get the builder: 00093 edm::ESHandle<TransientTrackBuilder> theB; 00094 iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder",theB); 00095 //do the conversion: 00096 vector<TransientTrack> t_tks = (*theB).build(tks); 00097 00098 edm::LogInfo("RecoVertex/KineExample") 00099 << "Found: " << t_tks.size() << " reconstructed tracks" << "\n"; 00100 00101 // Do a KindFit, if >= 4 tracks. 00102 if (t_tks.size() > 3) { 00103 00104 // For a first test, suppose that the first four tracks are the 2 muons, 00105 // then the 2 kaons. Since this will not be true, the result of the fit 00106 // will not be meaningfull, but at least you will get the idea of how to 00107 // do such a fit. 00108 00109 //First, to get started, a simple vertex fit: 00110 00111 vector<TransientTrack> ttv; 00112 ttv.push_back(t_tks[0]); ttv.push_back(t_tks[1]); ttv.push_back(t_tks[2]);ttv.push_back(t_tks[3]); 00113 KalmanVertexFitter kvf(false); 00114 TransientVertex tv = kvf.vertex(ttv); 00115 00116 std::cout << "Position: " << Vertex::Point(tv.position()) << "\n"; 00117 00118 00119 TransientTrack ttMuPlus = t_tks[0]; 00120 TransientTrack ttMuMinus = t_tks[1]; 00121 TransientTrack ttKPlus = t_tks[2]; 00122 TransientTrack ttKMinus = t_tks[3]; 00123 00124 //the final state muons and kaons from the Bs->J/PsiPhi->mumuKK decay 00125 //Creating a KinematicParticleFactory 00126 KinematicParticleFactoryFromTransientTrack pFactory; 00127 00128 //The mass of a muon and the insignificant mass sigma to avoid singularities in the covariance matrix. 00129 ParticleMass muon_mass = 0.1056583; 00130 ParticleMass kaon_mass = 0.493677; 00131 float muon_sigma = 0.0000000001; 00132 float kaon_sigma = 0.000016; 00133 00134 //initial chi2 and ndf before kinematic fits. The chi2 of the reconstruction is not considered 00135 float chi = 0.; 00136 float ndf = 0.; 00137 00138 //making particles 00139 vector<RefCountedKinematicParticle> muonParticles; 00140 vector<RefCountedKinematicParticle> phiParticles; 00141 vector<RefCountedKinematicParticle> allParticles; 00142 muonParticles.push_back(pFactory.particle (ttMuPlus,muon_mass,chi,ndf,muon_sigma)); 00143 muonParticles.push_back(pFactory.particle (ttMuMinus,muon_mass,chi,ndf,muon_sigma)); 00144 allParticles.push_back(pFactory.particle (ttMuPlus,muon_mass,chi,ndf,muon_sigma)); 00145 allParticles.push_back(pFactory.particle (ttMuMinus,muon_mass,chi,ndf,muon_sigma)); 00146 00147 phiParticles.push_back(pFactory.particle (ttKPlus,kaon_mass,chi,ndf,kaon_sigma)); 00148 phiParticles.push_back(pFactory.particle (ttKMinus,kaon_mass,chi,ndf,kaon_sigma)); 00149 allParticles.push_back(pFactory.particle (ttKPlus,kaon_mass,chi,ndf,kaon_sigma)); 00150 allParticles.push_back(pFactory.particle (ttKMinus,kaon_mass,chi,ndf,kaon_sigma)); 00151 00152 /* Example of a simple vertex fit, without other constraints 00153 * The reconstructed decay tree is a result of the kinematic fit 00154 * The KinematicParticleVertexFitter fits the final state particles to their vertex and 00155 * reconstructs the decayed state 00156 */ 00157 KinematicParticleVertexFitter fitter; 00158 RefCountedKinematicTree vertexFitTree = fitter.fit(allParticles); 00159 00160 printout(vertexFitTree); 00161 00163 00164 //creating the constraint for the J/Psi mass 00165 ParticleMass jpsi = 3.09687; 00166 00167 //creating the two track mass constraint 00168 MultiTrackKinematicConstraint * j_psi_c = new TwoTrackMassKinematicConstraint(jpsi); 00169 00170 //creating the fitter 00171 KinematicConstrainedVertexFitter kcvFitter; 00172 00173 //obtaining the resulting tree 00174 RefCountedKinematicTree myTree = kcvFitter.fit(allParticles, j_psi_c); 00175 00176 cout << "Global fit done:\n"; 00177 printout(myTree); 00178 00179 //creating the vertex fitter 00180 KinematicParticleVertexFitter kpvFitter; 00181 00182 //reconstructing a J/Psi decay 00183 RefCountedKinematicTree jpTree = kpvFitter.fit(muonParticles); 00184 00185 //creating the particle fitter 00186 KinematicParticleFitter csFitter; 00187 00188 // creating the constraint 00189 float jp_m_sigma = 0.00004; 00190 KinematicConstraint * jpsi_c2 = new MassKinematicConstraint(jpsi,jp_m_sigma); 00191 00192 //the constrained fit: 00193 jpTree = csFitter.fit(jpsi_c2,jpTree); 00194 00195 //getting the J/Psi KinematicParticle and putting it together with the kaons. 00196 //The J/Psi KinematicParticle has a pointer to the tree it belongs to 00197 jpTree->movePointerToTheTop(); 00198 RefCountedKinematicParticle jpsi_part = jpTree->currentParticle(); 00199 phiParticles.push_back(jpsi_part); 00200 00201 //making a vertex fit and thus reconstructing the Bs parameters 00202 // the resulting tree includes all the final state tracks, the J/Psi meson, 00203 // its decay vertex, the Bs meson and its decay vertex. 00204 RefCountedKinematicTree bsTree = kpvFitter.fit(phiParticles); 00205 cout << "Sequential fit done:\n"; 00206 printout(bsTree); 00207 00208 00209 00210 // // For the analysis: compare to your SimVertex 00211 // TrackingVertex sv = getSimVertex(iEvent); 00212 // edm::Handle<TrackingParticleCollection> TPCollectionH ; 00213 // iEvent.getByLabel("trackingtruth","TrackTruth",TPCollectionH); 00214 // const TrackingParticleCollection tPC = *(TPCollectionH.product()); 00215 // reco::RecoToSimCollection recSimColl=associatorForParamAtPca->associateRecoToSim(tks, 00216 // TPCollectionH, 00217 // &iEvent); 00218 // 00219 // tree->fill(tv, &sv, &recSimColl); 00220 // } 00221 00222 } 00223 } 00224 }
void KineExample::beginJob | ( | edm::EventSetup const & | setup | ) | [virtual] |
Reimplemented from edm::EDAnalyzer.
Definition at line 52 of file KineExample.cc.
References associatorForParamAtPca, edm::EventSetup::get(), and edm::ESHandle< T >::product().
00052 { 00053 edm::ESHandle<TrackAssociatorBase> theAssociatorForParamAtPca; 00054 setup.get<TrackAssociatorRecord>().get("TrackAssociatorByChi2",theAssociatorForParamAtPca); 00055 associatorForParamAtPca = (TrackAssociatorByChi2 *) theAssociatorForParamAtPca.product(); 00056 00057 // tree = new SimpleVertexTree("VertexFitter", associatorForParamAtPca); 00058 }
TrackingVertex KineExample::getSimVertex | ( | const edm::Event & | iEvent | ) | const [private] |
Definition at line 276 of file KineExample.cc.
References edm::Event::getByLabel(), and edm::Handle< T >::product().
00277 { 00278 // get the simulated vertices 00279 edm::Handle<TrackingVertexCollection> TVCollectionH ; 00280 iEvent.getByLabel("trackingtruth","VertexTruth",TVCollectionH); 00281 const TrackingVertexCollection tPC = *(TVCollectionH.product()); 00282 00283 // Handle<edm::SimVertexContainer> simVtcs; 00284 // iEvent.getByLabel("g4SimHits", simVtcs); 00285 // std::cout << "SimVertex " << simVtcs->size() << std::endl; 00286 // for(edm::SimVertexContainer::const_iterator v=simVtcs->begin(); 00287 // v!=simVtcs->end(); ++v){ 00288 // std::cout << "simvtx " 00289 // << v->position().x() << " " 00290 // << v->position().y() << " " 00291 // << v->position().z() << " " 00292 // << v->parentIndex() << " " 00293 // << v->noParent() << " " 00294 // << std::endl; 00295 // } 00296 return *(tPC.begin()); 00297 }
void KineExample::printout | ( | const RefCountedKinematicTree & | myTree | ) | const [private] |
Definition at line 243 of file KineExample.cc.
References i, and printout().
00244 { 00245 00246 //accessing the tree components, move pointer to top 00247 myTree->movePointerToTheTop(); 00248 00249 //We are now at the top of the decay tree getting the B_s reconstructed KinematicPartlcle 00250 RefCountedKinematicParticle b_s = myTree->currentParticle(); 00251 printout(b_s); 00252 00253 // The B_s decay vertex 00254 RefCountedKinematicVertex b_dec_vertex = myTree->currentDecayVertex(); 00255 printout(b_dec_vertex); 00256 00257 // Get all the children of Bs: 00258 //In this way, the pointer is not moved 00259 vector< RefCountedKinematicParticle > bs_children = myTree->finalStateParticles(); 00260 00261 for (unsigned int i=0;i< bs_children.size();++i) { 00262 printout(bs_children[i]); 00263 } 00264 00265 //Now navigating down the tree , pointer is moved: 00266 bool child = myTree->movePointerToTheFirstChild(); 00267 00268 if(child) while (myTree->movePointerToTheNextChild()) { 00269 RefCountedKinematicParticle aChild = myTree->currentParticle(); 00270 printout(aChild); 00271 } 00272 }
void KineExample::printout | ( | const RefCountedKinematicParticle & | myParticle | ) | const [private] |
Definition at line 231 of file KineExample.cc.
References GenMuonPlsPt100GeV_cfg::cout, and lat::endl().
00232 { 00233 cout << "Particle: \n"; 00234 //accessing the reconstructed Bs meson parameters: 00235 AlgebraicVector7 bs_par = myParticle->currentState().kinematicParameters().vector(); 00236 00237 //and their joint covariance matrix: 00238 AlgebraicSymMatrix77 bs_er = myParticle->currentState().kinematicParametersError().matrix(); 00239 cout << "Momentum at vertex: " << myParticle->currentState().globalMomentum ()<<endl; 00240 cout << "Parameters at vertex: " << myParticle->currentState().kinematicParameters().vector()<<endl; 00241 }
void KineExample::printout | ( | const RefCountedKinematicVertex & | myVertex | ) | const [private] |
Definition at line 226 of file KineExample.cc.
References GenMuonPlsPt100GeV_cfg::cout, and lat::endl().
Referenced by analyze(), and printout().
edm::ParameterSet KineExample::kvfPSet [private] |
std::string KineExample::outputFile_ [private] |
edm::ParameterSet KineExample::theConfig [private] |
Definition at line 64 of file KineExample.h.
std::string KineExample::trackLabel_ [private] |