Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
pdune::RecoStats Class Reference
Inheritance diagram for pdune::RecoStats:
art::EDAnalyzer art::detail::Analyzer art::detail::LegacyModule art::Observer art::ModuleBase

Classes

struct  Config
 

Public Types

using Parameters = art::EDAnalyzer::Table< Config >
 
- Public Types inherited from art::EDAnalyzer
using WorkerType = WorkerT< EDAnalyzer >
 
using ModuleType = EDAnalyzer
 

Public Member Functions

 RecoStats (Parameters const &config)
 
 RecoStats (RecoStats const &)=delete
 
 RecoStats (RecoStats &&)=delete
 
RecoStatsoperator= (RecoStats const &)=delete
 
RecoStatsoperator= (RecoStats &&)=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 Member Functions

template<size_t N>
bool fillChargeHistos (const art::Event &evt, detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp)
 
void fillChargeHisto (detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, TH2F *histo, const std::vector< art::Ptr< recob::Hit >> &hits)
 
double getHitMeV (detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const recob::Hit &hit) const
 
void ResetVars ()
 

Private Attributes

double fElectronsToGeV
 
std::unordered_map< int, std::pair< int, int > > mapTPCtoXY
 
TH2F * fEmChargePerTpcHist
 
TH2F * fHadChargePerTpcHist
 
TH2F * fChargePerTpcHist
 
TTree * fTree
 
int fRun
 
int fEvent
 
float fEkGen
 
float fEkDep
 
art::InputTag fEmTrkModuleLabel
 
calo::CalorimetryAlg fCalorimetryAlg
 

Additional Inherited Members

- 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 45 of file RecoStats_module.cc.

Member Typedef Documentation

Definition at line 60 of file RecoStats_module.cc.

Constructor & Destructor Documentation

pdune::RecoStats::RecoStats ( Parameters const &  config)
explicit

Definition at line 104 of file RecoStats_module.cc.

104  : EDAnalyzer(config),
105  fEmTrkModuleLabel(config().EmTrkModuleLabel()),
106  fCalorimetryAlg(config().CalorimetryAlg())
107 {
109  fElectronsToGeV = 1./larParameters->GeVToElectrons();
110 
111  mapTPCtoXY[0] = std::make_pair(-1, -1); // <- in case something falls into not active tpc
112  mapTPCtoXY[1] = std::make_pair(0, 1); // <- make 2D histo bins looking like in evd ortho
113  mapTPCtoXY[2] = std::make_pair(0, 0);
114  mapTPCtoXY[3] = std::make_pair(-1, -1);
115  mapTPCtoXY[4] = std::make_pair(-1, -1);
116  mapTPCtoXY[5] = std::make_pair(1, 1);
117  mapTPCtoXY[6] = std::make_pair(1, 0);
118  mapTPCtoXY[7] = std::make_pair(-1, -1);
119  mapTPCtoXY[8] = std::make_pair(-1, -1);
120  mapTPCtoXY[9] = std::make_pair(2, 1);
121  mapTPCtoXY[10] = std::make_pair(2, 0);
122  mapTPCtoXY[11] = std::make_pair(-1, -1);
123 }
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
static Config * config
Definition: config.cpp:1054
calo::CalorimetryAlg fCalorimetryAlg
std::unordered_map< int, std::pair< int, int > > mapTPCtoXY
double GeVToElectrons() const
art::InputTag fEmTrkModuleLabel
pdune::RecoStats::RecoStats ( RecoStats const &  )
delete
pdune::RecoStats::RecoStats ( RecoStats &&  )
delete

Member Function Documentation

void pdune::RecoStats::analyze ( art::Event const &  e)
overridevirtual

Implements art::EDAnalyzer.

Definition at line 213 of file RecoStats_module.cc.

