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

Public Member Functions

 TCShowerAnalysis (fhicl::ParameterSet const &pset)
 
- 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

void beginJob () override
 
void analyze (const art::Event &evt) override
 
void reset ()
 
void truthMatcher (detinfo::DetectorClocksData const &clockData, std::vector< art::Ptr< recob::Hit >> all_hits, std::vector< art::Ptr< recob::Hit >> shower_hits, const simb::MCParticle *&MCparticle, double &Efrac, double &Ecomplet)
 

Private Attributes

TTree * fTree
 
int run
 
int subrun
 
int event
 
int nuPDG_truth
 
int ccnc_truth
 
int mode_truth
 
int nshws
 
int shwid [kMaxShowers]
 
float shwdcosx [kMaxShowers]
 
float shwdcosy [kMaxShowers]
 
float shwdcosz [kMaxShowers]
 
float shwstartx [kMaxShowers]
 
float shwstarty [kMaxShowers]
 
float shwstartz [kMaxShowers]
 
double shwdedx [kMaxShowers][2]
 
int shwbestplane [kMaxShowers]
 
int highestHitsPDG
 
double highestHitsFrac
 
std::string fHitModuleLabel
 
std::string fShowerModuleLabel
 
std::string fGenieGenModuleLabel
 
std::string fDigitModuleLabel
 
calo::CalorimetryAlg fCalorimetryAlg
 

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 32 of file TCShowerAnalysis_module.cc.

Constructor & Destructor Documentation

shower::TCShowerAnalysis::TCShowerAnalysis ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 85 of file TCShowerAnalysis_module.cc.

86  : EDAnalyzer(pset)
87  , fHitModuleLabel(pset.get<std::string>("HitModuleLabel", "trajcluster"))
88  , fShowerModuleLabel(pset.get<std::string>("ShowerModuleLabel", "tcshower"))
89  , fGenieGenModuleLabel(pset.get<std::string>("GenieGenModuleLabel", "generator"))
90  , fDigitModuleLabel(pset.get<std::string>("DigitModuleLabel", "largeant"))
91  , fCalorimetryAlg(pset.get<fhicl::ParameterSet>("CalorimetryAlg"))
92 {} // TCShowerTemplateMaker
std::string string
Definition: nybbler.cc:12
calo::CalorimetryAlg fCalorimetryAlg
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25

Member Function Documentation

void shower::TCShowerAnalysis::analyze ( const art::Event evt)
overrideprivate

Definition at line 130 of file TCShowerAnalysis_module.cc.

