Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
lem::MakeLibrary Class Reference

Summarize ART events into LEM libary format. More...

Inheritance diagram for lem::MakeLibrary:
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

 MakeLibrary (const fhicl::ParameterSet &pset)
 
 ~MakeLibrary ()
 
virtual void produce (art::Event &evt)
 
virtual void reconfigure (const fhicl::ParameterSet &pset)
 
virtual void beginJob ()
 
virtual void endSubRun (art::SubRun &sr)
 
virtual void endJob ()
 
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

TVector3 SliceMeanPosEWeighted (const rb::Cluster &slice) const
 
int SliceOriginHelper (std::deque< int > &xs, double frac, int origin) const
 
void SliceOrigin (const rb::Cluster &slc, int &plane, int &cellX, int &cellY) const
 
CurrentProcessingContext const * currentContext () const
 
void validateConsumedProduct (BranchType const bt, ProductInfo const &pi)
 
void prepareForJob (fhicl::ParameterSet const &pset)
 
void showMissingConsumes () const
 

Protected Attributes

TTree * fTree
 
double fTotalPOT
 
std::string fSlicerLabel
 
std::string fMCTruthLabel
 
std::string fParticleLabel
 

Detailed Description

Summarize ART events into LEM libary format.

Definition at line 43 of file MakeLibrary_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

lem::MakeLibrary::MakeLibrary ( const fhicl::ParameterSet pset)
explicit

Definition at line 72 of file MakeLibrary_module.cc.

References reconfigure().

73  : fTree(0), fTotalPOT(0)
74  {
75  reconfigure(pset);
76  }
virtual void reconfigure(const fhicl::ParameterSet &pset)
lem::MakeLibrary::~MakeLibrary ( )

Definition at line 79 of file MakeLibrary_module.cc.

80  {
81  }

Member Function Documentation

void lem::MakeLibrary::beginJob ( )
virtual

Reimplemented from art::EDProducer.

Definition at line 97 of file MakeLibrary_module.cc.

References fTree, lem::EventSummary::InitToTree(), and art::TFileDirectory::make().

98  {
100  fTree = tfs->make<TTree>("tree", "tree");
101 
103  }
static void InitToTree(TTree *tr)
T * make(ARGS...args) const
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
void lem::MakeLibrary::endJob ( )
virtual

Reimplemented from art::EDProducer.

Definition at line 106 of file MakeLibrary_module.cc.

References fTotalPOT, and art::TFileDirectory::make().

107  {
109  TH1* hPOT = tfs->make<TH1F>("hTotalPOT", ";; POT", 1, 0, 1);
110  hPOT->Fill(.5, fTotalPOT);
111  }
T * make(ARGS...args) const
void lem::MakeLibrary::endSubRun ( art::SubRun sr)
virtual

Reimplemented from art::EDProducer.

Definition at line 114 of file MakeLibrary_module.cc.

References om::cout, allTimeWatchdog::endl, fMCTruthLabel, fTotalPOT, art::DataViewImpl::getByLabel(), pot, and sumdata::POTSum::totgoodpot.

115  {
117  sr.getByLabel(fMCTruthLabel, pot);
118 
119  fTotalPOT += pot->totgoodpot;
120 
121  std::cout << "POT " << pot->totgoodpot << std::endl;
122  }
std::string fMCTruthLabel
#define pot
OStream cout
Definition: OStream.cxx:6
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
double totgoodpot
normalized by 10^12 POT
Definition: POTSum.h:28
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 lem::MakeLibrary::produce ( art::Event evt)
virtual

Implements art::EDProducer.

Definition at line 183 of file MakeLibrary_module.cc.

