Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
wsnumu::WSNumu Class Reference
Inheritance diagram for wsnumu::WSNumu:
art::EDProducer art::ProducerBase art::Consumer art::EngineCreator art::ProductRegistryHelper

Public Types

using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
template<typename UserConfig , typename KeysToIgnore = void>
using Table = ProducerBase::Table< UserConfig, KeysToIgnore >
 

Public Member Functions

 WSNumu (fhicl::ParameterSet const &pset)
 
virtual ~WSNumu ()
 
void produce (art::Event &evt)
 
void beginRun (art::Run &run)
 
template<typename PROD , BranchType B = InEvent>
ProductID getProductID (std::string const &instanceName={}) const
 
template<typename PROD , BranchType B>
ProductID getProductID (ModuleDescription const &moduleDescription, std::string const &instanceName) const
 
bool modifiesEvent () const
 
template<typename T , BranchType = InEvent>
ProductToken< Tconsumes (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< Tconsumes (InputTag const &it)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ViewToken< TconsumesView (InputTag const &it)
 
template<typename T , BranchType = InEvent>
ProductToken< TmayConsume (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< TmayConsume (InputTag const &it)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ViewToken< TmayConsumeView (InputTag const &it)
 
base_engine_tcreateEngine (seed_t seed)
 
base_engine_tcreateEngine (seed_t seed, std::string const &kind_of_engine_to_make)
 
base_engine_tcreateEngine (seed_t seed, std::string const &kind_of_engine_to_make, label_t const &engine_label)
 
seed_t get_seed_value (fhicl::ParameterSet const &pset, char const key[]="seed", seed_t const implicit_seed=-1)
 

Static Public Member Functions

static cet::exempt_ptr< Consumernon_module_context ()
 

Protected Member Functions

CurrentProcessingContext const * currentContext () const
 
void validateConsumedProduct (BranchType const bt, ProductInfo const &pi)
 
void prepareForJob (fhicl::ParameterSet const &pset)
 
void showMissingConsumes () const
 

Protected Attributes

std::string fSlicerLabel
 
std::string fTrackLabel
 
std::string fPIDLabel
 
std::string fEnergyLabel
 
std::string fTMVApath
 
bool fUseLongestTrack
 
TMVA::Reader * fReader
 
float TMVAvars [6]
 

Detailed Description

Definition at line 34 of file WSNumu_module.cc.

Member Typedef Documentation

using art::EDProducer::ModuleType = EDProducer
inherited

Definition at line 34 of file EDProducer.h.

template<typename UserConfig , typename KeysToIgnore = void>
using art::EDProducer::Table = ProducerBase::Table<UserConfig, KeysToIgnore>
inherited

Definition at line 43 of file EDProducer.h.

using art::EDProducer::WorkerType = WorkerT<EDProducer>
inherited

Definition at line 35 of file EDProducer.h.

Constructor & Destructor Documentation

wsnumu::WSNumu::WSNumu ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 60 of file WSNumu_module.cc.

60  :
61  fSlicerLabel (pset.get< std::string >("SlicerLabel")),
62  fTrackLabel (pset.get< std::string >("TrackLabel")),
63  fPIDLabel (pset.get< std::string >("PIDLabel")),
64  fEnergyLabel (pset.get< std::string >("EnergyLabel")),
65  fTMVApath (pset.get< std::string >("tmvapath")),
66  fUseLongestTrack (pset.get< bool >("UseLongestTrack")),
67  fReader (nullptr)
68  {
69  produces< std::vector<wsnumu::WSNumuObj> >();
70  produces< art::Assns<wsnumu::WSNumuObj, rb::Cluster> >();
71 
72  }
std::string fPIDLabel
TMVA::Reader * fReader
std::string fEnergyLabel
std::string fSlicerLabel
std::string fTrackLabel
std::string fTMVApath
enum BeamMode string
wsnumu::WSNumu::~WSNumu ( )
virtual

Definition at line 76 of file WSNumu_module.cc.

References fReader.

77  {
78  if(fReader) delete fReader;
79  }
TMVA::Reader * fReader

Member Function Documentation

void wsnumu::WSNumu::beginRun ( art::Run run)
virtual

Reimplemented from art::EDProducer.

Definition at line 82 of file WSNumu_module.cc.

References geo::GeometryBase::DetId(), util::EnvExpansion(), fReader, fTMVApath, geom(), novadaq::cnv::kNEARDET, string, and TMVAvars.

83  {
84 
86 
87  if(geom->DetId() == novadaq::cnv::kNEARDET) {
88 
89  fReader = new TMVA::Reader;
90  fReader->AddVariable("theta",&TMVAvars[0]);
91  fReader->AddVariable("hadEhit",&TMVAvars[1]);
92  fReader->AddVariable("hadEfrac",&TMVAvars[2]);
93  fReader->AddVariable("muonE",&TMVAvars[3]);
94  fReader->AddVariable("nPlaneGap",&TMVAvars[4]);
95  fReader->AddSpectator("PDGcode",&TMVAvars[5]);
97  fReader->BookMVA("BDTG",pidpath+"WSNumu_BDTG_prod3_NDtraining.weights.xml");
98 
99  }
100 
101  } //end beginRun
std::string EnvExpansion(const std::string &inString)
Function to expand environment variables.
Definition: EnvExpand.cxx:8
novadaq::cnv::DetId DetId() const
Prefer ds::DetectorService::DetId() instead.
Definition: GeometryBase.h:243
Near Detector in the NuMI cavern.
float TMVAvars[6]
TMVA::Reader * fReader
void geom(int which=0)
Definition: geom.C:163
std::string fTMVApath
enum BeamMode string
template<typename T , BranchType = InEvent>
ProductToken<T> art::Consumer::consumes ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ProductToken<T> art::Consumer::consumes ( InputTag const &  it)
inherited

Definition at line 146 of file Consumer.h.

References art::InputTag::instance(), PandAna.reco_validation.prod5_pid_validation::invalid, art::InputTag::label(), art::InputTag::process(), and T.

147 {
148  if (!moduleContext_)
149  return ProductToken<T>::invalid();
150 
151  consumables_[BT].emplace_back(ConsumableType::Product,
152  TypeID{typeid(T)},
153  it.label(),
154  it.instance(),
155  it.process());
156  return ProductToken<T>{it};
157 }
set< int >::iterator it
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
template<typename T , art::BranchType BT>
void art::Consumer::consumesMany ( )
inherited

Definition at line 161 of file Consumer.h.

References T.

162 {
163  if (!moduleContext_)
164  return;
165 
166  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
167 }
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::Consumer::consumesView ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ViewToken<T> art::Consumer::consumesView ( InputTag const &  it)
inherited

Definition at line 171 of file Consumer.h.

References art::InputTag::instance(), PandAna.reco_validation.prod5_pid_validation::invalid, art::InputTag::label(), art::InputTag::process(), and T.

172 {
173  if (!moduleContext_)
174  return ViewToken<T>::invalid();
175 
176  consumables_[BT].emplace_back(ConsumableType::ViewElement,
177  TypeID{typeid(T)},
178  it.label(),
179  it.instance(),
180  it.process());
181  return ViewToken<T>{it};
182 }
set< int >::iterator it
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
base_engine_t& art::EngineCreator::createEngine ( seed_t  seed)
inherited
base_engine_t& art::EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make 
)
inherited
base_engine_t& art::EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make,
label_t const &  engine_label 
)
inherited
CurrentProcessingContext const* art::EDProducer::currentContext ( ) const
protectedinherited
seed_t art::EngineCreator::get_seed_value ( fhicl::ParameterSet const &  pset,
char const  key[] = "seed",
seed_t const  implicit_seed = -1 
)
inherited
template<typename PROD , BranchType B>
ProductID art::EDProducer::getProductID ( std::string const &  instanceName = {}) const
inlineinherited

