All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
ICARUSFlashFinder Class Reference
Inheritance diagram for ICARUSFlashFinder:

Public Member Functions

 ICARUSFlashFinder (fhicl::ParameterSet const &p)
 
 ICARUSFlashFinder (ICARUSFlashFinder const &)=delete
 
 ICARUSFlashFinder (ICARUSFlashFinder &&)=delete
 
ICARUSFlashFinderoperator= (ICARUSFlashFinder const &)=delete
 
ICARUSFlashFinderoperator= (ICARUSFlashFinder &&)=delete
 
void produce (art::Event &e) override
 

Private Member Functions

void GetFlashLocation (std::vector< double >, double &, double &, double &, double &)
 

Private Attributes

::pmtana::FlashFinderManager _mgr
 
::pmtana::PECalib _pecalib
 
std::string _hit_producer
 

Detailed Description

Definition at line 32 of file ICARUSFlashFinder_module.cc.

Constructor & Destructor Documentation

ICARUSFlashFinder::ICARUSFlashFinder ( fhicl::ParameterSet const &  p)
explicit

Definition at line 60 of file ICARUSFlashFinder_module.cc.

61  : EDProducer{p}
62 // Initialize member data here.
63 {
64  _hit_producer = p.get<std::string>("OpHitProducer");
65 
66  auto const flash_algo = p.get<std::string>("FlashFinderAlgo");
67  auto const flash_pset = p.get<pmtana::Config_t>("AlgoConfig");
68  auto algo_ptr = ::pmtana::FlashAlgoFactory::get().create(flash_algo,flash_algo);
69  algo_ptr->Configure(flash_pset);
70  _mgr.SetFlashAlgo(algo_ptr);
71 
72  _pecalib.Configure(p.get<pmtana::Config_t>("PECalib"));
73 
74  produces< std::vector<recob::OpFlash> >();
75  produces< art::Assns <recob::OpHit, recob::OpFlash> >();
76 }
FlashAlgoBase * create(const std::string name, const std::string instance_name)
Factory creation method (should be called by clients, possibly you!)
::pmtana::PECalib _pecalib
pdgs p
Definition: selectors.fcl:22
virtual void Configure(const Config_t &p)=0
static FlashAlgoFactory & get()
Static sharable instance getter.
::pmtana::FlashFinderManager _mgr
ICARUSFlashFinder::ICARUSFlashFinder ( ICARUSFlashFinder const &  )
delete
ICARUSFlashFinder::ICARUSFlashFinder ( ICARUSFlashFinder &&  )
delete

Member Function Documentation

void ICARUSFlashFinder::GetFlashLocation ( std::vector< double >  pePerOpChannel,
double &  Ycenter,
double &  Zcenter,
double &  Ywidth,
double &  Zwidth 
)
private

Definition at line 132 of file ICARUSFlashFinder_module.cc.

137 {
138 
139  // Reset variables
140  Ycenter = Zcenter = 0.;
141  Ywidth = Zwidth = -999.;
142  double totalPE = 0.;
143  double sumy = 0., sumz = 0., sumy2 = 0., sumz2 = 0.;
144 
145  for (unsigned int opch = 0; opch < pePerOpChannel.size(); opch++) {
146  /*
147  if (opch > 31 && opch < 200){
148  // std::cout << "Ignoring channel " << opch << " as it's not a real channel" << std::endl;
149  continue;
150  }
151  */
152  // Get physical detector location for this opChannel
153  double PMTxyz[3];
155 
156  // Add up the position, weighting with PEs
157  sumy += pePerOpChannel[opch]*PMTxyz[1];
158  sumy2 += pePerOpChannel[opch]*PMTxyz[1]*PMTxyz[1];
159  sumz += pePerOpChannel[opch]*PMTxyz[2];
160  sumz2 += pePerOpChannel[opch]*PMTxyz[2]*PMTxyz[2];
161 
162  totalPE += pePerOpChannel[opch];
163  }
164 
165  Ycenter = sumy/totalPE;
166  Zcenter = sumz/totalPE;
167 
168  // This is just sqrt(<x^2> - <x>^2)
169  if ( (sumy2*totalPE - sumy*sumy) > 0. )
170  Ywidth = std::sqrt(sumy2*totalPE - sumy*sumy)/totalPE;
171 
172  if ( (sumz2*totalPE - sumz*sumz) > 0. )
173  Zwidth = std::sqrt(sumz2*totalPE - sumz*sumz)/totalPE;
174 }
ICARUSFlashFinder& ICARUSFlashFinder::operator= ( ICARUSFlashFinder const &  )
delete
ICARUSFlashFinder& ICARUSFlashFinder::operator= ( ICARUSFlashFinder &&  )
delete
void ICARUSFlashFinder::produce ( art::Event &  e)
override

