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

Public Member Functions

 SupernovaAna (fhicl::ParameterSet const &p)
 
 SupernovaAna (SupernovaAna const &)=delete
 
 SupernovaAna (SupernovaAna &&)=delete
 
SupernovaAnaoperator= (SupernovaAna const &)=delete
 
SupernovaAnaoperator= (SupernovaAna &&)=delete
 
void analyze (art::Event const &e) override
 
void reconfigure (fhicl::ParameterSet const &p)
 
void beginJob () 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

std::string fTruthLabel
 
std::string fHitLabel
 
TTree * fNTuple
 
int EventNum
 
int EventNumCut
 
int NHits
 
double avgRMS
 
double avgRMSloop [kMaxNumHits]
 
double avgRMSloopsum
 
double SummedADC
 
int NMCTruths
 
int NParticles [kMaxNumParticles]
 
double MomentumYTruths [kMaxNumParticles]
 
double MomentumZTruths [kMaxNumParticles]
 
double NuEnergyTruths [kMaxNumParticles]
 
double LeptonEnergyTruths [kMaxNumParticles]
 
double ThetaTruths [kMaxNumParticles]
 
int OriginTruths [kMaxNumParticles]
 
int CCNCTruths [kMaxNumParticles]
 
int ModeTruths [kMaxNumParticles]
 
int NuPDGCodeTruths [kMaxNumParticles]
 
int LeptonPDGCodeTruths [kMaxNumParticles]
 
double xTruths [kMaxNumParticles]
 
double yTruths [kMaxNumParticles]
 
double zTruths [kMaxNumParticles]
 
double tTruths [kMaxNumParticles]
 
double EndxTruths [kMaxNumParticles]
 
double EndyTruths [kMaxNumParticles]
 
double EndzTruths [kMaxNumParticles]
 
double EndtTruths [kMaxNumParticles]
 
double DeltaXTruths [kMaxNumParticles]
 
double DeltaYTruths [kMaxNumParticles]
 

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 42 of file SupernovaAna_module.cc.

Constructor & Destructor Documentation

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

Definition at line 108 of file SupernovaAna_module.cc.

109  :
110  EDAnalyzer(p)
111 {
112  this->reconfigure(p);
113 }
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
void reconfigure(fhicl::ParameterSet const &p)
p
Definition: test.py:223
SupernovaAna::SupernovaAna ( SupernovaAna const &  )
delete
SupernovaAna::SupernovaAna ( SupernovaAna &&  )
delete

Member Function Documentation

void SupernovaAna::analyze ( art::Event const &  e)
overridevirtual

Implements art::EDAnalyzer.

Definition at line 169 of file SupernovaAna_module.cc.