Definition at line 123 of file EDProducer.h.

References art::EDProducer::moduleDescription_.

Referenced by skim::NueSkimmer::CopyMichelSlice(), and skim::NueSkimmer::CopyMichelTrack().

124  {
125  return ProducerBase::getProductID<PROD, B>(moduleDescription_,
126  instanceName);
127  }
ModuleDescription moduleDescription_
Definition: EDProducer.h:115
template<typename PROD , BranchType B>
ProductID art::ProducerBase::getProductID ( ModuleDescription const &  moduleDescription,
std::string const &  instanceName 
) const
inherited

Definition at line 56 of file ProducerBase.h.

References art::ModuleDescription::moduleLabel().

Referenced by art::ProducerBase::modifiesEvent().

58  {
59  auto const& pd =
60  get_ProductDescription<PROD>(B, md.moduleLabel(), instanceName);
61  return pd.productID();
62  }
template<typename T , BranchType = InEvent>
ProductToken<T> art::Consumer::mayConsume ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ProductToken<T> art::Consumer::mayConsume ( InputTag const &  it)
inherited

Definition at line 189 of file Consumer.h.

References art::InputTag::instance(), PandAna.reco_validation.prod5_pid_validation::invalid, art::InputTag::label(), art::InputTag::process(), and T.