214 {
215  ResetVars();
216 
217  fRun = evt.run();
218  fEvent = evt.id().event();
219 
220  // try to dig out 4- or 3-output MVA data product
221  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService>()->DataFor(evt);
222  auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService>()->DataFor(evt, clockData);
223  if (!fillChargeHistos<4>(evt, clockData, detProp) &&
224  !fillChargeHistos<3>(evt, clockData, detProp))
225  {
226  throw cet::exception("PMAlgTrackMaker") << "No EM/track MVA data products." << std::endl;
227  }
228 
229  fTree->Fill();
230 }
unsigned int event
Definition: DataStructs.h:636
unsigned int run
Definition: DataStructs.h:637
TCEvent evt
Definition: DataStructs.cxx:7
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
QTextStream & endl(QTextStream &s)
void pdune::RecoStats::beginJob ( )
overridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 125 of file RecoStats_module.cc.

126 {
128 
129  fEmChargePerTpcHist = tfs->make<TH2F>("EmChargePerTPC", "EM charge reconstucted", 3, 0., 3., 2, 0., 2.);
130  fHadChargePerTpcHist = tfs->make<TH2F>("HadChargePerTPC", "hadronic charge reconstucted", 3, 0., 3., 2, 0., 2.);
131  fChargePerTpcHist = tfs->make<TH2F>("ChargePerTPC", "total charge reconstucted", 3, 0., 3., 2, 0., 2.);
132 
133  fTree = tfs->make<TTree>("events", "summary tree");
134  fTree->Branch("fRun", &fRun, "fRun/I");
135  fTree->Branch("fEvent", &fEvent, "fEvent/I");
136  fTree->Branch("fEkGen", &fEkGen, "fEkGen/F");
137  fTree->Branch("fEkDep", &fEkDep, "fEkDep/F");
138 }
void pdune::RecoStats::endJob ( )
overridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 140 of file RecoStats_module.cc.

141 {
142 }
void pdune::RecoStats::fillChargeHisto ( detinfo::DetectorClocksData const &  clockData,
detinfo::DetectorPropertiesData const &  detProp,
TH2F *  histo,
const std::vector< art::Ptr< recob::Hit >> &  hits 
)
private

Definition at line 184 of file RecoStats_module.cc.

187 {
188  for (const auto & h : hits)
189  {
190  auto xy = mapTPCtoXY[ h->WireID().TPC ];
191  histo->Fill(xy.first, xy.second, getHitMeV(clockData, detProp, *h));
192  }
193 }
double getHitMeV(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const recob::Hit &hit) const
std::unordered_map< int, std::pair< int, int > > mapTPCtoXY
template<size_t N>
bool pdune::RecoStats::fillChargeHistos ( const art::Event evt,
detinfo::DetectorClocksData const &  clockData,
detinfo::DetectorPropertiesData const &  detProp 
)
private

Definition at line 145 of file RecoStats_module.cc.

148 {
149  float trackLikeThr = 0.63; // should move to fcl params
150  geo::View_t view = geo::kZ; // can move to fcl params
151 
153  if (!cluResults) { return false; }
154 
155  int trkLikeIdx = cluResults->getIndex("track");
156  int emLikeIdx = cluResults->getIndex("em");
157  if ((trkLikeIdx < 0) || (emLikeIdx < 0)) { return false; }
158 
159  const art::FindManyP< recob::Hit > hitsFromClusters(cluResults->dataHandle(), evt, cluResults->dataTag());
160  const auto & cnnOuts = cluResults->outputs();
161  const auto & clusters = cluResults->items();
162 
163  for (size_t i = 0; i < clusters.size(); ++i)
164  {
165  if (clusters[i].View() == view) { continue; } // take just one view
166 
167  double trackLike, trkOrEm = cnnOuts[i][trkLikeIdx] + cnnOuts[i][emLikeIdx];
168  if (trkOrEm > 0) { trackLike = cnnOuts[i][trkLikeIdx] / trkOrEm; }
169  else { trackLike = 0; }
170 
171  if (trackLike > trackLikeThr)
172  {
173  fillChargeHisto(clockData, detProp, fHadChargePerTpcHist, hitsFromClusters.at(i));
174  }
175  else
176  {
177  fillChargeHisto(clockData, detProp, fEmChargePerTpcHist, hitsFromClusters.at(i));
178  }
179  fillChargeHisto(clockData, detProp, fChargePerTpcHist, hitsFromClusters.at(i));
180  }
181  return true;
182 }
AdcChannelData::View View
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
Planes which measure Z direction.
Definition: geo_types.h:132
void fillChargeHisto(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, TH2F *histo, const std::vector< art::Ptr< recob::Hit >> &hits)
TCEvent evt
Definition: DataStructs.cxx:7
static std::unique_ptr< MVAReader > create(const art::Event &evt, const art::InputTag &tag)
Definition: MVAReader.h:110
art::InputTag fEmTrkModuleLabel
double pdune::RecoStats::getHitMeV ( detinfo::DetectorClocksData const &  clockData,
detinfo::DetectorPropertiesData const &  detProp,
const recob::Hit hit 
) const
private