131 {
132 
133  run = evt.run();
134  subrun = evt.subRun();
135  event = evt.id().event();
136 
138  std::vector<art::Ptr<recob::Hit>> hitlist;
139  if (evt.getByLabel(fHitModuleLabel, hitListHandle)) art::fill_ptr_vector(hitlist, hitListHandle);
140 
142  std::vector<art::Ptr<sim::SimChannel>> simchanlist;
143  if (evt.getByLabel(fDigitModuleLabel, scListHandle))
144  art::fill_ptr_vector(simchanlist, scListHandle);
145 
146  art::Handle<std::vector<recob::Shower>> showerListHandle;
147  std::vector<art::Ptr<recob::Shower>> showerlist;
148  if (evt.getByLabel(fShowerModuleLabel, showerListHandle))
149  art::fill_ptr_vector(showerlist, showerListHandle);
150 
151  art::Handle<std::vector<simb::MCTruth>> mctruthListHandle;
152  std::vector<art::Ptr<simb::MCTruth>> mclist;
153  if (evt.getByLabel(fGenieGenModuleLabel, mctruthListHandle))
154  art::fill_ptr_vector(mclist, mctruthListHandle);
155 
156  art::FindManyP<recob::Hit> shwfm(showerListHandle, evt, fShowerModuleLabel);
157 
158  //shower information
159  if (showerListHandle.isValid()) {
160  nshws = showerlist.size();
161 
162  for (int i = 0; i < std::min(int(showerlist.size()), kMaxShowers); ++i) {
163  shwid[i] = showerlist[i]->ID();
164  shwdcosx[i] = showerlist[i]->Direction().X();
165  shwdcosy[i] = showerlist[i]->Direction().Y();
166  shwdcosz[i] = showerlist[i]->Direction().Z();
167  shwstartx[i] = showerlist[i]->ShowerStart().X();
168  shwstarty[i] = showerlist[i]->ShowerStart().Y();
169  shwstartz[i] = showerlist[i]->ShowerStart().Z();
170  for (size_t j = 0; j < (showerlist[i]->dEdx()).size(); ++j) {
171  shwdedx[i][j] = showerlist[i]->dEdx()[j];
172  }
173  shwbestplane[i] = showerlist[i]->best_plane();
174  }
175 
176  } // shower info
177 
178  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
179 
180  if (mclist.size()) {
181  art::Ptr<simb::MCTruth> mctruth = mclist[0];
182  if (mctruth->NeutrinoSet()) {
183 
184  nuPDG_truth = mctruth->GetNeutrino().Nu().PdgCode();
185  ccnc_truth = mctruth->GetNeutrino().CCNC();
186  mode_truth = mctruth->GetNeutrino().Mode();
187 
188  if (showerlist.size()) { // only looks at the first shower since this is
189  // for tcshower
190  std::vector<art::Ptr<recob::Hit>> showerhits = shwfm.at(0);
191  // get shower truth info
192  const simb::MCParticle* particle;
193  double tmpEfrac = 0.0;
194  double tmpEcomplet = 0;
195  truthMatcher(clockData, hitlist, showerhits, particle, tmpEfrac, tmpEcomplet);
196  if (particle) {
197  std::cout << "shower pdg: " << particle->PdgCode() << " efrac " << tmpEfrac << std::endl;
198 
199  highestHitsPDG = particle->PdgCode();
200  highestHitsFrac = tmpEfrac;
201  }
202  }
203  }
204  }
205 
206  fTree->Fill();
207 
208 } // analyze
int PdgCode() const
Definition: MCParticle.h:212
int CCNC() const
Definition: MCNeutrino.h:148
double shwdedx[kMaxShowers][2]
const simb::MCNeutrino & GetNeutrino() const
Definition: MCTruth.h:77
void truthMatcher(detinfo::DetectorClocksData const &clockData, std::vector< art::Ptr< recob::Hit >> all_hits, std::vector< art::Ptr< recob::Hit >> shower_hits, const simb::MCParticle *&MCparticle, double &Efrac, double &Ecomplet)
const simb::MCParticle & Nu() const
Definition: MCNeutrino.h:146
bool isValid() const noexcept
Definition: Handle.h:191
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:92
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:633
constexpr int kMaxShowers
SubRunNumber_t subRun() const
Definition: DataViewImpl.cc:78
RunNumber_t run() const
Definition: DataViewImpl.cc:71
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55
EventNumber_t event() const
Definition: EventID.h:116
bool NeutrinoSet() const
Definition: MCTruth.h:78
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:297
int Mode() const
Definition: MCNeutrino.h:149
EventID id() const
Definition: Event.cc:34
QTextStream & endl(QTextStream &s)
void shower::TCShowerAnalysis::beginJob ( )
overrideprivatevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 97 of file TCShowerAnalysis_module.cc.

98 {
99 
101 
102  fTree = tfs->make<TTree>("tcshowerana", "tcshowerana");
103  fTree->Branch("run", &run, "run/I");
104  fTree->Branch("subrun", &subrun, "subrun/I");
105  fTree->Branch("event", &event, "event/I");
106 
107  fTree->Branch("nuPDG_truth", &nuPDG_truth, "nuPDG_truth/I");
108  fTree->Branch("ccnc_truth", &ccnc_truth, "ccnc_truth/I");
109  fTree->Branch("mode_truth", &mode_truth, "mode_truth/I");
110 
111  fTree->Branch("nshws", &nshws, "nshws/I");
112  fTree->Branch("shwid", shwid, "shwid[nshws]/I");
113  fTree->Branch("shwdcosx", shwdcosx, "shwdcosx[nshws]/F");
114  fTree->Branch("shwdcosy", shwdcosy, "shwdcosy[nshws]/F");
115  fTree->Branch("shwdcosz", shwdcosz, "shwdcosz[nshws]/F");
116  fTree->Branch("shwstartx", shwstartx, "shwstartx[nshws]/F");
117  fTree->Branch("shwstarty", shwstarty, "shwstarty[nshws]/F");
118  fTree->Branch("shwstartz", shwstartz, "shwstartz[nshws]/F");
119  fTree->Branch("shwdedx", shwdedx, "shwdedx[nshws][2]/D");
120  fTree->Branch("shwbestplane", shwbestplane, "shwbestplane[nshws]/I");
121 
122  fTree->Branch("highestHitsPDG", &highestHitsPDG, "highestHitsPDG/I");
123  fTree->Branch("highestHitsFrac", &highestHitsFrac, "highestHitsFrac/D");
124 
125 } // beginJob
double shwdedx[kMaxShowers][2]
Event finding and building.
void shower::TCShowerAnalysis::reset ( )
private

