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

Public Member Functions

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

const art::InputTag fSpacePointModuleLabel
 
const art::InputTag fBeamModuleLabel
 
const art::InputTag fTrackModuleLabel
 
const art::InputTag fTimeDecoderModuleLabel
 
protoana::ProtoDUNEBeamlineUtils fBeamlineUtils
 
TTree * fTree
 
int run
 
int subrun
 
int event
 
int trigger
 
double evttime
 
std::vector< double > vx
 
std::vector< double > vy
 
std::vector< double > vz
 
std::vector< double > vcharge
 
std::vector< int > vtpc
 
std::vector< int > vtrackid
 
std::vector< int > vpdg
 
std::vector< int > vg4id
 
std::vector< int > vorigin
 
std::vector< double > beamPosx
 
std::vector< double > beamPosy
 
std::vector< double > beamPosz
 
std::vector< double > beamDirx
 
std::vector< double > beamDiry
 
std::vector< double > beamDirz
 
std::vector< double > beamMomentum
 
double tof
 
short ckov0status
 
short ckov1status
 

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 43 of file SaveSpacePoints_module.cc.

Constructor & Destructor Documentation

proto::SaveSpacePoints::SaveSpacePoints ( fhicl::ParameterSet const &  p)
explicit

Definition at line 107 of file SaveSpacePoints_module.cc.

108  :
109  EDAnalyzer(p),
110  fSpacePointModuleLabel(p.get< art::InputTag >("SpacePointModuleLabel")),
111  fBeamModuleLabel(p.get< art::InputTag >("BeamModuleLabel")),
112  fTrackModuleLabel(p.get< art::InputTag >("TrackModuleLabel")),
113  fTimeDecoderModuleLabel(p.get< art::InputTag >("TimeDecoderModuleLabel")),
114  fBeamlineUtils(p.get<fhicl::ParameterSet>("BeamlineUtils"))
115 {}
protoana::ProtoDUNEBeamlineUtils fBeamlineUtils
const art::InputTag fTrackModuleLabel
const art::InputTag fSpacePointModuleLabel
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
const art::InputTag fTimeDecoderModuleLabel
const art::InputTag fBeamModuleLabel
p
Definition: test.py:223
proto::SaveSpacePoints::SaveSpacePoints ( SaveSpacePoints const &  )
delete
proto::SaveSpacePoints::SaveSpacePoints ( SaveSpacePoints &&  )
delete

Member Function Documentation

void proto::SaveSpacePoints::analyze ( art::Event const &  e)
overridevirtual

Implements art::EDAnalyzer.

Definition at line 117 of file SaveSpacePoints_module.cc.