References ana::assert(), simb::MCNeutrino::CCNC(), lem::EventSummary::ccnc, getBrightness::cell, rb::CellHit::Cell(), rb::Cluster::Cell(), lem::Clamp(), simb::MCParticle::E(), simb::MCParticle::EndPosition(), lem::EventSummary::event, art::Event::event(), art::Handle< T >::failedToGet(), flux, fMCTruthLabel, fParticleLabel, fSlicerLabel, fTree, geom(), art::DataViewImpl::getByLabel(), cheat::BackTracker::HitToTrackIDE(), PandAna.Demos.tute_pid_validation::ids, rb::RecoHit::IsCalibrated(), lem::kVertexCell, lem::kVertexPlane, geo::kX, Mag(), std::min(), simb::MCNeutrino::Mode(), lem::EventSummary::mode, simb::MCParticle::Mother(), getGoodRuns4SAM::n, rb::Cluster::NCell(), next(), simb::MCNeutrino::Nu(), lem::EventSummary::origPdg, part, submit_concat_project::parts, lem::EventSummary::pdg, simb::MCParticle::PdgCode(), rb::RecoHit::PECorr(), lem::EventSummary::photE0, lem::EventSummary::photE1, lem::EventSummary::photL0, lem::EventSummary::photL1, rb::CellHit::Plane(), geo::GeometryBase::Plane(), NDAPDHVSetting::plane, simb::MCParticle::Position(), simb::MCParticle::Process(), rb::Cluster::RecoHit(), lem::EventSummary::run, art::Event::run(), SliceOrigin(), lem::EventSummary::subrun, art::Event::subRun(), sum, std::swap(), lem::EventSummary::ToTree(), simb::MCParticle::TrackId(), cheat::BackTracker::TrackIDToParticle(), lem::EventSummary::trueEVis, lem::EventSummary::trueVtxCell, lem::EventSummary::trueVtxCellOther, lem::EventSummary::trueVtxPlane, lem::VertexToPlaneAndCell(), rb::CellHit::View(), geo::PlaneGeo::View(), lem::EventSummary::y, and simb::MCNeutrino::Y().