Definition at line 213 of file TCShowerAnalysis_module.cc.

214 {
215 
216  run = -99999;
217  subrun = -99999;
218  event = -99999;
219 
220  nuPDG_truth = -99999;
221  ccnc_truth = -99999;
222  mode_truth = -99999;
223 
224  nshws = 0;
225  for (int i = 0; i < kMaxShowers; ++i) {
226  shwid[i] = -99999;
227  shwdcosx[i] = -99999;
228  shwdcosy[i] = -99999;
229  shwdcosz[i] = -99999;
230  shwstartx[i] = -99999;
231  shwstarty[i] = -99999;
232  shwstartz[i] = -99999;
233  for (int j = 0; j < 2; ++j) {
234  shwdedx[i][j] = -99999;
235  }
236  shwbestplane[i] = -99999;
237  }
238 
239  highestHitsPDG = -99999;
240  highestHitsFrac = -99999;
241 
242 } // reset
double shwdedx[kMaxShowers][2]
constexpr int kMaxShowers
void shower::TCShowerAnalysis::truthMatcher ( detinfo::DetectorClocksData const &  clockData,
std::vector< art::Ptr< recob::Hit >>  all_hits,
std::vector< art::Ptr< recob::Hit >>  shower_hits,
const simb::MCParticle *&  MCparticle,
double &  Efrac,
double &  Ecomplet 
)
private

Definition at line 247 of file TCShowerAnalysis_module.cc.

253 {
254 
255  MCparticle = 0;
256  Efrac = 1.0;
257  Ecomplet = 0;
258 
261  std::map<int, double> trkID_E;
262  for (size_t j = 0; j < shower_hits.size(); ++j) {
263  art::Ptr<recob::Hit> hit = shower_hits[j];
264  // For know let's use collection plane to look at the shower reconstruction
265  if (hit->View() != 1) continue;
266  std::vector<sim::TrackIDE> TrackIDs = bt_serv->HitToEveTrackIDEs(clockData, hit);
267  for (size_t k = 0; k < TrackIDs.size(); k++) {
268  if (trkID_E.find(std::abs(TrackIDs[k].trackID)) == trkID_E.end())
269  trkID_E[std::abs(TrackIDs[k].trackID)] = 0;
270  trkID_E[std::abs(TrackIDs[k].trackID)] += TrackIDs[k].energy;
271  }
272  }
273  double max_E = -999.0;
274  double total_E = 0.0;
275  int TrackID = -999;
276  double partial_E = 0.0;
277 
278  if (!trkID_E.size()) return; // Ghost shower???
279  for (std::map<int, double>::iterator ii = trkID_E.begin(); ii != trkID_E.end(); ++ii) {
280  total_E += ii->second;
281  if ((ii->second) > max_E) {
282  partial_E = ii->second;
283  max_E = ii->second;
284  TrackID = ii->first;
285  }
286  }
287  MCparticle = pi_serv->TrackIdToParticle_P(TrackID);
288 
289  Efrac = partial_E / total_E;
290 
291  // completeness
292  double totenergy = 0;
293  for (size_t k = 0; k < all_hits.size(); ++k) {
294  art::Ptr<recob::Hit> hit = all_hits[k];
295  std::vector<sim::TrackIDE> TrackIDs = bt_serv->HitToEveTrackIDEs(clockData, hit);
296  for (size_t l = 0; l < TrackIDs.size(); ++l) {
297  if (std::abs(TrackIDs[l].trackID) == TrackID) { totenergy += TrackIDs[l].energy; }
298  }
299  }
300  Ecomplet = partial_E / totenergy;
301 
302 } // truthMatcher
intermediate_table::iterator iterator
std::vector< TrackID > TrackIDs
const simb::MCParticle * TrackIdToParticle_P(int id) const
geo::View_t View() const
View for the plane of the hit.
Definition: Hit.h:232
static QStrList * l
Definition: config.cpp:1044
T abs(T value)
Detector simulation of raw signals on wires.
std::vector< sim::TrackIDE > HitToEveTrackIDEs(detinfo::DetectorClocksData const &clockData, recob::Hit const &hit) const