118 {
119  // Implementation of required member function here.
120  run = evt.run();
121  subrun = evt.subRun();
122  event = evt.id().event();
123  art::Timestamp ts = evt.time();
124  //std::cout<<ts.timeHigh()<<" "<<ts.timeLow()<<std::endl;
125  if (ts.timeHigh() == 0){
126  TTimeStamp tts(ts.timeLow());
127  evttime = tts.AsDouble();
128  }
129  else{
130  TTimeStamp tts(ts.timeHigh(), ts.timeLow());
131  evttime = tts.AsDouble();
132  }
133  vx.clear();
134  vy.clear();
135  vz.clear();
136  vcharge.clear();
137  vtpc.clear();
138  vtrackid.clear();
139  vpdg.clear();
140  vg4id.clear();
141  vorigin.clear();
142  beamPosx.clear();
143  beamPosy.clear();
144  beamPosz.clear();
145  beamDirx.clear();
146  beamDiry.clear();
147  beamDirz.clear();
148  beamMomentum.clear();
149 
150  if (evt.isRealData()){
152 
153  //Access the Beam Event
154  auto beamHandle = evt.getValidHandle<std::vector<beam::ProtoDUNEBeamEvent>>("beamevent");
155 
156  std::vector<art::Ptr<beam::ProtoDUNEBeamEvent>> beamVec;
157  if( beamHandle.isValid()){
158  art::fill_ptr_vector(beamVec, beamHandle);
159  }
160 
161  const beam::ProtoDUNEBeamEvent & beamEvent = *(beamVec.at(0)); //Should just have one
162 
163  //Access momentum
164  const std::vector< double > & the_momenta = beamEvent.GetRecoBeamMomenta();
165  std::cout << "Number of reconstructed momenta: " << the_momenta.size() << std::endl;
166 
167  beamMomentum.insert( beamMomentum.end(), the_momenta.begin(), the_momenta.end() );
168 
169  tof = -1;
170  ckov0status = -1;
171  ckov1status = -1;
172 
173  //Access time of flight
174  const std::vector< double > & the_tofs = beamEvent.GetTOFs();
175 
176  if( the_tofs.size() > 0){
177  tof = the_tofs[0];
178  }
179  ckov0status = beamEvent.GetCKov0Status();
180  ckov1status = beamEvent.GetCKov1Status();
181  }
182 
183  trigger = -1;
184  art::ValidHandle<std::vector<raw::RDTimeStamp>> timeStamps = evt.getValidHandle<std::vector<raw::RDTimeStamp>>(fTimeDecoderModuleLabel);
185 
186  // Check that we have good information
187  if(timeStamps.isValid() && timeStamps->size() == 1){
188  // Access the trigger information. Beam trigger flag = 0xc
189  const raw::RDTimeStamp& timeStamp = timeStamps->at(0);
190  trigger = timeStamp.GetFlags();
191  }
192  }
193 
194  std::vector< art::Ptr<recob::SpacePoint> > sps;
195  auto spsHandle = evt.getHandle< std::vector<recob::SpacePoint> >(fSpacePointModuleLabel);
196  if (spsHandle) art::fill_ptr_vector(sps, spsHandle);
197 
198  std::vector< art::Ptr<recob::PointCharge> > pcs;
199  auto pcsHandle = evt.getHandle< std::vector<recob::PointCharge> >(fSpacePointModuleLabel);
200  if (pcsHandle) art::fill_ptr_vector(pcs, pcsHandle);
201 
202  art::FindManyP<recob::Hit> fmhsp(spsHandle, evt, fSpacePointModuleLabel);
203 
204  //Services
207 
208  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService>()->DataFor(evt);
209 
210  for (size_t i = 0; i<sps.size(); ++i){
211  vx.push_back(sps[i]->XYZ()[0]);
212  vy.push_back(sps[i]->XYZ()[1]);
213  vz.push_back(sps[i]->XYZ()[2]);
214  vcharge.push_back(pcs[i]->charge());
215  vtrackid.push_back(-1);
216  auto const& hits = fmhsp.at(i);
217  if (!evt.isRealData()){
218  int TrackID = 0;
219  std::map<int,double> trkide;
220  for (auto const & hit : hits){
221  std::vector<sim::TrackIDE> TrackIDs = bt_serv->HitToTrackIDEs(clockData, hit);
222  for(size_t e = 0; e < TrackIDs.size(); ++e){
223  trkide[TrackIDs[e].trackID] += TrackIDs[e].energy;
224  }
225  }
226  // Work out which IDE despoited the most charge in the hit if there was more than one.
227  double maxe = -1;
228  double tote = 0;
229  for (std::map<int,double>::iterator ii = trkide.begin(); ii!=trkide.end(); ++ii){
230  tote += ii->second;
231  if ((ii->second)>maxe){
232  maxe = ii->second;
233  TrackID = ii->first;
234  }
235  }
236  // Now have trackID, so get PdG code and T0 etc.
237  vg4id.push_back(TrackID);
238  const simb::MCParticle *particle = pi_serv->TrackIdToParticle_P(TrackID);
239  if (particle){
240  vpdg.push_back(particle->PdgCode());
241  vorigin.push_back(pi_serv->ParticleToMCTruth_P(particle)->Origin());
242  }
243  else{
244  vpdg.push_back(0);
245  vorigin.push_back(0);
246  }
247  }
248  else{
249  vg4id.push_back(0);
250  vpdg.push_back(0);
251  vorigin.push_back(0);
252  }
253  int spTPC = -1;
254  for (auto const & hit : hits){
255  spTPC = hit->WireID().TPC;
256  }
257  vtpc.push_back(spTPC);
258  }
259 
260  std::vector< art::Ptr<recob::Track> > trks;
261  auto trkHandle = evt.getHandle< std::vector<recob::Track> >(fTrackModuleLabel);
262  if (trkHandle) art::fill_ptr_vector(trks, trkHandle);
263 
264  for (size_t i = 0; i<trks.size(); ++i){
265  auto & trk = trks[i];
266  for (size_t j = 0; j<trk->NPoints(); ++j){
267  if (trk->HasValidPoint(j)){
268  vx.push_back(trk->TrajectoryPoint(j).position.X());
269  vy.push_back(trk->TrajectoryPoint(j).position.Y());
270  vz.push_back(trk->TrajectoryPoint(j).position.Z());
271  vcharge.push_back(0);
272  vtpc.push_back(-1);
273  vtrackid.push_back(trk->ID());
274  vpdg.push_back(-1);
275  vg4id.push_back(-1);
276  vorigin.push_back(-1);
277  }
278  }
279  }
280 
281  fTree->Fill();
282 }
std::vector< double > beamPosx
intermediate_table::iterator iterator
int PdgCode() const
Definition: MCParticle.h:212
constexpr std::uint32_t timeLow() const
Definition: Timestamp.h:29
unsigned int event
Definition: DataStructs.h:636
uint16_t GetFlags() const
Definition: RDTimeStamp.h:46
const std::vector< double > & GetTOFs() const
unsigned int run
Definition: DataStructs.h:637
std::vector< sim::TrackIDE > HitToTrackIDEs(detinfo::DetectorClocksData const &clockData, recob::Hit const &hit) const
std::vector< double > beamDirz
std::vector< double > vcharge
std::vector< TrackID > TrackIDs
const simb::MCParticle * TrackIdToParticle_P(int id) const
protoana::ProtoDUNEBeamlineUtils fBeamlineUtils
const art::InputTag fTrackModuleLabel
constexpr std::uint32_t timeHigh() const
Definition: Timestamp.h:34
simb::Origin_t Origin() const
Definition: MCTruth.h:74
const short & GetCKov1Status() const
const art::InputTag fSpacePointModuleLabel
std::vector< double > beamMomentum
std::vector< double > beamDiry
const art::Ptr< simb::MCTruth > & ParticleToMCTruth_P(const simb::MCParticle *p) const
const art::InputTag fTimeDecoderModuleLabel
std::vector< double > vy
std::vector< double > beamDirx
std::vector< double > vx
const double e
std::vector< double > beamPosz
const std::vector< double > & GetRecoBeamMomenta() const
bool IsGoodBeamlineTrigger(art::Event const &evt) const
Detector simulation of raw signals on wires.
std::vector< double > vz
std::vector< double > beamPosy
unsigned int subRun
Definition: DataStructs.h:638
const short & GetCKov0Status() const
TCEvent evt
Definition: DataStructs.cxx:7
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:297
QTextStream & endl(QTextStream &s)
bool isValid() const
Definition: Handle.h:330
void proto::SaveSpacePoints::beginJob ( )
overridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 284 of file SaveSpacePoints_module.cc.