184  {
187 
189  evt.getByLabel(fMCTruthLabel, fluxs);
190 
191  assert(fluxs->size() == 1);
192  const simb::MCFlux& flux = (*fluxs)[0];
193 
195  evt.getByLabel(fMCTruthLabel, truths);
196  assert(truths->size() == 1);
197  const simb::MCTruth& truth = (*truths)[0];
198 
199  const simb::MCNeutrino& nu = truth.GetNeutrino();
200  const TVector3 vtx = nu.Nu().Position(0).Vect();
201 
203  evt.getByLabel(fSlicerLabel, slices);
204 
205  // Find the biggest slice
206  int bestIdx = -1;
207  double bestADC = 0;
208  for(unsigned int sliceIdx = 0; sliceIdx < slices->size(); ++sliceIdx){
209  if((*slices)[sliceIdx].IsNoise()) continue;
210  const double adc = (*slices)[sliceIdx].TotalADC();
211  if(adc > bestADC){
212  bestADC = adc;
213  bestIdx = sliceIdx;
214  }
215  }
216 
217  if(bestIdx == -1) return;
218 
219  const rb::Cluster& slice = (*slices)[bestIdx];
220 
221  int originPlane, originCellX, originCellY;
222  SliceOrigin(slice, originPlane, originCellX, originCellY);
223 
224  // Collect all the track IDs that are ever primary for a hit
225  std::set<int> ids;
226  for(unsigned int cellIdx = 0; cellIdx < slice.NCell(); ++cellIdx){
227  const art::Ptr<rb::CellHit>& chit = slice.Cell(cellIdx);
228  const std::vector<cheat::TrackIDE> ides = bt->HitToTrackIDE(chit);
229  if(!ides.empty()) ids.insert(ides[0].trackID);
230  }
231  if(ids.size() > 255) mf::LogWarning("MakeLibrary") << "Track ID overflow";
232  // Map them onto small integers
233  std::map<int, unsigned char> idMap;
234  for(int id : ids){
235  const unsigned char next = std::min(idMap.size(), 255ul);
236  idMap[id] = next;
237  }
238 
239  // TODO: merge hits that fall on already hit cells. This apparently
240  // happens. Does it cause the self-energy to be wrong?
241  std::vector<LiteHit> hs;
242  for(unsigned int cellIdx = 0; cellIdx < slice.NCell(); ++cellIdx){
243  const art::Ptr<rb::CellHit>& chit = slice.Cell(cellIdx);
244 
245  const int originCell = (chit->View() == geo::kX ? originCellX : originCellY);
246 
247  const int plane = Clamp(chit->Plane()-originPlane+lem::kVertexPlane);
248 
249  // Get it central in the window
250  const int cell = Clamp(chit->Cell()-originCell+lem::kVertexCell);
251 
252  const std::vector<cheat::TrackIDE> ides = bt->HitToTrackIDE(chit);
253  const unsigned char idIdx = ides.empty() ? 255 : idMap[ides[0].trackID];
254 
255  const rb::RecoHit rhit = slice.RecoHit(chit);
256 
257  if(rhit.IsCalibrated())
258  hs.push_back(LiteHit(plane, cell, rhit.PECorr(), idIdx));
259  } // end for cellIdx
260 
261  std::vector<int> pdgs;
262  for(int id : ids){
263  if(id != 255){
264  const sim::Particle* part = bt->TrackIDToParticle(id);
265  if(part) pdgs.push_back(part->PdgCode());
266  }
267  }
268 
269  EventSummary sum(hs, -1, pdgs);
270 
271  sum.run = evt.run();
272  sum.subrun = evt.subRun();
273  sum.event = evt.event();
274 
275  sum.origPdg = flux.fntype;
276 
277  sum.pdg = nu.Nu().PdgCode();
278  sum.ccnc = nu.CCNC();
279  sum.mode = nu.Mode();
280  sum.y = nu.Y();
281  sum.trueEVis = nu.Nu().E()*(nu.CCNC() ? nu.Y() : 1);
282 
283 
284  // Convert the true vertex to an integer cell, and store in the summary
285 
286  VertexToPlaneAndCell(vtx, slice, sum.trueVtxPlane, sum.trueVtxCell, sum.trueVtxCellOther);
287  // That call labelled the views by which plane the true vertex is in. But
288  // we need them labelled by which plane our origin is in.
289  if(sum.trueVtxPlane%2 != originPlane%2)
290  std::swap(sum.trueVtxCell, sum.trueVtxCellOther);
291 
292  const int originCell = (geom->Plane(originPlane)->View() == geo::kX) ? originCellX : originCellY;
293  const int originCellOther = (geom->Plane(originPlane)->View() == geo::kX) ? originCellY : originCellX;
294 
295  sum.trueVtxPlane = Clamp(sum.trueVtxPlane-originPlane+lem::kVertexPlane);
296 
297  // Get it central in the window
298  sum.trueVtxCell = Clamp(sum.trueVtxCell-originCell+lem::kVertexCell);
299 
300  sum.trueVtxCellOther = Clamp(sum.trueVtxCellOther-originCellOther+lem::kVertexCell);
301 
302  // Conversion length on photon pi0 children
304  evt.getByLabel(fParticleLabel, parts);
305  if(!parts.failedToGet()){
306  int pi0Id = -10;
307  std::map<double, double> photLs; // -energy, length, just for sorting
308  for(unsigned int n = 0; n < parts->size(); ++n){
309  const sim::Particle& p = (*parts)[n];
310  if(p.Process() == "Primary" && p.PdgCode() == 111) pi0Id = p.TrackId();
311  if(p.PdgCode() == 22 && p.Mother() == pi0Id){
312  photLs[-p.E()] = (p.EndPosition().Vect()-vtx).Mag();
313  }
314  }
315  if(!photLs.empty()){
316  sum.photE0 = -photLs.begin()->first;
317  sum.photL0 = photLs.begin()->second;
318 
319  photLs.erase(photLs.begin());
320  if(!photLs.empty()){
321  sum.photE1 = -photLs.begin()->first;
322  sum.photL1 = photLs.begin()->second;
323  }
324  }
325  }
326 
327  sum.ToTree(fTree);
328  }
double E(const int i=0) const
Definition: MCParticle.h:232
::xsd::cxx::tree::id< char, ncname > id
Definition: Database.h:165
SubRunNumber_t subRun() const
Definition: Event.h:72
const TLorentzVector & Position(const int i=0) const
Definition: MCParticle.h:218
int PdgCode() const
Definition: MCParticle.h:211
int CCNC() const
Definition: MCNeutrino.h:148
unsigned int NCell(geo::View_t view) const
Number of cells in view view.
Definition: Cluster.cxx:134
const TLorentzVector & EndPosition() const
Definition: MCParticle.h:224
void SliceOrigin(const rb::Cluster &slc, int &plane, int &cellX, int &cellY) const
std::vector< TrackIDE > HitToTrackIDE(const rb::CellHit &hit, bool useBirksE=false) const
Convenience function. HitsToTrackIDE but for a single hit.
void VertexToPlaneAndCell(const TVector3 vtx, const rb::Cluster &slice, int &plane, int &cell, int &cellOtherView, bool reverse)
Definition: Util.cxx:60
unsigned short Plane() const
Definition: CellHit.h:39
int Mother() const
Definition: MCParticle.h:212
geo::View_t View() const
Definition: CellHit.h:41
const char * p
Definition: xmltok.h:285
const simb::MCParticle & Nu() const
Definition: MCNeutrino.h:146
Vertical planes which measure X.
Definition: PlaneGeo.h:28
const int kVertexPlane
Definition: EventSummary.h:22
A collection of associated CellHits.
Definition: Cluster.h:47
std::string fMCTruthLabel
const PlaneGeo * Plane(unsigned int i) const
std::string Process() const
Definition: MCParticle.h:214
Loaders::FluxType flux
int Clamp(int x)
int TrackId() const
Definition: MCParticle.h:209
Calibrated quantities relying on position in the orthogonal view. To generate a rb::CellHit from a rb...
Definition: RecoHit.h:19
void swap(art::HLTGlobalStatus &lhs, art::HLTGlobalStatus &rhs)
unsigned short Cell() const
Definition: CellHit.h:40
TString part[npart]
Definition: Style.C:32
View_t View() const
Which coordinate does this plane measure.
Definition: PlaneGeo.h:53
std::string fSlicerLabel
double Y() const
Definition: MCNeutrino.h:156
const int kVertexCell
Definition: EventSummary.h:23
rb::RecoHit RecoHit(const art::Ptr< rb::CellHit > &chit) const
Return calibrated hit based on assumed W coordinate.
Definition: Cluster.cxx:259
bool IsCalibrated() const
You MUST check here before accessing PECorr, MIP or GeV.
Definition: RecoHit.cxx:35
EventNumber_t event() const
Definition: Event.h:67
const sim::Particle * TrackIDToParticle(int const &id) const
Returns a pointer to the sim::Particle object corresponding to the given TrackID. ...
art::Ptr< rb::CellHit > Cell(geo::View_t view, unsigned int viewIdx) const
Get the ith cell from view view.
Definition: Cluster.cxx:145
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
void geom(int which=0)
Definition: geom.C:163
float Mag() const
assert(nhit_max >=nhit_nbins)
float PECorr() const
Definition: RecoHit.cxx:47
Event generator information.
Definition: MCTruth.h:32
T min(const caf::Proxy< T > &a, T b)
Double_t sum
Definition: plot.C:31
RunNumber_t run() const
Definition: Event.h:77
std::string fParticleLabel
Event generator information.
Definition: MCNeutrino.h:18
int Mode() const
Definition: MCNeutrino.h:149
void next()
Definition: show_event.C:84
bool failedToGet() const
Definition: Handle.h:196
void lem::MakeLibrary::reconfigure ( const fhicl::ParameterSet pset)
virtual

