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

Classes

struct  Config
 

Public Types

using Parameters = art::EDAnalyzer::Table< Config >
 

Public Member Functions

 ICARUSFlashAssAna (Parameters const &config)
 
 ICARUSFlashAssAna (ICARUSFlashAssAna const &)=delete
 
 ICARUSFlashAssAna (ICARUSFlashAssAna &&)=delete
 
ICARUSFlashAssAnaoperator= (ICARUSFlashAssAna const &)=delete
 
ICARUSFlashAssAnaoperator= (ICARUSFlashAssAna &&)=delete
 
void analyze (art::Event const &e) override
 
void beginJob () override
 
void endJob () override
 
template<typename T >
Median (std::vector< T > data) const
 
geo::CryostatID::CryostatID_t getCryostatByChannel (int channel)
 
int getSideByChannel (const int channel)
 
void processOpHits (art::Event const &e, unsigned int cryo)
 
void processOpHitsFlash (std::vector< art::Ptr< recob::OpHit >> const &ophits, int &multiplicity_left, int &multiplicity_right, float &sum_pe_left, float &sum_pe_right, float *xyz, TTree *ophittree)
 

Static Public Member Functions

static std::string_view firstLine (std::string const &s, const char *endl="\r")
 

Private Attributes

art::InputTag fTriggerLabel
 
bool fSaveWaveformInfo
 
std::vector< art::InputTag > fOpDetWaveformLabels
 
std::vector< art::InputTag > fOpHitLabels
 
std::vector< art::InputTag > fFlashLabels
 
float fPEOpHitThreshold
 
bool fDebug
 
TTree * fEventTree
 
std::vector< TTree * > fOpDetWaveformTrees
 
std::vector< TTree * > fOpFlashTrees
 
std::vector< TTree * > fOpHitTrees
 
std::vector< TTree * > fOpHitFlashTrees
 
int m_run
 
int m_event
 
int m_timestamp
 
short m_baseline
 
short m_chargesum
 
int m_nticks
 
float m_beam_gate_start =-99999
 
float m_beam_gate_width =-99999
 
int m_beam_type =-1
 
unsigned int m_gate_type
 
std::string m_gate_name
 
uint64_t m_trigger_timestamp
 
uint64_t m_gate_start_timestamp
 
uint64_t m_trigger_gate_diff
 
int m_flash_id
 
int m_multiplicity
 
int m_multiplicity_left
 
int m_multiplicity_right
 
float m_sum_pe
 
float m_sum_pe_left
 
float m_sum_pe_right
 
float m_flash_time
 
float m_flash_y
 
float m_flash_width_y
 
float m_flash_z
 
float m_flash_width_z
 
int m_channel_id
 
float m_integral
 
float m_amplitude
 
float m_start_time
 
float m_width
 
float m_abs_start_time
 
float m_pe
 
float m_fast_to_total
 
std::vector< float > m_pmt_x
 
std::vector< float > m_pmt_y
 
std::vector< float > m_pmt_z
 
geo::GeometryCore const * fGeom
 

Detailed Description

Definition at line 57 of file ICARUSFlashAssAna_module.cc.

Member Typedef Documentation

using opana::ICARUSFlashAssAna::Parameters = art::EDAnalyzer::Table<Config>

Definition at line 104 of file ICARUSFlashAssAna_module.cc.

Constructor & Destructor Documentation

opana::ICARUSFlashAssAna::ICARUSFlashAssAna ( Parameters const &  config)
explicit

Definition at line 200 of file ICARUSFlashAssAna_module.cc.

201  : EDAnalyzer(config)
202  , fTriggerLabel( config().TriggerLabel() )
203  , fSaveWaveformInfo( config().DumpWaveformsInfo() )
204  , fOpDetWaveformLabels( config().OpDetWaveformLabels() )
205  , fOpHitLabels( config().OpHitLabels() )
206  , fFlashLabels( config().FlashLabels() )
207  , fPEOpHitThreshold( config().PEOpHitThreshold() )
208  , fDebug( config().Debug() )
209  , fGeom( lar::providerFrom<geo::Geometry>() )
210 { }
std::vector< art::InputTag > fOpDetWaveformLabels
geo::GeometryCore const * fGeom
std::vector< art::InputTag > fFlashLabels
std::vector< art::InputTag > fOpHitLabels
opana::ICARUSFlashAssAna::ICARUSFlashAssAna ( ICARUSFlashAssAna const &  )
delete
opana::ICARUSFlashAssAna::ICARUSFlashAssAna ( ICARUSFlashAssAna &&  )
delete

Member Function Documentation

void opana::ICARUSFlashAssAna::analyze ( art::Event const &  e)
override

Definition at line 521 of file ICARUSFlashAssAna_module.cc.

