All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
ReconstructedParticleImpl_CopyProcessor.cc
Go to the documentation of this file.
2 #include "marlin/Global.h"
3 #include "EVENT/LCCollection.h"
4 #include "IMPL/LCCollectionVec.h"
5 #include "UTIL/LCRelationNavigator.h"
6 #include "IMPL/ReconstructedParticleImpl.h"
7 
9 
10 ReconstructedParticleImpl_CopyProcessor::ReconstructedParticleImpl_CopyProcessor() : Processor("ReconstructedParticleImpl_CopyProcessor") {
11 
12  _description = "ReconstructedParticleImpl_CopyProcessor: Copies each entry of a LCIO collection of ReconstructedParticleImpl. Select in the optional parameters which members should not be copied." ;
13 
14  registerInputCollection(LCIO::RECONSTRUCTEDPARTICLE,
15  "InputCollection",
16  "Pandora PFOs",
18  std::string("PandoraPFOs"));
19 
20  registerOutputCollection(LCIO::RECONSTRUCTEDPARTICLE,
21  "OutputCollection",
22  "New Pandora PFOs",
24  std::string("NewPandoraPFOs"));
25 
26  registerOutputCollection(LCIO::LCRELATION,
27  "RelationCollection",
28  "Old to New Pandora PFOs Link",
30  std::string("Old2NewPandoraPFOsLink"));
31 
32  registerProcessorParameter("copyType",
33  "Copy type.",
34  _copyType,
35  bool(true));
36 
37  registerProcessorParameter("copyMomentum",
38  "Copy momentum.",
40  bool(true));
41 
42  registerProcessorParameter("copyEnergy",
43  "Copy energy.",
45  bool(true));
46 
47  registerProcessorParameter("copyCovMatrix",
48  "Copy covariance matrix.",
50  bool(true));
51 
52  registerProcessorParameter("copyMass",
53  "Copy mass.",
54  _copyMass,
55  bool(true));
56 
57  registerProcessorParameter("copyCharge",
58  "Copy charge.",
60  bool(true));
61 
62  registerProcessorParameter("copyReferencePoint",
63  "Copy reference point.",
65  bool(true));
66 
67  registerProcessorParameter("copyParticleIDs",
68  "Copy all particle ID entries.",
70  bool(true));
71 
72  registerProcessorParameter("copyParticleIDUsed",
73  "Copy which particle ID is used.",
75  bool(true));
76 
77  registerProcessorParameter("copyGoodnessOfPID",
78  "Copy the goodness of the PID.",
80  bool(true));
81 
82  registerProcessorParameter("copyParticles",
83  "Copy all particles.",
85  bool(true));
86 
87  registerProcessorParameter("copyClusters",
88  "Copy all clusters.",
90  bool(true));
91 
92  registerProcessorParameter("copyTracks",
93  "Copy all tracks.",
95  bool(true));
96 
97  registerProcessorParameter("copyStartVertex",
98  "Copy start vertex.",
100  bool(true));
101 
102 }
103 
105 {
106  // usually a good idea to
107  printParameters();
108 
109  _nEvt = 0;
110 }
111 
113 {
114  LCCollection *incol{}, *relcol{};
115  int n_incol = 0;
116 
117  try
118  {
119  incol = evt->getCollection( _InputColName );
120  n_incol = incol->getNumberOfElements();
121  }
122  catch(DataNotAvailableException &e)
123  {
124  streamlog_out(MESSAGE) << "Input collection not found in event " << _nEvt << std::endl;
125  }
126 
127  LCCollectionVec* outcol = new LCCollectionVec( LCIO::RECONSTRUCTEDPARTICLE );
128  LCRelationNavigator relnav( LCIO::RECONSTRUCTEDPARTICLE , LCIO::RECONSTRUCTEDPARTICLE );
129 
130  for (int i=0; i<n_incol; ++i)
131  {
132  ReconstructedParticleImpl* inpart = dynamic_cast<ReconstructedParticleImpl*>(incol->getElementAt(i));
133  ReconstructedParticleImpl* outpart = new ReconstructedParticleImpl;
134 
135  if (_copyType) outpart->setType(inpart->getType());
136  if (_copyMomentum) outpart->setMomentum(inpart->getMomentum());
137  if (_copyEnergy) outpart->setEnergy(inpart->getEnergy());
138  if (_copyCovMatrix) outpart->setCovMatrix(inpart->getCovMatrix());
139  if (_copyMass) outpart->setMass(inpart->getMass());
140  if (_copyCharge) outpart->setCharge(inpart->getCharge());
141  if (_copyReferencePoint) outpart->setReferencePoint(inpart->getReferencePoint());
142  if (_copyParticleIDs)
143  for (unsigned int j=0; j<inpart->getParticleIDs().size(); ++j)
144  outpart->addParticleID(inpart->getParticleIDs()[j]);
145  if (_copyParticleIDUsed) outpart->setParticleIDUsed(inpart->getParticleIDUsed());
146  if (_copyGoodnessOfPID) outpart->setGoodnessOfPID(inpart->getGoodnessOfPID());
147  if (_copyParticles)
148  for (unsigned int j=0; j<inpart->getParticles().size(); ++j)
149  outpart->addParticle(inpart->getParticles()[j]);
150  if (_copyClusters)
151  for (unsigned int j=0; j<inpart->getClusters().size(); ++j)
152  outpart->addCluster(inpart->getClusters()[j]);
153  if (_copyTracks)
154  for (unsigned int j=0; j<inpart->getTracks().size(); ++j)
155  outpart->addTrack(inpart->getTracks()[j]);
156  if (_copyStartVertex) outpart->setStartVertex(inpart->getStartVertex());
157 
158  outcol->addElement(outpart);
159  relnav.addRelation(inpart,outpart,1);
160  }
161 
162  relcol = relnav.createLCCollection();
163  evt->addCollection(outcol,_OutputColName);
164  evt->addCollection(relcol,_RelationColName);
165 
166  _nEvt++;
167 }
168 
ReconstructedParticleImpl_CopyProcessor aReconstructedParticleImpl_CopyProcessor
static const float e
std::vector< LCCollection * > LCCollectionVec
Definition: SiStripClus.h:55