5 namespace TTbarAnalysis
11 _description =
"TruthVertexFinder extructs a secondary vertex from generator collection." ;
14 registerInputCollection( LCIO::MCPARTICLE,
16 "Name of the MCParticle collection" ,
18 std::string(
"MCParticleSkimmed")
20 registerOutputCollection( LCIO::VERTEX,
21 "OutputCollectionName" ,
22 "Name of the Vertex collection" ,
24 std::string(
"MCVertex")
26 registerOutputCollection( LCIO::MCPARTICLE,
28 "Name of the Vertex collection" ,
32 registerOutputCollection( LCIO::MCPARTICLE,
34 "Name of the Prongs collection" ,
36 std::string(
"EGProngs")
44 registerOutputCollection(LCIO::MCPARTICLE,
45 "QuarkCollectionName" ,
46 "Name of the b-quark collection" ,
48 std::string(
"MCbquarks")
50 registerInputCollection( LCIO::RECONSTRUCTEDPARTICLE,
52 "Name of the Jet relation collection",
54 std::string(
"RecoMCTruthLink")
56 registerProcessorParameter(
"DecayChainPDGs" ,
57 "PDGs of desired decays" ,
62 registerProcessorParameter(
"tagPDG" ,
63 "PDG of desired particle" ,
68 registerProcessorParameter(
"writeROOT" ,
74 registerProcessorParameter(
"initialQuarkPDG" ,
75 "PDG of initial particle" ,
80 registerProcessorParameter(
"a" ,
81 "a parameter of accuracy in mm" ,
86 registerProcessorParameter(
"b" ,
87 "b parameter of accuracy in mm" ,
92 registerProcessorParameter(
"writeBonly" ,
98 registerProcessorParameter(
"ROOTFileName" ,
118 streamlog_out(MESSAGE) <<
" init called " << std::endl;
122 streamlog_out(ERROR) <<
" ERROR: size " <<
inputPdg.size() <<
" - Running on default settings" << std::endl;
127 for (
unsigned int i = 0; i <
inputPdg.size(); i++)
138 _hBStarTree =
new TTree(
"BStar",
"My test tree!" );
139 _hBStarTree->Branch(
"bstarnumber", &
_bstarnumber,
"bstarnumber/I");
140 _hBStarTree->Branch(
"bstarmomentum",
_bstarmomentum,
"bstarmomentum[bstarnumber]/F");
141 _hBStarTree->Branch(
"bstaroffset",
_bstaroffset,
"bstaroffset[bstarnumber]/F");
142 _hVertexTree =
new TTree(
"Vertices",
"My test tree!" );
154 _hTree =
new TTree(
"Stats",
"My test tree!" );
194 _hTrackTree =
new TTree(
"Tracks",
"My test tree!" );
236 streamlog_out(MESSAGE) << std::fixed << std::setw( 6 ) << std::setprecision( 3 ) << std::setfill(
' ' );
237 streamlog_out(MESSAGE) <<
"|"<<particle->getPDG() <<
"\t\t|"<<particle->getMass()<<
"\t\t|"<<particle->getCharge() <<
"\t\t|"<<particle->getEnergy()<<
"\t\t|"<<particle->getVertex()[0]<<
"\t\t|"<<particle->getVertex()[1]<<
"\t\t|"<<particle->getVertex()[2] <<
"\t\t|\n";
242 if (!vertices || vertices->size() <
_pdgs.size()-1)
246 for (
unsigned int i = 0; i < vertices->size(); i++)
248 Vertex * vertex = vertices->at(i);
251 ReconstructedParticle * particle = vertex->getAssociatedParticle();
258 MyVertex * myvertex =
static_cast< MyVertex *
>(vertex);
259 for (
unsigned int j = 0; j < particle->getParticles().size(); j++)
274 for (
unsigned int i = 0; i < chain->size(); i++)
282 if (quarks.size() == 2)
286 mc->addElement(quarks[0]);
287 mc->addElement(quarks[1]);
294 if (!verticies || !chain)
298 int vsize = verticies->size();
299 bool useRelation =
false;
303 vertexOperator.
AddProngs(verticies->at(0), bdaughters, useRelation);
305 vertexOperator.
AddProngs(verticies->at(1), cdaughters, useRelation);
308 for (
unsigned int i = 0; i < bdaughters.size(); i++)
310 parameters.push_back( (
float) chain->
GetParentPDG() / 5.0 * 2);
311 col->addElement(bdaughters[i]);
313 for (
unsigned int i = 0; i < cdaughters.size(); i++)
315 parameters.push_back( (
float) chain->
GetParentPDG() / 5.0 * 3);
316 col->addElement(cdaughters[i]);
326 streamlog_out(MESSAGE) <<
"Prongs for quark " << chain->
GetParentPDG() <<
": \n";
327 for (
unsigned int i = 0; i < bdaughters.size(); i++)
331 vertexOperator.
AddProngs(verticies->at(0), bdaughters, useRelation);
334 for (
unsigned int i = 0; i < bdaughters.size(); i++)
336 col->addElement(bdaughters[i]);
354 LCCollection* col = evt->getCollection(
_colName );
355 streamlog_out(MESSAGE) <<
"***********TruthVertexFinder*"<<
_nEvt<<
"***************\n";
356 LCCollection* rel = evt->getCollection(
_colRelName);
365 streamlog_out(MESSAGE) <<
"\t|PDG\t\t|Mass\t\t|Charge\t\t|Energy\t\t|Vtx X\t\t|Vtx Y\t\t|Vtx Z\t\t|\n";
373 streamlog_out(MESSAGE) <<
"Additional B particles: \n";
374 for (
unsigned int i = 0; i < daughters.size(); i++)
379 mc->addElement(daughters[i]);
388 streamlog_out(MESSAGE) <<
"Additional Bbar particles: \n";
389 for (
unsigned int i = 0; i < daughters.size(); i++)
394 mc->addElement(daughters[i]);
400 vector< Vertex * > * bverticies = vertexOperator.
Construct(bChain);
401 vector< Vertex * > * bbarverticies = vertexOperator.
Construct(bbarChain);
403 vector <int> parameters;
404 prongs->setSubset ();
406 AddProngs(vertexOperator, opera, bChain, bverticies,parameters, prongs);
407 AddProngs(vertexOperator, opera, bbarChain, bbarverticies,parameters, prongs);
415 prongs->parameters().setValues(
"trackIDs", parameters);
416 prongs->parameters().setValue(
"GenVertexTag",
_tag);
425 Write(opera, bChain,bverticies);
426 Write(opera, bbarChain,bbarverticies);
441 streamlog_out(MESSAGE) <<
"b number: " <<
_btotalnumber <<
"\n";
445 catch( DataNotAvailableException &
e)
447 streamlog_out(MESSAGE) <<
"No collection!" << std::endl ;
456 if (particles.size() < 2)
468 if (!chain || !chain->
Get(0))
472 for (
int i = 0; i < chain->
GetSize(); i++)
481 const vector< MCParticle * > daughters =
static_cast< MyVertex *
>(verticies->at(0))->__GetMCParticles();
487 streamlog_out(MESSAGE) <<
"Vertex b-quark: " << verticies->at(0)->getParameters()[0]<<
" n-tracks: " <<
_bnumber <<
'\n';
489 const vector< MCParticle * > cdaughters =
static_cast< MyVertex *
>(verticies->at(1))->__GetMCParticles();
494 Write(cdaughters, 2);
496 streamlog_out(MESSAGE) <<
"Vertex c-quark: " << verticies->at(1)->getParameters()[0] <<
" n-tracks: " <<
_cnumber <<
'\n';
500 streamlog_out(MESSAGE) <<
"Checking b-quark meson...\n";
503 streamlog_out(MESSAGE) <<
"Checking c-quark meson...\n";
506 streamlog_out(MESSAGE) <<
"Missing pt for b-quark hadron: " <<
_bptmiss <<
"\n";
516 const vector< MCParticle * > daughters =
static_cast< MyVertex *
>(verticies->at(0))->__GetMCParticles();
517 Write(daughters, -1);
522 streamlog_out(MESSAGE) <<
"Vertex bbar-quark"<< 0 <<
": " << verticies->at(0)->getParameters()[0] <<
" n-tracks: " <<
_bbarnumber <<
'\n';
523 const vector< MCParticle * > cdaughters=
static_cast< MyVertex *
>(verticies->at(1))->__GetMCParticles();
526 streamlog_out(MESSAGE) <<
"Vertex cbar-quark: " << verticies->at(1)->getParameters()[0] <<
" n-tracks: " <<
_cbarnumber <<
'\n';
532 Write(cdaughters, -2);
534 streamlog_out(MESSAGE) <<
"Missing pt for bbar-quark hadron: " <<
_bbarptmiss <<
"\n";
547 streamlog_out(MESSAGE) <<
"Misreco: " <<
_misreconumber <<
" particles: " << particles->size() <<
'\n';
560 const float * position = vertex->getPosition();
561 for (
int i = 0; i < 3; i++)
563 streamlog_out(MESSAGE) << i <<
": " << position[i];
565 streamlog_out(MESSAGE) <<
'\n';
566 vector< const double * > vectors;
567 for (
unsigned int i = 0; i < bdaugthers.size(); i++)
569 vectors.push_back(bdaugthers[i]->getMomentum());
571 for (
unsigned int i = 0; i < cdaughters.size(); i++)
573 vectors.push_back(cdaughters[i]->getMomentum());
580 float * offset = NULL;
607 int size = daughters.size();
608 for (
int i = 0; i < size; i++)
610 MCParticle * daughter = daughters[i];
623 for (
unsigned int i = 0; i < bvertexes->size(); i++)
626 mc->addElement(bvertexes->at(i));
631 for (
unsigned int i = 0; i < bbarvertexes->size(); i++)
633 mc->addElement(bbarvertexes->at(i));
636 mc->parameters().setValue(
"GenVertexTag",
_tag);
674 for (
int i = 0; i < 2; i++)
680 for (
int i = 0; i <
MAXV; i++)
701 for (
int j = 0; j < 3; j++)
705 for (
int j = 0; j <
MAXV; j++)
709 _massOfParticles[i][j] = -1.0;
int _interactionOfParticles[MAXV][MAXV]
DecayChain * Construct(std::string name, int pdg, std::vector< PDGTYPE > typeOfProducts)
void Write(std::vector< EVENT::Vertex * > *vertices, int &number)
void AddProngs(VertexMCOperator &vertexOperator, MCOperator &opera, DecayChain *chain, std::vector< Vertex * > *vertices, std::vector< int > ¶meters, IMPL::LCCollectionVec *col=NULL)
std::vector< PDGTYPE > _pdgs
float _momentumOfParticles[MAXV][MAXV]
bool CheckCompatibility(const std::vector< EVENT::MCParticle * > &daughters, EVENT::MCParticle *parent, int plusCharge=0)
static std::vector< float > getDirection(std::vector< int > &vectorPoint1, std::vector< int > &vectorPoint2)
void PrintChain(std::vector< MCParticle * > *chain)
double getMissingPt(const std::vector< MCParticle * > &bdaugthers, const std::vector< MCParticle * > &cdaughters, Vertex *vertex)
int _initialQuarkPDGparameter
std::vector< EVENT::MCParticle * > CheckDaughterVisibility(const std::vector< EVENT::MCParticle * > &daughters)
float _secondVertexDistance[2]
static float getModule(const std::vector< int > &v)
virtual void processRunHeader(LCRunHeader *run)
float _distanceFromIP[MAXV]
std::vector< EVENT::MCParticle * > GetPairParticles(int pdg)
float _boffsettrack[MAXV]
TruthVertexFinder aTruthVertexFinder
std::string _outputProngsName
float _misrecocostheta[MAXVV]
float _cbaretatrack[MAXV]
void PrintParticle(MCParticle *particle)
float _cbaroffsettrack[MAXV]
void WriteQuarksCollection(LCEvent *evt, std::vector< MCParticle * > &quarks)
std::string _outputcolName
void WriteMisReco(std::vector< MCParticle * > *particles)
float _misrecomomentum[MAXVV]
static float getPt(const double *momentum)
float _firstVertexDistance[2]
float _coffsettrack[MAXV]
std::string _outputquarkcolName
std::vector< EVENT::MCParticle * > * CheckProcessForPair(int pdg)
static std::vector< float > getAngles(std::vector< float > &direction)
float GetAccuracy(EVENT::MCParticle *particle, float a, float b)
virtual void processEvent(LCEvent *evt)
float _misrecotheta[MAXVV]
float _bstarmomentum[MAXV]
std::string _outputBStarName
void WriteVertexCollection(LCEvent *evt, std::vector< Vertex * > *bvertexes, std::vector< Vertex * > *bbarvertexes)
DecayChain * RefineDecayChain(DecayChain *initial, std::vector< PDGTYPE > typeOfProducts)
std::vector< LCCollection * > LCCollectionVec
static double getMissingPt(std::vector< const double * > &vectors, const float *target)
void GetAsymmetry(std::vector< MCParticle * > &particles)
std::vector< EVENT::Vertex * > * Construct(DecayChain *chain)
float _bbaroffsettrack[MAXV]
float _massOfParticles[MAXV][MAXV]
This processor is designed to extruct a secondary/// vertices from collection of generated particles...
int _numberOfParticles[MAXV]
static float getDistance(const double *start, const double *end)
static float getDistanceTo(const std::vector< int > &vectorPoint1, const std::vector< float > &vector1, const std::vector< int > *pointOfLine)
float _bbaretatrack[MAXV]
EVENT::MCParticle * Get(int i)
virtual void check(LCEvent *evt)
float _energyOfParticles[MAXV][MAXV]
void AddProngs(EVENT::Vertex *vertex, std::vector< EVENT::MCParticle * > &particles, bool usingRelation=false)
std::vector< EVENT::MCParticle * > SelectStableCloseDaughters(EVENT::MCParticle *parent, int excludePDG=0, bool selectReco=false, std::vector< EVENT::MCParticle * > *misReconstructed=NULL)
float _coordinates[MAXV][3]