190 {
191  if (!moduleContext_)
192  return ProductToken<T>::invalid();
193 
194  consumables_[BT].emplace_back(ConsumableType::Product,
195  TypeID{typeid(T)},
196  it.label(),
197  it.instance(),
198  it.process());
199  return ProductToken<T>{it};
200 }
set< int >::iterator it
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
template<typename T , art::BranchType BT>
void art::Consumer::mayConsumeMany ( )
inherited

Definition at line 204 of file Consumer.h.

References T.

205 {
206  if (!moduleContext_)
207  return;
208 
209  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
210 }
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::Consumer::mayConsumeView ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ViewToken<T> art::Consumer::mayConsumeView ( InputTag const &  it)
inherited

Definition at line 214 of file Consumer.h.

References art::InputTag::instance(), PandAna.reco_validation.prod5_pid_validation::invalid, art::InputTag::label(), art::InputTag::process(), and T.

215 {
216  if (!moduleContext_)
217  return ViewToken<T>::invalid();
218 
219  consumables_[BT].emplace_back(ConsumableType::ViewElement,
220  TypeID{typeid(T)},
221  it.label(),
222  it.instance(),
223  it.process());
224  return ViewToken<T>{it};
225 }
set< int >::iterator it
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
bool art::ProducerBase::modifiesEvent ( ) const
inlineinherited

Definition at line 40 of file ProducerBase.h.

References art::ProducerBase::getProductID(), and string.

41  {
42  return true;
43  }
static cet::exempt_ptr<Consumer> art::Consumer::non_module_context ( )
staticinherited
void art::Consumer::prepareForJob ( fhicl::ParameterSet const &  pset)
protectedinherited
void wsnumu::WSNumu::produce ( art::Event evt)
virtual

Implements art::EDProducer.

Definition at line 104 of file WSNumu_module.cc.

References util::CreateAssn(), DEFINE_ART_MODULE(), geo::GeometryBase::DetId(), rb::Prong::Dir(), energy, fEnergyLabel, fPIDLabel, fReader, fSlicerLabel, fTrackLabel, fUseLongestTrack, geom(), art::DataViewImpl::getByLabel(), numue::NumuE::HadCalE(), numue::NumuE::HadCluster(), wsnumu::WSNumuObj::HadEfrac(), wsnumu::WSNumuObj::HadEhit(), remid::HighestPIDTrack(), MECModelEnuComparisons::i, rb::Prong::Is3D(), rb::Cluster::IsNoise(), novadaq::cnv::kNEARDET, geo::kXorY, wsnumu::WSNumuObj::MuonE(), rb::Cluster::NCell(), rb::Cluster::NMissingPlanes(), wsnumu::WSNumuObj::NPlaneGap(), art::Event::put(), numue::NumuE::RecoMuonE(), numue::NumuE::RecoTrkCCHadE(), wsnumu::WSNumuObj::SetHadEfrac(), wsnumu::WSNumuObj::SetHadEhit(), wsnumu::WSNumuObj::SetMuonE(), wsnumu::WSNumuObj::SetNPlaneGap(), wsnumu::WSNumuObj::SetTheta(), wsnumu::WSNumuObj::SetWSPID(), wsnumu::WSNumuObj::Theta(), chisquared::theta, TMVAvars, and numue::NumuE::TrkCCE().

