Public Member Functions | Protected Member Functions | Private Attributes | List of all members
gar::rec::SiPMHitFinder Class Reference
Inheritance diagram for gar::rec::SiPMHitFinder:
art::EDProducer art::detail::Producer art::detail::LegacyModule art::Modifier art::ModuleBase art::ProductRegistryHelper

Public Member Functions

 SiPMHitFinder (fhicl::ParameterSet const &p)
 
 SiPMHitFinder (SiPMHitFinder const &)=delete
 
 SiPMHitFinder (SiPMHitFinder &&)=delete
 
SiPMHitFinderoperator= (SiPMHitFinder const &)=delete
 
SiPMHitFinderoperator= (SiPMHitFinder &&)=delete
 
void produce (art::Event &e) override
 
- Public Member Functions inherited from art::EDProducer
 EDProducer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDProducer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Producer
virtual ~Producer () noexcept
 
 Producer (fhicl::ParameterSet const &)
 
 Producer (Producer const &)=delete
 
 Producer (Producer &&)=delete
 
Produceroperator= (Producer const &)=delete
 
Produceroperator= (Producer &&)=delete
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
- Public Member Functions inherited from art::Modifier
 ~Modifier () noexcept
 
 Modifier ()
 
 Modifier (Modifier const &)=delete
 
 Modifier (Modifier &&)=delete
 
Modifieroperator= (Modifier const &)=delete
 
Modifieroperator= (Modifier &&)=delete
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Protected Member Functions

void CollectDigiHits (const art::Event &evt, const std::string &label, const std::string &instance, std::vector< art::Ptr< gar::raw::CaloRawDigit > > &hitVector)
 
float CalibrateToMIP (unsigned int ADC)
 
float CalibratetoMeV (float x, float y, float z, double MIP)
 
std::array< double, 3U > CalculateStripHitPosition (float x, float y, float z, std::pair< float, float > hitTime, raw::CellID_t cID)
 
float CorrectStripHitTime (float x, float y, float z, std::pair< float, float > hitTime, raw::CellID_t cID)
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Private Attributes

std::string fRawDigitLabel
 label to find the right raw digits More...
 
std::string fInstanceLabelName
 product instance name More...
 
float fMIPThreshold
 zero-suppression threshold (in case the raw digits need to be zero-suppressed) More...
 
bool fDesaturation
 flag to perform the SiPM desaturation More...
 
float fSamplingCorrection
 
bool fUseTimePositionReco
 
const detinfo::DetectorPropertiesfDetProp
 detector properties More...
 
const geo::GeometryCorefGeo
 pointer to the geometry More...
 
std::unique_ptr< util::SiPMUtilsfSiPMUtils
 pointer to the Util fcn containing the SiPM desaturation function More...
 
gar::geo::BitFieldCoder const * fFieldDecoder
 

Additional Inherited Members

- Public Types inherited from art::EDProducer
using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
- Public Types inherited from art::detail::Producer
template<typename UserConfig , typename KeysToIgnore = void>
using Table = Modifier::Table< UserConfig, KeysToIgnore >
 
- Public Types inherited from art::Modifier
template<typename UserConfig , typename UserKeysToIgnore = void>
using Table = ProducerTable< UserConfig, detail::ModuleConfig, UserKeysToIgnore >
 
- Static Public Member Functions inherited from art::EDProducer
static void commitEvent (EventPrincipal &ep, Event &e)
 

Detailed Description

Definition at line 42 of file SiPMHitFinder_module.cc.

Constructor & Destructor Documentation

gar::rec::SiPMHitFinder::SiPMHitFinder ( fhicl::ParameterSet const &  p)
explicit

Definition at line 86 of file SiPMHitFinder_module.cc.