285 {
287  fTree = tfs->make<TTree>("spt","space point tree");
288  fTree->Branch("run",&run,"run/I");
289  fTree->Branch("subrun",&subrun,"subrun/I");
290  fTree->Branch("event",&event,"event/I");
291  fTree->Branch("trigger",&trigger,"trigger/I");
292  fTree->Branch("evttime",&evttime,"evttime/D");
293  fTree->Branch("vx",&vx);
294  fTree->Branch("vy",&vy);
295  fTree->Branch("vz",&vz);
296  fTree->Branch("vcharge",&vcharge);
297  fTree->Branch("vtpc",&vtpc);
298  fTree->Branch("vtrackid",&vtrackid);
299  fTree->Branch("vpdg",&vpdg);
300  fTree->Branch("vg4id",&vg4id);
301  fTree->Branch("vorigin",&vorigin);
302  fTree->Branch("beamPosx",&beamPosx);
303  fTree->Branch("beamPosy",&beamPosy);
304  fTree->Branch("beamPosz",&beamPosz);
305  fTree->Branch("beamDirx",&beamDirx);
306  fTree->Branch("beamDiry",&beamDiry);
307  fTree->Branch("beamDirz",&beamDirz);
308  fTree->Branch("beamMomentum",&beamMomentum);
309  fTree->Branch("tof", &tof, "tof/D");
310  fTree->Branch("ckov0status", &ckov0status, "ckov0status/S");
311  fTree->Branch("ckov1status", &ckov1status, "ckov1status/S");
312 }
std::vector< double > beamPosx
std::vector< double > beamDirz
std::vector< double > vcharge
std::vector< double > beamMomentum
std::vector< double > beamDiry
std::vector< double > vy
std::vector< double > beamDirx
std::vector< double > vx
std::vector< double > beamPosz
std::vector< double > vz
std::vector< double > beamPosy
Event finding and building.
SaveSpacePoints& proto::SaveSpacePoints::operator= ( SaveSpacePoints const &  )
delete
SaveSpacePoints& proto::SaveSpacePoints::operator= ( SaveSpacePoints &&  )
delete

