1 #include "ZVTOPZVKINProcessor.h"
4 #include <EVENT/LCCollection.h>
5 #include <EVENT/ReconstructedParticle.h>
6 #include <EVENT/Track.h>
7 #include <EVENT/Vertex.h>
8 #include <IMPL/LCCollectionVec.h>
9 #include <IMPL/LCRelationImpl.h>
11 #include <util/inc/memorymanager.h>
12 #include <algo/inc/zvkin.h>
13 #include <util/inc/matrix.h>
14 #include <inc/lciointerface.h>
19 using namespace marlin ;
21 using namespace vertex_lcfi;
25 ZVTOPZVKINProcessor::ZVTOPZVKINProcessor() : Processor(
"ZVTOP_ZVKINProcessor") {
28 _description =
"ZVTOP_ZVKIN - Kinematic Vertex Reconstruction Algorithm" ;
31 registerInputCollection( lcio::LCIO::RECONSTRUCTEDPARTICLE,
33 "Name of the ReconstructedParticle collection that represents jets" ,
34 _JetRPCollectionName ,
35 std::string(
"Jets") ) ;
36 registerInputCollection( lcio::LCIO::VERTEX,
37 "IPVertexCollection" ,
38 "Name of the Vertex collection that contains the primary vertex (Optional)" ,
39 _IPVertexCollectionName ,
40 std::string(
"IPVertex") ) ;
41 registerOutputCollection( lcio::LCIO::RECONSTRUCTEDPARTICLE,
42 "DecayChainRPTracksCollectionName" ,
43 "Name of the ReconstructedParticle collection that represents tracks in output decay chains" ,
44 _DecayChainRPTracksCollectionName,
45 std::string(
"ZVKINDecayChainRPTracks") ) ;
51 registerOutputCollection( lcio::LCIO::VERTEX,
53 "Name of the Vertex collection that contains found vertices" ,
54 _VertexCollectionName ,
55 std::string(
"ZVKINVertices") ) ;
56 registerOutputCollection( lcio::LCIO::RECONSTRUCTEDPARTICLE,
57 "DecayChainCollectionName" ,
58 "Name of the ReconstructedParticle collection that holds RPs representing output decay chains" ,
59 _DecayChainCollectionName,
60 std::string(
"ZVKINDecayChains") ) ;
61 registerProcessorParameter(
"ManualIPVertex" ,
62 "If false then the primary vertex from VertexCollection is used" ,
63 _ManualPrimaryVertex ,
66 DefaultPos.push_back(0.0);
67 DefaultPos.push_back(0.0);
68 DefaultPos.push_back(0.0);
70 registerOptionalParameter(
"ManualIPVertexPosition" ,
71 "Manually set position of the primary vertex (cm) - non origin IP not yet fully supported" ,
72 _ManualPrimaryVertexPos ,
76 DefaultErr.push_back(pow(5.0/1000.0,2.0));
77 DefaultErr.push_back(0.0);
78 DefaultErr.push_back(pow(5.0/1000.0,2.0));
79 DefaultErr.push_back(0.0);
80 DefaultErr.push_back(0.0);
81 DefaultErr.push_back(pow(20.0/1000.0,2.0));
83 registerOptionalParameter(
"ManualIPVertexError" ,
84 "Manually set error matrix of the primary vertex (cm) (lower symmetric)" ,
85 _ManualPrimaryVertexErr,
88 registerOptionalParameter(
"MinimumProbability" ,
89 "If a vertex candidate has a probability below this it will not be considered - lower value results in more merging and lower vertex multiplicity" ,
92 registerOptionalParameter(
"InitialGhostWidth" ,
93 "Width in cm of the ghost inital ghosttrack, also the smallest width it is allowed to have" ,
95 double(25.0/1000.0)) ;
96 registerOptionalParameter(
"MaxChi2Allowed" ,
97 "The ghost track is widened until all forward jet tracks have a chi squared lower than this value" ,
100 registerOptionalParameter(
"OutputTrackChi2" ,
101 "If true the chi squared contributions of tracks to vertices is written to LCIO" ,
107 void ZVTOPZVKINProcessor::init() {
116 _ZVKIN =
new ZVKIN();
119 _ZVKIN->setDoubleParameter(
"MinimumProbability",_MinimumProbability);
120 _ZVKIN->setDoubleParameter(
"InitialGhostWidth",_InitialGhostWidth);
121 _ZVKIN->setDoubleParameter(
"MaxChi2Allowed",_MaxChi2Allowed);
122 _ZVKIN->setStringParameter(
"AutoJetAxis",
"TRUE");
123 _ZVKIN->setStringParameter(
"UseEventIP",
"TRUE");
127 void ZVTOPZVKINProcessor::processRunHeader( LCRunHeader* run) {
131 void ZVTOPZVKINProcessor::processEvent( LCEvent * evt ) {
133 LCCollection* JetCollection;
134 JetCollection = evt->getCollection( _JetRPCollectionName );
139 if (_ManualPrimaryVertex)
143 IPPos.x() = _ManualPrimaryVertexPos[0];
144 IPPos.y() = _ManualPrimaryVertexPos[1];
145 IPPos.z() = _ManualPrimaryVertexPos[2];
146 IPErr(0,0) = _ManualPrimaryVertexErr[0];
147 IPErr(1,0) = _ManualPrimaryVertexErr[1];
148 IPErr(1,1) = _ManualPrimaryVertexErr[2];
149 IPErr(2,0) = _ManualPrimaryVertexErr[3];
150 IPErr(2,1) = _ManualPrimaryVertexErr[4];
151 IPErr(2,2) = _ManualPrimaryVertexErr[5];
156 LCCollection* VertexCol;
157 VertexCol = evt->getCollection( _IPVertexCollectionName );
160 int nVerts = VertexCol->getNumberOfElements() ;
162 for(
int i=0; i< nVerts ; i++)
164 lcio::Vertex* iVertex =
dynamic_cast<lcio::Vertex*
>(VertexCol->getElementAt(i));
165 if (iVertex->isPrimary())
167 IPPos.x() = iVertex->getPosition()[0];
168 IPPos.y() = iVertex->getPosition()[1];
169 IPPos.z() = iVertex->getPosition()[2];
170 IPErr(0,0) = iVertex->getCovMatrix()[0];
171 IPErr(1,0) = iVertex->getCovMatrix()[1];
172 IPErr(1,1) = iVertex->getCovMatrix()[2];
173 IPErr(2,0) = iVertex->getCovMatrix()[3];
174 IPErr(2,1) = iVertex->getCovMatrix()[4];
175 IPErr(2,2) = iVertex->getCovMatrix()[5];
186 std::vector<std::string>::const_iterator it = find(evt->getCollectionNames()->begin(),evt->getCollectionNames()->end(),_DecayChainCollectionName);
187 if (it == evt->getCollectionNames()->end())
190 LCCollection* MyCollection =
new LCCollectionVec(
"ReconstructedParticle");
191 evt->addCollection(MyCollection,_DecayChainCollectionName);
193 int nRCP = JetCollection->getNumberOfElements() ;
194 for(
int i=0; i< nRCP ; i++)
196 Jet* MyJet = jetFromLCIORP(MyEvent,dynamic_cast<ReconstructedParticle*>(JetCollection->getElementAt(i)));
201 DecayChain* ZVTOPResult = _ZVKIN->calculateFor(MyJet);
204 ReconstructedParticle* LCIOZVTOPResult = addDecayChainToLCIOEvent(evt, ZVTOPResult,_VertexCollectionName, _DecayChainRPTracksCollectionName, _OutputTrackChi2);
207 evt->getCollection(_DecayChainCollectionName)->addElement(LCIOZVTOPResult);
229 void ZVTOPZVKINProcessor::check( LCEvent * evt ) {
234 void ZVTOPZVKINProcessor::end(){
237 std::cout <<
"ZVTOPZVKINProcessor::end() " << name()
238 <<
" processed " << _nEvt <<
" events in " << _nRun <<
" runs "
Find vertices in a jet using kinematic ZVTOP-ZVKIN algorithm.
void registerObject(T *pointer)
Register an object for memory management.
Algorithm interface for decay chain construction or vertexing.