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

Rewrite a library file with events aligned according to vertex. More...

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

 AlignLibToVtx (const fhicl::ParameterSet &pset)
 
 ~AlignLibToVtx ()
 
virtual void reconfigure (const fhicl::ParameterSet &pset)
 
virtual void beginJob ()
 
virtual void respondToOpenInputFile (const art::FileBlock &fb)
 
virtual void produce (art::Event &evt)
 
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

TTree * fTreeIn
 
TTree * fTreeOut
 
std::string fSlicerLabel
 
std::string fVertexLabel
 

Detailed Description

Rewrite a library file with events aligned according to vertex.

Definition at line 34 of file AlignLibToVtx_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::AlignLibToVtx::AlignLibToVtx ( const fhicl::ParameterSet pset)
explicit

Definition at line 54 of file AlignLibToVtx_module.cc.

References reconfigure().

55  : fTreeIn(0), fTreeOut(0)
56  {
57  reconfigure(pset);
58 
59  // Just to mark where the vertex is so you can check it's right
60  produces<std::vector<geo::OfflineChan> >();
61  }
virtual void reconfigure(const fhicl::ParameterSet &pset)
lem::AlignLibToVtx::~AlignLibToVtx ( )

Definition at line 64 of file AlignLibToVtx_module.cc.

65  {
66  }

Member Function Documentation

void lem::AlignLibToVtx::beginJob ( )
virtual

Reimplemented from art::EDProducer.

Definition at line 81 of file AlignLibToVtx_module.cc.

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

82  {
84  fTreeOut = tfs->make<TTree>("tree", "tree");
86  }
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
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::AlignLibToVtx::produce ( art::Event evt)
virtual

Implements art::EDProducer.

Definition at line 100 of file AlignLibToVtx_module.cc.

References abs(), ana::assert(), getBrightness::cell, lem::LiteHit::Cell(), lem::DefaultVertex(), DEFINE_ART_MODULE(), art::Event::event(), lem::EventSummary::FromTree(), fSlicerLabel, fTreeIn, fTreeOut, fVertexLabel, geom(), art::DataViewImpl::getByLabel(), GetEntries(), make_syst_table_plots::h, lem::EventSummary::hits, MECModelEnuComparisons::i, lem::kVertexCell, lem::kVertexPlane, geo::PlaneGeo::Ncells(), lem::EventSummary::nhits, geo::GeometryBase::NPlanes(), lem::LiteHit::Plane(), geo::GeometryBase::Plane(), NDAPDHVSetting::plane, art::Event::put(), lem::LiteHit::SetCell(), lem::LiteHit::SetPlane(), sum, lem::EventSummary::ToTree(), lem::EventSummary::trueVtxCell, lem::EventSummary::trueVtxCellOther, lem::EventSummary::trueVtxPlane, and lem::VertexToPlaneAndCell().