Definition at line 84 of file MakeLibrary_module.cc.

References lem::EventSummary::fgChargePower, lem::EventSummary::fgDecayRate, fMCTruthLabel, fParticleLabel, fSlicerLabel, fhicl::ParameterSet::get(), and string.

Referenced by MakeLibrary().

85  {
86  fParticleLabel = pset.get<std::string>("ParticleLabel");
87  fSlicerLabel = pset.get<std::string>("SlicerLabel");
88  fMCTruthLabel = pset.get<std::string>("MCTruthLabel");
89 
90  // We want to store exactly the values of the hits, only rescale them later
91  // when actually doing matching.
94  }
static double fgChargePower
Definition: EventSummary.h:76
std::string fMCTruthLabel
std::string fSlicerLabel
T get(std::string const &key) const
Definition: ParameterSet.h:231
static double fgDecayRate
Definition: EventSummary.h:75
std::string fParticleLabel
enum BeamMode string
void art::Consumer::showMissingConsumes ( ) const
protectedinherited

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

TVector3 lem::MakeLibrary::SliceMeanPosEWeighted ( const rb::Cluster slice) const
protected

Definition at line 331 of file MakeLibrary_module.cc.

References rb::CellHit::Cell(), rb::Cluster::Cell(), DEFINE_ART_MODULE(), E, geom(), make_syst_table_plots::h, MECModelEnuComparisons::i, rb::RecoHit::IsCalibrated(), geo::kX, geo::kY, extractScale::mean, rb::Cluster::NCell(), rb::RecoHit::PECorr(), rb::CellHit::Plane(), geo::GeometryBase::Plane(), rb::Cluster::RecoHit(), POTSpillRate::view, submit_syst::x, submit_syst::y, and test::z.