521  {
522 
523 
524  m_run = e.id().run();
525  m_event = e.id().event();
526  m_timestamp = e.time().timeHigh(); // precision to the second
527 
528 
529  /*
530  This part is for the trigger information
531  */
532 
533 
534  // We work out the trigger information here
535  if( !fTriggerLabel.empty() ) {
536 
537  // Beam information
538  art::Handle<std::vector<sim::BeamGateInfo>> beamgate_handle;
539  e.getByLabel( fTriggerLabel, beamgate_handle );
540 
541  if( beamgate_handle.isValid() ) {
542 
543  for( auto const & beamgate : *beamgate_handle ) {
544 
545  m_beam_gate_start = beamgate.Start();
546  m_beam_gate_width = beamgate.Width();
547  m_beam_type = beamgate.BeamType() ;
548 
549  }
550 
551  }
552 
553  else {
554  mf::LogError("ICARUSFlashAssAna") << "No sim::BeamGateInfo associated to label: " << fTriggerLabel.label() << "\n" ;
555  }
556 
557  // Now trigger information
558  art::Handle<sbn::ExtraTriggerInfo> trigger_handle;
559  e.getByLabel( fTriggerLabel, trigger_handle );
560 
561  if( trigger_handle.isValid() ) {
562 
563  sbn::triggerSource bit = trigger_handle->sourceType;
564 
565  m_gate_type = (unsigned int)bit;
566  m_gate_name = bitName(bit);
567  m_trigger_timestamp = trigger_handle->triggerTimestamp;
568  m_gate_start_timestamp = trigger_handle->beamGateTimestamp;
569  m_trigger_gate_diff = trigger_handle->triggerTimestamp - trigger_handle->beamGateTimestamp;
570 
571  }
572  else{
573  mf::LogError("ICARUSFlashAssAna") << "No raw::Trigger associated to label: " << fTriggerLabel.label() << "\n" ;
574  }
575 
576  }
577 
578  else {
579  mf::LogError("ICARUSFlashAssAna") << "Trigger Data product " << fTriggerLabel.label() << " not found!\n" ;
580  }
581 
582 
583  /*
584  Now we work on the waveforms if we are allowed to
585  */
586 
587  if( !fOpDetWaveformLabels.empty() && fSaveWaveformInfo ) {
588 
589  for( size_t i=0; i<fOpDetWaveformLabels.size(); i++ ) {
590 
591  auto const label = fOpDetWaveformLabels[i];
592 
593  art::Handle<std::vector<raw::OpDetWaveform>> wfm_handle;
594  e.getByLabel( label, wfm_handle );
595 
596  if( wfm_handle.isValid() && !wfm_handle->empty() ) {
597 
598  for( auto const & wave : *wfm_handle ){
599 
600  m_channel_id = wave.ChannelNumber();
601  m_nticks = wave.Waveform().size();
602  m_baseline = Median( wave.Waveform() );
603  m_chargesum = std::accumulate( wave.Waveform().begin(), wave.Waveform().end(), 0,
604  [ & ](short x, short y){ return ((m_baseline-x) + (m_baseline-y)) ; } );
605 
606  fOpDetWaveformTrees[i]->Fill();
607 
608  }
609  }
610  }
611  }
612 
613 
614  /*
615  Now we take care of the flashes: we separate the case where we have a flash and the case where we have not a flash
616  */
617 
618  if ( !fFlashLabels.empty() ) {
619 
620  // Hold the cryostat information
621  std::vector<unsigned int> cids;
622 
623 
624  for ( size_t iFlashLabel=0; iFlashLabel<fFlashLabels.size(); iFlashLabel++ ) {
625 
626  auto const label = fFlashLabels[iFlashLabel];
627 
628  art::Handle<std::vector<recob::OpFlash>> flash_handle;
629  e.getByLabel( label, flash_handle );
630 
631  // We want our flashes to be valid and not empty
632  if( !flash_handle.isValid() ) {
633  mf::LogError("ICARUSFlashAssAna")
634  << "Not found a recob::OpFlash with label '" << label.encode() << "'";
635  } else if ( flash_handle->empty() ) {
636  mf::LogWarning("ICARUSFlashAssAna")
637  << "No recob::OpFlash in collection with label '" << label.encode() << "'";
638  }
639  else {
640 
641  art::FindManyP<recob::OpHit> ophitsPtr( flash_handle, e, label );
642 
643 
644  for ( size_t idx=0; idx<flash_handle->size(); idx++ ) {
645 
646  m_flash_id = idx;
647  auto const & flash = (*flash_handle)[idx];
648 
649  m_flash_time = flash.Time();
650  m_sum_pe = flash.TotalPE();
651 
652  auto const & ophits = ophitsPtr.at(idx);
653 
654  // We keep track of the cryistats where the flashes are found;
655  geo::CryostatID::CryostatID_t cid = getCryostatByChannel(ophits.front()->OpChannel());
656 
657  auto const found = std::find(cids.begin(), cids.end(), cid);
658  if( found != cids.end() ){
659  cids.push_back( cid );
660  }
661 
662  // Get the multiplicity, the position and the number of PE per Side
663  float xyz[3] = {0.0, 0.0, 0.0};
664  processOpHitsFlash( ophits,
666  m_sum_pe_left, m_sum_pe_right, xyz, fOpHitFlashTrees[iFlashLabel] );
667 
668  /*
669  std::cout << "\tflash id: " << idx << ", time: " << m_flash_time;
670  std::cout << ", multiplicity left: " << m_multiplicity_left << ", multiplicity right: " << m_multiplicity_right;
671  std::cout << ", sum pe left: " << m_sum_pe_left << ", sum pe right: " << m_sum_pe_right;
672  std::cout << " coor: [" << xyz[0] << ", " << xyz[1] << ", " << xyz[2] << "]";
673  std::cout << " coor: [" << 0.0 << ", " << flash.YCenter() << ", " << flash.ZCenter() << "]";
674  std::cout << " coor: [" << 0.0 << ", " << flash.YWidth() << ", " << flash.ZWidth() << "]";
675  std::cout << "\n";
676  */
677 
679 
680  //m_flash_x = 0.0;
681  //m_flash_width_x = 0.0;
682  m_flash_y = flash.YCenter();
683  m_flash_width_y = flash.YWidth();
684  m_flash_z = flash.ZCenter();
685  m_flash_width_z = flash.ZWidth();
686 
687  fOpFlashTrees[iFlashLabel]->Fill();
688  }
689  }
690  }
691 
692  // If the flashes did not cover all three cryostats..
693  // ..well, we save the ophits on what is missing
694  for( unsigned int cid=0; cid<fGeom->Ncryostats(); cid++ ){
695 
696  auto const found = std::find( cids.begin(), cids.end(), cid );
697  if( found == cids.end() ){
698  processOpHits(e, cid);
699  }
700  }
701  }
702 
703  else {
704 
705  mf::LogError("ICARUSFlashAssAna")
706  << "No recob::OpFlash labels selected\n";
707 
708  // We save the ophits anyways even in absence of flashes
709  for( unsigned int cid=0; cid<fGeom->Ncryostats(); cid++ ){
710  processOpHits(e, cid);
711  }
712 
713  }
714 
715 
716  fEventTree->Fill();
717 
718 }
std::vector< TTree * > fOpFlashTrees
process_name opflash particleana ie x
std::vector< TTree * > fOpDetWaveformTrees
void processOpHitsFlash(std::vector< art::Ptr< recob::OpHit >> const &ophits, int &multiplicity_left, int &multiplicity_right, float &sum_pe_left, float &sum_pe_right, float *xyz, TTree *ophittree)
std::vector< art::InputTag > fOpDetWaveformLabels
unsigned int Ncryostats() const
Returns the number of cryostats in the detector.
geo::CryostatID::CryostatID_t getCryostatByChannel(int channel)
std::string bitName(triggerSource bit)
Returns a mnemonic short name of the beam type.
Definition: BeamBits.h:267
process_name opflash particleana ie ie y
T Median(std::vector< T > data) const
geo::GeometryCore const * fGeom
unsigned int CryostatID_t
Type for the ID number.
Definition: geo_types.h:191
std::vector< TTree * > fOpHitFlashTrees
do i e
triggerSource
Type of beam or beam gate or other trigger source.
Definition: BeamBits.h:97
std::vector< art::InputTag > fFlashLabels
void processOpHits(art::Event const &e, unsigned int cryo)
void opana::ICARUSFlashAssAna::beginJob ( )
override

