Public Member Functions | Private Member Functions | Private Attributes | List of all members
protoana::ProtoDUNEBeamCuts Class Reference

#include <ProtoDUNEBeamCuts.h>

Public Member Functions

 ProtoDUNEBeamCuts ()
 
 ProtoDUNEBeamCuts (const fhicl::ParameterSet &pset)
 
bool IsBeamlike (const recob::Track &, const art::Event &, std::string)
 
bool IsBeamlike (const recob::Shower &, const art::Event &, std::string)
 

Private Member Functions

BeamVals GetMCBeam (const art::Event &)
 
BeamVals GetDataBeam (const art::Event &)
 

Private Attributes

std::map< std::string, fhicl::ParameterSetDataCuts
 
std::map< std::string, fhicl::ParameterSetMCCuts
 
std::vector< std::stringvalid_momenta
 

Detailed Description

Definition at line 22 of file ProtoDUNEBeamCuts.h.

Constructor & Destructor Documentation

protoana::ProtoDUNEBeamCuts::ProtoDUNEBeamCuts ( )
inline

Definition at line 25 of file ProtoDUNEBeamCuts.h.

25 {};
protoana::ProtoDUNEBeamCuts::ProtoDUNEBeamCuts ( const fhicl::ParameterSet pset)

Definition at line 5 of file ProtoDUNEBeamCuts.cxx.

5  {
6 
7 
8  std::vector< fhicl::ParameterSet > DataCuts_sets = pset.get< std::vector< fhicl::ParameterSet > >
9  ("DataCuts");
10  std::vector< fhicl::ParameterSet > MCCuts_sets = pset.get< std::vector< fhicl::ParameterSet > >
11  ("MCCuts");
12 
13  //Go through the data cuts
14  for( size_t i = 0; i < DataCuts_sets.size(); ++i ){
15  std::string momentum = DataCuts_sets[i].get<std::string>("Momentum");
16  if( std::find( valid_momenta.begin(), valid_momenta.end(), momentum ) == valid_momenta.end() ){
18  throw e;
19  }
20 
21  if( DataCuts.find( momentum ) != DataCuts.end() ){
22  std::cerr << "Error: Attempting to duplicate a cut parameter set" << std::endl;
24  throw e;
25  }
26 
27  DataCuts[momentum] = DataCuts_sets[i];
28  }
29 
30 
31  //Now go through the MC cuts
32  for( size_t i = 0; i < MCCuts_sets.size(); ++i ){
33 
34  std::string momentum = DataCuts_sets[i].get<std::string>("Momentum");
35  if( std::find( valid_momenta.begin(), valid_momenta.end(), momentum ) == valid_momenta.end() ){
37  throw e;
38  }
39 
40  if( MCCuts.find( momentum ) != MCCuts.end() ){
41  std::cerr << "Error: Attempting to duplicate a cut parameter set" << std::endl;
43  throw e;
44  }
45 
46  MCCuts[momentum] = MCCuts_sets[i];
47  }
48 
49 
50 }
std::string string
Definition: nybbler.cc:12
std::vector< std::string > valid_momenta
const double e
T get(std::string const &key) const
Definition: ParameterSet.h:271
std::map< std::string, fhicl::ParameterSet > DataCuts
std::map< std::string, fhicl::ParameterSet > MCCuts
def momentum(x1, x2, x3, scale=1.)
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
QTextStream & endl(QTextStream &s)

Member Function Documentation

protoana::BeamVals protoana::ProtoDUNEBeamCuts::GetDataBeam ( const art::Event evt)
private

Definition at line 206 of file ProtoDUNEBeamCuts.cxx.

206  {
207  std::vector<art::Ptr<beam::ProtoDUNEBeamEvent>> beamVec;
208  auto beamHandle = evt.getValidHandle< std::vector< beam::ProtoDUNEBeamEvent > >("beamevent");
209 
210  BeamVals result;
211  result.Valid = false;
212 
213  if( beamHandle.isValid()){
214  art::fill_ptr_vector(beamVec, beamHandle);
215  }
216  //Should just have one
217  const beam::ProtoDUNEBeamEvent & beamEvent = *(beamVec.at(0));
218 
219  const std::vector< recob::Track > & beamTracks = beamEvent.GetBeamTracks();
220  if( beamTracks.size() == 0 ){
221  std::cout << "Warning: no tracks associated to beam data" << std::endl;
222  return result;
223  }
224  else if( beamTracks.size() > 1 ){
225  std::cout << "Warning: mutiple tracks associated to beam data" << std::endl;
226  return result;
227  }
228 
229  result.Valid = true;
230  result.X = beamTracks.at(0).Trajectory().End().X();
231  result.Y = beamTracks.at(0).Trajectory().End().Y();
232 
233  result.DirX = beamTracks.at(0).EndDirection().X();
234  result.DirY = beamTracks.at(0).EndDirection().Y();
235  result.DirZ = beamTracks.at(0).EndDirection().Z();
236  return result;
237 }
static QCString result
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Definition: DataViewImpl.h:441
const std::vector< recob::Track > & GetBeamTracks() const
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:297
QTextStream & endl(QTextStream &s)
protoana::BeamVals protoana::ProtoDUNEBeamCuts::GetMCBeam ( const art::Event evt)
private

Definition at line 181 of file ProtoDUNEBeamCuts.cxx.

181  {
182 
184  auto mcTruths = evt.getValidHandle< std::vector< simb::MCTruth > >("generator");
185  const simb::MCParticle* true_beam_particle = truthUtil.GetGeantGoodParticle((*mcTruths)[0],evt);
186 
187  BeamVals result;
188  result.Valid = false;
189 
190  if( !true_beam_particle ){
191  std::cout << "No true beam particle" << std::endl;
192  return result;
193  }
194 
195  result.Valid = true;
196  result.DirX = true_beam_particle->Px() / true_beam_particle->P();
197  result.DirY = true_beam_particle->Py() / true_beam_particle->P();
198  result.DirZ = true_beam_particle->Pz() / true_beam_particle->P();
199 
200  //Project the beam to Z = 0
201  result.X = true_beam_particle->Position(0).X() + (-1.*true_beam_particle->Position(0).Z())*(result.DirX / result.DirZ);
202  result.Y = true_beam_particle->Position(0).Y() + (-1.*true_beam_particle->Position(0).Z())*(result.DirY / result.DirZ);
203  return result;
204 }
const simb::MCParticle * GetGeantGoodParticle(const simb::MCTruth &genTruth, const art::Event &evt) const
static QCString result
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Definition: DataViewImpl.h:441
QTextStream & endl(QTextStream &s)
bool protoana::ProtoDUNEBeamCuts::IsBeamlike ( const recob::Track ,
const art::Event ,
std::string   
)
bool protoana::ProtoDUNEBeamCuts::IsBeamlike ( const recob::Shower ,
const art::Event ,
std::string   
)

Member Data Documentation

std::map< std::string, fhicl::ParameterSet > protoana::ProtoDUNEBeamCuts::DataCuts
private

Definition at line 35 of file ProtoDUNEBeamCuts.h.

std::map< std::string, fhicl::ParameterSet > protoana::ProtoDUNEBeamCuts::MCCuts
private

Definition at line 36 of file ProtoDUNEBeamCuts.h.

std::vector< std::string > protoana::ProtoDUNEBeamCuts::valid_momenta
private
Initial value:
= {
".3", ".5", "1", "2", "3", "6", "7"
}

Definition at line 38 of file ProtoDUNEBeamCuts.h.


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