332  {
334 
335  double Ex = 0;
336  double Ey = 0;
337 
338  TVector3 mean;
339 
340  for(unsigned int i = 0; i < slice.NCell(); ++i){
341  const art::Ptr<rb::CellHit>& h = slice.Cell(i);
342  double xyz[3];
343  geom->Plane(h->Plane())->Cell(h->Cell())->GetCenter(xyz);
344  const double x = xyz[0];
345  const double y = xyz[1];
346  const double z = xyz[2];
347  const geo::View_t view = geom->Plane(h->Plane())->View();
348 
349  const rb::RecoHit rhit = slice.RecoHit(i);
350  if(!rhit.IsCalibrated()) continue;
351  const double E = rhit.PECorr();
352 
353  if(view == geo::kX){
354  mean.SetX(mean.X()+x*E);
355  Ex += E;
356  }
357  if(view == geo::kY){
358  mean.SetY(mean.Y()+y*E);
359  Ey += E;
360  }
361  mean.SetZ(mean.Z()+z*E);
362  }
363 
364  if(Ex) mean.SetX(mean.X()/Ex);
365  if(Ey) mean.SetY(mean.Y()/Ey);
366  if(Ex || Ey) mean.SetZ(mean.Z()/(Ex+Ey));
367 
368  return mean;
369  }
unsigned int NCell(geo::View_t view) const
Number of cells in view view.
Definition: Cluster.cxx:134
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
unsigned short Plane() const
Definition: CellHit.h:39
Vertical planes which measure X.
Definition: PlaneGeo.h:28
const PlaneGeo * Plane(unsigned int i) const
Horizontal planes which measure Y.
Definition: PlaneGeo.h:29
Calibrated quantities relying on position in the orthogonal view. To generate a rb::CellHit from a rb...
Definition: RecoHit.h:19
unsigned short Cell() const
Definition: CellHit.h:40
Float_t E
Definition: plot.C:20
rb::RecoHit RecoHit(const art::Ptr< rb::CellHit > &chit) const
Return calibrated hit based on assumed W coordinate.
Definition: Cluster.cxx:259
bool IsCalibrated() const
You MUST check here before accessing PECorr, MIP or GeV.
Definition: RecoHit.cxx:35
Definition: View.py:1
z
Definition: test.py:28
art::Ptr< rb::CellHit > Cell(geo::View_t view, unsigned int viewIdx) const
Get the ith cell from view view.
Definition: Cluster.cxx:145
void geom(int which=0)
Definition: geom.C:163
float PECorr() const
Definition: RecoHit.cxx:47
void lem::MakeLibrary::SliceOrigin ( const rb::Cluster slc,
int plane,
int cellX,
int cellY 
) const
protected