86  : EDProducer{p}
87  {
88  fRawDigitLabel = p.get<std::string>("RawDigitLabel", "daqsipm");
89  fInstanceLabelName = p.get<std::string>("InstanceLabelName", "");
90 
91  fMIPThreshold = p.get<float>("MIPThreshold", 0.25);
92  fDesaturation = p.get<bool>("Desaturation", false);
93  fSamplingCorrection = p.get<float>("ECALSamplingFactorGeV", 1.0);
94  fUseTimePositionReco = p.get<bool>("UseTimePositionReco", true);
95 
96  fGeo = gar::providerFrom<geo::GeometryGAr>();
97  fDetProp = gar::providerFrom<detinfo::DetectorPropertiesService>();
98  fSiPMUtils = std::make_unique<util::SiPMUtils>(fDetProp->EffectivePixel());
99 
100  std::string fEncoding = fGeo->GetECALCellIDEncoding();
102  consumes< std::vector<raw::CaloRawDigit> >(tag);
103  produces< std::vector<rec::CaloHit> >(fInstanceLabelName);
104  produces< art::Assns<rec::CaloHit, raw::CaloRawDigit> >(fInstanceLabelName);
105 
106  if(fInstanceLabelName.compare("MuID") == 0) {
107  fEncoding = fGeo->GetMuIDCellIDEncoding();
108  fSamplingCorrection = p.get<float>("MuIDSamplingFactorGeV", 1.0);
109  }
110 
111  fFieldDecoder = new gar::geo::BitFieldCoder( fEncoding );
112  }
float fMIPThreshold
zero-suppression threshold (in case the raw digits need to be zero-suppressed)
gar::geo::BitFieldCoder const * fFieldDecoder
const std::string GetMuIDCellIDEncoding() const
std::string string
Definition: nybbler.cc:12
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
std::string fInstanceLabelName
product instance name
virtual double EffectivePixel() const =0
Helper class for decoding and encoding a bit field of 64bits for convenient declaration.
p
Definition: test.py:223
const geo::GeometryCore * fGeo
pointer to the geometry
bool fDesaturation
flag to perform the SiPM desaturation
const detinfo::DetectorProperties * fDetProp
detector properties
const std::string GetECALCellIDEncoding() const
std::unique_ptr< util::SiPMUtils > fSiPMUtils
pointer to the Util fcn containing the SiPM desaturation function
std::string fRawDigitLabel
label to find the right raw digits
gar::rec::SiPMHitFinder::SiPMHitFinder ( SiPMHitFinder const &  )
delete
gar::rec::SiPMHitFinder::SiPMHitFinder ( SiPMHitFinder &&  )
delete

Member Function Documentation

std::array< double, 3 > gar::rec::SiPMHitFinder::CalculateStripHitPosition ( float  x,
float  y,
float  z,
std::pair< float, float >  hitTime,
raw::CellID_t  cID 
)
protected

Definition at line 256 of file SiPMHitFinder_module.cc.

257  {
258  std::array<double, 3> point = {x, y, z};
259  std::array<double, 3> pointLocal;
261  fGeo->WorldToLocal(point, pointLocal, trans);
262 
263  //Calculate the position of the hit based on the time of both SiPM along the strip
264  // pos along strip is
265  // x = c * (t1 - t2) / 2 (0 is the center of the strip)
266  float c = (CLHEP::c_light * CLHEP::mm / CLHEP::ns) / CLHEP::cm; // in cm/ns
267  float xlocal = c * ( hitTime.first - hitTime.second ) / 2.;
268 
269  std::array<double, 3> local_back = fGeo->ReconstructStripHitPosition(point, pointLocal, xlocal, cID);
270  std::array<double, 3> world_back;
271  fGeo->LocalToWorld(local_back, world_back, trans);
272 
273  return world_back;
274  }
static constexpr double cm
Definition: Units.h:68
bool WorldToLocal(std::array< double, 3 > const &world, std::array< double, 3 > &local, gar::geo::LocalTransformation< TGeoHMatrix > &trans) const
Class to transform between world and local coordinates.
bool LocalToWorld(std::array< double, 3 > const &local, std::array< double, 3 > &world, gar::geo::LocalTransformation< TGeoHMatrix > const &trans) const
const geo::GeometryCore * fGeo
pointer to the geometry
std::array< double, 3 > ReconstructStripHitPosition(const std::array< double, 3 > &point, const std::array< double, 3 > &local, const float &xlocal, const gar::raw::CellID_t &cID) const
static constexpr double mm
Definition: Units.h:65
list x
Definition: train.py:276
QAsciiDict< Entry > ns
float gar::rec::SiPMHitFinder::CalibratetoMeV ( float  x,
float  y,
float  z,
double  MIP 
)
protected