105  {
106 
109  evt.getByLabel(fSlicerLabel,slicevec);
110 
111  if(slicevec->empty()) {
112  mf::LogWarning ("No Slices")<<"No Slices in the input file";
113  return;
114  }
115 
116  art::FindManyP<rb::Track> trackAssnList(slicevec, evt, fTrackLabel);
117  art::FindOneP<numue::NumuE> sliceEnergyList(slicevec, evt, fEnergyLabel);
118 
119  std::unique_ptr< std::vector<wsnumu::WSNumuObj> > outputObjects(new std::vector<wsnumu::WSNumuObj>);
120  std::unique_ptr< art::Assns<wsnumu::WSNumuObj, rb::Cluster> > assoc(new art::Assns<wsnumu::WSNumuObj, rb::Cluster>);
121 
122  for(size_t i = 0; i < slicevec->size(); ++i){
123 
124  art::Ptr<rb::Cluster> slice(slicevec, i);
125 
126  if(slice->IsNoise()) {
127  continue;
128  }
129 
130  wsnumu::WSNumuObj wsnumuobj; // initialization in constructor
131 
132  unsigned int bestIdx = 999; // for index in list of the highest ReMId PID track
133 
134  if(!trackAssnList.isValid()) {
135  mf::LogWarning("WSNumu") << "WSNumu: No Kalman Tracks!";
136  outputObjects->push_back(wsnumuobj);
137  util::CreateAssn(*this, evt, *(outputObjects.get()), slice, *(assoc.get()));
138  continue;
139  }
140 
141  const std::vector< art::Ptr<rb::Track> > sliceTracks = trackAssnList.at(i);
142  art::FindOneP<remid::ReMId> remidVec(sliceTracks, evt, fPIDLabel);
143 
144  if(fUseLongestTrack) {
145  bestIdx = 0;
146  if(sliceTracks.size() == 0) {
147  outputObjects->push_back(wsnumuobj);
148  continue;
149  }
150  const art::Ptr<rb::Track> track = sliceTracks[0];
151  if(!track->Is3D()) {
152  outputObjects->push_back(wsnumuobj);
153  continue;
154  }
155  }
156  else if(!remidVec.isValid()) {
157  mf::LogWarning("WSNumu") << "WSNumu: No ReMId information!";
158  outputObjects->push_back(wsnumuobj);
159  util::CreateAssn(*this, evt, *(outputObjects.get()), slice, *(assoc.get()));
160  continue;
161  }
162  else {
163  bestIdx = remid::HighestPIDTrack(sliceTracks, fPIDLabel, evt);
164  }
165 
166 
167  if(geom->DetId() == novadaq::cnv::kNEARDET) { // Only for ND
168  // Main condition
169  if(bestIdx!=999) {
170 
171  float theta = 0.;
172  float hadEhit = 0.;
173  float hadEfrac = 0.;
174  float muonE = 0.;
175  int nPlaneGap = 0;
176 
177  const art::Ptr<rb::Track> track = sliceTracks[bestIdx];
178  const art::Ptr<numue::NumuE> energy = sliceEnergyList.at(i);
179  if (!energy) continue;
180 
181  double tdx = track->Dir().X();
182  double tdy = track->Dir().Y();
183  double tdz = track->Dir().Z();
184 
185  if(!(tdx>=-1&&tdx<=1&&tdy>=-1&&tdy<=1&&tdz>=-1&&tdz<=1)) continue; // mis-reconstructed track
186 
187  theta = TMath::ACos(tdz)*180./TMath::Pi();
188  wsnumuobj.SetTheta(theta);
189 
190  if( energy->HadCluster().NCell() > 0 ) {
191  hadEhit = energy->HadCalE() / energy->HadCluster().NCell();
192  }
193  wsnumuobj.SetHadEhit(hadEhit);
194 
195  if( energy->TrkCCE() > 0 ) {
196  hadEfrac = energy->RecoTrkCCHadE() / energy->TrkCCE();
197  }
198  wsnumuobj.SetHadEfrac(hadEfrac);
199 
200  if( energy->RecoMuonE() > 0 ) {
201  muonE = energy->RecoMuonE();
202  }
203  wsnumuobj.SetMuonE(muonE);
204 
205  nPlaneGap = track->NMissingPlanes(geo::kXorY);
206  wsnumuobj.SetNPlaneGap(nPlaneGap);
207 
208  //---
209  TMVAvars[0] = wsnumuobj.Theta();
210  TMVAvars[1] = wsnumuobj.HadEhit();
211  TMVAvars[2] = wsnumuobj.HadEfrac();
212  TMVAvars[3] = wsnumuobj.MuonE();
213  TMVAvars[4] = wsnumuobj.NPlaneGap();
214  TMVAvars[5] = 0; // Spectator(s)
215 
216  wsnumuobj.SetWSPID(fReader->EvaluateMVA("BDTG"));
217  }
218  } // end if good track
219 
220  outputObjects->push_back(wsnumuobj); // write out object with all information
221  util::CreateAssn(*this, evt, *(outputObjects.get()), slice, *(assoc.get()));
222 
223  } //end loop over slices
224 
225  evt.put(std::move(outputObjects));
226  evt.put(std::move(assoc));
227 
228  } //end produce
static bool CreateAssn(art::EDProducer const &prod, art::Event &evt, std::vector< T > &a, art::Ptr< U > b, art::Assns< T, U > &assn, size_t indx=UINT_MAX, std::string const &instance=std::string())
Create a 1 to 1 association between a new product and one already in the event.
unsigned int NCell(geo::View_t view) const
Number of cells in view view.
Definition: Cluster.cxx:134
void SetHadEfrac(float hadefrac)
hadronic energy fraction of the slice
Definition: WSNumuObj.cxx:35
void SetWSPID(float wspid)
numu-focused wrong sign PID
Definition: WSNumuObj.cxx:53
X or Y views.
Definition: PlaneGeo.h:30
Definition: event.h:19
float TrkCCE() const
Definition: NumuE.cxx:254
float HadEhit() const
Definition: WSNumuObj.cxx:65
void SetHadEhit(float hadehit)
hadronic energy per hit in the slice
Definition: WSNumuObj.cxx:29
rb::Cluster HadCluster() const
Definition: NumuE.cxx:389
float RecoTrkCCHadE() const
Definition: NumuE.cxx:274
float RecoMuonE() const
Definition: NumuE.cxx:269
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
void SetNPlaneGap(int nplanegap)
number of plane gaps in the main track
Definition: WSNumuObj.cxx:47
std::string fPIDLabel
void SetMuonE(float muonE)
muon energy
Definition: WSNumuObj.cxx:41
float MuonE() const
Definition: WSNumuObj.cxx:77
novadaq::cnv::DetId DetId() const
Prefer ds::DetectorService::DetId() instead.
Definition: GeometryBase.h:243
virtual TVector3 Dir() const
Unit vector describing prong direction.
Definition: Prong.h:77
double energy
Definition: plottest35.C:25
int NPlaneGap() const
Definition: WSNumuObj.cxx:83
Near Detector in the NuMI cavern.
float TMVAvars[6]
TMVA::Reader * fReader
void SetTheta(float theta)
direction angle of the leading muon (in deg)
Definition: WSNumuObj.cxx:23
float HadCalE() const
Definition: NumuE.cxx:279
int NMissingPlanes(geo::View_t view) const
Total number of missing planes in cluster.
Definition: Cluster.cxx:693
std::string fEnergyLabel
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
void geom(int which=0)
Definition: geom.C:163
std::string fSlicerLabel
std::string fTrackLabel
virtual bool Is3D() const
Definition: Prong.h:71
unsigned int HighestPIDTrack(const std::vector< art::Ptr< rb::Track > > &sliceTracks, const std::string &remidModuleLabel, const art::Event &e)
Definition: ReMId.cxx:249
float Theta() const
Definition: WSNumuObj.cxx:59
float HadEfrac() const
Definition: WSNumuObj.cxx:71
void art::Consumer::showMissingConsumes ( ) const
protectedinherited