170 {
171 
172 
173  //==============================HITS================================
174 
175  // Get the Hits out of the event
176  auto hits_list = e.getHandle< std::vector< recob::Hit > >(fHitLabel);
177 
178  // Gets the number of hits per event and fills into a histogram
179  NHits = hits_list->size();
180 
181  // Get summed ADC and average RMS of hit slope
182  SummedADC = 0.0;
183  for(unsigned int i = 0; i < hits_list->size();i++){
184  recob::Hit const& hit = hits_list->at(i);
185  avgRMSloop[i] = hit.RMS();
187  SummedADC += hit.SummedADC();
188  }
189  avgRMS = avgRMSloopsum/(hits_list->size());
190 
191  //============================MCTRUTHS==============================
192 
193  // Get the MCTruths out of the event
194  auto truths_list = e.getHandle< std::vector< simb::MCTruth > >(fTruthLabel);
195 
196  // Gets the number of MC truths per event and fills into a histogram
197  NMCTruths = truths_list->size();
198 
199  // Loop through the truth arrays and sets the values of the arrays
200  // to an arbitrary default (unfilled) value
201  for(int i=0;i<kMaxNumParticles;i++){
202  xTruths[i] = -1.0e9;
203  yTruths[i] = -1.0e9;
204  zTruths[i] = -1.0e9;
205  tTruths[i] = -1.0e9;
206  EndxTruths[i] = -1.0e9;
207  EndyTruths[i] = -1.0e9;
208  EndzTruths[i] = -1.0e9;
209  EndtTruths[i] = -1.0e9;
210  NParticles[i] = -999;
211  MomentumYTruths[i] = -1.0e9;
212  MomentumZTruths[i] = -1.0e9;
213  NuEnergyTruths[i] = -999;
214  LeptonEnergyTruths[i] = -999;
215  ThetaTruths[i] = -999;
216  OriginTruths[i] = -999;
217  CCNCTruths[i] = -999;
218  ModeTruths[i] = -999;
219  NuPDGCodeTruths[i] = 0;
220  LeptonPDGCodeTruths[i] = 0;
221  DeltaXTruths[i] = -1.0e9;
222  DeltaYTruths[i] = -1.0e9;
223 
224  }
225 
226  // Detect if the number of MC truths per event is greater than
227  // or equal to the maximum number of particles per event else
228  // we'll fall off the end of the array and cause a seg fault
229  if(NMCTruths >= kMaxNumParticles) {
230  std::cerr << "ERROR: NMCTruths " << NMCTruths <<
231  " >= kMaxNumParticles " << kMaxNumParticles <<
232  " , will cause a segmentation fault" << std::endl;}
233  // Detect if the number of hits per event is greater than
234  // or equal to the maximum number of particles per event else
235  // we'll fall off the end of the array and cause a seg fault
236  if(NHits >= kMaxNumHits) {
237  std::cerr << "ERROR: NHits " << NHits <<
238  " >= kMaxNumHits " << kMaxNumHits <<
239  " , will cause a segmentation fault" << std::endl;}
240 
241  // Create nTuple data for any number of truths
242  for(unsigned int i = 0; i < truths_list->size();i++){
243  simb::MCTruth const& truth = truths_list->at(i);
244 
245  NParticles[i] = truth.NParticles();
246 
247  // Get the ith particle's Origin truths
248  OriginTruths[i] = truth.Origin();
249 
250  // Only get neutrino truths if they exist to avoid a segmentation fault
251  if (truth.NeutrinoSet()){
252  simb::MCNeutrino const& mc_neutrino = truth.GetNeutrino();
253  // should change notation such that mc_neutrino = truth.GetNeutrino().Nu(); // and then remove .Nu() when called
254  simb::MCParticle const& mc_lepton = mc_neutrino.Lepton();
255 
256  // Get data to be filled into nTuple
257  xTruths[i] = mc_lepton.Vx();
258  yTruths[i] = mc_lepton.Vy();
259  zTruths[i] = mc_lepton.Vz();
260  tTruths[i] = mc_lepton.T();
261  EndxTruths[i] = mc_lepton.EndX();
262  EndyTruths[i] = mc_lepton.EndY();
263  EndzTruths[i] = mc_lepton.EndZ();
264  EndtTruths[i] = mc_lepton.EndT();
265  MomentumYTruths[i] = mc_lepton.Py();
266  MomentumZTruths[i] = mc_lepton.Pz();
267  NuEnergyTruths[i] = mc_neutrino.Nu().E();
268  LeptonEnergyTruths[i] = mc_lepton.E();
269  ThetaTruths[i] = mc_neutrino.Theta();
270  CCNCTruths[i] = mc_neutrino.CCNC();
271  ModeTruths[i] = mc_neutrino.Mode();
272  NuPDGCodeTruths[i] = mc_neutrino.Nu().PdgCode();
273  LeptonPDGCodeTruths[i] = mc_lepton.PdgCode();
274  DeltaXTruths[i] = EndxTruths[i] - xTruths[i];
275  DeltaYTruths[i] = EndyTruths[i] - yTruths[i];
276  }
277  }
278 
279  art::EventNumber_t event = e.id().event();
280  EventNum = event;
281  if (NHits<2) {
282  EventNumCut = event;
283  }
284 
285 
286  // Now we should have NMCTruths = truths_list->size() and
287  // PDGCodeTruths [0 - (NMCTruths - 1)] should contain PdgCodes,
288  // [ NMCTruths - 500 ] should be equal to -999, signifying that
289  // we did not fill this part
290 
291  // Fill nTuple
292  fNTuple->Fill();
293 }
double E(const int i=0) const
Definition: MCParticle.h:233
double NuEnergyTruths[kMaxNumParticles]
int PdgCode() const
Definition: MCParticle.h:212
int CCNC() const
Definition: MCNeutrino.h:148
const int kMaxNumHits
double Theta() const
angle between incoming and outgoing leptons, in radians
Definition: MCNeutrino.cxx:63
const simb::MCNeutrino & GetNeutrino() const
Definition: MCTruth.h:77
double Py(const int i=0) const
Definition: MCParticle.h:231
double EndZ() const
Definition: MCParticle.h:228
int LeptonPDGCodeTruths[kMaxNumParticles]
int OriginTruths[kMaxNumParticles]
double avgRMSloop[kMaxNumHits]
float RMS() const
RMS of the hit shape, in tick units.
Definition: Hit.h:220
double DeltaYTruths[kMaxNumParticles]
const simb::MCParticle & Nu() const
Definition: MCNeutrino.h:146
simb::Origin_t Origin() const
Definition: MCTruth.h:74
double zTruths[kMaxNumParticles]
int NParticles() const
Definition: MCTruth.h:75
double yTruths[kMaxNumParticles]
double EndY() const
Definition: MCParticle.h:227
double MomentumYTruths[kMaxNumParticles]
int CCNCTruths[kMaxNumParticles]
int ModeTruths[kMaxNumParticles]
double ThetaTruths[kMaxNumParticles]
const double e
const simb::MCParticle & Lepton() const
Definition: MCNeutrino.h:147
const int kMaxNumParticles
double xTruths[kMaxNumParticles]
int NuPDGCodeTruths[kMaxNumParticles]
double T(const int i=0) const
Definition: MCParticle.h:224
double EndtTruths[kMaxNumParticles]
double EndxTruths[kMaxNumParticles]
std::string fTruthLabel
double EndzTruths[kMaxNumParticles]
double EndT() const
Definition: MCParticle.h:229
Detector simulation of raw signals on wires.
double LeptonEnergyTruths[kMaxNumParticles]
double Vx(const int i=0) const
Definition: MCParticle.h:221
int NParticles[kMaxNumParticles]
double DeltaXTruths[kMaxNumParticles]
double Pz(const int i=0) const
Definition: MCParticle.h:232
IDNumber_t< Level::Event > EventNumber_t
Definition: IDNumber.h:118
double Vz(const int i=0) const
Definition: MCParticle.h:223
float SummedADC() const
The sum of calibrated ADC counts of the hit (0. by default)
Definition: Hit.h:223
std::string fHitLabel
double MomentumZTruths[kMaxNumParticles]
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:48
bool NeutrinoSet() const
Definition: MCTruth.h:78
Event generator information.
Definition: MCTruth.h:32
double EndX() const
Definition: MCParticle.h:226
double EndyTruths[kMaxNumParticles]
double tTruths[kMaxNumParticles]
Event generator information.
Definition: MCNeutrino.h:18
int Mode() const
Definition: MCNeutrino.h:149
double Vy(const int i=0) const
Definition: MCParticle.h:222
QTextStream & endl(QTextStream &s)
void SupernovaAna::beginJob ( )
overridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 127 of file SupernovaAna_module.cc.

