1 #include "VertexChargeProcessor.h"
5 #include <EVENT/LCParameters.h>
6 #include <EVENT/LCCollection.h>
7 #include <EVENT/ReconstructedParticle.h>
8 #include <EVENT/Track.h>
9 #include <EVENT/LCRelation.h>
10 #include <IMPL/LCCollectionVec.h>
11 #include <UTIL/LCRelationNavigator.h>
12 #include <IMPL/ParticleIDImpl.h>
13 #include <EVENT/LCFloatVec.h>
15 #include <inc/event.h>
16 #include <util/inc/memorymanager.h>
18 #include <inc/track.h>
20 #include <inc/vertex.h>
21 #include <algo/inc/vertexcharge.h>
22 #include <algo/inc/trackattach.h>
23 #include <util/inc/helixrep.h>
24 #include <util/inc/projection.h>
25 #include <inc/track.h>
26 #include <inc/lciointerface.h>
27 #include <algo/inc/twotrackpid.h>
33 using namespace marlin ;
35 using namespace vertex_lcfi;
42 VertexChargeProcessor::VertexChargeProcessor() : Processor(
"VertexChargeProcessor") {
44 _description =
"VertexChargeProcessor - takes a set of vertices as a decay chain with its associated jet and calculates the vertex charge." ;
47 registerInputCollection( lcio::LCIO::RECONSTRUCTEDPARTICLE,
49 "Name of the ReconstructedParticle collection that represents jets",
51 std::string(
"Jets") ) ;
52 registerInputCollection( lcio::LCIO::VERTEX,
53 "IPVertexCollection" ,
54 "Name of the Vertex collection that contains the primary vertex (Optional)" ,
55 _IPVertexCollectionName ,
56 std::string(
"IPVertex") ) ;
57 registerInputCollection( lcio::LCIO::RECONSTRUCTEDPARTICLE,
58 "DecayChainRPCollection" ,
59 "Name of the ReconstructedParticle collection that represents decay chains" ,
60 _DecayChainRPColName ,
61 std::string(
"DecayChains") ) ;
62 registerOutputCollection( lcio::LCIO::LCFLOATVEC,
63 "VertexChargeCollection" ,
64 "Name of the LCFloatVec Collection that will be created to contain the flavour tag inputs" ,
65 _VertexChargeCollectionName,
67 registerOptionalParameter(
"ChargeAllSecondaryTracks",
68 "Parameter determining whether all tracks from secondary are included in the B-Charge" ,
69 _ChargeAddAllTracksFromSecondary,
71 registerOptionalParameter(
"ChargeLoDCutmin",
72 "Cut determining the minimum L/D for the B-Charge" ,
75 registerOptionalParameter(
"ChargeLoDCutmax",
76 "Cut determining the maximum L/D for the B-Charge" ,
79 registerOptionalParameter(
"ChargeCloseapproachCut",
80 "Upper cut on track distance of closest approach to the seed axis for the B-Charge " ,
81 _ChargeCloseapproachCut,
86 void VertexChargeProcessor::init()
96 _Attach->setDoubleParameter(
"AddAllTracksFromSecondary",_ChargeAddAllTracksFromSecondary );
97 _Attach->setDoubleParameter(
"LoDCutmin",_ChargeLoDCutmin );
98 _Attach->setDoubleParameter(
"LoDCutmax",_ChargeLoDCutmax );
99 _Attach->setDoubleParameter(
"CloseapproachCut",_ChargeCloseapproachCut );
107 void VertexChargeProcessor::processRunHeader( LCRunHeader* run) {
109 _JetVariableNames.clear();
110 _JetVariableNames.push_back(
"Charge");
111 run->parameters().setValues(_VertexChargeCollectionName, _JetVariableNames);
116 void VertexChargeProcessor::processEvent( LCEvent * evt ) {
123 std::cout <<
"Collections in Event" << std::endl;
124 const std::vector<std::string>* names = evt->getCollectionNames();
125 for (
unsigned int i = 0 ; i<names->size() ; ++i) std::cout << (*names)[i] << std::endl;
128 LCCollection* JetRPCol = evt->getCollection( _JetRPColName );
129 LCCollection* DecayChainRPCol = evt->getCollection( _DecayChainRPColName );
132 LCCollection* VertexCol;
133 VertexCol = evt->getCollection( _IPVertexCollectionName );
138 int nVerts = VertexCol->getNumberOfElements() ;
140 for(
int i=0; i< nVerts ; i++)
142 lcio::Vertex* iVertex =
dynamic_cast<lcio::Vertex*
>(VertexCol->getElementAt(i));
143 if (iVertex->isPrimary())
145 IPPos.x() = iVertex->getPosition()[0];
146 IPPos.y() = iVertex->getPosition()[1];
147 IPPos.z() = iVertex->getPosition()[2];
148 IPErr(0,0) = iVertex->getCovMatrix()[0];
149 IPErr(1,0) = iVertex->getCovMatrix()[1];
150 IPErr(1,1) = iVertex->getCovMatrix()[2];
151 IPErr(2,0) = iVertex->getCovMatrix()[3];
152 IPErr(2,1) = iVertex->getCovMatrix()[4];
153 IPErr(2,2) = iVertex->getCovMatrix()[5];
163 std::map<Jet*,DecayChain*> DecayChainOf;
164 std::map<Jet*,ReconstructedParticle*> LCIORPOf;
168 int nRCP = JetRPCol->getNumberOfElements() ;
170 if(nRCP ==0 ) std::cerr<<
"Warning: VertexChargeProcessor.cc:336 : NO jets present "<<std::endl;
173 for(
int i=0; i< nRCP ; i++)
175 ReconstructedParticle* JetRP =
dynamic_cast<ReconstructedParticle*
>(JetRPCol->getElementAt(i));
176 Jet* ThisJet = jetFromLCIORP(MyEvent,JetRP);
177 LCIORPOf[ThisJet] = JetRP;
179 DecayChainOf[ThisJet] = decayChainFromLCIORP(ThisJet,dynamic_cast<ReconstructedParticle*>(DecayChainRPCol->getElementAt(i)));
198 LCCollectionVec* OutCollection =
new LCCollectionVec(
"LCFloatVec");
199 evt->addCollection(OutCollection,_VertexChargeCollectionName);
203 for (vector<Jet*>::const_iterator iJet=MyEvent->
jets().begin();iJet != MyEvent->
jets().end();++iJet)
209 VertexCharge.push_back(_VertexCharge->calculateFor(_Attach->calculateFor(DecayChainOf[*iJet])));
210 LCFloatVec* OutVec =
new LCFloatVec(VertexCharge);
211 OutCollection->addElement(OutVec);
223 void VertexChargeProcessor::check( LCEvent * evt ) {
228 void VertexChargeProcessor::end(){
231 std::cout <<
"VertexChargeProcessor::end() " << name()
232 <<
" processed " << _nEvt <<
" events in " << _nRun <<
" runs "
void registerObject(T *pointer)
Register an object for memory management.
Projection
Projection Type.
const std::vector< Jet * > & jets() const
Get Jets.
Calculates the Vertex Charge.
static MemoryManager< T > * Event()
Returns the Event duration singleton instance of the MemoryManager for type T.
Calculation of the charge of the vertex.
Track attachment algorithm. Calculates the seed vertex and the Tracks attached to it...