Definition at line 213 of file ICARUSFlashAssAna_module.cc.

213  {
214 
215  art::ServiceHandle<art::TFileService const> tfs;
216 
217  TTree* fGeoTree = tfs->make<TTree>("geotree", "geometry information" );
218  fGeoTree->Branch("pmt_x",&m_pmt_x);
219  fGeoTree->Branch("pmt_y",&m_pmt_y);
220  fGeoTree->Branch("pmt_z",&m_pmt_z);
221 
222  double PMTxyz[3];
223  for(size_t opch=0; opch<fGeom->NOpChannels(); ++opch) {
224 
225  fGeom->OpDetGeoFromOpChannel(opch).GetCenter(PMTxyz);
226 
227  //std::cout << PMTxyz[0] << " " << PMTxyz[1] << " " << PMTxyz[2] << std::endl;
228 
229  m_pmt_x.push_back(PMTxyz[0]);
230  m_pmt_y.push_back(PMTxyz[1]);
231  m_pmt_z.push_back(PMTxyz[2]);
232 
233  }
234 
235  fGeoTree->Fill();
236 
237  fEventTree = tfs->make<TTree>("eventstree", "higher level information on the event" );
238  fEventTree->Branch("run", &m_run, "run/I");
239  fEventTree->Branch("event", &m_event, "event/I");
240  fEventTree->Branch("timestamp", &m_timestamp, "timestamp/I");
241  //fEventTree->Branch("nflashes", &m_nflashes, "nflashes/I");
242  //fEventTree->Branch("nophits", &m_nophit, "nophits/I");
243  fEventTree->Branch("beam_gate_start", &m_beam_gate_start, "beam_gate_start/F");
244  fEventTree->Branch("beam_gate_width", &m_beam_gate_width, "beam_gate_width/F");
245  fEventTree->Branch("beam_type", &m_beam_type, "beam_type/I");
246  fEventTree->Branch("gate_type", &m_gate_type, "gate_type/b");
247  fEventTree->Branch("gate_name", &m_gate_name);
248  fEventTree->Branch("trigger_timestamp", &m_trigger_timestamp, "trigger_timestamp/l");
249  fEventTree->Branch("gate_start_timestamp", &m_gate_start_timestamp, "gate_start_timestamp/l");
250  fEventTree->Branch("trigger_gate_diff", &m_trigger_gate_diff, "trigger_gate_diff/l");
251 
252  // This tree will hold some aggregated optical waveform information
253  // The flag must be enabled to have the information saved
254  if( !fOpDetWaveformLabels.empty() && fSaveWaveformInfo ) {
255 
256  for( auto const & label : fOpDetWaveformLabels ) {
257 
258  std::string name = label.label()+"wfttree";
259  std::string info = "TTree with aggregated optical waveform information with label: " + label.label();
260 
261  TTree* ttree = tfs->make<TTree>(name.c_str(), info.c_str());
262  ttree->Branch("run", &m_run, "run/I");
263  ttree->Branch("event", &m_event, "event/I");
264  ttree->Branch("timestamp", &m_timestamp, "timestamp/I");
265  ttree->Branch("channel_id", &m_channel_id, "channel_id/I");
266  ttree->Branch("baseline", &m_baseline, "baseline/s");
267  ttree->Branch("chargesum", &m_chargesum, "chargesum/s");
268  ttree->Branch("nticks", &m_nticks, "nticks/I");
269 
270  fOpDetWaveformTrees.push_back(ttree);
271 
272  }
273 
274  }
275 
276 
277  // This ttree will hold the ophit information when a flash is not found in the event
278  // NB: information of the optical hits in events where flashes are present are lost
279 
280  for( auto const & label : fOpHitLabels ) {
281 
282  std::string name = label.label()+"_ttree";
283  std::string info = "TTree for the recob::OpHit objects with label " + label.label() + " in events without flashes.";
284 
285  TTree* ttree = tfs->make<TTree>(name.c_str(), info.c_str());
286  ttree->Branch("run", &m_run, "run/I");
287  ttree->Branch("event", &m_event, "event/I");
288  ttree->Branch("timestamp", &m_timestamp, "timestamp/I");
289  ttree->Branch("channel_id", &m_channel_id, "channel_id/I");
290  ttree->Branch("integral", &m_integral, "integral/F");
291  ttree->Branch("amplitude", &m_amplitude, "amplitude/F");
292  ttree->Branch("start_time", &m_start_time, "start_time/F");
293  ttree->Branch("abs_start_time", &m_abs_start_time, "abs_start_time/F");
294  ttree->Branch("pe", &m_pe, "pe/F");
295  ttree->Branch("width", &m_width, "width/F");
296  ttree->Branch("fast_to_total", &m_fast_to_total, "fast_to_total/F");
297 
298  fOpHitTrees.push_back(ttree);
299 
300  }
301 
302 
303  if ( !fFlashLabels.empty() ) {
304 
305  for( auto const & label : fFlashLabels ) {
306 
307  // TTree for the flash in a given cryostat
308  std::string name = label.label()+"_flashtree";
309  std::string info = "TTree for the recob::Flashes with label "+label.label();
310 
311  TTree* ttree = tfs->make<TTree>(name.c_str(), info.c_str() );
312  ttree->Branch("run", &m_run, "run/I");
313  ttree->Branch("event", &m_event, "event/I");
314  ttree->Branch("timestamp", &m_timestamp, "timestamp/I");
315  ttree->Branch("flash_id", &m_flash_id, "flash_id/I");
316  ttree->Branch("multiplicity", &m_multiplicity, "multiplicity/I");
317  ttree->Branch("multiplicity_right", &m_multiplicity_right, "multiplicity_right/I" );
318  ttree->Branch("multiplicity_left", &m_multiplicity_left, "multiplicity_left/I" );
319  ttree->Branch("sum_pe", &m_sum_pe, "sum_pe/F");
320  ttree->Branch("sum_pe_right", &m_sum_pe_right, "sum_pe_right/F");
321  ttree->Branch("sum_pe_left", &m_sum_pe_left, "sum_pe_left/F");
322  ttree->Branch("flash_time", &m_flash_time, "flash_time/F");
323  //ttree->Branch("flash_x", &m_flash_x, "flash_x/F");
324  //ttree->Branch("flash_width_x", &m_flash_width_x, "flash_width_x/F");
325  ttree->Branch("flash_y", &m_flash_y, "flash_y/F");
326  ttree->Branch("flash_width_y", &m_flash_width_y, "flash_width_y/F");
327  ttree->Branch("flash_z", &m_flash_z, "flash_z/F");
328  ttree->Branch("flash_width_z", &m_flash_width_z, "flash_width_z/F");
329 
330  fOpFlashTrees.push_back( ttree );
331 
332  // Now the ttree for the OpHit associated in the flash
333  name = label.label()+"_ophittree";
334  info = "Three for the recob::OpHit associated with an OpHitFlash"+label.label();
335 
336  TTree* ophittree = tfs->make<TTree>(name.c_str(), info.c_str() );
337  ophittree->Branch("run", &m_run, "run/I");
338  ophittree->Branch("event", &m_event, "event/I");
339  ophittree->Branch("timestamp", &m_timestamp, "timestamp/I");
340  ophittree->Branch("flash_id", &m_flash_id, "flash_id/I");
341  ophittree->Branch("channel_id", &m_channel_id, "channel_id/I");
342  ophittree->Branch("integral", &m_integral, "integral/F");
343  ophittree->Branch("amplitude", &m_amplitude, "amplitude/F");
344  ophittree->Branch("start_time", &m_start_time, "start_time/F");
345  ophittree->Branch("abs_start_time", &m_abs_start_time, "abs_start_time/F");
346  ophittree->Branch("pe", &m_pe, "pe/F");
347  ophittree->Branch("width", &m_width, "width/F");
348  ophittree->Branch("fast_to_total", &m_fast_to_total, "fast_to_total/F");
349 
350  fOpHitFlashTrees.push_back( ophittree );
351 
352  }
353  }
354 
355 }
std::vector< TTree * > fOpFlashTrees
std::vector< TTree * > fOpDetWaveformTrees
std::vector< art::InputTag > fOpDetWaveformLabels
void GetCenter(double *xyz, double localz=0.0) const
Definition: OpDetGeo.cxx:40
unsigned int NOpChannels() const
Number of electronics channels for all the optical detectors.
geo::GeometryCore const * fGeom
std::vector< TTree * > fOpHitFlashTrees
std::vector< TTree * > fOpHitTrees
then echo fcl name
std::vector< art::InputTag > fFlashLabels
art::ServiceHandle< art::TFileService > tfs
OpDetGeo const & OpDetGeoFromOpChannel(unsigned int OpChannel) const
Returns the geo::OpDetGeo object for the given channel number.
std::vector< art::InputTag > fOpHitLabels
void opana::ICARUSFlashAssAna::endJob ( )
override

Definition at line 516 of file ICARUSFlashAssAna_module.cc.

516  {
517 
518 }
static std::string_view opana::ICARUSFlashAssAna::firstLine ( std::string const &  s,
const char *  endl = "\r" 
)
static
geo::CryostatID::CryostatID_t opana::ICARUSFlashAssAna::getCryostatByChannel ( int  channel)

Definition at line 369 of file ICARUSFlashAssAna_module.cc.

369  {
370 
371 
372  const geo::OpDetGeo& opdetgeo = fGeom->OpDetGeoFromOpChannel(channel);
373  geo::CryostatID::CryostatID_t cid = opdetgeo.ID().Cryostat ;
374 
375  return cid;
376 
377 }
CryostatID_t Cryostat
Index of cryostat.
Definition: geo_types.h:212
geo::GeometryCore const * fGeom
unsigned int CryostatID_t
Type for the ID number.
Definition: geo_types.h:191
geo::OpDetID const & ID() const
Returns the geometry ID of this optical detector.
Definition: OpDetGeo.h:72
OpDetGeo const & OpDetGeoFromOpChannel(unsigned int OpChannel) const
Returns the geo::OpDetGeo object for the given channel number.
int opana::ICARUSFlashAssAna::getSideByChannel ( const int  channel)

Definition at line 380 of file ICARUSFlashAssAna_module.cc.

380  {
381 
382  /*
383  Channels are numbered from east to west, from North (cryo side) to South (beam side)
384  We look in the opposide direction wrt to the beam direction South->North:
385 
386  - Left is the east wall of each cryostat;
387 
388  - Right is the west side of each cryostat;
389 
390  - [ 0:89 ] and [180:269] are on the left,
391  the return value of the function is 0;
392 
393  - [ 90-179 ] and [ 270:359 ] are on the right,
394  the return value of the function is 1;
395  */
396 
397 
398  int side = channel / 90; // always round down
399 
400  return side % 2;
401 }
template<typename T >
T opana::ICARUSFlashAssAna::Median ( std::vector< T >  data) const

Definition at line 360 of file ICARUSFlashAssAna_module.cc.

360  {
361 
362  std::nth_element( data.begin(), data.begin() + data.size()/2, data.end() );
363 
364  return data[ data.size()/2 ];
365 
366 }
ICARUSFlashAssAna& opana::ICARUSFlashAssAna::operator= ( ICARUSFlashAssAna const &  )
delete
ICARUSFlashAssAna& opana::ICARUSFlashAssAna::operator= ( ICARUSFlashAssAna &&  )
delete
void opana::ICARUSFlashAssAna::processOpHits ( art::Event const &  e,
unsigned int  cryo 
)

Definition at line 404 of file ICARUSFlashAssAna_module.cc.

404  {
405 
406 
407  if( fOpHitLabels.empty() ){
408 
409  mf::LogError("ICARUSFlashAssAna") << "No recob::OpHit labels selected.";
410 
411  return;
412  }
413 
414  for( size_t iOpHitLabel=0; iOpHitLabel<fOpHitLabels.size(); iOpHitLabel++ ) {
415 
416  auto const label = fOpHitLabels[iOpHitLabel];
417 
418  art::Handle<std::vector<recob::OpHit>> ophit_handle;
419  e.getByLabel( label, ophit_handle );
420 
421 
422  // We want our flashes to be valid and not empty
423  if( !ophit_handle.isValid() || ophit_handle->empty() ) {
424  mf::LogError("ICARUSFlashAssAna")
425  << "Invalid recob::OpHit with label '" << label.encode() << "'";
426  continue;
427  }
428 
429 
430  for( auto const & ophit : *ophit_handle ) {
431 
432  //auto const & ophit = (*ophit_handle)[idx];
433 
434  const int channel_id = ophit.OpChannel();
435 
436  if( getCryostatByChannel(channel_id) != cryo ){ continue; }
437 
438  m_channel_id = channel_id;
439  m_integral = ophit.Area(); // in ADC x tick
440  m_amplitude = ophit.Amplitude(); // in ADC
441  m_start_time = ophit.PeakTime();
442  m_width = ophit.Width();
443  m_abs_start_time = ophit.PeakTimeAbs();
444  m_pe = ophit.PE();
445  m_fast_to_total = ophit.FastToTotal();
446 
447  fOpHitTrees[iOpHitLabel]->Fill();
448 
449  }
450  }
451 
452  return;
453 
454 }
geo::CryostatID::CryostatID_t getCryostatByChannel(int channel)
BEGIN_PROLOG opflashCryoW opflashCryoW triggerfilterBNB triggerfilterNuMI triggerfilterOffbeamBNB triggerfilterOffbeamNuMI triggerfilterUnknown roifinder roifinder2d gaushitTPCEE gaushitTPCWE purityana1 ophit
std::vector< TTree * > fOpHitTrees
do i e
std::vector< art::InputTag > fOpHitLabels
void opana::ICARUSFlashAssAna::processOpHitsFlash ( std::vector< art::Ptr< recob::OpHit >> const &  ophits,
int &  multiplicity_left,
int &  multiplicity_right,
float &  sum_pe_left,
float &  sum_pe_right,
float *  xyz,
TTree *  ophittree 
)

Definition at line 457 of file ICARUSFlashAssAna_module.cc.

