hpstr
The Heavy Photon Search Toolkit for Reconstruction (hpstr) provides an interface to physics data from the HPS experiment saved in the LCIO format and converts it into an ROOT based format.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
HodoDataProcessor.cxx
Go to the documentation of this file.
1
7#include "HodoDataProcessor.h"
8
10 tree->Branch(hitCollRoot_.c_str(), &hits_);
11 tree->Branch(clusCollRoot_.c_str(), &clusters_);
12}
13
14
16
17 try
18 {
19 debug_ = parameters.getInteger("debug",debug_);
20 hitCollLcio_ = parameters.getString("hitCollLcio",hitCollLcio_);
21 hitCollRoot_ = parameters.getString("hitCollRoot",hitCollRoot_);
22 clusCollLcio_ = parameters.getString("clusCollLcio",clusCollLcio_);
23 clusCollRoot_ = parameters.getString("clusCollRoot",clusCollRoot_);
24 }
25 catch (std::runtime_error& error)
26 {
27 std::cout << error.what() << std::endl;
28 }
29}
30
31
33
34 // Clean up. TODO:: new/delete is an inefficient way to go about all this. Fix with better memory use.
35 for(int i = 0; i < hits_.size(); i++) delete hits_.at(i);
36 for(int i = 0; i < clusters_.size(); i++) delete clusters_.at(i);
37 hits_.clear();
38 clusters_.clear();
39
40 // Interface to implementation cast. Not sure why we bother with an interface.
41 Event* event = static_cast<Event*> (ievent);
42
43 EVENT::LCCollection* lcio_hits{nullptr};
44// EVENT::LCCollection* lcio_hits_generic{nullptr};
45 EVENT::LCCollection* lcio_clus_generic{nullptr};
46
47 try{
48 lcio_hits = static_cast<EVENT::LCCollection*>(event->getLCCollection(hitCollLcio_));
49 }catch(EVENT::DataNotAvailableException e){
50 if(debug_ > 0) std::cout << "Barfed on not finding the hodoscope collections. \n";
51 return false;
52 }
53
54 // Loop through the hits and add them to the event.
55 for(int i=0; i< lcio_hits->getNumberOfElements(); ++i){
56 // Grab the hit from the collection and push it as a HodoHit object onto the vector<HodoHit *> hits_
57 IMPL::CalorimeterHitImpl *hit=static_cast<IMPL::CalorimeterHitImpl *>(lcio_hits->getElementAt(i));
58
59 // TODO: This is inefficient, doing a new and delete on every hit for every event ==> implement proper memory use.
60 hits_.push_back(new HodoHit(
61 getIdentifierFieldValue("ix", hit),
62 getIdentifierFieldValue("iy", hit),
63 getIdentifierFieldValue("layer", hit),
64 getIdentifierFieldValue("hole", hit),
65 hit->getEnergy(),
66 hit->getTime()
67 )
68 );
69 }
70
71 // Now deal with the clusters.
72
73 try{
74 lcio_clus_generic = static_cast<EVENT::LCCollection*>(event->getLCCollection(clusCollLcio_));
75 }catch(EVENT::DataNotAvailableException e){
76 if(debug_ > 0) std::cout << "Barfed on not finding the generic hodoscope cluster collections. \n";
77 return false;
78 }
79
80 IMPL::LCGenericObjectImpl *gclus_ix = static_cast<IMPL::LCGenericObjectImpl *>(lcio_clus_generic->getElementAt(0));
81 IMPL::LCGenericObjectImpl *gclus_iy = static_cast<IMPL::LCGenericObjectImpl *>(lcio_clus_generic->getElementAt(1));
82 IMPL::LCGenericObjectImpl *gclus_layer = static_cast<IMPL::LCGenericObjectImpl *>(lcio_clus_generic->getElementAt(2));
83 IMPL::LCGenericObjectImpl *gclus_energy = static_cast<IMPL::LCGenericObjectImpl *>(lcio_clus_generic->getElementAt(3));
84 IMPL::LCGenericObjectImpl *gclus_time = static_cast<IMPL::LCGenericObjectImpl *>(lcio_clus_generic->getElementAt(4));
85// IMPL::LCGenericObjectImpl *gclus_ids = static_cast<IMPL::LCGenericObjectImpl *>(lcio_hits_generic->getElementAt(5));
86
87 for(int i=0; i < gclus_ix->getNInt(); ++i){
88 clusters_.push_back(new HodoCluster(
89 gclus_ix->getIntVal(i),
90 gclus_iy->getIntVal(i),
91 gclus_layer->getIntVal(i),
92 gclus_energy->getDoubleVal(i),
93 gclus_time->getDoubleVal(i)));
94 }
95
96 return true;
97}
98
99UTIL::BitFieldValue HodoDataProcessor::getIdentifierFieldValue(std::string field, EVENT::CalorimeterHit* hit){
100
101 UTIL::BitField64 decoder(encoder_string_);
102 long long value = (long long)( hit->getCellID0() & 0xffffffff ) | ( (long long)( hit->getCellID1() ) << 32 ) ;
103 decoder.setValue(value);
104
105 return decoder[field];
106}
107
Processor for the Hodoscope, to convert LCIO to the HodoCluster and HodoHit classes in event.
#define DECLARE_PROCESSOR(CLASS)
Macro which allows the framework to construct a producer given its name during configuration.
Definition Processor.h:139
Definition Event.h:35
Processor for the Hodoscope, to convert LCIO to the HodoCluster and HodoHit classes in event....
UTIL::BitFieldValue getIdentifierFieldValue(std::string field, EVENT::CalorimeterHit *hit)
Method to unpack field value from a hodoscope hit ID from the ID string.
int debug_
Debug level. 0 is very quiet, 1 info, 2 debug.
std::string clusCollRoot_
description
const std::string encoder_string_
virtual void configure(const ParameterSet &parameters)
Callback from ConfigurePython step for the Processor to configure itself from the given set of parame...
std::vector< HodoHit * > hits_
virtual void initialize(TTree *tree)
Callback for the Processor to take any necessary action when the processing of events starts.
std::string hitCollRoot_
description
std::vector< HodoCluster * > clusters_
std::string clusCollLcio_
description
std::string hitCollLcio_
description
Definition IEvent.h:7
description
virtual bool process()
Process the histograms and generate analysis output.
Definition Processor.h:95