Definition at line 241 of file SiPMHitFinder_module.cc.

242  {
243  float calibrated_MIP = 0.;
244  if(MIP <= 0) {
245  return calibrated_MIP;
246  }
247 
248  TVector3 point(x, y, z);
249  float factor = fGeo->GetSensVolumeThickness(point) / 0.5;
250 
251  calibrated_MIP = MIP * fDetProp->MeVtoMIP() * factor;
252  return calibrated_MIP; // MeV
253  }
float GetSensVolumeThickness(const TVector3 &point) const
const geo::GeometryCore * fGeo
pointer to the geometry
virtual double MeVtoMIP() const =0
const detinfo::DetectorProperties * fDetProp
detector properties
list x
Definition: train.py:276
float gar::rec::SiPMHitFinder::CalibrateToMIP ( unsigned int  ADC)
protected

Definition at line 229 of file SiPMHitFinder_module.cc.

230  {
231  float calibrated_ADC = 0.;
232  if (ADC <= 0) {
233  return calibrated_ADC;
234  }
235 
236  calibrated_ADC = ADC / (fDetProp->LightYield() * fDetProp->SiPMGain());
237  return calibrated_ADC;
238  }
virtual double SiPMGain() const =0
virtual double LightYield() const =0
const detinfo::DetectorProperties * fDetProp
detector properties
void gar::rec::SiPMHitFinder::CollectDigiHits ( const art::Event evt,
const std::string label,
const std::string instance,
std::vector< art::Ptr< gar::raw::CaloRawDigit > > &  hitVector 
)
protected

Definition at line 214 of file SiPMHitFinder_module.cc.

215  {
217  auto theHits = evt.getHandle< std::vector<gar::raw::CaloRawDigit> >(itag);
218  if (!theHits) return;
219 
220  for (unsigned int i = 0; i < theHits->size(); ++i)
221  {
222  const art::Ptr<gar::raw::CaloRawDigit> hit(theHits, i);
223  hitVector.push_back(hit);
224  }
225  return;
226  }
Handle< PROD > getHandle(SelectorBase const &) const
Definition: DataViewImpl.h:382
const std::string instance
Detector simulation of raw signals on wires.
Definition: fwd.h:31
float gar::rec::SiPMHitFinder::CorrectStripHitTime ( float  x,
float  y,
float  z,
std::pair< float, float >  hitTime,
raw::CellID_t  cID 
)
protected

Definition at line 277 of file SiPMHitFinder_module.cc.

278  {
279  std::array<double, 3> point = {x, y, z};
280  double stripLength = fGeo->getStripLength(point, cID); // in cm
281 
282  float c = (CLHEP::c_light * CLHEP::mm / CLHEP::ns) / CLHEP::cm; // in cm/ns
283  float time = (hitTime.first + hitTime.second) / 2. - (stripLength / (2 * c));
284 
285  return time;
286  }
static constexpr double cm
Definition: Units.h:68
double getStripLength(const std::array< double, 3 > &point, const gar::raw::CellID_t &cID) const
const geo::GeometryCore * fGeo
pointer to the geometry
static constexpr double mm
Definition: Units.h:65
list x
Definition: train.py:276
QAsciiDict< Entry > ns
SiPMHitFinder& gar::rec::SiPMHitFinder::operator= ( SiPMHitFinder const &  )
delete
SiPMHitFinder& gar::rec::SiPMHitFinder::operator= ( SiPMHitFinder &&  )
delete
void gar::rec::SiPMHitFinder::produce ( art::Event e)
overridevirtual

Implements art::EDProducer.

Definition at line 114 of file SiPMHitFinder_module.cc.

