Public Member Functions | Private Attributes | List of all members
Infill::MakeInfillTrainingData Class Reference
Inheritance diagram for Infill::MakeInfillTrainingData:
art::EDAnalyzer art::detail::Analyzer art::detail::LegacyModule art::Observer art::ModuleBase

Public Member Functions

 MakeInfillTrainingData (fhicl::ParameterSet const &p)
 
 MakeInfillTrainingData (MakeInfillTrainingData const &)=delete
 
 MakeInfillTrainingData (MakeInfillTrainingData &&)=delete
 
MakeInfillTrainingDataoperator= (MakeInfillTrainingData const &)=delete
 
MakeInfillTrainingDataoperator= (MakeInfillTrainingData &&)=delete
 
void analyze (art::Event const &e) override
 
void beginJob () override
 
void endJob () override
 
- Public Member Functions inherited from art::EDAnalyzer
 EDAnalyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDAnalyzer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Analyzer
virtual ~Analyzer () noexcept
 
 Analyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 Analyzer (Table< Config > const &config)
 
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::Observer
 ~Observer () noexcept
 
 Observer (Observer const &)=delete
 
 Observer (Observer &&)=delete
 
Observeroperator= (Observer const &)=delete
 
Observeroperator= (Observer &&)=delete
 
void registerProducts (ProductDescriptions &, ModuleDescription const &)
 
void fillDescriptions (ModuleDescription const &)
 
fhicl::ParameterSetID selectorConfig () const
 
- 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)
 

Private Attributes

const geo::GeometryCorefGeom
 
art::ServiceHandle< art::TFileService > tfs
 
std::set< raw::ChannelID_tfBadChannels
 
std::set< raw::ChannelID_tfNoisyChannels
 
std::set< raw::ChannelID_tfDeadChannels
 
std::set< readout::ROPIDfActiveRops
 
std::string fInputLabel
 

Additional Inherited Members

- Public Types inherited from art::EDAnalyzer
using WorkerType = WorkerT< EDAnalyzer >
 
using ModuleType = EDAnalyzer
 
- Protected Member Functions inherited from art::Observer
std::string const & processName () const
 
bool wantAllEvents () const noexcept
 
bool wantEvent (ScheduleID id, Event const &e) const
 
Handle< TriggerResultsgetTriggerResults (Event const &e) const
 
 Observer (fhicl::ParameterSet const &config)
 
 Observer (std::vector< std::string > const &select_paths, std::vector< std::string > const &reject_paths, fhicl::ParameterSet const &config)
 
- 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 ()
 

Detailed Description

Definition at line 46 of file MakeInfillTrainingData_module.cc.

Constructor & Destructor Documentation

Infill::MakeInfillTrainingData::MakeInfillTrainingData ( fhicl::ParameterSet const &  p)
explicit

Definition at line 80 of file MakeInfillTrainingData_module.cc.

81  : EDAnalyzer{p},
82  fInputLabel (p.get<std::string> ("inputLabel"))
83 {
84  consumes<std::vector<raw::RawDigit>>(fInputLabel);
85 }
std::string string
Definition: nybbler.cc:12
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
p
Definition: test.py:223
Infill::MakeInfillTrainingData::MakeInfillTrainingData ( MakeInfillTrainingData const &  )
delete
Infill::MakeInfillTrainingData::MakeInfillTrainingData ( MakeInfillTrainingData &&  )
delete

Member Function Documentation

void Infill::MakeInfillTrainingData::analyze ( art::Event const &  e)
overridevirtual

Implements art::EDAnalyzer.

Definition at line 87 of file MakeInfillTrainingData_module.cc.

88 {
89  std::string sEvent = (
90  "Ev" + std::to_string(e.id().event()) + "Run" + std::to_string(e.id().run()) +
91  "SRun" + std::to_string(e.id().subRun())
92  );
93  std::map<readout::ROPID, TH2F*> ropImages;
94 
95  auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService>()->DataFor(e);
96  // Networks expect a fixed image size
97  if (detProp.NumberTimeSamples() != 6000) {
98  std::cerr << "MakeInfillTrainingData_module.cc: Training data should have 6000 time ticks\n";
99  std::abort();
100  }
101 
102  // Prepare TH2s
103  for (const readout::ROPID& rop : fActiveRops) {
104  std::string sTitle = (
105  sEvent + "_TPCset" + std::to_string(rop.TPCset) + "_ROP" + std::to_string(rop.ROP)
106  );
107  ropImages[rop] = tfs->make<TH2F>(
108  sTitle.c_str(), sTitle.c_str(), fGeom->Nchannels(rop), 0, fGeom->Nchannels(rop), 6000, 0, 6000
109  );
110  }
111 
112  auto digs = e.getHandle<std::vector<raw::RawDigit>>(fInputLabel);
113 
114  // Fill TH2s
115  for(const raw::RawDigit& dig : *digs){
116  readout::ROPID rop = fGeom->ChannelToROP(dig.Channel());
117  if(ropImages.count(rop)){ // Ignores ROPs associated with only inactive TPCIDs
118  raw::RawDigit::ADCvector_t adcs(dig.Samples());
119  // raw::Uncompress(dig.ADCs(), adcs, dig.GetPedestal(), dig.Compression());
120  raw::Uncompress(dig.ADCs(), adcs, dig.Compression());
121 
122  const raw::ChannelID_t firstCh = fGeom->FirstChannelInROP(rop);
123  for(unsigned int tick = 0; tick < adcs.size(); ++tick){
124  const int adc = adcs[tick] ? int(adcs[tick]) - dig.GetPedestal() : 0;
125 
126  ropImages[rop]->Fill(dig.Channel() - firstCh, tick, adc);
127  }
128  }
129  }
130 
131  tfs->file().Write();
132  tfs->file().Flush();
133  for(auto it: ropImages) delete it.second;
134 }
Collection of charge vs time digitized from a single readout channel.
Definition: RawDigit.h:69
std::string string
Definition: nybbler.cc:12
art::ServiceHandle< art::TFileService > tfs
std::vector< short > ADCvector_t
Type representing a (compressed) vector of ADC counts.
Definition: RawDigit.h:73
int16_t adc
Definition: CRTFragment.hh:202
unsigned int Nchannels() const
Returns the number of TPC readout channels in the detector.
const double e
raw::ChannelID_t FirstChannelInROP(readout::ROPID const &ropid) const
Returns the ID of the first channel in the specified readout plane.
tick_as<> tick
Tick number, represented by std::ptrdiff_t.
Definition: electronics.h:75
Class identifying a set of planes sharing readout channels.
readout::ROPID ChannelToROP(raw::ChannelID_t channel) const
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:28
void Uncompress(const std::vector< short > &adc, std::vector< short > &uncompressed, raw::Compress_t compress)
Uncompresses a raw data buffer.
Definition: raw.cxx:776
std::string to_string(ModuleType const mt)
Definition: ModuleType.h:34
void Infill::MakeInfillTrainingData::beginJob ( )
overridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 136 of file MakeInfillTrainingData_module.cc.

137 {
139 
140  // Get active ROPs (not facing a wall)
143  for (iRop = rBegin; iRop != rEnd; ++iRop) { // Iterate over ROPs in detector
144  for (const geo::TPCID tpcId : fGeom->ROPtoTPCs(*iRop)) {
145  const geo::TPCGeo tpc = fGeom->TPC(tpcId);
146  const TGeoVolume* tpcVol = tpc.ActiveVolume();
147 
148  if (tpcVol->Capacity() > 1000000) { // At least one of the ROP's TPCIDs needs to be active
149  // Networks expect a fixed image size
150  if(fGeom->SignalType(*iRop) == geo::kInduction && fGeom->Nchannels(*iRop) != 800) {
151  std::cerr << "MakeInfillTrainingData_module.cc: Induction view training data should have 800 channels\n";
152  std::abort();
153  }
154  if(fGeom->SignalType(*iRop) == geo::kCollection && fGeom->Nchannels(*iRop) != 480) {
155  std::cerr << "MakeInfillTrainingData_module.cc: Collection view training data should have 480 channels\n";
156  std::abort();
157  }
158 
159  fActiveRops.insert(*iRop);
160  break;
161  }
162  }
163  }
164 }
std::vector< geo::TPCID > ROPtoTPCs(readout::ROPID const &ropid) const
Returns a list of ID of TPCs the specified ROP spans.
static constexpr BeginPos_t begin_pos
Definition: GeometryCore.h:107
Base forward iterator browsing all readout plane IDs in the detector.
Geometry information for a single TPC.
Definition: TPCGeo.h:38
static constexpr EndPos_t end_pos
Definition: GeometryCore.h:108
virtual const provider_type * provider() const override
SigType_t SignalType(geo::PlaneID const &pid) const
Returns the type of signal on the channels of specified TPC plane.
unsigned int Nchannels() const
Returns the number of TPC readout channels in the detector.
Signal from induction planes.
Definition: geo_types.h:145
const TGeoVolume * ActiveVolume() const
Definition: TPCGeo.h:119
The data type to uniquely identify a TPC.
Definition: geo_types.h:386
TPCGeo const & TPC(unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified TPC.
Signal from collection planes.
Definition: geo_types.h:146
void Infill::MakeInfillTrainingData::endJob ( )
overridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 166 of file MakeInfillTrainingData_module.cc.

167 {
168  std::cout << "Getting dead channels..." << std::endl;
169 
172 
173  std::merge(
174  fBadChannels.begin(), fBadChannels.end(), fNoisyChannels.begin(), fNoisyChannels.end(),
175  std::inserter(fDeadChannels, fDeadChannels.begin())
176  );
177 
178  // Print dead channels to terminal
179  for(const readout::ROPID& rop : fActiveRops) {
180  std::cout << "(TPCset " << rop.TPCset << ", ROP " << rop.ROP << "): ";
181  const raw::ChannelID_t firstCh = fGeom->FirstChannelInROP(rop);
182  for (const raw::ChannelID_t ch : fDeadChannels) {
183  if (fGeom->ChannelToROP(ch) == rop) {
184  std::cout << ch - firstCh << " ";
185  }
186  } // Could break early if ch > last ch in currentRop to save a bit of looping?
187  std::cout << std::endl;
188  }
189 }
std::set< raw::ChannelID_t > fNoisyChannels
raw::ChannelID_t FirstChannelInROP(readout::ROPID const &ropid) const
Returns the ID of the first channel in the specified readout plane.
Class identifying a set of planes sharing readout channels.
std::set< raw::ChannelID_t > fBadChannels
std::set< raw::ChannelID_t > fDeadChannels
readout::ROPID ChannelToROP(raw::ChannelID_t channel) const
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:28
QTextStream & endl(QTextStream &s)
MakeInfillTrainingData& Infill::MakeInfillTrainingData::operator= ( MakeInfillTrainingData const &  )
delete
MakeInfillTrainingData& Infill::MakeInfillTrainingData::operator= ( MakeInfillTrainingData &&  )
delete

Member Data Documentation

std::set<readout::ROPID> Infill::MakeInfillTrainingData::fActiveRops
private

Definition at line 75 of file MakeInfillTrainingData_module.cc.

std::set<raw::ChannelID_t> Infill::MakeInfillTrainingData::fBadChannels
private

Definition at line 71 of file MakeInfillTrainingData_module.cc.

std::set<raw::ChannelID_t> Infill::MakeInfillTrainingData::fDeadChannels
private

Definition at line 73 of file MakeInfillTrainingData_module.cc.

const geo::GeometryCore* Infill::MakeInfillTrainingData::fGeom
private

Definition at line 67 of file MakeInfillTrainingData_module.cc.

std::string Infill::MakeInfillTrainingData::fInputLabel
private

Definition at line 77 of file MakeInfillTrainingData_module.cc.

std::set<raw::ChannelID_t> Infill::MakeInfillTrainingData::fNoisyChannels
private

Definition at line 72 of file MakeInfillTrainingData_module.cc.

art::ServiceHandle<art::TFileService> Infill::MakeInfillTrainingData::tfs
private

Definition at line 69 of file MakeInfillTrainingData_module.cc.


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