460  {
461 
462 
463  std::unordered_map<int, float > sumpe_map;
464 
465  // We caluclate the total charge clustered in the flash per channel taking part to the flash
466  for( auto const ophit : ophits ) {
467 
468  if ( ophit->PE() < fPEOpHitThreshold ) { continue; }
469 
470  const int channel_id = ophit->OpChannel();
471 
472  sumpe_map[ channel_id ]+=ophit->PE() ;
473 
474  //xyz[0] += m_pmt_x[channel_id]*ophit->PE();
475  //xyz[1] += m_pmt_y[channel_id]*ophit->PE();
476  //xyz[2] += m_pmt_z[channel_id]*ophit->PE();
477 
478  m_channel_id = channel_id;
479  m_integral = ophit->Area(); // in ADC x tick
480  m_amplitude = ophit->Amplitude(); // in ADC
481  m_start_time = ophit->PeakTime();
482  m_width = ophit->Width();
483  m_abs_start_time = ophit->PeakTimeAbs();
484  m_pe = ophit->PE();
485  m_fast_to_total = ophit->FastToTotal();
486 
487  ophittree->Fill();
488 
489  }
490 
491  m_multiplicity_left = std::accumulate( sumpe_map.begin(), sumpe_map.end(), 0,
492  [&](int value, const std::map<int, float>::value_type& p) {
493  return getSideByChannel(p.first)==0 ? ++value : value ;
494  });
495 
496  m_multiplicity_right =std::accumulate( sumpe_map.begin(), sumpe_map.end(), 0,
497  [&](int value, const std::map<int, float>::value_type& p) {
498  return getSideByChannel(p.first)==1 ? ++value : value ;
499  });
500 
501  m_sum_pe_left = std::accumulate( sumpe_map.begin(), sumpe_map.end(), 0.0,
502  [&](float value, const std::map<int, float>::value_type& p) {
503  return getSideByChannel(p.first)==0 ? value+p.second : value ;
504  });
505 
506  m_sum_pe_right = std::accumulate( sumpe_map.begin(), sumpe_map.end(), 0.0,
507  [&](float value, const std::map<int, float>::value_type& p) {
508  return getSideByChannel(p.first)==1 ? value+p.second : value ;
509  });
510 
511  //for( int i=0; i<3; i++ ){ xyz[i] /= (m_sum_pe_left+ m_sum_pe_right); }
512 
513 }
pdgs p
Definition: selectors.fcl:22
int getSideByChannel(const int channel)
BEGIN_PROLOG opflashCryoW opflashCryoW triggerfilterBNB triggerfilterNuMI triggerfilterOffbeamBNB triggerfilterOffbeamNuMI triggerfilterUnknown roifinder roifinder2d gaushitTPCEE gaushitTPCWE purityana1 ophit
temporary value

Member Data Documentation

bool opana::ICARUSFlashAssAna::fDebug
private

Definition at line 141 of file ICARUSFlashAssAna_module.cc.

TTree* opana::ICARUSFlashAssAna::fEventTree
private

Definition at line 144 of file ICARUSFlashAssAna_module.cc.

std::vector<art::InputTag> opana::ICARUSFlashAssAna::fFlashLabels
private

Definition at line 139 of file ICARUSFlashAssAna_module.cc.

geo::GeometryCore const* opana::ICARUSFlashAssAna::fGeom
private

Definition at line 195 of file ICARUSFlashAssAna_module.cc.

std::vector<art::InputTag> opana::ICARUSFlashAssAna::fOpDetWaveformLabels
private

Definition at line 137 of file ICARUSFlashAssAna_module.cc.

std::vector<TTree*> opana::ICARUSFlashAssAna::fOpDetWaveformTrees
private

Definition at line 145 of file ICARUSFlashAssAna_module.cc.

std::vector<TTree*> opana::ICARUSFlashAssAna::fOpFlashTrees
private

Definition at line 146 of file ICARUSFlashAssAna_module.cc.

std::vector<TTree*> opana::ICARUSFlashAssAna::fOpHitFlashTrees
private

Definition at line 148 of file ICARUSFlashAssAna_module.cc.

std::vector<art::InputTag> opana::ICARUSFlashAssAna::fOpHitLabels
private

Definition at line 138 of file ICARUSFlashAssAna_module.cc.

std::vector<TTree*> opana::ICARUSFlashAssAna::fOpHitTrees
private

Definition at line 147 of file ICARUSFlashAssAna_module.cc.

float opana::ICARUSFlashAssAna::fPEOpHitThreshold
private

Definition at line 140 of file ICARUSFlashAssAna_module.cc.

bool opana::ICARUSFlashAssAna::fSaveWaveformInfo
private

Definition at line 136 of file ICARUSFlashAssAna_module.cc.

art::InputTag opana::ICARUSFlashAssAna::fTriggerLabel
private

Definition at line 135 of file ICARUSFlashAssAna_module.cc.

float opana::ICARUSFlashAssAna::m_abs_start_time
private

Definition at line 187 of file ICARUSFlashAssAna_module.cc.

float opana::ICARUSFlashAssAna::m_amplitude
private

Definition at line 184 of file ICARUSFlashAssAna_module.cc.

short opana::ICARUSFlashAssAna::m_baseline
private

Definition at line 155 of file ICARUSFlashAssAna_module.cc.

float opana::ICARUSFlashAssAna::m_beam_gate_start =-99999
private

Definition at line 158 of file ICARUSFlashAssAna_module.cc.

