All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
JetPFOsProcessor.cc
Go to the documentation of this file.
1 // *****************************************************
2 // Processor to save particles from jets to a PFO collection
3 // ----Junping
4 // *****************************************************
5 #include "JetPFOsProcessor.h"
6 #include <iostream>
7 #include <sstream>
8 #include <iomanip>
9 
10 #include <EVENT/LCCollection.h>
11 #include <IMPL/LCCollectionVec.h>
12 #include <EVENT/ReconstructedParticle.h>
13 #include <IMPL/ReconstructedParticleImpl.h>
14 #include <UTIL/LCTypedVector.h>
15 #include <marlin/Exceptions.h>
16 
17 // ----- include for verbosity dependend logging ---------
18 #include "marlin/VerbosityLevels.h"
19 
20 using namespace lcio ;
21 using namespace marlin ;
22 using namespace std;
23 
25 
26 
27 JetPFOsProcessor::JetPFOsProcessor() : Processor("JetPFOsProcessor") {
28 
29  // modify processor description
30  _description = "JetPFOsProcessor does whatever it does ..." ;
31 
32 
33  // register steering parameters: name, description, class-variable, default value
34 
35  registerInputCollection( LCIO::RECONSTRUCTEDPARTICLE,
36  "InputJetCollection" ,
37  "Name of the input jet collection" ,
38  _colJet ,
39  std::string("JetsFromKt") ) ;
40 
41  registerOutputCollection( LCIO::RECONSTRUCTEDPARTICLE,
42  "OutputPFOsCollection",
43  "Name of the output PFOs collection",
45  std::string("PFOsFromKtJet") );
46 
47 }
48 
50 
51  streamlog_out(DEBUG) << " JetPFOs Processor init called "
52  << std::endl ;
53 
54 }
55 
56 void JetPFOsProcessor::processRunHeader( LCRunHeader* /*run*/) {
57 }
58 
59 void JetPFOsProcessor::processEvent( LCEvent * evt ) {
60 
61  LCCollection *colJet = evt->getCollection(_colJet);
62  if (!colJet) {
63  std::cerr << "No Input Jet Collection Found!" << std::endl;
64  throw marlin::SkipEventException(this);
65  }
66  LCCollectionVec *pPFOsFromJetCollection = new LCCollectionVec(LCIO::RECONSTRUCTEDPARTICLE);
67  pPFOsFromJetCollection->setSubset(true);
68  int nJets = colJet->getNumberOfElements();
69  for (int i=0;i<nJets;i++) {
70  ReconstructedParticle *jet = dynamic_cast<ReconstructedParticle*>(colJet->getElementAt(i));
71  std::vector<lcio::ReconstructedParticle*> partVec = jet->getParticles();
72  for (std::vector<lcio::ReconstructedParticle*>::const_iterator iPart=partVec.begin();iPart!=partVec.end();++iPart) {
73  pPFOsFromJetCollection->addElement((*iPart));
74  }
75  }
76  evt->addCollection(pPFOsFromJetCollection,_colPFOsFromJet.c_str());
77 
78 }
79 
80 
81 
82 void JetPFOsProcessor::check( LCEvent * /*evt*/ ) {
83  // nothing to check here - could be used to fill checkplots in reconstruction processor
84 }
85 
86 
88 }
std::string _colJet
Input collection name.
virtual void check(LCEvent *evt)
std::string _colPFOsFromJet
Output collection name.
virtual void end()
Called after data processing for clean up.
std::vector< LCCollection * > LCCollectionVec
Definition: SiStripClus.h:55
A simple processor for to save particles from jets to a PFO collection.
JetPFOsProcessor aJetPFOsProcessor
virtual void processEvent(LCEvent *evt)
Called for every event - the working horse.
virtual void processRunHeader(LCRunHeader *run)
Called for every run.
virtual void init()
Called at the begin of the job before anything is read.