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
SvtRawDataProcessor.cxx
Go to the documentation of this file.
1
6#include "SvtRawDataProcessor.h"
7#include "utilities.h"
8
9SvtRawDataProcessor::SvtRawDataProcessor(const std::string& name, Process& process)
10 : Processor(name, process) {
11 }
12
15
17
18 std::cout << "Configuring SvtRawDataProcessor" << std::endl;
19 try
20 {
21 debug_ = parameters.getInteger("debug", debug_);
22 hitCollLcio_ = parameters.getString("hitCollLcio", hitCollLcio_);
23 hitfitCollLcio_ = parameters.getString("hitfitCollLcio", hitfitCollLcio_);
24 hitCollRoot_ = parameters.getString("hitCollRoot", hitCollRoot_);
25 }
26 catch (std::runtime_error& error)
27 {
28 std::cout << error.what() << std::endl;
29 }
30}
31
32
34
35 tree->Branch(hitCollRoot_.c_str(),&rawhits_);
36}
37
39
40 Event* event = static_cast<Event*>(ievent);
41 UTIL::LCRelationNavigator* rawTracker_hit_fits_nav;
42 // Get the collection of 3D hits from the LCIO event. If no such collection
43 // exist, a DataNotAvailableException is thrown
44 EVENT::LCCollection* raw_svt_hits{nullptr};
45 try
46 {
47 raw_svt_hits = event->getLCCollection(hitCollLcio_.c_str());
48 }
49 catch (EVENT::DataNotAvailableException e)
50 {
51 std::cout << e.what() << std::endl;
52 }
53
54 //Check to see if fits are in the file
55 auto evColls = event->getLCEvent()->getCollectionNames();
56 auto it = std::find (evColls->begin(), evColls->end(), hitfitCollLcio_.c_str());
57 bool hasFits = true;
58 EVENT::LCCollection* raw_svt_hit_fits;
59 if(it == evColls->end()) hasFits = false;
60 if(hasFits)
61 {
62 raw_svt_hit_fits = event->getLCCollection(hitfitCollLcio_.c_str());
63 // Heap an LCRelation navigator which will allow faster access
64 rawTracker_hit_fits_nav = new UTIL::LCRelationNavigator(raw_svt_hit_fits);
65
66 }
67
68 // Get decoders to read cellids
69 UTIL::BitField64 decoder("system:6,barrel:3,layer:4,module:12,sensor:1,side:32:-2,strip:12");
70 //decoder[field] returns the value
71
72 // Loop over all of the raw SVT hits in the LCIO event and add them to the
73 // HPS event
74 for(int i = 0; i < rawhits_.size(); i++) delete rawhits_.at(i);
75 rawhits_.clear();
76
77 for (int ihit = 0; ihit < raw_svt_hits->getNumberOfElements(); ++ihit) {
78
79 // Get a raw hit from the list of hits
80 EVENT::TrackerRawData* rawTracker_hit
81 = static_cast<EVENT::TrackerRawData*>(raw_svt_hits->getElementAt(ihit));
82 //Decode the cellid
83 EVENT::long64 value = EVENT::long64( rawTracker_hit->getCellID0() & 0xffffffff ) |
84 ( EVENT::long64( rawTracker_hit->getCellID1() ) << 32 ) ;
85 decoder.setValue(value);
86
87 // Add a raw tracker hit to the event
88 RawSvtHit* rawHit = new RawSvtHit();
89
90 rawHit->setSystem(decoder["system"]);
91 rawHit->setBarrel(decoder["barrel"]);
92 rawHit->setLayer(decoder["layer"]);
93 rawHit->setModule(decoder["module"]);
94 rawHit->setSensor(decoder["sensor"]);
95 rawHit->setSide(decoder["side"]);
96 rawHit->setStrip(decoder["strip"]);
97
98 // Extract ADC values for this hit
99 int hit_adcs[6] = {
100 (int)rawTracker_hit->getADCValues().at(0),
101 (int)rawTracker_hit->getADCValues().at(1),
102 (int)rawTracker_hit->getADCValues().at(2),
103 (int)rawTracker_hit->getADCValues().at(3),
104 (int)rawTracker_hit->getADCValues().at(4),
105 (int)rawTracker_hit->getADCValues().at(5)
106 };
107 rawHit->setADCs(hit_adcs);
108
109
110 if (hasFits)
111 {
112 // Get the list of fit params associated with the raw tracker hit
113 EVENT::LCObjectVec rawTracker_hit_fits_list
114 = rawTracker_hit_fits_nav->getRelatedToObjects(rawTracker_hit);
115
116 // Get the list SVTFittedRawTrackerHit GenericObject associated with the SVTRawTrackerHit
117 IMPL::LCGenericObjectImpl* hit_fit_param
118 = static_cast<IMPL::LCGenericObjectImpl*>(rawTracker_hit_fits_list.at(0));
119 double fit_params[5] = {
120 (double)hit_fit_param->getDoubleVal(0),
121 (double)hit_fit_param->getDoubleVal(1),
122 (double)hit_fit_param->getDoubleVal(2),
123 (double)hit_fit_param->getDoubleVal(3),
124 (double)hit_fit_param->getDoubleVal(4)
125 };
126 rawHit->setFit(fit_params, 0);
127 if(rawTracker_hit_fits_list.size()>1)
128 {
129 hit_fit_param = static_cast<IMPL::LCGenericObjectImpl*>(rawTracker_hit_fits_list.at(1));
130 fit_params[0] = (double)hit_fit_param->getDoubleVal(0);
131 fit_params[1] = (double)hit_fit_param->getDoubleVal(1);
132 fit_params[2] = (double)hit_fit_param->getDoubleVal(2);
133 fit_params[3] = (double)hit_fit_param->getDoubleVal(3);
134 fit_params[4] = (double)hit_fit_param->getDoubleVal(4);
135
136 rawHit->setFit(fit_params, 1);
137 }
138
139 rawHit->setFitN(rawTracker_hit_fits_list.size());
140 }
141 rawhits_.push_back(rawHit);
142 }
143
144 //Clean up
145 if (hasFits) delete rawTracker_hit_fits_nav;
146
147 return true;
148}
149
152
#define DECLARE_PROCESSOR(CLASS)
Macro which allows the framework to construct a producer given its name during configuration.
Definition Processor.h:139
Processor used to add Raw SVT data to tree.
Definition Event.h:35
EVENT::LCCollection * getLCCollection(std::string name)
Definition Event.h:102
Definition IEvent.h:7
description
Base class for all event processing components.
Definition Processor.h:34
virtual bool process()
Process the histograms and generate analysis output.
Definition Processor.h:95
void setBarrel(int barrel)
Definition RawSvtHit.cxx:48
void setSystem(int system)
Definition RawSvtHit.cxx:44
void setFit(double fit[5], int fitI)
Definition RawSvtHit.cxx:27
void setStrip(int strip)
Definition RawSvtHit.cxx:68
void setSensor(int sensor)
Definition RawSvtHit.cxx:60
void setSide(int side)
Definition RawSvtHit.cxx:64
void setADCs(int adcs[6])
Definition RawSvtHit.cxx:35
void setFitN(int fitN)
Definition RawSvtHit.cxx:23
void setLayer(int layer)
Definition RawSvtHit.cxx:52
void setModule(int module)
Definition RawSvtHit.cxx:56
virtual void configure(const ParameterSet &parameters)
Callback for the Processor to configure itself from the given set of parameters.
virtual void finalize()
Callback for the Processor to take any necessary action when the processing of events finishes.
virtual void initialize(TTree *tree)
Callback for the Processor to take any necessary action when the processing of events starts.
std::string hitfitCollLcio_
collection name
std::vector< RawSvtHit * > rawhits_
Container to hold all TrackerHit objects.
std::string hitCollRoot_
collection name
SvtRawDataProcessor(const std::string &name, Process &process)
Class constructor.
std::string hitCollLcio_
collection name