Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
novaddt::NNFastMMTrigger Class Reference
Inheritance diagram for novaddt::NNFastMMTrigger:
art::EDFilter art::ProducerBase art::Consumer art::EngineCreator art::ProductRegistryHelper

Public Types

using ModuleType = EDFilter
 
using WorkerType = WorkerT< EDFilter >
 
template<typename UserConfig >
using Table = ProducerBase::Table< UserConfig >
 

Public Member Functions

 NNFastMMTrigger (fhicl::ParameterSet const &p)
 
virtual ~NNFastMMTrigger ()
 
virtual bool filter (art::Event &e) override
 
void beginJob () override
 
void endJob () override
 
void StdevCellsPerPlane (HitList const &hits, double &stdev_cells_per_plane_xview, double &stdev_cells_per_plane_yview) const
 
void NumberOfCellsPerLength (HitList const &hits, double tracklength_of_xview, double tracklength_of_yview, double &number_of_cells_per_length_xview, double &number_of_cells_per_length_yview) const
 
float Distance (unsigned const &xcell1, unsigned const &ycell1, unsigned const &plane1, unsigned const &xcell2, unsigned const &ycell2, unsigned const &plane2) const
 
bool SurfAssign (DAQHit const &hit) const
 
double WeightedCenterCut (HitList const &hits, float PX_min, float PX_max, float PY_min, float PY_max, float CX_min, float CX_max, float CY_min, float CY_max, double &weighted_off_center_xx, double &weighted_off_center_xz, double &weighted_off_center_yy, double &weighted_off_center_yz) const
 
double NumberOfHitsInOverlapPlanesCut (HitList const &hits, float PX_min, float PX_max, float PY_min, float PY_max) const
 
int NumberOfSurfaceHits (HitList const &hits) const
 
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 ()
 

Static Public Attributes

static constexpr bool Pass {true}
 
static constexpr bool Fail {false}
 

Protected Member Functions

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

Private Member Functions

void LinFit (const std::vector< double > &x, const std::vector< double > &y, double *fitpar)
 

Private Attributes

unsigned _prescale
 
std::string _slicelabel
 
std::string _sliceinstance
 
std::string _monopole_id_lib_path
 
int _xMin
 
int _xMax
 
int _yMin
 
int _yMax
 
int _zMin
 
int _zMax
 
int _deltx
 
int _delty
 
int _deltz
 
int _sigmaP
 
int PX_max
 
int PY_max
 
int PX_min
 
int PY_min
 
int CX_max
 
int CX_min
 
int CY_max
 
int CY_min
 
TDC::value_type TX_max
 
TDC::value_type TY_max
 
TDC::value_type TX_min
 
TDC::value_type TY_min
 
int _verbose
 
unsigned _trigger_counts
 
keras::KerasModel_model =NULL
 

Detailed Description

Definition at line 45 of file NNFastMMTrigger_module.cc.

Member Typedef Documentation

using art::EDFilter::ModuleType = EDFilter
inherited

Definition at line 37 of file EDFilter.h.

template<typename UserConfig >
using art::EDFilter::Table = ProducerBase::Table<UserConfig>
inherited

Definition at line 46 of file EDFilter.h.

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

Definition at line 38 of file EDFilter.h.

Constructor & Destructor Documentation

novaddt::NNFastMMTrigger::NNFastMMTrigger ( fhicl::ParameterSet const &  p)
explicit

Definition at line 70 of file NNFastMMTrigger_module.cc.

71  :
72  _prescale(p.get<unsigned>("prescale")),
73  _slicelabel(p.get<std::string>("slice_label")),
74  _sliceinstance(p.get<std::string>("slice_instance")),
75  _monopole_id_lib_path(p.get<std::string>("MONOPOLEIDLibPath")),
76  _xMin(p.get<int>("x_min")),
77  _xMax(p.get<int>("x_max")),
78  _yMin(p.get<int>("y_min")),
79  _yMax(p.get<int>("y_max")),
80  _zMin(p.get<int>("z_min")),
81  _zMax(p.get<int>("z_max")),
82  _deltx(p.get<int>("x_delt")),
83  _delty(p.get<int>("y_delt")),
84  _deltz(p.get<int>("z_delt")),
85  _sigmaP(p.get<int>("sigma_P")),
86  _verbose(p.get<int>("verbose")),
88 {
89  // Call appropriate Produces<>() functions here.
90  produces<std::vector<TriggerDecision>>();
91 }
const char * p
Definition: xmltok.h:285
enum BeamMode string
novaddt::NNFastMMTrigger::~NNFastMMTrigger ( )
virtual

Definition at line 93 of file NNFastMMTrigger_module.cc.

93  {
94  // Clean up dynamic memory and other resources here.
95 }

Member Function Documentation

void novaddt::NNFastMMTrigger::beginJob ( )
overridevirtual

Reimplemented from art::EDFilter.

Definition at line 97 of file NNFastMMTrigger_module.cc.

References _model, and _monopole_id_lib_path.

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::EDFilter::currentContext ( ) const
protectedinherited
float novaddt::NNFastMMTrigger::Distance ( unsigned const &  xcell1,
unsigned const &  ycell1,
unsigned const &  plane1,
unsigned const &  xcell2,
unsigned const &  ycell2,
unsigned const &  plane2 
) const

Definition at line 410 of file NNFastMMTrigger_module.cc.

References std::sqrt().

Referenced by filter().

410  {
411  return std::sqrt((plane1-plane2)*(plane1-plane2)*2.82072+(xcell1-xcell2)*(xcell1-xcell2)+(ycell1-ycell2)*(ycell1-ycell2));
412 }
T sqrt(T number)
Definition: d0nt_math.hpp:156
void novaddt::NNFastMMTrigger::endJob ( )
overridevirtual

Reimplemented from art::EDFilter.

Definition at line 100 of file NNFastMMTrigger_module.cc.

References _model.

100  {
101  delete _model;
102 }
bool novaddt::NNFastMMTrigger::filter ( art::Event e)
overridevirtual

Implements art::EDFilter.

Definition at line 104 of file NNFastMMTrigger_module.cc.

References _deltx, _delty, _deltz, _model, _prescale, _sigmaP, _sliceinstance, _slicelabel, _trigger_counts, _verbose, _xMax, _xMin, _yMax, _yMin, _zMax, _zMin, keras::KerasModel::compute_output(), om::cout, CX_max, CX_min, CY_max, CY_min, deltaTDC(), Distance(), allTimeWatchdog::endl, art::DataViewImpl::getByLabel(), hits(), MECModelEnuComparisons::i, boost::math::isfinite(), LinFit(), std::max(), std::min(), NumberOfSurfaceHits(), art::Event::put(), PX_max, PX_min, PY_max, PY_min, fillBadChanDBTables::result, keras::DataChunk::set_data(), std::sqrt(), StdevCellsPerPlane(), daqdataformats::TRIG_ID_DATA_FASTMONONN, TX_max, TX_min, TY_max, TY_min, registry_explorer::v, WeightedCenterCut(), and daqchannelmap::X_VIEW.

104  {
105  bool result = false;
106  std::unique_ptr<std::vector<TriggerDecision>>
107  trigger_decisions(new std::vector<TriggerDecision>);
110 
111  for (unsigned i = 0; i!= slices->size(); ++i) {
112  HitList const &hits = (*slices)[i];
113  PX_max = 0;//P is short for plane.
114  CX_max = 0;//C is short for cell.
115  CY_max = 0;
116  PY_max = 0;
117  PX_min = 99999;
118  CX_min = 99999;
119  CY_min = 99999;
120  PY_min = 99999;
121  TX_max = hits.front().TDC().val;
122  TY_max = TX_max;
123  TX_min = hits.back().TDC().val;
124  TY_min = TX_min;
125  if(_verbose != 0){
126  int nb_hits = hits.size();
127  std::cout<<"slice number = "<<i+1<<" number of hits: "<<nb_hits<<std::endl;
128  }
129  int entry_id = 0, nx = 0, ny = 0;
130  bool PassThrough = false, Intrusion = false;
131  double meanADC = 0, stdevADC = 0, sq_sum_ADC = 0;
132 
133  std::vector<double> x_hit, y_hit, zy_hit, zx_hit;
134  for (auto const hit: hits) {
135  if(_verbose != 0) std::cout<<"TDC: "<<hit.TDC().val << " ADC: "<<hit.ADC().val<<" Plane: "<<hit.Plane().val<<" Cell: "<<hit.Cell().val<<std::endl;
136  //X view hits
137  meanADC += hit.ADC().val;
138  sq_sum_ADC += hit.ADC().val*hit.ADC().val;
139  if (hit.View().val == daqchannelmap::X_VIEW) {
140  if(_verbose != 0) std::cout<<"X hits"<<std::endl;
141  ++nx;
142  x_hit.push_back(hit.Cell().val);
143  zx_hit.push_back(hit.Plane().val);
144  if (PX_max < hit.Plane().val) PX_max = hit.Plane().val;
145  if (PX_min > hit.Plane().val) PX_min = hit.Plane().val;
146  if (CX_max < hit.Cell().val) CX_max = hit.Cell().val;
147  if (CX_min > hit.Cell().val) CX_min = hit.Cell().val;
148  if (TX_max < hit.TDC().val) TX_max = hit.TDC().val;
149  if (TX_min > hit.TDC().val) TX_min = hit.TDC().val;
150  if (!Intrusion) {
151  if (hit.Cell().val < _xMin+_deltx) {
152  entry_id = 1;
153  Intrusion = true;
154  }
155  else if (hit.Cell().val> _xMax-_deltx) {
156  entry_id = 2;
157  Intrusion = true;
158  }
159  }
160  else if (!PassThrough) {
161  if (hit.Cell().val < _xMin+_deltx && entry_id != 1) PassThrough = true;
162  else if (hit.Cell().val> _xMax-_deltx && entry_id != 2) PassThrough = true;
163  }
164  }
165  //Y view hits
166  else {
167  if(_verbose != 0) std::cout<<"Y hits"<<std::endl;
168  ++ny;
169  y_hit.push_back(hit.Cell().val);
170  zy_hit.push_back(hit.Plane().val);
171  if (PY_max < hit.Plane().val) PY_max = hit.Plane().val;
172  if (PY_min > hit.Plane().val) PY_min = hit.Plane().val;
173  if (CY_max < hit.Cell().val) CY_max = hit.Cell().val;
174  if (CY_min > hit.Cell().val) CY_min = hit.Cell().val;
175  if (TY_max < hit.TDC().val ) TY_max = hit.TDC().val;
176  if (TY_min > hit.TDC().val ) TY_min = hit.TDC().val;
177  if (!Intrusion) {
178  if (hit.Cell().val < _yMin+_delty) {
179  entry_id = 3;
180  Intrusion = true;
181  }
182  else if (hit.Cell().val> _yMax-_delty) {
183  entry_id = 4;
184  Intrusion = true;
185  }
186  }
187  else if (!PassThrough) {
188  if (hit.Cell().val < _yMin+_delty && entry_id != 3) PassThrough = true;
189  else if (hit.Cell().val> _yMax-_delty && entry_id != 4) PassThrough = true;
190  }
191  }
192  //No matter which view:
193  if (!Intrusion) {
194  if (hit.Plane().val < _zMin+_deltz) {
195  entry_id = 5;
196  Intrusion = true;
197  }
198  else if (hit.Plane().val > _zMax-_deltz) {
199  entry_id = 6;
200  Intrusion = true;
201  }
202  }
203  else if (!PassThrough) {
204  if (hit.Plane().val < _zMin+_deltz && entry_id != 5) PassThrough=true;
205  else if (hit.Plane().val > _zMax-_deltz && entry_id != 6) PassThrough=true;
206  }
207  }
208  meanADC = meanADC/(nx+ny);
209 
210  //Min-hits on both view:
211  if(_verbose != 0) std::cout<<"xhits number : "<<nx<<" yhits number : "<<ny<<std::endl;
212  if (nx<10 || ny<10) continue;
213  if(_verbose != 0) std::cout<<"minimum hits requirement met!"<<std::endl;
214  //Passing Through Test:
215  if (!PassThrough) continue;
216  if(_verbose != 0) std::cout<<"through!"<<std::endl;
217  if(_verbose != 0) std::cout<<"X view Plane range: "<<PX_min<<" "<<PX_max<<std::endl;
218  if(_verbose != 0) std::cout<<"X view Cell range: "<<CX_min<<" "<<CX_max<<std::endl;
219  if(_verbose != 0) std::cout<<"X view time range: "<<TX_min<<" "<<TX_max<<std::endl;
220 
221  if(_verbose != 0) std::cout<<"Y view Plane range: "<<PY_min<<" "<<PY_max<<std::endl;
222  if(_verbose != 0) std::cout<<"Y view Cell range: "<<CY_min<<" "<<CY_max<<std::endl;
223  if(_verbose != 0) std::cout<<"Y view time range: "<<TY_min<<" "<<TY_max<<std::endl;
224 
225  //Matching Test:
226  double deltaP = std::max(PX_max,PY_max) - std::min(PX_min,PY_min);
228  if (std::min(PX_max,PY_max) < std::max(PX_min,PY_min)+_sigmaP) continue; //Require minimum overlapping planes
229  if (std::min(TX_max,TY_max) < std::max(TX_min,TY_min) ) continue;
230  //double preselection = 1;
231 
232  unsigned dT = std::max(TX_max,TY_max)-std::min(TX_min,TY_min);
233 
234  float tracklength =Distance(CX_max, CY_max, PX_max, CX_min, CY_min, PX_min);
235  double number_of_surface_hits = NumberOfSurfaceHits(hits);
236  if(_verbose != 0) std::cout<<"number of surface hits: "<<number_of_surface_hits<<std::endl;
237  if(_verbose != 0) std::cout<<"slice diagonal length: "<<tracklength<<std::endl;
238  if(_verbose != 0) std::cout<<"number of hits divided by slice diagonal length"<<hits.size()/tracklength<<std::endl;
239 
240  // Linear fit of the hits in XZ/YZ views.
241  double fitpar[3];
242  LinFit(x_hit, zx_hit, fitpar);
243  double r2x = 0;
244  if( std::isfinite(fitpar[2]))
245  r2x = fitpar[2];
246  LinFit(y_hit, zy_hit, fitpar);
247  //double r2y = 0;
248 
249  double number_of_cells_per_length_xview=0;
250  double number_of_cells_per_length_yview=0;
251  //double tracklength_of_xview=Distance(CX_max, 0, PX_max, CX_min, 0, PX_min);
252  //double tracklength_of_yview=Distance(0, CY_max, PY_max, 0, CY_min, PY_min);
253 // NumberOfCellsPerLength(hits,tracklength_of_xview,tracklength_of_yview,number_of_cells_per_length_xview,number_of_cells_per_length_yview);
254  if(_verbose != 0) std::cout<<"number of cells per length xview: "<<number_of_cells_per_length_xview<<" yview: "<<number_of_cells_per_length_yview<<std::endl;
255  double stdev_cells_per_plane_xview=0, stdev_cells_per_plane_yview=0;
256  StdevCellsPerPlane(hits, stdev_cells_per_plane_xview, stdev_cells_per_plane_yview);
257  if(_verbose != 0) std::cout<<"stdev cells per plane xview: "<<stdev_cells_per_plane_xview<<" yview: "<<stdev_cells_per_plane_yview<<std::endl;
258  double weighted_off_center_xx=0, weighted_off_center_xz=0, weighted_off_center_yy=0, weighted_off_center_yz=0;
259  WeightedCenterCut(hits, PX_min, PX_max, PY_min, PY_max, CX_min, CX_max, CY_min, CY_max, weighted_off_center_xx, weighted_off_center_xz, weighted_off_center_yy, weighted_off_center_yz );
260  if(_verbose != 0) std::cout<<"weighted off center xz: "<<weighted_off_center_xz<<" yz: "<<weighted_off_center_yz<<std::endl;
261  //double percentage_of_hits_in_overlap_planes = NumberOfHitsInOverlapPlanesCut(hits,PX_min,PX_max,PY_min,PY_max);
262  //if(_verbose != 0) std::cout<<"percent of hits in overlap planes: "<<percentage_of_hits_in_overlap_planes<<std::endl;
263  stdevADC = std::sqrt( sq_sum_ADC*1.0/(nx+ny) - meanADC*meanADC);
264  //Keras model
265  keras::DataChunk *sample = new keras::DataChunkFlat();
266  //Init input to keras model with normalization.
267  float myfloats[] = {(hits.size()/tracklength-0.0206254683435)/94.6383405961,
268  (stdev_cells_per_plane_xview-0.816496580928)/12.9743518339,
269  (stdev_cells_per_plane_yview-0.816496580928)/15.2366123639,
270  (weighted_off_center_yy-0.0)/0.499630220584,
271  (number_of_surface_hits-1.0)/30304.0,
272  (meanADC-239.074074074)/3603.61013645,
273  (stdevADC-8.75437337874)/1912.00668817,
274  (ny-3.0)/78720.0,
275  (deltaTDC-0.0)/27478.0,
276  (deltaP-3.0)/892.0,
277  (r2x-0.0)/1.0 };
278 
279  std::vector<float> v (myfloats, myfloats + sizeof(myfloats) / sizeof(float) );
280  if(_verbose!=0){
281  for (auto data_i : v)
282  std::cout<<data_i<<std::endl;
283  }
284  sample->set_data(v);
285  double score = _model->compute_output(sample)[0];
286  if(_verbose != 0) std::cout<< "Score is: "<< score<< std::endl;
287  delete sample;
288  if(score<0.5) continue;
289  ++_trigger_counts;
290 
292  trigger_decisions->
293  emplace_back(std::min(TX_min,TY_min),
294  dT,
296  result = true;
297  }
298  }
299  e.put(std::move(trigger_decisions));
300  return result;
301 }
T max(const caf::Proxy< T > &a, T b)
bool isfinite(const stan::math::var &v)
void LinFit(const std::vector< double > &x, const std::vector< double > &y, double *fitpar)
std::vector< DAQHit > HitList
Definition: HitList.h:15
T sqrt(T number)
Definition: d0nt_math.hpp:156
virtual void set_data(std::vector< std::vector< std::vector< float > > > const &)
Definition: KerasModel.h:38
std::vector< float > compute_output(keras::DataChunk *dc)
Definition: KerasModel.cxx:354
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
void hits()
Definition: readHits.C:15
Identifier for the X measuring view of the detector (top)
double deltaTDC(const novaddt::TDC &h1, const novaddt::TDC &h2)
OStream cout
Definition: OStream.cxx:6
float Distance(unsigned const &xcell1, unsigned const &ycell1, unsigned const &plane1, unsigned const &xcell2, unsigned const &ycell2, unsigned const &plane2) const
void StdevCellsPerPlane(HitList const &hits, double &stdev_cells_per_plane_xview, double &stdev_cells_per_plane_yview) const
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
Definition: structs.h:12
T min(const caf::Proxy< T > &a, T b)
double WeightedCenterCut(HitList const &hits, float PX_min, float PX_max, float PY_min, float PY_max, float CX_min, float CX_max, float CY_min, float CY_max, double &weighted_off_center_xx, double &weighted_off_center_xz, double &weighted_off_center_yy, double &weighted_off_center_yz) const
int NumberOfSurfaceHits(HitList const &hits) const
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::EDFilter::getProductID ( std::string const &  instanceName = {}) const
inlineinherited

Definition at line 131 of file EDFilter.h.

References art::EDFilter::moduleDescription_.

Referenced by novaddt::HoughTrackMaker::create_associations().

132  {
133  return ProducerBase::getProductID<PROD, B>(moduleDescription_,
134  instanceName);
135  }
ModuleDescription moduleDescription_
Definition: EDFilter.h:124
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  }
void novaddt::NNFastMMTrigger::LinFit ( const std::vector< double > &  x,
const std::vector< double > &  y,
double *  fitpar 
)
private

Definition at line 303 of file NNFastMMTrigger_module.cc.

References a, b, getGoodRuns4SAM::n, r(), std::sqrt(), submit_syst::x, xx, and submit_syst::y.

Referenced by filter().

303  {
304  // http://en.wikipedia.org/wiki/Simple_linear_regression
305  const auto n = x_val.size();
306  const auto x = (std::accumulate(x_val.begin(), x_val.end(), 0.0))/n; // <x>
307  const auto y = (std::accumulate(y_val.begin(), y_val.end(), 0.0))/n; // <y>
308  const auto xx = (std::inner_product(x_val.begin(), x_val.end(), x_val.begin(), 0.0))/n; // <xx>
309  const auto yy = (std::inner_product(y_val.begin(), y_val.end(), y_val.begin(), 0.0))/n; // <yy>
310  const auto xy = (std::inner_product(x_val.begin(), x_val.end(), y_val.begin(), 0.0))/n; // <xy>
311 
312  const auto b = (xy - x*y)/(xx - x*x); // slope
313  const auto a = y - b*x; // intercept
314  const auto r = (xy - x*y)/sqrt((xx - x*x)*(yy - y*y)); // Rxy - coeffcient of determination
315  fitpar[0] = a;
316  fitpar[1] = b;
317  fitpar[2] = r*r;
318 }
Double_t xx
Definition: macro.C:12
T sqrt(T number)
Definition: d0nt_math.hpp:156
const double a
const hit & b
Definition: hits.cxx:21
TRandom3 r(0)
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 novaddt::NNFastMMTrigger::NumberOfCellsPerLength ( HitList const &  hits,
double  tracklength_of_xview,
double  tracklength_of_yview,
double &  number_of_cells_per_length_xview,
double &  number_of_cells_per_length_yview 
) const

Definition at line 320 of file NNFastMMTrigger_module.cc.

References distance(), febshutoff_auto::end, MECModelEnuComparisons::i, it, PX_max, PX_min, PY_max, PY_min, daqchannelmap::X_VIEW, and daqchannelmap::Y_VIEW.

320  {
321  std::vector<std::vector<int>> x_hits_plane(PX_max-PX_min+1,std::vector<int>(0));
322  std::vector<std::vector<int>> y_hits_plane(PY_max-PY_min+1,std::vector<int>(0));
323  for (auto const hit: hits) {
324  if (hit.View().val == daqchannelmap::X_VIEW) {
325  //std::cout<<"X hits"<<std::endl;
326  x_hits_plane[hit.Plane().val-PX_min].push_back(hit.Cell().val);
327  }
328  if (hit.View().val == daqchannelmap::Y_VIEW) {
329  //std::cout<<"Y hits"<<std::endl;
330  y_hits_plane[hit.Plane().val-PY_min].push_back(hit.Cell().val);
331  }
332  }
333  //following is to get unique number of cells hit per plane
334  std::vector<int> x_cells_plane(PX_max-PX_min+1,0);
335  std::vector<int> y_cells_plane(PY_max-PY_min+1,0);
336  for (unsigned i=0;i!=x_hits_plane.size();i++){
337  std::sort(x_hits_plane[i].begin(),x_hits_plane[i].end());
338  std::vector<int>::iterator it;
339  it = std::unique (x_hits_plane[i].begin(),x_hits_plane[i].end());
340  x_hits_plane[i].resize(std::distance(x_hits_plane[i].begin(),it));
341  x_cells_plane[i]=x_hits_plane[i].size();
342  }
343  for (unsigned i=0;i!=y_hits_plane.size();i++){
344  std::sort(y_hits_plane[i].begin(),y_hits_plane[i].end());
345  std::vector<int>::iterator it;
346  it = std::unique (y_hits_plane[i].begin(),y_hits_plane[i].end());
347  y_hits_plane[i].resize(std::distance(y_hits_plane[i].begin(),it));
348  y_cells_plane[i]=y_hits_plane[i].size();
349  }
350  //following is to get number of cells per track length in x view and y view
351  int sum_of_cells=0;
352  for (unsigned i=0;i!=x_cells_plane.size();i++){
353  sum_of_cells+=x_cells_plane[i];
354  }
355  number_of_cells_per_length_xview=sum_of_cells/tracklength_of_xview;
356  sum_of_cells=0;
357  for (unsigned i=0;i!=y_cells_plane.size();i++){
358  sum_of_cells+=y_cells_plane[i];
359  }
360  number_of_cells_per_length_yview=sum_of_cells/tracklength_of_yview;
361 
362 }
set< int >::iterator it
unsigned distance(const T &t1, const T &t2)
Identifier for the Y measuring view of the detector (side)
void hits()
Definition: readHits.C:15
Identifier for the X measuring view of the detector (top)
Definition: structs.h:12
double novaddt::NNFastMMTrigger::NumberOfHitsInOverlapPlanesCut ( HitList const &  hits,
float  PX_min,
float  PX_max,
float  PY_min,
float  PY_max 
) const

Definition at line 455 of file NNFastMMTrigger_module.cc.

References DEFINE_ART_MODULE(), cet::sqlite::max(), std::max(), min(), and std::min().

455  {
456  int max=std::min(PX_max,PY_max);
457  int min=std::max(PX_min,PY_min);
458  double number_hits_in_overlap_planes=0;
459  for (auto const hit: hits) {
460  if(hit.Plane().val<=max && hit.Plane().val>=min) number_hits_in_overlap_planes++;
461  }
462  return number_hits_in_overlap_planes/hits.size();
463 }
T max(const caf::Proxy< T > &a, T b)
void hits()
Definition: readHits.C:15
static float min(const float a, const float b, const float c)
Definition: absgeo.cxx:45
Definition: structs.h:12
T min(const caf::Proxy< T > &a, T b)
T max(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:68
int novaddt::NNFastMMTrigger::NumberOfSurfaceHits ( HitList const &  hits) const

Definition at line 423 of file NNFastMMTrigger_module.cc.

References MECModelEnuComparisons::i, and SurfAssign().

Referenced by filter().

423  {
424  int number_of_surface_hits=0;
425  for(unsigned i=0;i!=hits.size();++i){
426  if(SurfAssign(hits[i])==true) number_of_surface_hits++;
427  }
428  return number_of_surface_hits;
429 }
bool SurfAssign(DAQHit const &hit) const
void hits()
Definition: readHits.C:15
void art::Consumer::prepareForJob ( fhicl::ParameterSet const &  pset)
protectedinherited
void art::Consumer::showMissingConsumes ( ) const
protectedinherited

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

void novaddt::NNFastMMTrigger::StdevCellsPerPlane ( HitList const &  hits,
double &  stdev_cells_per_plane_xview,
double &  stdev_cells_per_plane_yview 
) const

Definition at line 363 of file NNFastMMTrigger_module.cc.

References distance(), febshutoff_auto::end, MECModelEnuComparisons::i, it, extractScale::mean, PX_max, PX_min, PY_max, PY_min, std::sqrt(), HandyFuncs::stdev(), sum, daqchannelmap::X_VIEW, and daqchannelmap::Y_VIEW.

Referenced by filter().

363  {
364  //fluctuation of number of cells of each plane check by Enhao
365  std::vector<std::vector<int>> x_hits_plane(PX_max-PX_min+1,std::vector<int>(0));
366  std::vector<std::vector<int>> y_hits_plane(PY_max-PY_min+1,std::vector<int>(0));
367  for (auto const hit: hits) {
368  if (hit.View().val == daqchannelmap::X_VIEW) {
369  //std::cout<<"X hits"<<std::endl;
370  x_hits_plane[hit.Plane().val-PX_min].push_back(hit.Cell().val);
371  }
372  if (hit.View().val == daqchannelmap::Y_VIEW) {
373  //std::cout<<"Y hits"<<std::endl;
374  y_hits_plane[hit.Plane().val-PY_min].push_back(hit.Cell().val);
375  }
376  }
377  double sum = 0.;
378  double mean = 0.;
379  double sq_sum = 0.;
380  double stdev = 0.;
381  //double min_stdev = 0.;
382  //following is to get unique number of cells hit per plane
383  std::vector<int> x_cells_plane(PX_max-PX_min+1,0);
384  std::vector<int> y_cells_plane(PY_max-PY_min+1,0);
385  for (unsigned i=0;i!=x_hits_plane.size();i++){
386  std::sort(x_hits_plane[i].begin(),x_hits_plane[i].end());
387  std::vector<int>::iterator it;
388  it = std::unique (x_hits_plane[i].begin(),x_hits_plane[i].end());
389  x_hits_plane[i].resize(std::distance(x_hits_plane[i].begin(),it));
390  x_cells_plane[i]=x_hits_plane[i].size();
391  }
392  for (unsigned i=0;i!=y_hits_plane.size();i++){
393  std::sort(y_hits_plane[i].begin(),y_hits_plane[i].end());
394  std::vector<int>::iterator it;
395  it = std::unique (y_hits_plane[i].begin(),y_hits_plane[i].end());
396  y_hits_plane[i].resize(std::distance(y_hits_plane[i].begin(),it));
397  y_cells_plane[i]=y_hits_plane[i].size();
398  }
399  sum = std::accumulate(x_cells_plane.begin(),x_cells_plane.end(),0.0);
400  mean = sum / x_cells_plane.size();
401  sq_sum = std::inner_product(x_cells_plane.begin(),x_cells_plane.end(),x_cells_plane.begin(),0.0);
402  stdev = std::sqrt(sq_sum / x_cells_plane.size()-mean * mean);
403  stdev_cells_per_plane_xview=stdev/mean;
404  sum = std::accumulate(y_cells_plane.begin(),y_cells_plane.end(),0.0);
405  mean = sum / y_cells_plane.size();
406  sq_sum = std::inner_product(y_cells_plane.begin(),y_cells_plane.end(),y_cells_plane.begin(),0.0);
407  stdev = std::sqrt(sq_sum / y_cells_plane.size()-mean * mean);
408  stdev_cells_per_plane_yview=stdev/mean;
409 }
def stdev(lst)
Definition: HandyFuncs.py:286
set< int >::iterator it
T sqrt(T number)
Definition: d0nt_math.hpp:156
unsigned distance(const T &t1, const T &t2)
Identifier for the Y measuring view of the detector (side)
void hits()
Definition: readHits.C:15
Identifier for the X measuring view of the detector (top)
Definition: structs.h:12
Double_t sum
Definition: plot.C:31
bool novaddt::NNFastMMTrigger::SurfAssign ( DAQHit const &  hit) const

Definition at line 414 of file NNFastMMTrigger_module.cc.

References _deltx, _deltz, _xMax, _zMax, novaddt::DAQHit::Cell(), novaddt::DAQHit::Plane(), novaddt::Plane::val, and novaddt::Cell::val.

Referenced by NumberOfSurfaceHits().

414  {
415  //Check if this is close to surface
416  if ( hit.Cell().val > _xMax - _deltx ) return true;
417  else if ( hit.Cell().val < _deltx ) return true;
418  else if ( hit.Plane().val < _deltz ) return true;
419  else if ( hit.Plane().val > _zMax - _deltz ) return true;
420 
421  return false;
422 }
Definition: structs.h:12
void art::Consumer::validateConsumedProduct ( BranchType const  bt,
ProductInfo const &  pi 
)
protectedinherited
double novaddt::NNFastMMTrigger::WeightedCenterCut ( HitList const &  hits,
float  PX_min,
float  PX_max,
float  PY_min,
float  PY_max,
float  CX_min,
float  CX_max,
float  CY_min,
float  CY_max,
double &  weighted_off_center_xx,
double &  weighted_off_center_xz,
double &  weighted_off_center_yy,
double &  weighted_off_center_yz 
) const

Definition at line 430 of file NNFastMMTrigger_module.cc.

References std::abs(), CX_min, CY_min, std::max(), PX_min, PY_min, daqchannelmap::X_VIEW, and daqchannelmap::Y_VIEW.

Referenced by filter().

430  {
431  float Weighted_PX_Center=0.5,Weighted_CX_Center=0.5,Weighted_PY_Center=0.5,Weighted_CY_Center=0.5,SumOfXHitsADC=0,SumOfYHitsADC=0;
432  for (auto const hit: hits) {
433  if (hit.View().val == daqchannelmap::X_VIEW) {
434  SumOfXHitsADC+=hit.ADC().val;
435  Weighted_PX_Center+=hit.ADC().val*(hit.Plane().val-PX_min);
436  Weighted_CX_Center+=hit.ADC().val*(hit.Cell().val-CX_min);
437  }
438  if (hit.View().val == daqchannelmap::Y_VIEW) {
439  SumOfYHitsADC+=hit.ADC().val;
440  Weighted_PY_Center+=hit.ADC().val*(hit.Plane().val-PY_min);
441  Weighted_CY_Center+=hit.ADC().val*(hit.Cell().val-CY_min);
442  }
443  }
444  if(PX_max!=PX_min) Weighted_PX_Center=Weighted_PX_Center/SumOfXHitsADC/(PX_max-PX_min);
445  if(PY_max!=PY_min) Weighted_PY_Center=Weighted_PY_Center/SumOfYHitsADC/(PY_max-PY_min);
446  if(CX_max!=CX_min) Weighted_CX_Center=Weighted_CX_Center/SumOfXHitsADC/(CX_max-CX_min);
447  if(CY_max!=CY_min) Weighted_CY_Center=Weighted_CY_Center/SumOfYHitsADC/(CY_max-CY_min);
448  weighted_off_center_xx=std::abs(Weighted_CX_Center-0.5);
449  weighted_off_center_xz=std::abs(Weighted_PX_Center-0.5);
450  weighted_off_center_yy=std::abs(Weighted_CY_Center-0.5);
451  weighted_off_center_yz=std::abs(Weighted_PY_Center-0.5);
452  return std::max(std::max(std::abs(Weighted_PX_Center-0.5),std::abs(Weighted_PY_Center-0.5)),std::max(std::abs(Weighted_CX_Center-0.5),std::abs(Weighted_CY_Center-0.5)));
453 }
T max(const caf::Proxy< T > &a, T b)
float abs(float number)
Definition: d0nt_math.hpp:39
Identifier for the Y measuring view of the detector (side)
void hits()
Definition: readHits.C:15
Identifier for the X measuring view of the detector (top)
Definition: structs.h:12

Member Data Documentation

int novaddt::NNFastMMTrigger::_deltx
private

Definition at line 62 of file NNFastMMTrigger_module.cc.

Referenced by filter(), and SurfAssign().

int novaddt::NNFastMMTrigger::_delty
private

Definition at line 62 of file NNFastMMTrigger_module.cc.

Referenced by filter().

int novaddt::NNFastMMTrigger::_deltz
private

Definition at line 62 of file NNFastMMTrigger_module.cc.

Referenced by filter(), and SurfAssign().

keras::KerasModel* novaddt::NNFastMMTrigger::_model =NULL
private

Definition at line 67 of file NNFastMMTrigger_module.cc.

Referenced by beginJob(), endJob(), and filter().

std::string novaddt::NNFastMMTrigger::_monopole_id_lib_path
private

Definition at line 61 of file NNFastMMTrigger_module.cc.

Referenced by beginJob().

unsigned novaddt::NNFastMMTrigger::_prescale
private

Definition at line 60 of file NNFastMMTrigger_module.cc.

Referenced by filter().

int novaddt::NNFastMMTrigger::_sigmaP
private

Definition at line 62 of file NNFastMMTrigger_module.cc.

Referenced by filter().

std::string novaddt::NNFastMMTrigger::_sliceinstance
private

Definition at line 61 of file NNFastMMTrigger_module.cc.

Referenced by filter().

std::string novaddt::NNFastMMTrigger::_slicelabel
private

Definition at line 61 of file NNFastMMTrigger_module.cc.

Referenced by filter().

unsigned novaddt::NNFastMMTrigger::_trigger_counts
private

Definition at line 66 of file NNFastMMTrigger_module.cc.

Referenced by filter().

int novaddt::NNFastMMTrigger::_verbose
private

Definition at line 65 of file NNFastMMTrigger_module.cc.

Referenced by filter().

int novaddt::NNFastMMTrigger::_xMax
private

Definition at line 62 of file NNFastMMTrigger_module.cc.

Referenced by filter(), and SurfAssign().

int novaddt::NNFastMMTrigger::_xMin
private

Definition at line 62 of file NNFastMMTrigger_module.cc.

Referenced by filter().

int novaddt::NNFastMMTrigger::_yMax
private

Definition at line 62 of file NNFastMMTrigger_module.cc.

Referenced by filter().

int novaddt::NNFastMMTrigger::_yMin
private

Definition at line 62 of file NNFastMMTrigger_module.cc.

Referenced by filter().

int novaddt::NNFastMMTrigger::_zMax
private

Definition at line 62 of file NNFastMMTrigger_module.cc.

Referenced by filter(), and SurfAssign().

int novaddt::NNFastMMTrigger::_zMin
private

Definition at line 62 of file NNFastMMTrigger_module.cc.

Referenced by filter().

int novaddt::NNFastMMTrigger::CX_max
private

Definition at line 63 of file NNFastMMTrigger_module.cc.

Referenced by filter().

int novaddt::NNFastMMTrigger::CX_min
private

Definition at line 63 of file NNFastMMTrigger_module.cc.

Referenced by filter(), and WeightedCenterCut().

int novaddt::NNFastMMTrigger::CY_max
private

Definition at line 63 of file NNFastMMTrigger_module.cc.

Referenced by filter().

int novaddt::NNFastMMTrigger::CY_min
private

Definition at line 63 of file NNFastMMTrigger_module.cc.

Referenced by filter(), and WeightedCenterCut().

constexpr bool art::EDFilter::Fail {false}
staticinherited

Definition at line 33 of file EDFilter.h.

Referenced by evgen::GENIEFilter::filter().

constexpr bool art::EDFilter::Pass {true}
staticinherited

Definition at line 32 of file EDFilter.h.

Referenced by evgen::GENIEFilter::filter().

int novaddt::NNFastMMTrigger::PX_max
private

Definition at line 63 of file NNFastMMTrigger_module.cc.

Referenced by filter(), NumberOfCellsPerLength(), and StdevCellsPerPlane().

int novaddt::NNFastMMTrigger::PX_min
private
int novaddt::NNFastMMTrigger::PY_max
private

Definition at line 63 of file NNFastMMTrigger_module.cc.

Referenced by filter(), NumberOfCellsPerLength(), and StdevCellsPerPlane().

int novaddt::NNFastMMTrigger::PY_min
private
TDC::value_type novaddt::NNFastMMTrigger::TX_max
private

Definition at line 64 of file NNFastMMTrigger_module.cc.

Referenced by filter().

TDC::value_type novaddt::NNFastMMTrigger::TX_min
private

Definition at line 64 of file NNFastMMTrigger_module.cc.

Referenced by filter().

TDC::value_type novaddt::NNFastMMTrigger::TY_max
private

Definition at line 64 of file NNFastMMTrigger_module.cc.

Referenced by filter().

TDC::value_type novaddt::NNFastMMTrigger::TY_min
private

Definition at line 64 of file NNFastMMTrigger_module.cc.

Referenced by filter().


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