Referenced by art::RootOutput::endJob().

void art::Consumer::validateConsumedProduct ( BranchType const  bt,
ProductInfo const &  pi 
)
protectedinherited

Member Data Documentation

std::string wsnumu::WSNumu::fEnergyLabel
protected

Definition at line 47 of file WSNumu_module.cc.

Referenced by produce().

std::string wsnumu::WSNumu::fPIDLabel
protected

Definition at line 46 of file WSNumu_module.cc.

Referenced by produce().

TMVA::Reader* wsnumu::WSNumu::fReader
protected

Definition at line 50 of file WSNumu_module.cc.

Referenced by beginRun(), produce(), and ~WSNumu().

std::string wsnumu::WSNumu::fSlicerLabel
protected

Definition at line 44 of file WSNumu_module.cc.

Referenced by produce().

std::string wsnumu::WSNumu::fTMVApath
protected

Definition at line 48 of file WSNumu_module.cc.

Referenced by beginRun().

std::string wsnumu::WSNumu::fTrackLabel
protected

Definition at line 45 of file WSNumu_module.cc.

Referenced by produce().

bool wsnumu::WSNumu::fUseLongestTrack
protected

Definition at line 49 of file WSNumu_module.cc.

Referenced by produce().

float wsnumu::WSNumu::TMVAvars[6]
protected

Definition at line 51 of file WSNumu_module.cc.

Referenced by beginRun(), and produce().


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