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

CTPEvaluator class. More...

Inheritance diagram for ctp::CTPEvaluator:
art::EDProducer art::detail::Producer art::detail::LegacyModule art::Modifier art::ModuleBase art::ProductRegistryHelper

Public Member Functions

 CTPEvaluator (fhicl::ParameterSet const &pset)
 Constructor. More...
 
virtual ~CTPEvaluator ()
 Destructor. More...
 
void beginJob ()
 
void endJob ()
 
void produce (art::Event &evt)
 
- Public Member Functions inherited from art::EDProducer
 EDProducer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDProducer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Producer
virtual ~Producer () noexcept
 
 Producer (fhicl::ParameterSet const &)
 
 Producer (Producer const &)=delete
 
 Producer (Producer &&)=delete
 
Produceroperator= (Producer const &)=delete
 
Produceroperator= (Producer &&)=delete
 
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::Modifier
 ~Modifier () noexcept
 
 Modifier ()
 
 Modifier (Modifier const &)=delete
 
 Modifier (Modifier &&)=delete
 
Modifieroperator= (Modifier const &)=delete
 
Modifieroperator= (Modifier &&)=delete
 
- 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

fhicl::ParameterSet fHelperPars
 
CTPHelper fConvTrackPID
 
std::string fParticleLabel
 
bool fWriteTree
 
std::vector< float > fMuonScoreVector
 
std::vector< float > fPionScoreVector
 
std::vector< float > fProtonScoreVector
 
std::vector< int > fPDGVector
 
std::vector< unsigned int > fCaloPoints
 
TTree * fPIDTree
 

Additional Inherited Members

- Public Types inherited from art::EDProducer
using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
- Public Types inherited from art::detail::Producer
template<typename UserConfig , typename KeysToIgnore = void>
using Table = Modifier::Table< UserConfig, KeysToIgnore >
 
- Public Types inherited from art::Modifier
template<typename UserConfig , typename UserKeysToIgnore = void>
using Table = ProducerTable< UserConfig, detail::ModuleConfig, UserKeysToIgnore >
 
- Static Public Member Functions inherited from art::EDProducer
static void commitEvent (EventPrincipal &ep, Event &e)
 
- 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

CTPEvaluator class.

Definition at line 39 of file CTPEvaluator_module.cc.

Constructor & Destructor Documentation

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

Constructor.

Parameters
pset

Definition at line 109 of file CTPEvaluator_module.cc.

109  : art::EDProducer(pset),
110 fHelperPars(pset.get<fhicl::ParameterSet>("ctpHelper")),
112 fParticleLabel(pset.get<std::string>("particleLabel")),
113 fWriteTree(pset.get<bool>("writeTree"))
114 {
115  produces<std::vector<ctp::CTPResult>>();
116  produces<art::Assns<recob::Track,ctp::CTPResult>>();
117 }
std::string string
Definition: nybbler.cc:12
fhicl::ParameterSet fHelperPars
ctp::CTPEvaluator::~CTPEvaluator ( )
virtual

Destructor.

Definition at line 121 of file CTPEvaluator_module.cc.

122 {
123 }

Member Function Documentation

void ctp::CTPEvaluator::beginJob ( )
virtual

Reimplemented from art::EDProducer.

Definition at line 127 of file CTPEvaluator_module.cc.

128 {
129  if (!fWriteTree) return;
130 
132 
133  fPIDTree = tfs->make<TTree>("pidTree","pidTree");
134  fPIDTree->Branch("muonScores",&fMuonScoreVector);
135  fPIDTree->Branch("pionScores",&fPionScoreVector);
136  fPIDTree->Branch("protonScores",&fProtonScoreVector);
137  fPIDTree->Branch("pdgCodes",&fPDGVector);
138  fPIDTree->Branch("caloPoints",&fCaloPoints);
139 }
std::vector< float > fPionScoreVector
std::vector< unsigned int > fCaloPoints
std::vector< int > fPDGVector
std::vector< float > fProtonScoreVector
std::vector< float > fMuonScoreVector
void ctp::CTPEvaluator::endJob ( )
virtual

Reimplemented from art::EDProducer.

Definition at line 143 of file CTPEvaluator_module.cc.

144 {
145 }
void ctp::CTPEvaluator::produce ( art::Event evt)
virtual

Implements art::EDProducer.

Definition at line 149 of file CTPEvaluator_module.cc.

