CombinedBeamlineDetectorAna_module.cc
Go to the documentation of this file.
1  ////////////////////////////////////////////////////////////////////////////
2 /// \file BeamlineSimInput_module.cc
3 /// \module producer
4 /// \brief Module to add NOvASoft-formatted simulated beamline
5 /// information to the corresponding detector simulation.
6 /// \author Mike Wallbank (University of Cincinnati) <wallbank@fnal.gov>
7 /// Abhilash Y D (Syracuse University) <ayallapp@syr.edu>
8 /// \date January 2019
9 ////////////////////////////////////////////////////////////////////////////
10 
11 ////////////////////////////////////////////////////////////////////////////////////
12 /// What this module's all about.
13 ///
14 /// Beamline simulation:
15 /// Junting's beamline generator are used as input to the NOvA GEANT4 simulation,
16 /// which propagate the particles from the end of the beamline through the
17 /// detector.
18 /// The information stored in the beamline simulation files contain properties of
19 /// the particles as they traverse the beamline. This information isn't included
20 /// in the NOvASoft simulation files.
21 ///
22 /// BeamlineSimInput:
23 /// Designed to reconcile the information from the beamline simulation with the
24 /// detector simulation.
25 /// This module runs over the detector simulation files, which should contain
26 /// art::Events corresponding to the input particles from the end of the beamline.
27 /// It also takes the beamline output as input, reformats the data into the
28 /// NOvASoft data products, and adds them to the event.
29 ////////////////////////////////////////////////////////////////////////////////////
30 
31 // framework
36 #include "fhiclcpp/ParameterSet.h"
44 
45 // nova
46 #include "RawData/RawBeamline.h"
51 #include "BeamlineRecoBase/ToF.h"
53 #include "Utilities/AssociationUtil.h"
55 
56 
57 // stl
58 #include <iostream>
59 
60 // root
61 #include "TTree.h"
62 #include "TFile.h"
63 #include "TMath.h"
64 #include <TTreeReader.h>
65 #include <TTreeReaderValue.h>
66 #include <TTreeReaderArray.h>
67 #include <fstream>
68 #include <vector>
69 #include <utility>
70 
71 // -----------------------------------------------------------------------
72 namespace beamlinesim {
73 
75  {
76  public:
77 
79 
80  void reconfigure(const fhicl::ParameterSet& pset);
81  //void beginRun(art::Run &r);
82  void analyze(const art::Event& event) override;
83 
84  private:
85  // configuration
86 
87  // keep a track
88  int fevent;
90 
91  // particle properties
92 
93 
94  };
95 }
96 
97 // -----------------------------------------------------------------------
99 {
100 }
101 
102 // -----------------------------------------------------------------------
104 
106  std::vector<art::Ptr<simb::MCTruth> > mcTruths;
107  if (evt.getByLabel("generator", mcTruthHandle))
108  art::fill_ptr_vector(mcTruths, mcTruthHandle);
109 
110  std::cout << "There are " << mcTruths.size() << " mc truths in event " << evt.event() << std::endl;
111 
112  fevent=evt.event();
113  std::cout<<"event number "<<fevent<<std::endl;
114  for (std::vector<art::Ptr<simb::MCTruth> >::const_iterator mcTruthIt = mcTruths.begin(); mcTruthIt != mcTruths.end(); ++mcTruthIt)
115  {
116  std::cout << " There are " << (*mcTruthIt)->NParticles() << " particles in this MCTruth." << std::endl;
117  fparticles=(*mcTruthIt)->NParticles();
118  }
119 
121  std::vector<art::Ptr<rawdata::RawBeamlineWC> > WC;
122  if(evt.getByLabel("beamlinesiminput",WCHandle))
123  art::fill_ptr_vector(WC,WCHandle);
124 
125  std::cout << "There are " << WC.size() << " wire chamber objects." << std::endl;
126 
127  for (std::vector<art::Ptr<rawdata::RawBeamlineWC>>::const_iterator WCit = WC.begin(); WCit!=WC.end(); ++WCit)
128  {
129  //std::cout << " Wire chamber number is " << (*WCit)->WCNumber() << std::endl;
130  rawdata::RawBeamlineWC digit = *(*WCit);
131  std::vector<rawdata::RawBeamlineWC::WCPulse> xPulses = digit.XPulses();
132  std::vector<rawdata::RawBeamlineWC::WCPulse> yPulses = digit.YPulses();
133  std::cout<<"WC " << digit.DetectorID().Detector << " has " << xPulses.size() << " x pulses"<<std::endl;
134  std::cout<<"WC " << digit.DetectorID().Detector << " has " << yPulses.size() << " y pulses"<<std::endl;
135 
136  for (size_t x_pulse = 0; x_pulse < xPulses.size(); ++x_pulse)
137  {
138 
139  std::cout << "X pulse " << x_pulse << ": wire " << xPulses[x_pulse].Channel
140  << " and time " << xPulses[x_pulse].Time << std::endl;
141  }
142  for (size_t y_pulse = 0; y_pulse < yPulses.size(); ++y_pulse)
143  {
144 
145  std::cout << "Y pulse " << y_pulse << ": wire " << yPulses[y_pulse].Channel
146  << " and time " << yPulses[y_pulse].Time << std::endl;
147 
148  }
149  xPulses.clear();
150  yPulses.clear();
151  }
152 
153 return;
154 }
std::vector< WCPulse > YPulses() const
std::vector< WCPulse > XPulses() const
DEFINE_ART_MODULE(TestTMapFile)
Encapsulation of reconstructed digitizer &#39;hits&#39;. Used for ToF PMTs and SiPMs, and Cherenkov and Muon ...
Encapsulation of reconstructed Time-of-Flight (ToF) information. Part of beamline reconstruction for ...
int evt
Encapsulation of reconstructed Wire Chamber track. Part of beamline reconstruction for NOvA test beam...
void reconfigure(const fhicl::ParameterSet &pset)
EventNumber_t event() const
Definition: Event.h:67
EDAnalyzer(Table< Config > const &config)
Definition: EDAnalyzer.h:100
OStream cout
Definition: OStream.cxx:6
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
Raw data definitions for beamline data used in NOvA test beam experiment.
Encapsulation of &#39;reconstructed&#39; Cherenkov information. Part of beamline reconstruction for NOvA test...
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:464
Encapsulation of reconstructed PID information from detectors in the beamline (ToF, WCs, Cherenkov). Part of beamline reconstruction for NOvA test beam.
beamlinegeo::DetectorID DetectorID() const
Encapsulation of reconstructed track in the muon stack downstream of test beam detector. Part of beamline reconstruction for NOvA test beam.