Member Data Documentation

int shower::TCShowerAnalysis::ccnc_truth
private

Definition at line 54 of file TCShowerAnalysis_module.cc.

int shower::TCShowerAnalysis::event
private

Definition at line 52 of file TCShowerAnalysis_module.cc.

calo::CalorimetryAlg shower::TCShowerAnalysis::fCalorimetryAlg
private

Definition at line 77 of file TCShowerAnalysis_module.cc.

std::string shower::TCShowerAnalysis::fDigitModuleLabel
private

Definition at line 75 of file TCShowerAnalysis_module.cc.

std::string shower::TCShowerAnalysis::fGenieGenModuleLabel
private

Definition at line 74 of file TCShowerAnalysis_module.cc.

std::string shower::TCShowerAnalysis::fHitModuleLabel
private

Definition at line 72 of file TCShowerAnalysis_module.cc.

std::string shower::TCShowerAnalysis::fShowerModuleLabel
private

Definition at line 73 of file TCShowerAnalysis_module.cc.

TTree* shower::TCShowerAnalysis::fTree
private

Definition at line 49 of file TCShowerAnalysis_module.cc.

double shower::TCShowerAnalysis::highestHitsFrac
private

Definition at line 70 of file TCShowerAnalysis_module.cc.

int shower::TCShowerAnalysis::highestHitsPDG
private

Definition at line 69 of file TCShowerAnalysis_module.cc.

int shower::TCShowerAnalysis::mode_truth
private

Definition at line 55 of file TCShowerAnalysis_module.cc.

int shower::TCShowerAnalysis::nshws
private

Definition at line 56 of file TCShowerAnalysis_module.cc.

int shower::TCShowerAnalysis::nuPDG_truth
private

Definition at line 53 of file TCShowerAnalysis_module.cc.

int shower::TCShowerAnalysis::run
private

Definition at line 50 of file TCShowerAnalysis_module.cc.

int shower::TCShowerAnalysis::shwbestplane[kMaxShowers]
private

Definition at line 66 of file TCShowerAnalysis_module.cc.

float shower::TCShowerAnalysis::shwdcosx[kMaxShowers]
private

Definition at line 58 of file TCShowerAnalysis_module.cc.

float shower::TCShowerAnalysis::shwdcosy[kMaxShowers]
private

Definition at line 59 of file TCShowerAnalysis_module.cc.

float shower::TCShowerAnalysis::shwdcosz[kMaxShowers]
private

Definition at line 60 of file TCShowerAnalysis_module.cc.

double shower::TCShowerAnalysis::shwdedx[kMaxShowers][2]
private

Definition at line 64 of file TCShowerAnalysis_module.cc.

int shower::TCShowerAnalysis::shwid[kMaxShowers]
private

Definition at line 57 of file TCShowerAnalysis_module.cc.

float shower::TCShowerAnalysis::shwstartx[kMaxShowers]
private

Definition at line 61 of file TCShowerAnalysis_module.cc.

float shower::TCShowerAnalysis::shwstarty[kMaxShowers]
private

Definition at line 62 of file TCShowerAnalysis_module.cc.

float shower::TCShowerAnalysis::shwstartz[kMaxShowers]
private

Definition at line 63 of file TCShowerAnalysis_module.cc.

int shower::TCShowerAnalysis::subrun
private

Definition at line 51 of file TCShowerAnalysis_module.cc.


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