150 {
151  // Define containers for the things we're going to produce
152  std::unique_ptr< std::vector<ctp::CTPResult> > resultCol(new std::vector<ctp::CTPResult>);
153  std::unique_ptr< art::Assns<recob::Track,ctp::CTPResult> > trackResultAssn(new art::Assns<recob::Track,ctp::CTPResult>);
154 
155  if (fWriteTree)
156  {
157  fMuonScoreVector.clear();
158  fPionScoreVector.clear();
159  fProtonScoreVector.clear();
160  fPDGVector.clear();
161  fCaloPoints.clear();
162  }
163 
164  // Get all of the PFParticles
165  const std::vector<art::Ptr<recob::PFParticle>> particles = dune_ana::DUNEAnaEventUtils::GetPFParticles(evt,fParticleLabel);
166 
167  // Get the tracks too
168  const std::string trkLabel = fHelperPars.get<std::string>("TrackLabel");
169  const std::vector<art::Ptr<recob::Track>> tracks = dune_ana::DUNEAnaEventUtils::GetTracks(evt,trkLabel);
170 
171  for (const art::Ptr<recob::PFParticle> &particle : particles)
172  {
173  int thisTrackID = -999;
174 
175  // Get the track if this particle is track-like
176  unsigned int nCaloPoints = 0;
178  {
180  const std::string caloLabel = fHelperPars.get<std::string>("CalorimetryLabel");
182 
183  thisTrackID = trk.key();
184  nCaloPoints = calo->dEdx().size();
185  }
186  else continue;
187 
188  // Returns a dummy value if not a track or not suitable
189  CTPResult thisPID = fConvTrackPID.RunConvolutionalTrackPID(particle,evt);
190  resultCol->push_back(thisPID);
191  auto const ptrMaker = art::PtrMaker<ctp::CTPResult>(evt);
192  art::Ptr<ctp::CTPResult> ptrResult = ptrMaker(resultCol->size()-1);
193  art::Ptr<recob::Track> thisTrack = tracks.at(thisTrackID);
194 
195 // std::cout << "Making association between track " << thisTrack.key() << " and PID result " << ptrResult.key() << std::endl;
196 
197  // Now to make the association
198  util::CreateAssn(evt,ptrResult,thisTrack,*trackResultAssn);
199 
200  if (fWriteTree)
201  {
202  if (!thisPID.IsValid()) continue;
203  int pdg = 0;
204  if(!evt.isRealData()){
205  pdg = fConvTrackPID.GetTruePDGCode(particle,evt);
206  }
207  std::cout << "Got a track PID for particle of type " << pdg << ": " << thisPID.GetMuonScore() << ", " << thisPID.GetPionScore() << ", " << thisPID.GetProtonScore() << std::endl;
208  fMuonScoreVector.push_back(thisPID.GetMuonScore());
209  fPionScoreVector.push_back(thisPID.GetPionScore());
210  fProtonScoreVector.push_back(thisPID.GetProtonScore());
211  fPDGVector.push_back(pdg);
212  fCaloPoints.push_back(nCaloPoints);
213  }
214  }
215  if (fWriteTree) fPIDTree->Fill();
216 
217  evt.put(std::move(resultCol));
218  evt.put(std::move(trackResultAssn));
219 }
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::vector< float > fPionScoreVector
std::string string
Definition: nybbler.cc:12
const int GetTruePDGCode(const art::Ptr< recob::PFParticle >, const art::Event &evt) const
Definition: CTPHelper.cxx:185
std::vector< unsigned int > fCaloPoints
std::vector< int > fPDGVector
bool isRealData() const
static std::vector< art::Ptr< recob::Track > > GetTracks(const art::Event &evt, const std::string &label)
Get the tracks from the event. This function shouldn&#39;t be used as the basis of an analysis...
def move(depos, offset)
Definition: depos.py:107
key_type key() const noexcept
Definition: Ptr.h:216
T get(std::string const &key) const
Definition: ParameterSet.h:271
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: DataViewImpl.h:686
bool CreateAssn(PRODUCER const &prod, art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t indx=UINT_MAX)
Creates a single one-to-one association.
std::vector< float > fProtonScoreVector
Definition: tracks.py:1
fhicl::ParameterSet fHelperPars
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.
TCEvent evt
Definition: DataStructs.cxx:7
static std::vector< art::Ptr< recob::PFParticle > > GetPFParticles(const art::Event &evt, const std::string &label)
Get the particles from the event.
calorimetry
QTextStream & endl(QTextStream &s)
const ctp::CTPResult RunConvolutionalTrackPID(const art::Ptr< recob::PFParticle > particle, const art::Event &evt) const
Definition: CTPHelper.cxx:57
std::vector< float > fMuonScoreVector

Member Data Documentation

std::vector<unsigned int> ctp::CTPEvaluator::fCaloPoints
private

Definition at line 69 of file CTPEvaluator_module.cc.

CTPHelper ctp::CTPEvaluator::fConvTrackPID
private

Definition at line 61 of file CTPEvaluator_module.cc.

fhicl::ParameterSet ctp::CTPEvaluator::fHelperPars
private

Definition at line 60 of file CTPEvaluator_module.cc.

std::vector<float> ctp::CTPEvaluator::fMuonScoreVector
private

Definition at line 65 of file CTPEvaluator_module.cc.

std::string ctp::CTPEvaluator::fParticleLabel
private

Definition at line 62 of file CTPEvaluator_module.cc.

std::vector<int> ctp::CTPEvaluator::fPDGVector
private

Definition at line 68 of file CTPEvaluator_module.cc.

TTree* ctp::CTPEvaluator::fPIDTree
private

Definition at line 72 of file CTPEvaluator_module.cc.

std::vector<float> ctp::CTPEvaluator::fPionScoreVector
private

Definition at line 66 of file CTPEvaluator_module.cc.

std::vector<float> ctp::CTPEvaluator::fProtonScoreVector
private

Definition at line 67 of file CTPEvaluator_module.cc.

bool ctp::CTPEvaluator::fWriteTree
private

Definition at line 63 of file CTPEvaluator_module.cc.


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