1 #include "ZVTOPZVRESProcessor.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/zvres.h>
13 #include <util/inc/matrix.h>
14 #include <inc/lciointerface.h>
19 using namespace marlin ;
21 using namespace vertex_lcfi;
25 ZVTOPZVRESProcessor::ZVTOPZVRESProcessor() : Processor(
"ZVTOP_ZVRESProcessor") {
28 _description =
"ZVTOP_ZVRES - 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(
"ZVRESDecayChainRPTracks") ) ;
51 registerOutputCollection( lcio::LCIO::VERTEX,
53 "Name of the Vertex collection that contains found vertices" ,
54 _VertexCollectionName ,
55 std::string(
"ZVRESVertices") ) ;
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(
"ZVRESDecayChains") ) ;
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)" ,
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(
"IPWeighting" ,
89 "Weight of the IP in the Vertex Function" ,
92 registerOptionalParameter(
"JetWeightingEnergyScaling" ,
93 "Scaling factor for Weight of the jet direction in the Vertex Function" ,
94 _JetWeightingEnergyScaling,
96 registerOptionalParameter(
"TwoTrackCut" ,
97 "Chi Squared cut for making initial track pairs - chi squared of either track NOT sum" ,
100 registerOptionalParameter(
"TrackTrimCut" ,
101 "Chi Squared cut for final trimming of tracks from vertices" ,
104 registerOptionalParameter(
"ResolverCut" ,
105 "Cut to determine if two vertices are resolved" ,
108 registerOptionalParameter(
"OutputTrackChi2" ,
109 "If true the chi squared contributions of tracks to vertices is written to LCIO" ,
116 void ZVTOPZVRESProcessor::init() {
125 _ZVRES =
new ZVRES();
138 void ZVTOPZVRESProcessor::processRunHeader( LCRunHeader* run) {
142 void ZVTOPZVRESProcessor::processEvent( LCEvent * evt ) {
144 LCCollection* JetCollection;
145 JetCollection = evt->getCollection( _JetRPCollectionName );
150 if (_ManualPrimaryVertex)
154 IPPos.x() = _ManualPrimaryVertexPos[0];
155 IPPos.y() = _ManualPrimaryVertexPos[1];
156 IPPos.z() = _ManualPrimaryVertexPos[2];
157 IPErr(0,0) = _ManualPrimaryVertexErr[0];
158 IPErr(1,0) = _ManualPrimaryVertexErr[1];
159 IPErr(1,1) = _ManualPrimaryVertexErr[2];
160 IPErr(2,0) = _ManualPrimaryVertexErr[3];
161 IPErr(2,1) = _ManualPrimaryVertexErr[4];
162 IPErr(2,2) = _ManualPrimaryVertexErr[5];
167 LCCollection* VertexCol;
168 VertexCol = evt->getCollection( _IPVertexCollectionName );
171 int nVerts = VertexCol->getNumberOfElements() ;
173 for(
int i=0; i< nVerts ; i++)
175 lcio::Vertex* iVertex =
dynamic_cast<lcio::Vertex*
>(VertexCol->getElementAt(i));
176 if (iVertex->isPrimary())
178 IPPos.x() = iVertex->getPosition()[0];
179 IPPos.y() = iVertex->getPosition()[1];
180 IPPos.z() = iVertex->getPosition()[2];
181 IPErr(0,0) = iVertex->getCovMatrix()[0];
182 IPErr(1,0) = iVertex->getCovMatrix()[1];
183 IPErr(1,1) = iVertex->getCovMatrix()[2];
184 IPErr(2,0) = iVertex->getCovMatrix()[3];
185 IPErr(2,1) = iVertex->getCovMatrix()[4];
186 IPErr(2,2) = iVertex->getCovMatrix()[5];
198 std::vector<std::string>::const_iterator it = find(evt->getCollectionNames()->begin(),evt->getCollectionNames()->end(),_DecayChainCollectionName);
199 if (it == evt->getCollectionNames()->end())
202 LCCollection* MyCollection =
new LCCollectionVec(
"ReconstructedParticle");
203 evt->addCollection(MyCollection,_DecayChainCollectionName);
206 int nRCP = JetCollection->getNumberOfElements() ;
207 for(
int i=0; i< nRCP ; i++)
209 Jet* MyJet = jetFromLCIORP(MyEvent,dynamic_cast<ReconstructedParticle*>(JetCollection->getElementAt(i)));
216 std::cout << ZVTOPResult->
vertices().size() <<
" ";
219 ReconstructedParticle* LCIOZVTOPResult = addDecayChainToLCIOEvent(evt, ZVTOPResult,_VertexCollectionName, _DecayChainRPTracksCollectionName, _OutputTrackChi2);
222 evt->getCollection(_DecayChainCollectionName)->addElement(LCIOZVTOPResult);
238 std::cout <<
",";std::cout.flush();
239 MetaMemoryManager::Event()->delAllObjects();
245 void ZVTOPZVRESProcessor::check( LCEvent * evt ) {
250 void ZVTOPZVRESProcessor::end(){
252 MetaMemoryManager::Run()->delAllObjects();
253 std::cout <<
"ZVTOPZVRESProcessor::end() " << name()
254 <<
" processed " << _nEvt <<
" events in " << _nRun <<
" runs "
void registerObject(T *pointer)
Register an object for memory management.
Find vertices in a jet using topological ZVTOP-ZVRES algorithm.
double energy() const
Energy.
const std::vector< Vertex * > & vertices() const
Vertices contained in DecayChain.
virtual void setDoubleParameter(const string &Parameter, const double Value)=0
Set Double Parameter.
Algorithm interface for decay chain construction or vertexing.
virtual void setStringParameter(const string &Parameter, const string &Value)=0
Set String Parameter.
virtual OUTTYPE calculateFor(INTYPE Input) const =0
Run the algorithm on a jet.