Definition at line 195 of file RecoStats_module.cc.

198 {
199  double adc = hit.Integral();
200  if (!std::isnormal(adc) || (adc < 0)) adc = 0.0;
201 
202  unsigned short plane = hit.WireID().Plane;
203  double tdrift = hit.PeakTime();
204  double dqel = fCalorimetryAlg.ElectronsFromADCArea(adc, plane);
205 
206  double correllifetime = fCalorimetryAlg.LifetimeCorrection(clockData, detProp, tdrift, 0); // for the moment T0 = 0 (beam particles)
207  double dq = dqel * correllifetime * fElectronsToGeV * 1000;
208  if (!std::isnormal(dq) || (dq < 0)) dq = 0.0;
209 
210  return dq;
211 }
geo::WireID WireID() const
Definition: Hit.h:233
int16_t adc
Definition: CRTFragment.hh:202
float Integral() const
Integral under the calibrated signal waveform of the hit, in tick x ADC units.
Definition: Hit.h:224
double ElectronsFromADCArea(double area, unsigned short plane) const
PlaneID_t Plane
Index of the plane within its TPC.
Definition: geo_types.h:493
float PeakTime() const
Time of the signal peak, in tick units.
Definition: Hit.h:218
calo::CalorimetryAlg fCalorimetryAlg
double LifetimeCorrection(detinfo::DetectorClocksData const &clock_data, detinfo::DetectorPropertiesData const &det_prop, double time, double T0=0) const
RecoStats& pdune::RecoStats::operator= ( RecoStats const &  )
delete
RecoStats& pdune::RecoStats::operator= ( RecoStats &&  )
delete
void pdune::RecoStats::ResetVars ( void  )
private

Definition at line 232 of file RecoStats_module.cc.

233 {
234  fRun = 0;
235  fEvent = 0;
236  fEkGen = 0;
237  fEkDep = 0;
238 }

Member Data Documentation

calo::CalorimetryAlg pdune::RecoStats::fCalorimetryAlg
private

Definition at line 101 of file RecoStats_module.cc.

TH2F* pdune::RecoStats::fChargePerTpcHist
private

Definition at line 90 of file RecoStats_module.cc.

float pdune::RecoStats::fEkDep
private

Definition at line 96 of file RecoStats_module.cc.

float pdune::RecoStats::fEkGen
private

Definition at line 96 of file RecoStats_module.cc.

double pdune::RecoStats::fElectronsToGeV
private

Definition at line 85 of file RecoStats_module.cc.

TH2F* pdune::RecoStats::fEmChargePerTpcHist
private

Definition at line 88 of file RecoStats_module.cc.

art::InputTag pdune::RecoStats::fEmTrkModuleLabel
private

Definition at line 99 of file RecoStats_module.cc.

int pdune::RecoStats::fEvent
private

Definition at line 94 of file RecoStats_module.cc.

TH2F* pdune::RecoStats::fHadChargePerTpcHist
private

Definition at line 89 of file RecoStats_module.cc.

int pdune::RecoStats::fRun
private

Definition at line 94 of file RecoStats_module.cc.

TTree* pdune::RecoStats::fTree
private

Definition at line 92 of file RecoStats_module.cc.

std::unordered_map<int, std::pair<int, int> > pdune::RecoStats::mapTPCtoXY
private

Definition at line 86 of file RecoStats_module.cc.


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