Definition at line 78 of file ICARUSFlashFinder_module.cc.

79 {
80 
81  // produce OpFlash data-product to be filled within module
82  std::unique_ptr< std::vector<recob::OpFlash> > opflashes(new std::vector<recob::OpFlash>);
83  std::unique_ptr< art::Assns <recob::OpHit, recob::OpFlash> > flash2hit_assn_v ( new art::Assns<recob::OpHit, recob::OpFlash> );
84  // load OpHits previously created
85  art::Handle<std::vector<recob::OpHit> > ophit_h;
86  e.getByLabel(_hit_producer,ophit_h);
87 
88  // make sure hits look good
89  if(!ophit_h.isValid()) {
90  std::cerr<<"\033[93m[ERROR]\033[00m ... could not locate OpHit!"<<std::endl;
91  throw std::exception();
92  }
93 
95  double trigger_time=1.1e20;
96  for(auto const& oph : *ophit_h) {
98  if(trigger_time > 1.e20) trigger_time = oph.PeakTimeAbs() - oph.PeakTime();
99  loph.peak_time = oph.PeakTime();
100 
101  size_t opdet = ::pmtana::OpDetFromOpChannel(oph.OpChannel());
102  loph.pe = _pecalib.Calibrate(opdet,oph.Area());
103  loph.channel = oph.OpChannel();
104  ophits.emplace_back(std::move(loph));
105  }
106 
107  auto const flash_v = _mgr.RecoFlash(ophits);
108 
109  for(const auto& lflash : flash_v) {
110 
111  double Ycenter, Zcenter, Ywidth, Zwidth;
112  GetFlashLocation(lflash.channel_pe, Ycenter, Zcenter, Ywidth, Zwidth);
113 
114  recob::OpFlash flash(lflash.time, lflash.time_err,
115  trigger_time + lflash.time,
116  (trigger_time + lflash.time) / 1600.,
117  lflash.channel_pe,
118  0, 0, 1, // this are just default values
119  Ycenter, Ywidth, Zcenter, Zwidth);
120  opflashes->emplace_back(std::move(flash));
121 
122  for(auto const& hitidx : lflash.asshit_idx) {
123  const art::Ptr<recob::OpHit> hit_ptr(ophit_h, hitidx);
124  util::CreateAssn(*this, e, *opflashes, hit_ptr, *flash2hit_assn_v);
125  }
126  }
127 
128  e.put(std::move(opflashes));
129  e.put(std::move(flash2hit_assn_v));
130 }
std::vector< pmtana::LiteOpHit_t > LiteOpHitArray_t
BEGIN_PROLOG could also be cerr
::pmtana::PECalib _pecalib
timescale_traits< TriggerTimeCategory >::time_point_t trigger_time
A point in time on the trigger time scale.
double Calibrate(const size_t opdet, const double area) const
bool CreateAssn(art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t index=UINT_MAX)
Creates a single one-to-one association.
do i e
::pmtana::FlashFinderManager _mgr
void GetFlashLocation(std::vector< double >, double &, double &, double &, double &)
LiteOpFlashArray_t RecoFlash(const LiteOpHitArray_t &ophits) const

Member Data Documentation

std::string ICARUSFlashFinder::_hit_producer
private

Definition at line 53 of file ICARUSFlashFinder_module.cc.

::pmtana::FlashFinderManager ICARUSFlashFinder::_mgr
private

Definition at line 51 of file ICARUSFlashFinder_module.cc.

::pmtana::PECalib ICARUSFlashFinder::_pecalib
private

Definition at line 52 of file ICARUSFlashFinder_module.cc.


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