Member Data Documentation

std::vector<double> proto::SaveSpacePoints::beamDirx
private

Definition at line 94 of file SaveSpacePoints_module.cc.

std::vector<double> proto::SaveSpacePoints::beamDiry
private

Definition at line 95 of file SaveSpacePoints_module.cc.

std::vector<double> proto::SaveSpacePoints::beamDirz
private

Definition at line 96 of file SaveSpacePoints_module.cc.

std::vector<double> proto::SaveSpacePoints::beamMomentum
private

Definition at line 98 of file SaveSpacePoints_module.cc.

std::vector<double> proto::SaveSpacePoints::beamPosx
private

Definition at line 90 of file SaveSpacePoints_module.cc.

std::vector<double> proto::SaveSpacePoints::beamPosy
private

Definition at line 91 of file SaveSpacePoints_module.cc.

std::vector<double> proto::SaveSpacePoints::beamPosz
private

Definition at line 92 of file SaveSpacePoints_module.cc.

short proto::SaveSpacePoints::ckov0status
private

Definition at line 101 of file SaveSpacePoints_module.cc.

short proto::SaveSpacePoints::ckov1status
private

Definition at line 102 of file SaveSpacePoints_module.cc.

int proto::SaveSpacePoints::event
private

Definition at line 74 of file SaveSpacePoints_module.cc.

double proto::SaveSpacePoints::evttime
private

Definition at line 76 of file SaveSpacePoints_module.cc.

protoana::ProtoDUNEBeamlineUtils proto::SaveSpacePoints::fBeamlineUtils
private

Definition at line 68 of file SaveSpacePoints_module.cc.

const art::InputTag proto::SaveSpacePoints::fBeamModuleLabel
private

Definition at line 64 of file SaveSpacePoints_module.cc.

const art::InputTag proto::SaveSpacePoints::fSpacePointModuleLabel
private

Definition at line 63 of file SaveSpacePoints_module.cc.

const art::InputTag proto::SaveSpacePoints::fTimeDecoderModuleLabel
private

Definition at line 66 of file SaveSpacePoints_module.cc.

const art::InputTag proto::SaveSpacePoints::fTrackModuleLabel
private

Definition at line 65 of file SaveSpacePoints_module.cc.

TTree* proto::SaveSpacePoints::fTree
private

Definition at line 70 of file SaveSpacePoints_module.cc.

int proto::SaveSpacePoints::run
private

Definition at line 72 of file SaveSpacePoints_module.cc.

int proto::SaveSpacePoints::subrun
private

Definition at line 73 of file SaveSpacePoints_module.cc.

double proto::SaveSpacePoints::tof
private

Definition at line 100 of file SaveSpacePoints_module.cc.

int proto::SaveSpacePoints::trigger
private

Definition at line 75 of file SaveSpacePoints_module.cc.

std::vector<double> proto::SaveSpacePoints::vcharge
private

Definition at line 82 of file SaveSpacePoints_module.cc.

std::vector<int> proto::SaveSpacePoints::vg4id
private

Definition at line 86 of file SaveSpacePoints_module.cc.

std::vector<int> proto::SaveSpacePoints::vorigin
private

Definition at line 87 of file SaveSpacePoints_module.cc.

std::vector<int> proto::SaveSpacePoints::vpdg
private

Definition at line 85 of file SaveSpacePoints_module.cc.

std::vector<int> proto::SaveSpacePoints::vtpc
private

Definition at line 83 of file SaveSpacePoints_module.cc.

std::vector<int> proto::SaveSpacePoints::vtrackid
private

Definition at line 84 of file SaveSpacePoints_module.cc.

std::vector<double> proto::SaveSpacePoints::vx
private

Definition at line 79 of file SaveSpacePoints_module.cc.

std::vector<double> proto::SaveSpacePoints::vy
private

Definition at line 80 of file SaveSpacePoints_module.cc.

std::vector<double> proto::SaveSpacePoints::vz
private

Definition at line 81 of file SaveSpacePoints_module.cc.


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