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
MCEcalHitProcessor.cxx
Go to the documentation of this file.
1
6#include "MCEcalHitProcessor.h"
7
8MCEcalHitProcessor::MCEcalHitProcessor(const std::string& name, Process& process)
9 : Processor(name, process) {
10 }
11
14
16
17 std::cout << "Configuring MCEcalHitProcessor" << std::endl;
18 try
19 {
20 debug_ = parameters.getInteger("debug", debug_);
21 hitCollLcio_ = parameters.getString("hitCollLcio", hitCollLcio_);
22 hitCollRoot_ = parameters.getString("hitCollRoot", hitCollRoot_);
23 }
24 catch (std::runtime_error& error)
25 {
26 std::cout << error.what() << std::endl;
27 }
28}
29
31
32 tree->Branch(hitCollRoot_.c_str(), &ecalhits_);
33}
34
36
37 Event* event = static_cast<Event*>(ievent);
38 // Get the collection of simulated ecal hits from the LCIO event.
39 EVENT::LCCollection* lcio_ecalhits{nullptr};
40 try
41 {
42 lcio_ecalhits = event->getLCCollection(hitCollLcio_.c_str());
43 }
44 catch (EVENT::DataNotAvailableException e)
45 {
46 std::cout << e.what() << std::endl;
47 }
48
49
50 // Get decoders to read cellids
51 UTIL::BitField64 decoder("system:0:6,layer:6:2,ix:8:-8,iy:16:-6");
52 //decoder[field] returns the value
53
54 // Loop over all of the raw SVT hits in the LCIO event and add them to the
55 // HPS event
56 for(int i = 0; i < ecalhits_.size(); i++) delete ecalhits_.at(i);
57 ecalhits_.clear();
58 for (int ihit = 0; ihit < lcio_ecalhits->getNumberOfElements(); ++ihit) {
59
60 // Get a 3D hit from the list of hits
61 EVENT::SimCalorimeterHit* lcio_mcEcal_hit
62 = static_cast<EVENT::SimCalorimeterHit*>(lcio_ecalhits->getElementAt(ihit));
63 //Decode the cellid
64 EVENT::long64 value = EVENT::long64( lcio_mcEcal_hit->getCellID0() & 0xffffffff ) |
65 ( EVENT::long64( lcio_mcEcal_hit->getCellID1() ) << 32 ) ;
66 decoder.setValue(value);
67
68 // Add a mc ecal hit to the event
69 MCEcalHit* mc_ecal_hit = new MCEcalHit();
70
71 // Set sensitive detector identification
72 mc_ecal_hit->setSystem(decoder["system"]);
73 mc_ecal_hit->setLayer(decoder["layer"]);
74 mc_ecal_hit->setIX(decoder["ix"]);
75 mc_ecal_hit->setIY(decoder["iy"]);
76
77 // Set the position of the hit, dealing with it being a float and not double
78 const float hitPosF[3] = {lcio_mcEcal_hit->getPosition()[0], lcio_mcEcal_hit->getPosition()[1], lcio_mcEcal_hit->getPosition()[2]};
79 double hitPosD[3] = {(double)hitPosF[0], (double)hitPosF[1], (double)hitPosF[2]};
80 mc_ecal_hit->setPosition(hitPosD);
81
82 // Set the energy deposit of the hit
83 mc_ecal_hit->setEnergy(lcio_mcEcal_hit->getEnergy());
84
85 //Push onto vector of hits
86 ecalhits_.push_back(mc_ecal_hit);
87
88 }
89
90 return true;
91}
92
95
Processor used to add simulated ecal hits to the 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
EVENT::LCCollection * getLCCollection(std::string name)
Definition Event.h:102
Definition IEvent.h:7
Processor used to add simulated ecal hits to the event more details.
int debug_
Debug Level.
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::vector< MCEcalHit * > ecalhits_
MCEcalHitProcessor(const std::string &name, Process &process)
Class constructor.
std::string hitCollRoot_
description
std::string hitCollLcio_
description
void setLayer(const int layer)
Definition MCEcalHit.h:79
void setPosition(const double *position, bool rotate=false)
Definition MCEcalHit.cxx:23
void setSystem(const int system)
Definition MCEcalHit.h:69
void setEnergy(const double energy)
Definition MCEcalHit.h:59
void setIY(const int iy)
Definition MCEcalHit.h:99
void setIX(const int ix)
Definition MCEcalHit.h:89
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