115  {
116  // create an emtpy output hit collection -- to add to.
117  std::unique_ptr< std::vector<rec::CaloHit> > hitCol ( new std::vector< rec::CaloHit > );
118  std::unique_ptr< art::Assns<rec::CaloHit, raw::CaloRawDigit> > RecoDigiHitsAssns( new art::Assns<rec::CaloHit, raw::CaloRawDigit> );
119 
120  //Collect the hits to be passed to the algo
121  std::vector< art::Ptr<gar::raw::CaloRawDigit> > artDigiHits;
122  this->CollectDigiHits(e, fRawDigitLabel, fInstanceLabelName, artDigiHits);
123 
125 
126  for (std::vector< art::Ptr<gar::raw::CaloRawDigit> >::const_iterator iter = artDigiHits.begin(), iterEnd = artDigiHits.end(); iter != iterEnd; ++iter)
127  {
128  art::Ptr<gar::raw::CaloRawDigit> digiArtPtr = *iter;
129  const gar::raw::CaloRawDigit &digitHit = *(digiArtPtr.get());
130 
131  unsigned int hitADC = digitHit.ADC().first;
132  std::pair<float, float> hitTime = digitHit.Time();
133  float x = digitHit.X();
134  float y = digitHit.Y();
135  float z = digitHit.Z();
136  raw::CellID_t cellID = digitHit.CellID();
137 
138  //Do Calibration of the hit in MIPs
139  float hitMIP = this->CalibrateToMIP(hitADC);
140 
141  if (hitMIP < fMIPThreshold)
142  {
143  MF_LOG_DEBUG("SiPMHitFinder") << "Signal under the " << fMIPThreshold << " MIP threshold" << std::endl;
144  continue;
145  }
146 
147  //Desaturation
148  float energy = 0.;
149  if (fDesaturation)
150  {
151  double sat_px = hitMIP * fDetProp->LightYield();
152  //DeSaturate
153  double unsat_px = fSiPMUtils->DeSaturate(sat_px);
154 
155  //Calibrate to the MeV scale
156  double unsat_energy = unsat_px / fDetProp->LightYield();
157  energy = this->CalibratetoMeV(x, y, z, unsat_energy);
158  }
159  else {
160  //Calibrate to the MeV scale
161  energy = this->CalibratetoMeV(x, y, z, hitMIP);
162  }
163 
164  //Position reconstruction based on time for the strips
165  float pos[3] = {0., 0., 0.};
166  std::pair<float, float> time;
167  const std::array<double, 3> point = { x, y, z };
168 
169  if (fGeo->isTile(point, cellID))
170  {
171  pos[0] = x;
172  pos[1] = y;
173  pos[2] = z;
174  time = hitTime;
175  }
176  else {
177  if( fUseTimePositionReco) {
178  std::array<double, 3> strip_pos = this->CalculateStripHitPosition(x, y, z, hitTime, cellID);
179  pos[0] = strip_pos[0];
180  pos[1] = strip_pos[1];
181  pos[2] = strip_pos[2];
182  time = std::make_pair( this->CorrectStripHitTime(pos[0], pos[1], pos[2], hitTime, cellID), 0. );
183  } else {
184  pos[0] = x;
185  pos[1] = y;
186  pos[2] = z;
187  time = hitTime;
188  }
189  }
190 
191  //Store the hit (energy in GeV, time in ns, pos in cm and cellID)
192  unsigned int layer = fFieldDecoder->get(cellID, "layer");
193  rec::CaloHit hit(fSamplingCorrection * energy * CLHEP::MeV / CLHEP::GeV, time, pos, cellID, layer);
194  hitCol->emplace_back(hit);
195 
196  MF_LOG_DEBUG("SiPMHitFinder") << "recohit " << &hit
197  << " with cellID " << cellID
198  << " has energy " << fSamplingCorrection * energy * CLHEP::MeV / CLHEP::GeV
199  << " pos (" << pos[0] << ", " << pos[1] << ", " << pos[2] << ")";
200 
201  //Make association between digi hits and reco hits
202  art::Ptr<rec::CaloHit> hitPtr = makeHitPtr(hitCol->size() - 1);
203  RecoDigiHitsAssns->addSingle(hitPtr, digiArtPtr);
204  }
205 
206  //move the reco hit collection
207  e.put(std::move(hitCol), fInstanceLabelName);
208  e.put(std::move(RecoDigiHitsAssns), fInstanceLabelName);
209 
210  return;
211  }
float fMIPThreshold
zero-suppression threshold (in case the raw digits need to be zero-suppressed)
float CalibratetoMeV(float x, float y, float z, double MIP)
std::pair< float, float > Time() const
Timestmap.
Definition: CaloRawDigit.h:79
gar::geo::BitFieldCoder const * fFieldDecoder
float Y() const
Y position.
Definition: CaloRawDigit.h:81
std::pair< unsigned int, unsigned int > ADC() const
Reference to the compressed ADC count vector.
Definition: CaloRawDigit.h:78
void CollectDigiHits(const art::Event &evt, const std::string &label, const std::string &instance, std::vector< art::Ptr< gar::raw::CaloRawDigit > > &hitVector)
float CorrectStripHitTime(float x, float y, float z, std::pair< float, float > hitTime, raw::CellID_t cID)
float X() const
X position.
Definition: CaloRawDigit.h:80
struct vector vector
static constexpr double MeV
Definition: Units.h:129
std::string fInstanceLabelName
product instance name
std::array< double, 3U > CalculateStripHitPosition(float x, float y, float z, std::pair< float, float > hitTime, raw::CellID_t cID)
bool isTile(const std::array< double, 3 > &point, const gar::raw::CellID_t &cID) const
static constexpr double GeV
Definition: Units.h:28
CellID_t CellID() const
cellID
Definition: CaloRawDigit.h:83
def move(depos, offset)
Definition: depos.py:107
virtual double LightYield() const =0
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: DataViewImpl.h:686
long long int CellID_t
Definition: CaloRawDigit.h:24
const geo::GeometryCore * fGeo
pointer to the geometry
Detector simulation of raw signals on wires.
bool fDesaturation
flag to perform the SiPM desaturation
long64 get(long64 bitfield, size_t index) const
const detinfo::DetectorProperties * fDetProp
detector properties
float CalibrateToMIP(unsigned int ADC)
#define MF_LOG_DEBUG(id)
list x
Definition: train.py:276
T const * get() const
Definition: Ptr.h:149
std::unique_ptr< util::SiPMUtils > fSiPMUtils
pointer to the Util fcn containing the SiPM desaturation function
float Z() const
Z position.
Definition: CaloRawDigit.h:82
Definition: fwd.h:31
std::string fRawDigitLabel
label to find the right raw digits
QTextStream & endl(QTextStream &s)