Definition at line 160 of file MakeLibrary_module.cc.

References rb::CellHit::Cell(), rb::Cluster::Cell(), lem::kVertexCell, lem::kVertexPlane, geo::kX, rb::Cluster::NCell(), rb::CellHit::Plane(), SliceOriginHelper(), and rb::CellHit::View().

Referenced by produce().

162  {
163  cellX = cellY = 0; // Default in case of empty view
164 
165  std::deque<int> xcells, ycells, planes;
166 
167  const unsigned int N = slc.NCell();
168  for(unsigned int cellIdx = 0; cellIdx < N; ++cellIdx){
169  const art::Ptr<rb::CellHit> chit = slc.Cell(cellIdx);
170  planes.push_back(chit->Plane());
171  if(chit->View() == geo::kX)
172  xcells.push_back(chit->Cell());
173  else
174  ycells.push_back(chit->Cell());
175  }
176 
177  plane = SliceOriginHelper(planes, .05, lem::kVertexPlane);
178  cellX = SliceOriginHelper(xcells, .5, lem::kVertexCell);
179  cellY = SliceOriginHelper(ycells, .5, lem::kVertexCell);
180  }
unsigned int NCell(geo::View_t view) const
Number of cells in view view.
Definition: Cluster.cxx:134
unsigned short Plane() const
Definition: CellHit.h:39
geo::View_t View() const
Definition: CellHit.h:41
Vertical planes which measure X.
Definition: PlaneGeo.h:28
const int kVertexPlane
Definition: EventSummary.h:22
unsigned short Cell() const
Definition: CellHit.h:40
int SliceOriginHelper(std::deque< int > &xs, double frac, int origin) const
const int kVertexCell
Definition: EventSummary.h:23
art::Ptr< rb::CellHit > Cell(geo::View_t view, unsigned int viewIdx) const
Get the ith cell from view view.
Definition: Cluster.cxx:145
int lem::MakeLibrary::SliceOriginHelper ( std::deque< int > &  xs,
double  frac,
int  origin 
) const
protected

Definition at line 125 of file MakeLibrary_module.cc.

References submit_syst::x.

Referenced by SliceOrigin().

127  {
128  if(xs.empty()) return 0;
129 
130  std::sort(xs.begin(), xs.end());
131 
132  // If the range is too big to fit drop outlier entries until it isn't
133  while(xs.back()-xs.front() > 255){
134  xs.pop_back();
135  if(xs.back()-xs.front() > 255) xs.pop_front();
136  }
137 
138  // Initial estimate is this far through the list
139  int x = xs[frac*xs.size()];
140 
141  // If that drops entries off the bottom nudge it up
142  if(xs.front() - x + origin < 0){
143  x = xs.front() - origin;
144  }
145  // If it drops entries off the top nudge it down
146  if(xs.back() - x + origin > 255){
147  x = xs.back() + origin - 255;
148  }
149 
150  return x;
151  }
double frac(double x)
Fractional part.
void art::Consumer::validateConsumedProduct ( BranchType const  bt,
ProductInfo const &  pi 
)
protectedinherited

Member Data Documentation

std::string lem::MakeLibrary::fMCTruthLabel
protected

Definition at line 67 of file MakeLibrary_module.cc.

Referenced by endSubRun(), produce(), and reconfigure().

std::string lem::MakeLibrary::fParticleLabel
protected

Definition at line 68 of file MakeLibrary_module.cc.

Referenced by produce(), and reconfigure().

std::string lem::MakeLibrary::fSlicerLabel
protected

Definition at line 66 of file MakeLibrary_module.cc.

Referenced by produce(), and reconfigure().

double lem::MakeLibrary::fTotalPOT
protected

Definition at line 64 of file MakeLibrary_module.cc.

Referenced by endJob(), and endSubRun().

TTree* lem::MakeLibrary::fTree
protected

Definition at line 63 of file MakeLibrary_module.cc.

Referenced by beginJob(), and produce().


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