Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
dune::T0Counter Class Reference
Inheritance diagram for dune::T0Counter:
art::EDProducer art::detail::Producer art::detail::LegacyModule art::Modifier art::ModuleBase art::ProductRegistryHelper

Classes

struct  t0
 

Public Member Functions

 T0Counter (fhicl::ParameterSet const &p)
 
 T0Counter (T0Counter const &)=delete
 
 T0Counter (T0Counter &&)=delete
 
T0Counteroperator= (T0Counter const &)=delete
 
T0Counteroperator= (T0Counter &&)=delete
 
void produce (art::Event &e) override
 
void beginJob () override
 
- Public Member Functions inherited from art::EDProducer
 EDProducer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDProducer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Producer
virtual ~Producer () noexcept
 
 Producer (fhicl::ParameterSet const &)
 
 Producer (Producer const &)=delete
 
 Producer (Producer &&)=delete
 
Produceroperator= (Producer const &)=delete
 
Produceroperator= (Producer &&)=delete
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
- Public Member Functions inherited from art::Modifier
 ~Modifier () noexcept
 
 Modifier ()
 
 Modifier (Modifier const &)=delete
 
 Modifier (Modifier &&)=delete
 
Modifieroperator= (Modifier const &)=delete
 
Modifieroperator= (Modifier &&)=delete
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Private Member Functions

double tick2Time (unsigned int t)
 

Private Attributes

std::string fTriggerModuleLabel
 
double fClockSpeedCounter
 
double fCombinedTimeDelay
 
int fCoincidenceTolerance
 
bool fVerbose
 
bool fMakeTree
 
double fSampleTimeCounter
 
double fTriggerOffsetTPC
 
double t0time
 
unsigned int trigtype
 
int trigbits
 
TTree * fTree
 
int run
 
int subrun
 
int event
 
int ntrigs
 
unsigned int auxdetid
 
unsigned int tick
 
double time
 

Additional Inherited Members

- Public Types inherited from art::EDProducer
using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
- Public Types inherited from art::detail::Producer
template<typename UserConfig , typename KeysToIgnore = void>
using Table = Modifier::Table< UserConfig, KeysToIgnore >
 
- Public Types inherited from art::Modifier
template<typename UserConfig , typename UserKeysToIgnore = void>
using Table = ProducerTable< UserConfig, detail::ModuleConfig, UserKeysToIgnore >
 
- Static Public Member Functions inherited from art::EDProducer
static void commitEvent (EventPrincipal &ep, Event &e)
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Detailed Description

Definition at line 37 of file T0Counter_module.cc.

Constructor & Destructor Documentation

dune::T0Counter::T0Counter ( fhicl::ParameterSet const &  p)
explicit

Definition at line 128 of file T0Counter_module.cc.

129  : EDProducer{p}, fTriggerModuleLabel(p.get<std::string>("TriggerModuleLabel")),
130  fClockSpeedCounter(p.get<double>("ClockSpeedCounter")), // MHz
131  fCombinedTimeDelay(p.get<double>("CombinedTimeDelay")), // ns
132  fCoincidenceTolerance(p.get<int>("CoincidenceTolerance")), // ticks
133  fVerbose(p.get<bool>("Verbose",true)),
134  fMakeTree(p.get<bool>("MakeTree",false))
135 {
137 
138  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataForJob();
139 
140  fTriggerOffsetTPC = clockData.TriggerOffsetTPC()*1.e3; // ns
141 
142  produces< std::vector< anab::T0 > >();
143  produces< art::Assns< anab::T0, raw::ExternalTrigger> >();
144 }
std::string string
Definition: nybbler.cc:12
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
p
Definition: test.py:223
std::string fTriggerModuleLabel
dune::T0Counter::T0Counter ( T0Counter const &  )
delete
dune::T0Counter::T0Counter ( T0Counter &&  )
delete

Member Function Documentation

void dune::T0Counter::beginJob ( )
overridevirtual

Reimplemented from art::EDProducer.

Definition at line 233 of file T0Counter_module.cc.

234 {
236 
237  if (fMakeTree) {
238  fTree = tfs->make<TTree>("T0Counter","T0Counter");
239  fTree->Branch("run",&run,"run/I");
240  fTree->Branch("subrun",&subrun,"subrun/I");
241  fTree->Branch("event",&event,"event/I");
242  fTree->Branch("ntrigs",&ntrigs,"ntrigs/I");
243  fTree->Branch("auxdetid",&auxdetid,"auxdetid/I");
244  fTree->Branch("tick",&tick,"tick/I");
245  fTree->Branch("time",&time,"time/D");
246  }
247 }
unsigned int auxdetid
Event finding and building.
T0Counter& dune::T0Counter::operator= ( T0Counter const &  )
delete
T0Counter& dune::T0Counter::operator= ( T0Counter &&  )
delete
void dune::T0Counter::produce ( art::Event e)
overridevirtual

Implements art::EDProducer.

Definition at line 148 of file T0Counter_module.cc.

149 {
150  // make collection of T0 objects, and associations
151  std::unique_ptr< std::vector< anab::T0> > t0col(new std::vector<anab::T0>);
152  std::unique_ptr< art::Assns< anab::T0, raw::ExternalTrigger> > assn( new art::Assns< anab::T0, raw::ExternalTrigger>);
153 
154  // get basic info
155  run = e.run();
156  subrun = e.subRun();
157  event = e.id().event();
158 
159  // get raw::ExternalTriggers
160  auto externalTriggerListHandle = e.getHandle< std::vector< raw::ExternalTrigger> >(fTriggerModuleLabel);
161  if (externalTriggerListHandle)
162  {
163 
164  std::vector< art::Ptr< raw::ExternalTrigger> > trigs;
165  art::fill_ptr_vector(trigs,externalTriggerListHandle);
166 
167  ntrigs = externalTriggerListHandle->size();
168 
169  // this vector will contain t0 objects in a nice, convenient, organised package
170  std::vector<t0> t0vect;
171 
172  // fill t0vect with triggers, group if times are within fCoincidenceTolerance
173  for (auto const& trig : trigs) {
174  auxdetid = trig->GetTrigID();
175  tick = trig->GetTrigTime();
176  time = tick2Time(tick);
177  if (fMakeTree) fTree->Fill();
178 
179  // convert # PENN ticks tolerance to nsec
181 
182  // loop over t0vect
184  for (t0it = t0vect.begin(); t0it != t0vect.end(); ++t0it) {
185  // get t0 object
186  t0* t = &(*t0it);
187  // test for coincidence with all triggers associated with t0 object
188  if (t->testCoincidence(time,tol)) {
189  // insert trigger into t0
190  t->insert(time,auxdetid,trig);
191  // stop loop after one hit to prevent multiple insertions
192  break;
193  }
194  }
195  // if the above loop didn't find a coincidence, create a new t0 object
196  if (t0it == t0vect.end()) t0vect.push_back(t0(time,auxdetid,trig));
197  }
198 
199  // print information, if interested
200  if (fVerbose) {
201  int num = 0;
202  for (auto const &i : t0vect) {
203  std::cout << "Trigger " << num << " has " << i.idtime.size() << " triggers associated." << std::endl;
204  for (auto const &tit : i.idtime) {
205  std::cout << " time=" << std::fixed << std::setprecision(1) << tit.second << " ID=" << tit.first << std::endl;
206  }
207  ++num;
208  }
209  }
210 
211 
212  // make anab::T0 and Assns<anab::T0, raw::ExternalTrigger>
213  for (auto const &i : t0vect) {
214  t0time = i.avgTime(); // calculate average time of triggers, use as T0 time
215  trigtype = 1; // use 1 for counters
216  trigbits = i.idtime.size(); // number of associated triggers
217  t0col->push_back(anab::T0(t0time,
218  trigtype,
219  trigbits,
220  (*t0col).size()
221  ));
222  util::CreateAssn(*this, e, *t0col, i.trigs, *assn);
223  }
224 
225  }
226  e.put(std::move(t0col));
227  e.put(std::move(assn));
228 
229 }
code to link reconstructed objects back to the MC truth information
intermediate_table::iterator iterator
Handle< PROD > getHandle(SelectorBase const &) const
Definition: DataViewImpl.h:382
auto const tol
Definition: SurfXYZTest.cc:16
Definition: T0.h:16
Q_EXPORT QTSManip setprecision(int p)
Definition: qtextstream.h:343
def move(depos, offset)
Definition: depos.py:107
unsigned int trigtype
SubRunNumber_t subRun() const
Definition: DataViewImpl.cc:78
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: DataViewImpl.h:686
bool CreateAssn(PRODUCER const &prod, art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t indx=UINT_MAX)
Creates a single one-to-one association.
RunNumber_t run() const
Definition: DataViewImpl.cc:71
unsigned int auxdetid
EventNumber_t event() const
Definition: EventID.h:116
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:297
EventID id() const
Definition: Event.cc:34
QTextStream & endl(QTextStream &s)
std::string fTriggerModuleLabel
double tick2Time(unsigned int t)
double dune::T0Counter::tick2Time ( unsigned int  t)
private

Definition at line 251 of file T0Counter_module.cc.

252 {
253  double calctime = (double)t+0.5;//get central value of tick bin
254  calctime *= fSampleTimeCounter;//convert tick to time in ns
255  calctime += fTriggerOffsetTPC;//adjust for possible TPC window offset
256  calctime -= fCombinedTimeDelay;//correct for delay in signal propagation in cables and processing
257  return calctime;
258 }

Member Data Documentation

unsigned int dune::T0Counter::auxdetid
private

Definition at line 119 of file T0Counter_module.cc.

int dune::T0Counter::event
private

Definition at line 117 of file T0Counter_module.cc.

double dune::T0Counter::fClockSpeedCounter
private

Definition at line 97 of file T0Counter_module.cc.

int dune::T0Counter::fCoincidenceTolerance
private

Definition at line 99 of file T0Counter_module.cc.

double dune::T0Counter::fCombinedTimeDelay
private

Definition at line 98 of file T0Counter_module.cc.

bool dune::T0Counter::fMakeTree
private

Definition at line 101 of file T0Counter_module.cc.

double dune::T0Counter::fSampleTimeCounter
private

Definition at line 104 of file T0Counter_module.cc.

TTree* dune::T0Counter::fTree
private

Definition at line 114 of file T0Counter_module.cc.

std::string dune::T0Counter::fTriggerModuleLabel
private

Definition at line 96 of file T0Counter_module.cc.

double dune::T0Counter::fTriggerOffsetTPC
private

Definition at line 105 of file T0Counter_module.cc.

bool dune::T0Counter::fVerbose
private

Definition at line 100 of file T0Counter_module.cc.

int dune::T0Counter::ntrigs
private

Definition at line 118 of file T0Counter_module.cc.

int dune::T0Counter::run
private

Definition at line 115 of file T0Counter_module.cc.

int dune::T0Counter::subrun
private

Definition at line 116 of file T0Counter_module.cc.

double dune::T0Counter::t0time
private

Definition at line 108 of file T0Counter_module.cc.

unsigned int dune::T0Counter::tick
private

Definition at line 120 of file T0Counter_module.cc.

double dune::T0Counter::time
private

Definition at line 121 of file T0Counter_module.cc.

int dune::T0Counter::trigbits
private

Definition at line 110 of file T0Counter_module.cc.

unsigned int dune::T0Counter::trigtype
private

Definition at line 109 of file T0Counter_module.cc.


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