128 {
129 
131 
132  // Make nTuple
133  fNTuple = tfs->make<TTree>("SupernovaAna","Supernonva analysis tree");
134 
135  // Add branches to nTuple
136  fNTuple->Branch("EventNum",&EventNum);
137  fNTuple->Branch("EventNumCut",&EventNumCut);
138  fNTuple->Branch("NHits",&NHits);
139  fNTuple->Branch("avgRMS",&avgRMS);
140  fNTuple->Branch("SummedADC",&SummedADC);
141  fNTuple->Branch("NMCTruths",&NMCTruths);
142  fNTuple->Branch("NParticles",NParticles,"NParticles[NMCTruths]/I");
143  fNTuple->Branch("MomentumYTruths",MomentumYTruths,"MomentumYTruths[NMCTruths]/D");
144  fNTuple->Branch("MomentumZTruths",MomentumZTruths,"MomentumZTruths[NMCTruths]/D");
145  fNTuple->Branch("NuEnergyTruths",NuEnergyTruths,"NuEnergyTruths[NMCTruths]/D");
146  fNTuple->Branch("LeptonEnergyTruths",LeptonEnergyTruths,"LeptonEnergyTruths[NMCTruths]/D");
147  fNTuple->Branch("ThetaTruths",ThetaTruths,"ThetaTruths[NMCTruths]/D");
148  fNTuple->Branch("OriginTruths",OriginTruths,"OriginTruths[NMCTruths]/I");
149  fNTuple->Branch("CCNCTruths",CCNCTruths,"CCNCTruths[NMCTruths]/I");
150  fNTuple->Branch("ModeTruths",ModeTruths,"ModeTruths[NMCTruths]/I");
151  fNTuple->Branch("NuPDGCodeTruths",NuPDGCodeTruths,"NuPDGCodeTruths[NMCTruths]/I");
152  fNTuple->Branch("LeptonPDGCodeTruths",LeptonPDGCodeTruths,"LeptonPDGCodeTruths[NMCTruths]/I");
153  fNTuple->Branch("xTruths",xTruths,"xTruths[NMCTruths]/D");
154  fNTuple->Branch("yTruths",yTruths,"yTruths[NMCTruths]/D");
155  fNTuple->Branch("zTruths",zTruths,"zTruths[NMCTruths]/D");
156  fNTuple->Branch("tTruths",tTruths,"tTruths[NMCTruths]/D");
157  fNTuple->Branch("EndxTruths",EndxTruths,"EndxTruths[NMCTruths]/D");
158  fNTuple->Branch("EndyTruths",EndyTruths,"EndyTruths[NMCTruths]/D");
159  fNTuple->Branch("EndzTruths",EndzTruths,"EndzTruths[NMCTruths]/D");
160  fNTuple->Branch("EndtTruths",EndtTruths,"EndtTruths[NMCTruths]/D");
161  fNTuple->Branch("DeltaXTruths",DeltaXTruths,"DeltaXTruths[NMCTruths]/D");
162  fNTuple->Branch("DeltaYTruths",DeltaYTruths,"DeltaYTruths[NMCTruths]/D");
163 
164 }
double NuEnergyTruths[kMaxNumParticles]
int LeptonPDGCodeTruths[kMaxNumParticles]
int OriginTruths[kMaxNumParticles]
double DeltaYTruths[kMaxNumParticles]
double zTruths[kMaxNumParticles]
double yTruths[kMaxNumParticles]
double MomentumYTruths[kMaxNumParticles]
int CCNCTruths[kMaxNumParticles]
int ModeTruths[kMaxNumParticles]
double ThetaTruths[kMaxNumParticles]
double xTruths[kMaxNumParticles]
int NuPDGCodeTruths[kMaxNumParticles]
double EndtTruths[kMaxNumParticles]
double EndxTruths[kMaxNumParticles]
double EndzTruths[kMaxNumParticles]
double LeptonEnergyTruths[kMaxNumParticles]
int NParticles[kMaxNumParticles]
double DeltaXTruths[kMaxNumParticles]
double MomentumZTruths[kMaxNumParticles]
double EndyTruths[kMaxNumParticles]
double tTruths[kMaxNumParticles]
SupernovaAna& SupernovaAna::operator= ( SupernovaAna const &  )
delete
SupernovaAna& SupernovaAna::operator= ( SupernovaAna &&  )
delete
void SupernovaAna::reconfigure ( fhicl::ParameterSet const &  p)

Definition at line 118 of file SupernovaAna_module.cc.

119 {
120  fTruthLabel = p.get<std::string> ("TruthLabel");
121  fHitLabel = p.get<std::string> ("HitLabel");
122 }
std::string string
Definition: nybbler.cc:12
p
Definition: test.py:223
std::string fTruthLabel
std::string fHitLabel

Member Data Documentation

double SupernovaAna::avgRMS
private

Definition at line 76 of file SupernovaAna_module.cc.

double SupernovaAna::avgRMSloop[kMaxNumHits]
private

Definition at line 77 of file SupernovaAna_module.cc.

double SupernovaAna::avgRMSloopsum
private

Definition at line 78 of file SupernovaAna_module.cc.

int SupernovaAna::CCNCTruths[kMaxNumParticles]
private

Definition at line 88 of file SupernovaAna_module.cc.

double SupernovaAna::DeltaXTruths[kMaxNumParticles]
private

Definition at line 100 of file SupernovaAna_module.cc.

double SupernovaAna::DeltaYTruths[kMaxNumParticles]
private

Definition at line 101 of file SupernovaAna_module.cc.

double SupernovaAna::EndtTruths[kMaxNumParticles]
private

Definition at line 99 of file SupernovaAna_module.cc.

double SupernovaAna::EndxTruths[kMaxNumParticles]
private

Definition at line 96 of file SupernovaAna_module.cc.

double SupernovaAna::EndyTruths[kMaxNumParticles]
private

Definition at line 97 of file SupernovaAna_module.cc.

double SupernovaAna::EndzTruths[kMaxNumParticles]
private

Definition at line 98 of file SupernovaAna_module.cc.

int SupernovaAna::EventNum
private

Definition at line 73 of file SupernovaAna_module.cc.

int SupernovaAna::EventNumCut
private

Definition at line 74 of file SupernovaAna_module.cc.

std::string SupernovaAna::fHitLabel
private

Definition at line 67 of file SupernovaAna_module.cc.

TTree* SupernovaAna::fNTuple
private

Definition at line 70 of file SupernovaAna_module.cc.

std::string SupernovaAna::fTruthLabel
private

Definition at line 66 of file SupernovaAna_module.cc.

double SupernovaAna::LeptonEnergyTruths[kMaxNumParticles]
private

Definition at line 85 of file SupernovaAna_module.cc.

int SupernovaAna::LeptonPDGCodeTruths[kMaxNumParticles]
private

Definition at line 91 of file SupernovaAna_module.cc.

int SupernovaAna::ModeTruths[kMaxNumParticles]
private

Definition at line 89 of file SupernovaAna_module.cc.

double SupernovaAna::MomentumYTruths[kMaxNumParticles]
private

Definition at line 82 of file SupernovaAna_module.cc.

double SupernovaAna::MomentumZTruths[kMaxNumParticles]
private

Definition at line 83 of file SupernovaAna_module.cc.

int SupernovaAna::NHits
private

Definition at line 75 of file SupernovaAna_module.cc.

int SupernovaAna::NMCTruths
private

Definition at line 80 of file SupernovaAna_module.cc.

int SupernovaAna::NParticles[kMaxNumParticles]
private

Definition at line 81 of file SupernovaAna_module.cc.

double SupernovaAna::NuEnergyTruths[kMaxNumParticles]
private

Definition at line 84 of file SupernovaAna_module.cc.

int SupernovaAna::NuPDGCodeTruths[kMaxNumParticles]
private

Definition at line 90 of file SupernovaAna_module.cc.

int SupernovaAna::OriginTruths[kMaxNumParticles]
private

Definition at line 87 of file SupernovaAna_module.cc.

double SupernovaAna::SummedADC
private

Definition at line 79 of file SupernovaAna_module.cc.

double SupernovaAna::ThetaTruths[kMaxNumParticles]
private

Definition at line 86 of file SupernovaAna_module.cc.

double SupernovaAna::tTruths[kMaxNumParticles]
private

Definition at line 95 of file SupernovaAna_module.cc.

double SupernovaAna::xTruths[kMaxNumParticles]
private

Definition at line 92 of file SupernovaAna_module.cc.

double SupernovaAna::yTruths[kMaxNumParticles]
private

Definition at line 93 of file SupernovaAna_module.cc.

double SupernovaAna::zTruths[kMaxNumParticles]
private

Definition at line 94 of file SupernovaAna_module.cc.


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