Public Member Functions | Private Member Functions | Private Attributes | List of all members
ctp::CTPTrackDump Class Reference

CTPTrackDump class. More...

Inheritance diagram for ctp::CTPTrackDump:
art::EDAnalyzer art::detail::Analyzer art::detail::LegacyModule art::Observer art::ModuleBase

Public Member Functions

 CTPTrackDump (fhicl::ParameterSet const &pset)
 Constructor. More...
 
virtual ~CTPTrackDump ()
 Destructor. More...
 
void beginJob ()
 
void endJob ()
 
void analyze (const art::Event &evt)
 
- 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 WriteTextFile (const art::Event &evt, const std::vector< std::vector< float >> &inputs, const std::pair< const simb::MCParticle *, float > &trueParticle, const unsigned int &trackNumber, const unsigned int &nHits) const
 

Private Attributes

fhicl::ParameterSet fHelperPars
 
CTPHelper fConvTrackPID
 
std::string fParticleLabel
 

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

CTPTrackDump class.

Definition at line 39 of file CTPTrackDump_module.cc.

Constructor & Destructor Documentation

ctp::CTPTrackDump::CTPTrackDump ( fhicl::ParameterSet const &  pset)

Constructor.

Parameters
pset

Definition at line 100 of file CTPTrackDump_module.cc.

100  : art::EDAnalyzer(pset),
101 fHelperPars(pset.get<fhicl::ParameterSet>("ctpHelper")),
103 fParticleLabel(pset.get<std::string>("particleLabel"))
104 {
105 
106 }
std::string string
Definition: nybbler.cc:12
fhicl::ParameterSet fHelperPars
ctp::CTPTrackDump::~CTPTrackDump ( )
virtual

Destructor.

Definition at line 110 of file CTPTrackDump_module.cc.

111 {
112 }

Member Function Documentation

void ctp::CTPTrackDump::analyze ( const art::Event evt)

Definition at line 128 of file CTPTrackDump_module.cc.

129 {
130 
131  // Get all of the PFParticles
132  const std::vector<art::Ptr<recob::PFParticle>> particles = dune_ana::DUNEAnaEventUtils::GetPFParticles(evt,fParticleLabel);
133 
134  unsigned int nTracks = 0;
135  for (const art::Ptr<recob::PFParticle> &particle : particles)
136  {
137  // Get the track if this particle is track-like
138  unsigned int nCaloPoints = 0;
139  const std::string trkLabel = fHelperPars.get<std::string>("TrackLabel");
141  {
143  const std::string caloLabel = fHelperPars.get<std::string>("CalorimetryLabel");
145 
146  nCaloPoints = calo->dEdx().size();
147  }
148  else continue;
149 
150  // Returns a dummy value if not a track or not suitable
151  std::vector<std::vector<float>> netInputs = fConvTrackPID.GetNetworkInputs(particle,evt);
152 
153  if(netInputs.empty()) continue;
154 
155  const std::pair<const simb::MCParticle*,float> trueParticle = fConvTrackPID.GetTrueParticle(particle,evt);
156 
157  this->WriteTextFile(evt,netInputs,trueParticle,nTracks,nCaloPoints);
158  ++nTracks;
159  }
160 
161 }
static art::Ptr< recob::Track > GetTrack(const art::Ptr< recob::PFParticle > &pParticle, const art::Event &evt, const std::string &pParticleLabel, const std::string &trackLabel)
Get the track associated to this particle. Should only be called if IsTrack method succeeds...
std::string string
Definition: nybbler.cc:12
const std::vector< std::vector< float > > GetNetworkInputs(const art::Ptr< recob::PFParticle >, const art::Event &evt) const
Definition: CTPHelper.cxx:81
T get(std::string const &key) const
Definition: ParameterSet.h:271
const std::pair< const simb::MCParticle *, float > GetTrueParticle(const art::Ptr< recob::PFParticle >, const art::Event &evt) const
Definition: CTPHelper.cxx:152
void WriteTextFile(const art::Event &evt, const std::vector< std::vector< float >> &inputs, const std::pair< const simb::MCParticle *, float > &trueParticle, const unsigned int &trackNumber, const unsigned int &nHits) const
static art::Ptr< anab::Calorimetry > GetCalorimetry(const art::Ptr< recob::Track > &pTrack, const art::Event &evt, const std::string &trackLabel, const std::string &caloLabel)
Get the particle associated with the track.
static bool IsTrack(const art::Ptr< recob::PFParticle > &pParticle, const art::Event &evt, const std::string &pParticleLabel, const std::string &trackLabel)
Check if this particle has an associated track.
fhicl::ParameterSet fHelperPars
static std::vector< art::Ptr< recob::PFParticle > > GetPFParticles(const art::Event &evt, const std::string &label)
Get the particles from the event.
calorimetry
void ctp::CTPTrackDump::beginJob ( )
virtual

Reimplemented from art::EDAnalyzer.

Definition at line 116 of file CTPTrackDump_module.cc.

117 {
118 }
void ctp::CTPTrackDump::endJob ( )
virtual

Reimplemented from art::EDAnalyzer.

Definition at line 122 of file CTPTrackDump_module.cc.

123 {
124 }
void ctp::CTPTrackDump::WriteTextFile ( const art::Event evt,
const std::vector< std::vector< float >> &  inputs,
const std::pair< const simb::MCParticle *, float > &  trueParticle,
const unsigned int &  trackNumber,
const unsigned int &  nHits 
) const
private

Definition at line 163 of file CTPTrackDump_module.cc.

164  {
165 
166  // Open our output file stream
167  std::stringstream filename;
168  filename << "tracks_" << evt.id().run() << "_" << evt.id().subRun() << "_" << evt.id().event() << "_" << trackNumber << "_" << std::floor(inputs.at(1).at(3)*1000) << ".dat";
169  std::ofstream output_file(filename.str());
170 
171  for(const float dedx : inputs.at(0))
172 // for(const float val : chargeVector)
173  {
174  output_file << dedx << "\n";
175  }
176  output_file << "End of dE/dx\n";
177 
178  for(const float var : inputs.at(1)){
179  output_file << var << "\n";
180  }
181 
182  output_file << trueParticle.first->PdgCode() << "\n";
183  output_file << nHits << "\n";
184  output_file << trueParticle.first->P() << "\n";
185  output_file << trueParticle.second << "\n";
186  output_file.close();
187 
188 }
string filename
Definition: train.py:213
RunNumber_t run() const
Definition: EventID.h:98
int var
Definition: 018_def.c:9
EventNumber_t event() const
Definition: EventID.h:116
SubRunNumber_t subRun() const
Definition: EventID.h:110
EventID id() const
Definition: Event.cc:34

Member Data Documentation

CTPHelper ctp::CTPTrackDump::fConvTrackPID
private

Definition at line 64 of file CTPTrackDump_module.cc.

fhicl::ParameterSet ctp::CTPTrackDump::fHelperPars
private

Definition at line 63 of file CTPTrackDump_module.cc.

std::string ctp::CTPTrackDump::fParticleLabel
private

Definition at line 65 of file CTPTrackDump_module.cc.


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