Member Data Documentation

bool gar::rec::SiPMHitFinder::fDesaturation
private

flag to perform the SiPM desaturation

Definition at line 75 of file SiPMHitFinder_module.cc.

const detinfo::DetectorProperties* gar::rec::SiPMHitFinder::fDetProp
private

detector properties

Definition at line 79 of file SiPMHitFinder_module.cc.

gar::geo::BitFieldCoder const* gar::rec::SiPMHitFinder::fFieldDecoder
private

Definition at line 82 of file SiPMHitFinder_module.cc.

const geo::GeometryCore* gar::rec::SiPMHitFinder::fGeo
private

pointer to the geometry

Definition at line 80 of file SiPMHitFinder_module.cc.

std::string gar::rec::SiPMHitFinder::fInstanceLabelName
private

product instance name

Definition at line 72 of file SiPMHitFinder_module.cc.

float gar::rec::SiPMHitFinder::fMIPThreshold
private

zero-suppression threshold (in case the raw digits need to be zero-suppressed)

Definition at line 74 of file SiPMHitFinder_module.cc.

std::string gar::rec::SiPMHitFinder::fRawDigitLabel
private

label to find the right raw digits

Definition at line 71 of file SiPMHitFinder_module.cc.

float gar::rec::SiPMHitFinder::fSamplingCorrection
private

Definition at line 76 of file SiPMHitFinder_module.cc.

std::unique_ptr<util::SiPMUtils> gar::rec::SiPMHitFinder::fSiPMUtils
private

pointer to the Util fcn containing the SiPM desaturation function

Definition at line 81 of file SiPMHitFinder_module.cc.

bool gar::rec::SiPMHitFinder::fUseTimePositionReco
private

Definition at line 77 of file SiPMHitFinder_module.cc.


The documentation for this class was generated from the following file: