Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
novaddt::Calibration Class Reference
Inheritance diagram for novaddt::Calibration:
art::EDAnalyzer art::EventObserverBase art::Consumer art::EngineCreator

Public Types

using WorkerType = WorkerT< EDAnalyzer >
 
using ModuleType = EDAnalyzer
 

Public Member Functions

 Calibration (fhicl::ParameterSet const &p)
 
 Calibration (Calibration const &)=delete
 
 Calibration (Calibration &&)=delete
 
Calibrationoperator= (Calibration const &)=delete
 
Calibrationoperator= (Calibration &&)=delete
 
void analyze (art::Event const &e) override
 
void beginJob () override
 
void endJob () override
 
std::string workerType () const
 
bool modifiesEvent () const
 
void registerProducts (MasterProductRegistry &, ProductDescriptions &, ModuleDescription const &)
 
std::string const & processName () const
 
bool wantAllEvents () const
 
bool wantEvent (Event const &e)
 
fhicl::ParameterSetID selectorConfig () const
 
art::Handle< art::TriggerResultsgetTriggerResults (Event const &e) 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
 
detail::CachedProducts & cachedProducts ()
 
void validateConsumedProduct (BranchType const bt, ProductInfo const &pi)
 
void prepareForJob (fhicl::ParameterSet const &pset)
 
void showMissingConsumes () const
 

Private Member Functions

void accumulate (art::Event const &e)
 
void recalibrate ()
 
TH2I * MakeNoiseHisto (const novaddt::calib::FDHitMap &m)
 
novaddt::HitSet fetchAllTrackHits (const art::Event &event)
 

Private Attributes

unsigned _EventCounter = 0
 
unsigned _EventsToCollect = 50
 
std::vector< std::string_hits_id
 
std::vector< std::string_tracks_id
 
TProfile * _histAtt
 

Detailed Description

Definition at line 42 of file Calibration_module.cc.

Member Typedef Documentation

Definition at line 39 of file EDAnalyzer.h.

Definition at line 38 of file EDAnalyzer.h.

Constructor & Destructor Documentation

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

Definition at line 99 of file Calibration_module.cc.

99  :
100  EDAnalyzer(p),
101  _hits_id(p.get<std::vector<std::string>>("hits_id")),
102  _tracks_id(p.get<std::vector<std::string>>("tracks_id"))
103 {
104 }
std::vector< std::string > _tracks_id
const char * p
Definition: xmltok.h:285
EDAnalyzer(Table< Config > const &config)
Definition: EDAnalyzer.h:100
std::vector< std::string > _hits_id
novaddt::Calibration::Calibration ( Calibration const &  )
delete
novaddt::Calibration::Calibration ( Calibration &&  )
delete

Member Function Documentation

void novaddt::Calibration::accumulate ( art::Event const &  e)
private
void novaddt::Calibration::analyze ( art::Event const &  e)
overridevirtual

Implements art::EDAnalyzer.

Definition at line 106 of file Calibration_module.cc.

References _EventCounter, _histAtt, _hits_id, _tracks_id, std::abs(), om::cout, E, allTimeWatchdog::endl, fetchAllTrackHits(), FindE(), FindW(), art::DataViewImpl::getByLabel(), MakeNoiseHisto(), nt, novaddt::HitSet::subtract(), and W.

107 {
108  ++_EventCounter;
109  // Hitlist from event (input)
111  e.getByLabel(_hits_id[0],_hits_id[1], hitsHandle);
112 
113  //Create a set of all hits in tracks
114  novaddt::HitSet allTrackHits=fetchAllTrackHits(e);
115  novaddt::HitSet freeHits(*hitsHandle);
116  freeHits.subtract(allTrackHits);
117 
118  //get access to the shared hit map
120  //increment event counter
121  std::cout<<"Counter="<<cms->getCounter()<<std::endl;
122  cms->addCounter();
123  //obtain sharable lock, to indicate we're currently R\W data in map
124  auto lock = cms->GetLock();
125  auto &NoiseMap = cms->GetWMap();
126  //fill the hits map
127  for(const auto &hit: freeHits)
128  NoiseMap[hit]+=1;
129 
130  //now try reading the previous map
131  if(cms->getCounter()==1){
132  MakeNoiseHisto(cms->GetRMap());
133  }
134  //do the attenuation calibration:
135  //read tracks from event
137  e.getByLabel(_tracks_id[0],_tracks_id[1], tracksHandle);
138  //get associated hits
139  art::FindOneP<novaddt::HitList> fohl(tracksHandle, e, _tracks_id[0]);
140  for(size_t nt = 0; nt < tracksHandle->size(); ++nt){
141  auto track=tracksHandle->at(nt);
142  //skip non-3D tracks
143  if(track.Is3D() == false)continue;
144  //skip too vertical tracks
145  if(std::abs(track.End().Z()-track.Start().Z())<30)continue;
146  //track direction cosine
147  //double Cz = (track.End()-track.Start()).CosTheta();
148  //get all hits for this track
149  art::Ptr<novaddt::HitList> trackHits = fohl.at(nt);
150 
151  for(const auto& hit: *trackHits){
152  //get the distance from hit to the center of detector
153  double W=FindW(track,hit);
154  double E=FindE(track,hit);
155  /* std::cout<<"hit (ADC="<<hit.ADC().val
156  <<", cell="<<hit.Cell().val
157  <<", plane="<<hit.Plane().val
158  <<",view="<<hit.View().val<<")"
159  <<" W = "<<W
160  <<" E = "<<E
161  <<std::endl;*/
162  _histAtt->Fill(W,E);
163  }
164 
165  }
166 
167 }
std::vector< std::string > _tracks_id
TH2I * MakeNoiseHisto(const novaddt::calib::FDHitMap &m)
Definition: event.h:19
float abs(float number)
Definition: d0nt_math.hpp:39
novaddt::HitSet fetchAllTrackHits(const art::Event &event)
Float_t E
Definition: plot.C:20
OStream cout
Definition: OStream.cxx:6
Definition: structs.h:12
Float_t e
Definition: plot.C:35
TNtuple * nt
Definition: drawXsec.C:2
#define W(x)
double FindW(const novaddt::Track3D &t, const novaddt::DAQHit &h)
Definition: fwd.h:28
double FindE(const novaddt::Track3D &t, const novaddt::DAQHit &h)
std::vector< std::string > _hits_id
void novaddt::Calibration::beginJob ( )
overridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 198 of file Calibration_module.cc.

References _EventsToCollect, _histAtt, _hits_id, _tracks_id, om::cout, allTimeWatchdog::endl, and art::TFileDirectory::make().

199 {
200  std::cout<<"---- Calibration analyzer options -----"<<std::endl;
201  std::cout<<"\tEventsToCollect = "<<_EventsToCollect <<std::endl;
202  std::cout<<"\tInput hits label = ["<<_hits_id[0] <<" : "<<_hits_id[1] <<"]"<<std::endl;
203  std::cout<<"\tInput tracks label = ["<<_tracks_id[0]<<" : "<<_tracks_id[1]<<"]"<<std::endl;
205  _histAtt=tfs->make<TProfile>("hAtt","Attenuation;#cell;ADC_{corr}",
206  200,0,384);
207 }
std::vector< std::string > _tracks_id
OStream cout
Definition: OStream.cxx:6
T * make(ARGS...args) const
std::vector< std::string > _hits_id
detail::CachedProducts& art::EventObserverBase::cachedProducts ( )
inlineprotectedinherited

Definition at line 79 of file EventObserverBase.h.

References art::EventObserverBase::selectors_.

80  {
81  return selectors_;
82  }
detail::CachedProducts selectors_
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::EDAnalyzer::currentContext ( ) const
protectedinherited
void novaddt::Calibration::endJob ( )
overridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 209 of file Calibration_module.cc.

References DEFINE_ART_MODULE().

210 {
211  // Implementation of optional member function here.
212 }
novaddt::HitSet novaddt::Calibration::fetchAllTrackHits ( const art::Event event)
private

Definition at line 169 of file Calibration_module.cc.

References _tracks_id, and novaddt::HitSet::add().

Referenced by analyze().

169  {
170  //Create a set of all hits, that belong to tracks
171  novaddt::HitSet allTrackHits;
172  //Fill this set from tracks
174  event.getByLabel(_tracks_id[0],_tracks_id[1],trackHitLists);
175  for(const auto& trackHits: *trackHitLists)
176  allTrackHits.add(trackHits);
177  return allTrackHits;
178 }
std::vector< std::string > _tracks_id
void add(const AnyCollection &v)
Definition: HitSet.h:24
seed_t art::EngineCreator::get_seed_value ( fhicl::ParameterSet const &  pset,
char const  key[] = "seed",
seed_t const  implicit_seed = -1 
)
inherited
art::Handle<art::TriggerResults> art::EventObserverBase::getTriggerResults ( Event const &  e) const
inlineinherited

Definition at line 61 of file EventObserverBase.h.

References art::detail::CachedProducts::getOneTriggerResults(), and art::EventObserverBase::selectors_.

62  {
64  }
detail::CachedProducts selectors_
art::Handle< art::TriggerResults > getOneTriggerResults(Event const &) const
Float_t e
Definition: plot.C:35
TH2I * novaddt::Calibration::MakeNoiseHisto ( const novaddt::calib::FDHitMap m)
private

Definition at line 181 of file Calibration_module.cc.

References _EventCounter, om::cout, allTimeWatchdog::endl, analysePickle::hist, m, art::TFileDirectory::make(), nc, novaddt::calib::HitMap< T, Dimension >::Ncells(), novaddt::calib::HitMap< T, Dimension >::Nplanes(), sum, and febshutoff_auto::val.

Referenced by analyze().

181  {
183  auto hist=tfs->make<TH2I>(Form("h_%d",_EventCounter),
184  Form("Noise, event #%d",_EventCounter),
185  m.Nplanes(),0,m.Nplanes(),
186  m.Ncells(),0,m.Ncells());
187  uint64_t sum=0;
188  for(size_t nc=0;nc<m.Ncells();++nc)
189  for(size_t np=0;np<m.Nplanes();++np){
190  auto val=m(novaddt::Plane(np),novaddt::Cell(nc));
191  sum+=val;
192  hist->SetBinContent(np,nc,val);
193  }
194  std::cout<<"Made hist with "<<sum<<" hits"<<std::endl;
195  return hist;
196 }
static size_t Ncells()
Definition: HitMap.h:35
static size_t Nplanes()
Definition: HitMap.h:34
OStream cout
Definition: OStream.cxx:6
T * make(ARGS...args) const
enum BeamMode nc
Double_t sum
Definition: plot.C:31
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::EventObserverBase::modifiesEvent ( ) const
inlineinherited

Definition at line 25 of file EventObserverBase.h.

26  {
27  return false;
28  }
static cet::exempt_ptr<Consumer> art::Consumer::non_module_context ( )
staticinherited
Calibration& novaddt::Calibration::operator= ( Calibration const &  )
delete
Calibration& novaddt::Calibration::operator= ( Calibration &&  )
delete
void art::Consumer::prepareForJob ( fhicl::ParameterSet const &  pset)
protectedinherited
std::string const& art::EventObserverBase::processName ( ) const
inlineinherited
void novaddt::Calibration::recalibrate ( )
private
void art::EventObserverBase::registerProducts ( MasterProductRegistry ,
ProductDescriptions ,
ModuleDescription const &   
)
inlineinherited

Definition at line 33 of file EventObserverBase.h.

References string.

36  {}
fhicl::ParameterSetID art::EventObserverBase::selectorConfig ( ) const
inlineinherited

Definition at line 56 of file EventObserverBase.h.

References art::EventObserverBase::selector_config_id_.

57  {
58  return selector_config_id_;
59  }
fhicl::ParameterSetID selector_config_id_
void art::Consumer::showMissingConsumes ( ) const
protectedinherited

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

void art::Consumer::validateConsumedProduct ( BranchType const  bt,
ProductInfo const &  pi 
)
protectedinherited
bool art::EventObserverBase::wantAllEvents ( ) const
inlineinherited

Definition at line 46 of file EventObserverBase.h.

References art::EventObserverBase::wantAllEvents_.

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

47  {
48  return wantAllEvents_;
49  }
bool art::EventObserverBase::wantEvent ( Event const &  e)
inlineinherited

Definition at line 51 of file EventObserverBase.h.

References art::EventObserverBase::selectors_, and art::detail::CachedProducts::wantEvent().

52  {
53  return selectors_.wantEvent(e);
54  }
detail::CachedProducts selectors_
Float_t e
Definition: plot.C:35
bool wantEvent(Event const &)
std::string art::EDAnalyzer::workerType ( ) const
inlineinherited

Definition at line 109 of file EDAnalyzer.h.

References art::EDAnalyzer::currentContext().

110  {
111  return "WorkerT<EDAnalyzer>";
112  }

Member Data Documentation

unsigned novaddt::Calibration::_EventCounter = 0
private

Definition at line 69 of file Calibration_module.cc.

Referenced by analyze(), and MakeNoiseHisto().

unsigned novaddt::Calibration::_EventsToCollect = 50
private

Definition at line 70 of file Calibration_module.cc.

Referenced by beginJob().

TProfile* novaddt::Calibration::_histAtt
private

Definition at line 73 of file Calibration_module.cc.

Referenced by analyze(), and beginJob().

std::vector<std::string> novaddt::Calibration::_hits_id
private

Definition at line 71 of file Calibration_module.cc.

Referenced by analyze(), and beginJob().

std::vector<std::string> novaddt::Calibration::_tracks_id
private

Definition at line 72 of file Calibration_module.cc.

Referenced by analyze(), beginJob(), and fetchAllTrackHits().


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