101  {
102  std::unique_ptr<std::vector<geo::OfflineChan> > chancol(new std::vector<geo::OfflineChan>);
103 
105 
107  evt.getByLabel(fVertexLabel, vtxs);
108 
110  evt.getByLabel(fSlicerLabel, slices);
111  assert(slices->size() == 2); // The real slice, plus the noise slice
112  const rb::Cluster& slice = (*slices)[1];
113  assert(!slice.IsNoise());
114 
115  int plane, cell, cellOther;
116  if(vtxs->size() == 1){
117  VertexToPlaneAndCell((*vtxs)[0].GetXYZ(), slice, plane, cell, cellOther);
118  }
119  else{
120  DefaultVertex(slice, plane, cell, cellOther);
121  }
122 
123  chancol->push_back(geo::OfflineChan(plane, cell));
124  // Should really be nextPlane, but that's lost inside of Util.cxx. This is
125  // almost always right, and only for display purposes anyway.
126  chancol->push_back(geo::OfflineChan(plane+1, cellOther));
127 
128  evt.put(std::move(chancol));
129 
130 
131  const int trIdx = evt.event()-1;
132  // Should be exactly the same file
133  assert(trIdx < fTreeIn->GetEntries());
134 
135  // This is the offset GenFromLib applied to put the event in the middle of
136  // the detector. Take it out again here.
137  const int plane0 = geom->NPlanes()/2-128;
138  const int cell0 = geom->Plane(0)->Ncells()/2-128;
139 
140  // Doesn't matter if we say it's enriched or not
141  EventSummary sum = EventSummary::FromTree(fTreeIn, trIdx, false);
142 
143  // Occasionally fails, should just be a warning.
144  // assert(sum.hits.size() == slice.NCell());
145 
146  const int recoVtxPlane = plane-plane0;
147  const int recoVtxCell = cell-cell0;
148  const int recoVtxCellOtherView = cellOther-cell0;
149 
150  for(int i = 0; i < sum.nhits; ++i){
151  lem::LiteHit& h = sum.hits[i];
152 
153  const int planeDelta = h.Plane()-recoVtxPlane;
154  const int cellDelta = ((abs(planeDelta)%2) ?
155  h.Cell()-recoVtxCellOtherView :
156  h.Cell()-recoVtxCell);
157 
158  h.SetPlane(planeDelta+lem::kVertexPlane);
159  h.SetCell(cellDelta+lem::kVertexCell);
160  }
161 
162  // Transform the true vertex the same way
163  const int planeDelta = sum.trueVtxPlane-recoVtxPlane;
164  const int cellDelta = ((abs(planeDelta)%2) ?
165  sum.trueVtxCell-recoVtxCellOtherView :
166  sum.trueVtxCell-recoVtxCell);
167  const int cellDeltaOther = ((abs(planeDelta)%2) ?
168  sum.trueVtxCellOther-recoVtxCell :
169  sum.trueVtxCellOther-recoVtxCellOtherView);
170 
171  sum.trueVtxPlane = planeDelta+lem::kVertexPlane;
172  sum.trueVtxCell = cellDelta+lem::kVertexCell;
173  sum.trueVtxCellOther = cellDeltaOther+lem::kVertexCell;
174 
175  sum.ToTree(fTreeOut);
176  }
void VertexToPlaneAndCell(const TVector3 vtx, const rb::Cluster &slice, int &plane, int &cell, int &cellOtherView, bool reverse)
Definition: Util.cxx:60
unsigned int Ncells() const
Number of cells in this plane.
Definition: PlaneGeo.h:43
const int kVertexPlane
Definition: EventSummary.h:22
A collection of associated CellHits.
Definition: Cluster.h:47
void abs(TH1 *hist)
int Cell() const
Definition: LiteHit.h:39
const PlaneGeo * Plane(unsigned int i) const
cout<< t1-> GetEntries()
Definition: plottest35.C:29
void SetPlane(int p)
Definition: LiteHit.h:41
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
void DefaultVertex(const rb::Cluster &slice, int &plane, int &cell, int &cellOtherView, bool reverse)
Definition: Util.cxx:20
int Plane() const
Definition: LiteHit.h:38
const int kVertexCell
Definition: EventSummary.h:23
static EventSummary FromTree(TTree *tr, int evtIdx, bool enrich)
EventNumber_t event() const
Definition: Event.h:67
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
A (plane, cell) pair.
Definition: OfflineChan.h:17
void geom(int which=0)
Definition: geom.C:163
assert(nhit_max >=nhit_nbins)
void SetCell(int c)
Definition: LiteHit.h:42
unsigned int NPlanes() const
Compressed hit info, basic component of LEM events.
Definition: LiteHit.h:18
Double_t sum
Definition: plot.C:31
void lem::AlignLibToVtx::reconfigure ( const fhicl::ParameterSet pset)
virtual

Definition at line 69 of file AlignLibToVtx_module.cc.

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

Referenced by AlignLibToVtx().

70  {
71  fVertexLabel = pset.get<std::string>("VertexLabel");
72  fSlicerLabel = pset.get<std::string>("SlicerLabel");
73 
74  // We want to store exactly the values of the hits, only rescale them later
75  // when actually doing matching.
78  }
static double fgChargePower
Definition: EventSummary.h:76
T get(std::string const &key) const
Definition: ParameterSet.h:231
static double fgDecayRate
Definition: EventSummary.h:75
enum BeamMode string
void lem::AlignLibToVtx::respondToOpenInputFile ( const art::FileBlock fb)
virtual

Definition at line 89 of file AlignLibToVtx_module.cc.

References ana::assert(), art::FileBlock::fileName(), fin, fTreeIn, and lem::EventSummary::InitFromTree().

90  {
91  TFile* fin = new TFile(fb.fileName().c_str());
92  assert(!fin->IsZombie());
93  fTreeIn = (TTree*)fin->Get("makelib/tree");
94  assert(fTreeIn);
95 
97  }
TString fin
Definition: Style.C:24
std::string const & fileName() const
Definition: FileBlock.h:38
static void InitFromTree(TTree *tr)
assert(nhit_max >=nhit_nbins)
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 lem::AlignLibToVtx::fSlicerLabel
protected

Definition at line 49 of file AlignLibToVtx_module.cc.

Referenced by produce(), and reconfigure().

TTree* lem::AlignLibToVtx::fTreeIn
protected

Definition at line 46 of file AlignLibToVtx_module.cc.

Referenced by produce(), and respondToOpenInputFile().

TTree* lem::AlignLibToVtx::fTreeOut
protected

Definition at line 47 of file AlignLibToVtx_module.cc.

Referenced by beginJob(), and produce().

std::string lem::AlignLibToVtx::fVertexLabel
protected

Definition at line 50 of file AlignLibToVtx_module.cc.

Referenced by produce(), and reconfigure().


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