float opana::ICARUSFlashAssAna::m_beam_gate_width =-99999
private

Definition at line 159 of file ICARUSFlashAssAna_module.cc.

int opana::ICARUSFlashAssAna::m_beam_type =-1
private

Definition at line 160 of file ICARUSFlashAssAna_module.cc.

int opana::ICARUSFlashAssAna::m_channel_id
private

Definition at line 182 of file ICARUSFlashAssAna_module.cc.

short opana::ICARUSFlashAssAna::m_chargesum
private

Definition at line 156 of file ICARUSFlashAssAna_module.cc.

int opana::ICARUSFlashAssAna::m_event
private

Definition at line 151 of file ICARUSFlashAssAna_module.cc.

float opana::ICARUSFlashAssAna::m_fast_to_total
private

Definition at line 189 of file ICARUSFlashAssAna_module.cc.

int opana::ICARUSFlashAssAna::m_flash_id
private

Definition at line 167 of file ICARUSFlashAssAna_module.cc.

float opana::ICARUSFlashAssAna::m_flash_time
private

Definition at line 174 of file ICARUSFlashAssAna_module.cc.

float opana::ICARUSFlashAssAna::m_flash_width_y
private

Definition at line 178 of file ICARUSFlashAssAna_module.cc.

float opana::ICARUSFlashAssAna::m_flash_width_z
private

Definition at line 180 of file ICARUSFlashAssAna_module.cc.

float opana::ICARUSFlashAssAna::m_flash_y
private

Definition at line 177 of file ICARUSFlashAssAna_module.cc.

float opana::ICARUSFlashAssAna::m_flash_z
private

Definition at line 179 of file ICARUSFlashAssAna_module.cc.

std::string opana::ICARUSFlashAssAna::m_gate_name
private

Definition at line 162 of file ICARUSFlashAssAna_module.cc.

uint64_t opana::ICARUSFlashAssAna::m_gate_start_timestamp
private

Definition at line 164 of file ICARUSFlashAssAna_module.cc.

unsigned int opana::ICARUSFlashAssAna::m_gate_type
private

Definition at line 161 of file ICARUSFlashAssAna_module.cc.

float opana::ICARUSFlashAssAna::m_integral
private

Definition at line 183 of file ICARUSFlashAssAna_module.cc.

int opana::ICARUSFlashAssAna::m_multiplicity
private

Definition at line 168 of file ICARUSFlashAssAna_module.cc.

int opana::ICARUSFlashAssAna::m_multiplicity_left
private

Definition at line 169 of file ICARUSFlashAssAna_module.cc.

int opana::ICARUSFlashAssAna::m_multiplicity_right
private

Definition at line 170 of file ICARUSFlashAssAna_module.cc.

int opana::ICARUSFlashAssAna::m_nticks
private

Definition at line 157 of file ICARUSFlashAssAna_module.cc.

float opana::ICARUSFlashAssAna::m_pe
private

Definition at line 188 of file ICARUSFlashAssAna_module.cc.

std::vector<float> opana::ICARUSFlashAssAna::m_pmt_x
private

Definition at line 191 of file ICARUSFlashAssAna_module.cc.

std::vector<float> opana::ICARUSFlashAssAna::m_pmt_y
private

Definition at line 192 of file ICARUSFlashAssAna_module.cc.

std::vector<float> opana::ICARUSFlashAssAna::m_pmt_z
private

Definition at line 193 of file ICARUSFlashAssAna_module.cc.

int opana::ICARUSFlashAssAna::m_run
private

Definition at line 150 of file ICARUSFlashAssAna_module.cc.

float opana::ICARUSFlashAssAna::m_start_time
private

Definition at line 185 of file ICARUSFlashAssAna_module.cc.

float opana::ICARUSFlashAssAna::m_sum_pe
private

Definition at line 171 of file ICARUSFlashAssAna_module.cc.

float opana::ICARUSFlashAssAna::m_sum_pe_left
private

Definition at line 172 of file ICARUSFlashAssAna_module.cc.

float opana::ICARUSFlashAssAna::m_sum_pe_right
private

Definition at line 173 of file ICARUSFlashAssAna_module.cc.

int opana::ICARUSFlashAssAna::m_timestamp
private

Definition at line 152 of file ICARUSFlashAssAna_module.cc.

uint64_t opana::ICARUSFlashAssAna::m_trigger_gate_diff
private

Definition at line 165 of file ICARUSFlashAssAna_module.cc.

uint64_t opana::ICARUSFlashAssAna::m_trigger_timestamp
private

Definition at line 163 of file ICARUSFlashAssAna_module.cc.

float opana::ICARUSFlashAssAna::m_width
private

Definition at line 186 of file ICARUSFlashAssAna_module.cc.


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