Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes | List of all members
calib::TimingCalibration Class Reference
Inheritance diagram for calib::TimingCalibration:
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

 TimingCalibration (fhicl::ParameterSet const &p)
 
virtual ~TimingCalibration ()
 
void produce (art::Event &e) override
 
void reconfigure (const fhicl::ParameterSet &pset)
 
void beginJob () override
 
void clearNTuple ()
 
void beginRun (art::Run &run) override
 
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
 

Private Attributes

std::string fTCTrackLabel
 Where to find calibration tracks. More...
 
std::string fTrackLabel
 Where to find reco Tracks. More...
 
int fMinDCMHits
 minimum number of hits on a dcm to keep results More...
 
int fMinDCM
 minimum number of good dcms on a track More...
 
bool fDebug
 Add exta debugging info to ntuple. More...
 
float fFiberSpeed
 fixed fiberspeed More...
 
bool fRemoveOutlier
 remove outlier hits in DCMs based on timing resolution More...
 
int fRemoveThreshold
 number of sigma away from mean to remove hits More...
 
bool fCorrectTimewalk
 adjust hit times based on timewalk effect for distance to readout More...
 
bool fAdjustSpeed
 adjust fiberspeed based on distance to readout instead of assuming flat speed More...
 
std::map< int, std::vector< art::Ptr< caldp::PCHit > > > fDCMHitMap
 
int run
 
int subrun
 
int event
 
int cosmictr
 
double sX
 
double sY
 
double sZ
 
double eX
 
double eY
 
double eZ
 
double plength
 
int minPl
 
int maxPl
 
int minPlX
 
int minPlY
 
int maxPlX
 
int maxPlY
 
int ncellsfitT
 
int ncellsfitX
 
int ncellsfitY
 
uint32_t evtTime
 
std::vector< float > dcmnum
 dcm index More...
 
std::vector< float > dcmhits
 number of hits in dcm More...
 
std::vector< float > dcmsimtime
 simultaneous hit time in dcm More...
 
std::vector< float > cellnum
 cell number More...
 
std::vector< float > planenum
 plane number More...
 
std::vector< float > dcmsimresid
 difference between simultaneous hit time and average More...
 
std::vector< float > dcmtime
 uncorrected times of hits More...
 
std::vector< float > dcmstime
 times with distance to readout, time-of-flight, timewalk corrections More...
 
std::vector< float > dcmrd
 distance to readout More...
 
std::vector< float > dcmpe
 number of photoelectrons More...
 
std::vector< float > dcmpl
 path length along track More...
 
TTree * fOutTree
 
fhicl::ParameterSet fPSetND
 
fhicl::ParameterSet fPSetFD
 
fhicl::ParameterSet fPSetTB
 

Detailed Description

Definition at line 44 of file TimingCalibration_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

calib::TimingCalibration::TimingCalibration ( fhicl::ParameterSet const &  p)
explicit

Definition at line 143 of file TimingCalibration_module.cc.

References reconfigure().

146  {
147  this->reconfigure(pset);
148 
149  produces< std::vector<caldp::DCMStat> >();
150  produces< art::Assns<caldp::DCMStat, rb::Track> >();
151  }
void reconfigure(const fhicl::ParameterSet &pset)
calib::TimingCalibration::~TimingCalibration ( )
virtual

Definition at line 173 of file TimingCalibration_module.cc.

174  {
175  }

Member Function Documentation

void calib::TimingCalibration::beginJob ( )
overridevirtual

Reimplemented from art::EDProducer.

Definition at line 178 of file TimingCalibration_module.cc.

References cellnum, cosmictr, dcmhits, dcmnum, dcmpe, dcmpl, dcmrd, dcmsimresid, dcmsimtime, dcmstime, dcmtime, event, evtTime, eX, eY, eZ, fDebug, fOutTree, art::TFileDirectory::make(), maxPl, maxPlX, maxPlY, minPl, minPlX, minPlY, ncellsfitT, ncellsfitX, ncellsfitY, planenum, plength, subrun, sX, sY, and sZ.

179  {
180 
182 
183  // define the tree
184  fOutTree = tfs->make<TTree>("TimingCalib","Timing Calibaration");
185 
186  //define ntuple branches
187  fOutTree->Branch("run", &run, "run/I");
188  fOutTree->Branch("subrun", &subrun, "subrun/I");
189  fOutTree->Branch("event", &event, "event/I");
190  fOutTree->Branch("cosmictr", &cosmictr, "cosmictr/I");
191  fOutTree->Branch("sX", &sX, "sX/D");
192  fOutTree->Branch("sY", &sY, "sY/D");
193  fOutTree->Branch("sZ", &sZ, "sZ/D");
194  fOutTree->Branch("eX", &eX, "eX/D");
195  fOutTree->Branch("eY", &eY, "eY/D");
196  fOutTree->Branch("eZ", &eZ, "eZ/D");
197  fOutTree->Branch("plength", &plength, "plength/D");
198  fOutTree->Branch("minPl", &minPl, "minPl/I");
199  fOutTree->Branch("maxPl", &maxPl, "maxPl/I");
200  fOutTree->Branch("minPlX", &minPlX, "minPlX/I");
201  fOutTree->Branch("minPlY", &minPlY, "minPlY/I");
202  fOutTree->Branch("maxPlX", &maxPlX, "maxPlX/I");
203  fOutTree->Branch("maxPlY", &maxPlY, "maxPlY/I");
204  fOutTree->Branch("ncellsfitT", &ncellsfitT, "ncellsfitT/I");
205  fOutTree->Branch("ncellsfitX", &ncellsfitX, "ncellsfitX/I");
206  fOutTree->Branch("ncellsfitY", &ncellsfitY, "ncellsfitY/I");
207  fOutTree->Branch("evtTime", &evtTime, "evtTime/i");
208 
209  fOutTree->Branch("dcmnum", &dcmnum);
210  fOutTree->Branch("dcmhits", &dcmhits);
211  fOutTree->Branch("dcmsimtime", &dcmsimtime);
212  if (fDebug){
213  fOutTree->Branch("planenum", &planenum);
214  fOutTree->Branch("cellnum", &cellnum);
215  fOutTree->Branch("dcmsimresid", &dcmsimresid);
216  fOutTree->Branch("dcmtime", &dcmtime);
217  fOutTree->Branch("dcmstime", &dcmstime);
218  fOutTree->Branch("dcmrd", &dcmrd);
219  fOutTree->Branch("dcmpe", &dcmpe);
220  fOutTree->Branch("dcmpl",&dcmpl);
221  }
222 
223 
224  }
std::vector< float > dcmrd
distance to readout
std::vector< float > planenum
plane number
bool fDebug
Add exta debugging info to ntuple.
std::vector< float > dcmtime
uncorrected times of hits
std::vector< float > cellnum
cell number
std::vector< float > dcmsimtime
simultaneous hit time in dcm
std::vector< float > dcmstime
times with distance to readout, time-of-flight, timewalk corrections
std::vector< float > dcmnum
dcm index
std::vector< float > dcmpl
path length along track
Definition: run.py:1
T * make(ARGS...args) const
std::vector< float > dcmsimresid
difference between simultaneous hit time and average
std::vector< float > dcmhits
number of hits in dcm
std::vector< float > dcmpe
number of photoelectrons
void calib::TimingCalibration::beginRun ( art::Run run)
overridevirtual

Reimplemented from art::EDProducer.

Definition at line 227 of file TimingCalibration_module.cc.

References ana::assert(), geo::GeometryBase::DetId(), fMinDCM, fMinDCMHits, fPSetFD, fPSetND, fPSetTB, geom(), fhicl::ParameterSet::get(), novadaq::cnv::kFARDET, novadaq::cnv::kNEARDET, and novadaq::cnv::kTESTBEAM.

228  {
230 
231  fhicl::ParameterSet pset;
232  switch(geom->DetId()){
234  pset = fPSetND;
235  break;
237  pset = fPSetFD;
238  break;
240  pset = fPSetTB;
241  break;
242  default:
243  assert(0 && "Unknown detector");
244  }
245 
246  fMinDCMHits = pset.get< int >("MinDCMHits");
247  fMinDCM = pset.get< int >("MinDCM");
248 
249  }
int fMinDCMHits
minimum number of hits on a dcm to keep results
int fMinDCM
minimum number of good dcms on a track
Far Detector at Ash River, MN.
T get(std::string const &key) const
Definition: ParameterSet.h:231
novadaq::cnv::DetId DetId() const
Prefer ds::DetectorService::DetId() instead.
Definition: GeometryBase.h:243
Near Detector in the NuMI cavern.
void geom(int which=0)
Definition: geom.C:163
assert(nhit_max >=nhit_nbins)
void calib::TimingCalibration::clearNTuple ( )

Definition at line 453 of file TimingCalibration_module.cc.

References cellnum, dcmhits, dcmnum, dcmpe, dcmpl, dcmrd, dcmsimresid, dcmsimtime, dcmstime, dcmtime, DEFINE_ART_MODULE(), eX, eY, eZ, maxPl, maxPlX, maxPlY, minPl, minPlX, minPlY, ncellsfitT, ncellsfitX, ncellsfitY, planenum, plength, sX, sY, and sZ.

Referenced by produce().

453  {
454 
455  //track start coordinate
456  sX = -999.0;
457  sY = -999.0;
458  sZ = -999.0;
459  //track end coordinate
460  eX = -999.0;
461  eY = -999.0;
462  eZ = -999.0;
463  plength = -5.0;
464  //min, max plane
465  minPl = -5;
466  maxPl = -5;
467  //min, max cell
468  minPlX = -5;
469  minPlY = -5;
470  maxPlX = -5;
471  maxPlY = -5;
472  //number of cells used in final fiber speed fit
473  ncellsfitT = 0;
474  ncellsfitX = 0;
475  ncellsfitY = 0;
476 
477 
478  dcmnum.clear();
479  dcmhits.clear();
480  dcmsimtime.clear();
481  planenum.clear();
482  cellnum.clear();
483  dcmsimresid.clear();
484  dcmtime.clear();
485  dcmstime.clear();
486  dcmrd.clear();
487  dcmpe.clear();
488  dcmpl.clear();
489 
490  }
std::vector< float > dcmrd
distance to readout
std::vector< float > planenum
plane number
std::vector< float > dcmtime
uncorrected times of hits
std::vector< float > cellnum
cell number
std::vector< float > dcmsimtime
simultaneous hit time in dcm
std::vector< float > dcmstime
times with distance to readout, time-of-flight, timewalk corrections
std::vector< float > dcmnum
dcm index
std::vector< float > dcmpl
path length along track
std::vector< float > dcmsimresid
difference between simultaneous hit time and average
std::vector< float > dcmhits
number of hits in dcm
std::vector< float > dcmpe
number of photoelectrons
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 calib::TimingCalibration::produce ( art::Event e)
overridevirtual

Implements art::EDProducer.

Definition at line 252 of file TimingCalibration_module.cc.

References daqchannelmap::AFULLAFULL_DIBLOCK, cellnum, clearNTuple(), cosmictr, util::CreateAssn(), caldp::PCHit::DCM(), caldp::DCMTime::dcmHits, dcmhits, caldp::DCMStat::dcmList, caldp::DCMTime::dcmNum, dcmnum, dcmpe, dcmpl, dcmrd, dcmsimresid, dcmsimtime, dcmstime, caldp::DCMTime::dcmTime, dcmtime, geo::GeometryBase::DetId(), runNovaSAM::detId, caldp::PCHit::Diblock(), febshutoff_auto::end, art::EventID::event(), evtTime, eX, eY, eZ, stan::math::fabs(), fAdjustSpeed, fCorrectTimewalk, fDCMHitMap, fFiberSpeed, art::fill_ptr_vector(), fMinDCM, fMinDCMHits, fOutTree, fRemoveOutlier, fTCTrackLabel, fTrackLabel, geom(), art::DataViewImpl::getByLabel(), daqchannelmap::DAQChannelMap::getInstance(), daqchannelmap::DAQChannelMap::getNumberOfDCM(), calib::Calibrator::GetTimingOffset(), cheat::BackTracker::HaveTruthInfo(), MECModelEnuComparisons::i, art::Event::id(), calib::j, findDuplicateFiles::key, geo::kX, geo::kXorY, geo::kY, Mag(), maxPl, maxPlX, maxPlY, minPl, minPlX, minPlY, ncellsfitT, ncellsfitX, ncellsfitY, std_candles::pl, planenum, plength, art::Event::put(), art::Event::run(), caldp::DCMTime::sigma, sigma(), std::sqrt(), febshutoff_auto::start, rb::Prong::Start(), HandyFuncs::stdev(), rb::Track::Stop(), art::Event::subRun(), subrun, sum, sX, sY, sZ, art::Event::time(), art::Timestamp::timeHigh(), make_root_from_grid_output::tr, w, ana::weight, and weights.

253  {
256 
257  std::unique_ptr< std::vector<caldp::DCMStat> > dcmstats(new std::vector<caldp::DCMStat>);
258 
259  std::unique_ptr<art::Assns<caldp::DCMStat, rb::Track> > dcmAssns(new art::Assns<caldp::DCMStat, rb::Track>);
260 
263  novadaq::cnv::DetId detId = geom->DetId();
264 
265  //get the cosmic tracks associated with each event
267  evt.getByLabel(fTrackLabel,trackcol);
268 
269  //get associationgs between slices and tracks
271 
272  std::vector< art::Ptr<rb::Track> > tracks;
273  art::fill_ptr_vector(tracks, trackcol);
274 
275  //store event info in ntuple
276  run = evt.run();
277  subrun = evt.subRun();
278  event = evt.id().event();
279 
280  evtTime = evt.time().timeHigh();
281 
282  //now loop over the tracks
283  for (unsigned int i=0; i<tracks.size(); ++i){
284 
285  this->clearNTuple();
286 
287  const art::Ptr<rb::Track> tr = tracks.at(i);
288 
289  //if ((tr->NXCell()==0) || (tr->NYCell()==0)) continue;
290  //get the tctrack associated with the cosmic track
291  std::vector<art::Ptr<caldp::TCTrack> > tct = fmtc.at(i);
292  //if we failed to get tctracks skip s
293  if (!(fmtc.isValid())) continue;
294  //there should only be one tctrack associated with a reco track
295  if (tct.size() != 1) continue;
296 
297  //make selection cuts on tracks
298  fDCMHitMap.clear();
299 
300 
301  cosmictr = i; //store track number
302  //passed initial round of cuts, now get track information
303  TVector3 start(tr->Start());
304  TVector3 end(tr->Stop());
305  sX = start.X();
306  sY = start.Y();
307  sZ = start.Z();
308  eX = end.X();
309  eY = end.Y();
310  eZ = end.Z();
311  plength = (end - start).Mag();
312  minPl = tct[0]->MinPlane(geo::kXorY);
313  maxPl = tct[0]->MaxPlane(geo::kXorY);
314 
315  minPlX = tct[0]->MinPlane(geo::kX);
316  minPlY = tct[0]->MinPlane(geo::kY);
317  maxPlX = tct[0]->MaxPlane(geo::kX);
318  maxPlY = tct[0]->MaxPlane(geo::kY);
319 
320  //make other selection cuts if desired
321 
322 
323  //put hits into map connected to DCM
324  for(unsigned int j=0; j<tct[0]->NPCHit(); ++j){
325  art::Ptr<caldp::PCHit> phit = tct[0]->PCHit(j);
326  int key = cmap->getNumberOfDCM(daqchannelmap::AFULLAFULL_DIBLOCK)*(phit->Diblock()-1) + phit->DCM();
327  fDCMHitMap[key].push_back(phit);
328  }
329 
330  //for each dcm calculate timing offsets
331  caldp::DCMStat dcms; //create object to hold dcm info for the track
332  for(std::map<int, std::vector<art::Ptr<caldp::PCHit> > >::iterator itr = fDCMHitMap.begin(); itr!=fDCMHitMap.end(); ++itr){
333  std::vector<art::Ptr<caldp::PCHit> > dcmcells = itr->second;
334  if ((int)dcmcells.size() < fMinDCMHits) continue;
335 
336  caldp::DCMTime dcmTime;
337 
338  std::vector<float> cellnumtemp;
339  std::vector<float> planenumtemp;
340  std::vector<float> dcmtimetemp;
341  std::vector<float> dcmstimetemp;
342  std::vector<float> dcmrdtemp;
343  std::vector<float> dcmpetemp;
344  std::vector<float> dcmpltemp;
345  std::vector<double> weights;
346  std::vector<double> sigma;
347  for(unsigned int k=0; k<dcmcells.size(); ++k){
348  double tns = dcmcells[k]->TNS();
349  double rd = dcmcells[k]->ReadDist();
350  double pl = dcmcells[k]->FlightLen();
351  if (fCorrectTimewalk) tns += tct[0]->ReadoutDistCorrection(dcmcells[k]->ReadDist(), detId);
352  //reverse any timing calibration that has been baked in
353  tns -= cal->GetTimingOffset(dcmcells[k]->Plane(), dcmcells[k]->Cell(), !bt->HaveTruthInfo());
354  float tmpFiberSpeed = fFiberSpeed;
355  if (fAdjustSpeed) tmpFiberSpeed = tct[0]->CalcFiberVelocity(rd, detId);
356  dcmstimetemp.push_back(tns - pl/sCmPerNsec - rd/tmpFiberSpeed);
357  dcmtimetemp.push_back(tns);
358  dcmrdtemp.push_back(rd);
359  dcmpetemp.push_back(dcmcells[k]->PE());
360  dcmpltemp.push_back(pl);
361  cellnumtemp.push_back(dcmcells[k]->Cell());
362  planenumtemp.push_back(dcmcells[k]->Plane());
363  double stdev = tct[0]->TNSUncertainty(dcmcells[k]->PE(), dcmcells[k]->GoodTime(), detId);
364  sigma.push_back(stdev);
365  double w = 1.0/(stdev*stdev);
366  weights.push_back(w);
367  }
368 
369  while (true){
370  double st = 0.0;
371  double weight = 0.0;
372  for(unsigned int k=0; k<dcmstimetemp.size(); ++k){
373  st += dcmstimetemp[k]*weights[k];
374  weight += weights[k];
375  }
376  st /= weight;
377  double maxresid = 0;
378  unsigned int maxpos = 0;
379  for(unsigned int k=0; k<dcmstimetemp.size(); ++k){
380  float recresid = st - dcmstimetemp[k];
381  if (fabs(recresid/sigma[k]) > fabs(maxresid)){
382  maxresid = fabs(recresid/sigma[k]);
383  maxpos = k;
384  }
385  }
386  if (dcmcells.size() <= 2) break;
387  if (maxresid > 2.0){
388  if (fRemoveOutlier){
389  dcmcells.erase(dcmcells.begin()+maxpos);
390  cellnumtemp.erase(cellnumtemp.begin()+maxpos);
391  planenumtemp.erase(planenumtemp.begin()+maxpos);
392  dcmtimetemp.erase(dcmtimetemp.begin()+maxpos);
393  dcmstimetemp.erase(dcmstimetemp.begin()+maxpos);
394  dcmrdtemp.erase(dcmrdtemp.begin()+maxpos);
395  dcmpetemp.erase(dcmpetemp.begin()+maxpos);
396  dcmpltemp.erase(dcmpltemp.begin()+maxpos);
397  weights.erase(weights.begin()+maxpos);
398  sigma.erase(sigma.begin()+maxpos);
399  continue;
400  }
401  }
402  if ((int)dcmcells.size() < fMinDCMHits) break;
403  dcmnum.push_back(itr->first);
404  dcmhits.push_back(dcmstimetemp.size());
405  dcmsimtime.push_back(st);
406  dcmTime.dcmTime = st;
407  dcmTime.dcmNum = itr->first;
408  dcmTime.dcmHits = dcmcells.size();
409  double sum = 0.0;
410  for(unsigned int k=0; k<dcmstimetemp.size(); ++k){
411  double recresid = st - dcmstimetemp[k];
412  dcmsimresid.push_back(recresid);
413  sum += weights[k]*(dcmstimetemp[k] - st)*(dcmstimetemp[k]-st);
414  cellnum.push_back(cellnumtemp[k]);
415  planenum.push_back(planenumtemp[k]);
416  dcmtime.push_back(dcmtimetemp[k]);
417  dcmstime.push_back(dcmstimetemp[k]);
418  dcmrd.push_back(dcmrdtemp[k]);
419  dcmpe.push_back(dcmpetemp[k]);
420  dcmpl.push_back(dcmpltemp[k]);
421  }
422  dcmTime.sigma = sqrt(sum/weight);
423  dcms.dcmList.push_back(dcmTime);
424  break;
425  }
426 
427  }
428 
429  if ((int)dcms.dcmList.size() < fMinDCM) continue;
430 
431  dcmstats->push_back(dcms);
432 
433  util::CreateAssn(*this, evt, *dcmstats, tr, *dcmAssns);
434 
435 
436 
437  ncellsfitT = tct[0]->NPCHit();
438  ncellsfitX = tct[0]->NXPCHit();
439  ncellsfitY = tct[0]->NYPCHit();
440 
441 
442  fOutTree->Fill();
443 
444 
445  }//end loop over tracks
446 
447  evt.put(std::move(dcmstats));
448  evt.put(std::move(dcmAssns));
449 
450  }
static bool CreateAssn(art::EDProducer const &prod, art::Event &evt, std::vector< T > &a, art::Ptr< U > b, art::Assns< T, U > &assn, size_t indx=UINT_MAX, std::string const &instance=std::string())
Create a 1 to 1 association between a new product and one already in the event.
def stdev(lst)
Definition: HandyFuncs.py:286
int fMinDCMHits
minimum number of hits on a dcm to keep results
std::vector< float > dcmrd
distance to readout
virtual unsigned int getNumberOfDCM(DiBlock_TYPE dbt) const =0
How many DCMs does this diblock have?
std::vector< float > planenum
plane number
float sigma
uncertainty in average hit time
Definition: DCMStat.h:21
fvar< T > fabs(const fvar< T > &x)
Definition: fabs.hpp:15
int fMinDCM
minimum number of good dcms on a track
const Var weight
X or Y views.
Definition: PlaneGeo.h:30
std::vector< float > dcmtime
uncorrected times of hits
T sqrt(T number)
Definition: d0nt_math.hpp:156
std::vector< float > cellnum
cell number
Vertical planes which measure X.
Definition: PlaneGeo.h:28
bool fCorrectTimewalk
adjust hit times based on timewalk effect for distance to readout
virtual TVector3 Start() const
Definition: Prong.h:73
Horizontal planes which measure Y.
Definition: PlaneGeo.h:29
std::map< int, std::vector< art::Ptr< caldp::PCHit > > > fDCMHitMap
std::string fTCTrackLabel
Where to find calibration tracks.
std::string fTrackLabel
Where to find reco Tracks.
int dcmHits
number of hits in dcm
Definition: DCMStat.h:19
std::vector< float > dcmsimtime
simultaneous hit time in dcm
static DAQChannelMap * getInstance(int detID)
novadaq::cnv::DetId DetId() const
Prefer ds::DetectorService::DetId() instead.
Definition: GeometryBase.h:243
int evt
float dcmTime
weighted average time of hits in dcm, correcting for time-of-flight and path lenght ...
Definition: DCMStat.h:20
std::vector< float > dcmstime
times with distance to readout, time-of-flight, timewalk corrections
std::vector< float > dcmnum
dcm index
Var weights
const double j
Definition: BetheBloch.cxx:29
std::vector< float > dcmpl
path length along track
Identifier for diblocks using a 32/32 configuration.
int Diblock() const
Return diblock value.
Definition: PCHit.h:28
double sigma(TH1F *hist, double percentile)
Definition: run.py:1
static const double sCmPerNsec
bool fRemoveOutlier
remove outlier hits in DCMs based on timing resolution
double GetTimingOffset(unsigned int const &plane, unsigned int const &cell, bool const &isData)
Get the timing offset for a given plane, cell. Useful downstream to check calibration.
void geom(int which=0)
Definition: geom.C:163
bool HaveTruthInfo() const
Is this a file with truth info in? (Is BackTracker going to be any use to you?)
Definition: BackTracker.h:133
float Mag() const
std::vector< float > dcmsimresid
difference between simultaneous hit time and average
std::vector< float > dcmhits
number of hits in dcm
bool fAdjustSpeed
adjust fiberspeed based on distance to readout instead of assuming flat speed
cmap::CMap class source code
Definition: CMap.cxx:17
std::vector< DCMTime > dcmList
Definition: DCMStat.h:31
int DCM() const
Return dcm value.
Definition: PCHit.h:30
float fFiberSpeed
fixed fiberspeed
TVector3 Stop() const
Position of the final trajectory point.
Definition: Track.cxx:186
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:464
Double_t sum
Definition: plot.C:31
std::vector< float > dcmpe
number of photoelectrons
Float_t w
Definition: plot.C:20
int dcmNum
Number of the dcm.
Definition: DCMStat.h:18
void calib::TimingCalibration::reconfigure ( const fhicl::ParameterSet pset)

Definition at line 154 of file TimingCalibration_module.cc.

References fAdjustSpeed, fCorrectTimewalk, fDebug, fFiberSpeed, fMinDCM, fMinDCMHits, fPSetFD, fPSetND, fPSetTB, fRemoveOutlier, fRemoveThreshold, fTCTrackLabel, fTrackLabel, fhicl::ParameterSet::get(), and string.

Referenced by TimingCalibration().

155  {
156  fTCTrackLabel = pset.get< std::string >("TCTrackLabel");
157  fTrackLabel = pset.get< std::string >("TrackLabel");
158  fMinDCMHits = 0;
159  fMinDCM = 0;
160  fDebug = pset.get< bool >("Debug");
161  fFiberSpeed = pset.get< float >("FiberSpeed");
162  fRemoveOutlier = pset.get< bool >("RemoveOutlier");
163  fRemoveThreshold = pset.get< int >("RemoveThreshold");
164  fCorrectTimewalk = pset.get< bool >("CorrectTimewalk");
165  fAdjustSpeed = pset.get< bool >("AdjustSpeed");
166  fPSetND = pset.get< fhicl::ParameterSet >("nd");
167  fPSetFD = pset.get< fhicl::ParameterSet >("fd");
168  fPSetTB = pset.get< fhicl::ParameterSet >("tb");
169 
170  }
int fMinDCMHits
minimum number of hits on a dcm to keep results
int fMinDCM
minimum number of good dcms on a track
bool fDebug
Add exta debugging info to ntuple.
bool fCorrectTimewalk
adjust hit times based on timewalk effect for distance to readout
std::string fTCTrackLabel
Where to find calibration tracks.
std::string fTrackLabel
Where to find reco Tracks.
int fRemoveThreshold
number of sigma away from mean to remove hits
T get(std::string const &key) const
Definition: ParameterSet.h:231
bool fRemoveOutlier
remove outlier hits in DCMs based on timing resolution
bool fAdjustSpeed
adjust fiberspeed based on distance to readout instead of assuming flat speed
float fFiberSpeed
fixed fiberspeed
enum BeamMode string
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::vector<float> calib::TimingCalibration::cellnum
private

cell number

Definition at line 115 of file TimingCalibration_module.cc.

Referenced by beginJob(), clearNTuple(), and produce().

int calib::TimingCalibration::cosmictr
private

Definition at line 82 of file TimingCalibration_module.cc.

Referenced by beginJob(), and produce().

std::vector<float> calib::TimingCalibration::dcmhits
private

number of hits in dcm

Definition at line 111 of file TimingCalibration_module.cc.

Referenced by beginJob(), clearNTuple(), and produce().

std::vector<float> calib::TimingCalibration::dcmnum
private

dcm index

Definition at line 110 of file TimingCalibration_module.cc.

Referenced by beginJob(), clearNTuple(), and produce().

std::vector<float> calib::TimingCalibration::dcmpe
private

number of photoelectrons

Definition at line 121 of file TimingCalibration_module.cc.

Referenced by beginJob(), clearNTuple(), and produce().

std::vector<float> calib::TimingCalibration::dcmpl
private

path length along track

Definition at line 122 of file TimingCalibration_module.cc.

Referenced by beginJob(), clearNTuple(), and produce().

std::vector<float> calib::TimingCalibration::dcmrd
private

distance to readout

Definition at line 120 of file TimingCalibration_module.cc.

Referenced by beginJob(), clearNTuple(), and produce().

std::vector<float> calib::TimingCalibration::dcmsimresid
private

difference between simultaneous hit time and average

Definition at line 117 of file TimingCalibration_module.cc.

Referenced by beginJob(), clearNTuple(), and produce().

std::vector<float> calib::TimingCalibration::dcmsimtime
private

simultaneous hit time in dcm

Definition at line 112 of file TimingCalibration_module.cc.

Referenced by beginJob(), clearNTuple(), and produce().

std::vector<float> calib::TimingCalibration::dcmstime
private

times with distance to readout, time-of-flight, timewalk corrections

Definition at line 119 of file TimingCalibration_module.cc.

Referenced by beginJob(), clearNTuple(), and produce().

std::vector<float> calib::TimingCalibration::dcmtime
private

uncorrected times of hits

Definition at line 118 of file TimingCalibration_module.cc.

Referenced by beginJob(), clearNTuple(), and produce().

int calib::TimingCalibration::event
private

Definition at line 81 of file TimingCalibration_module.cc.

Referenced by beginJob().

uint32_t calib::TimingCalibration::evtTime
private

Definition at line 107 of file TimingCalibration_module.cc.

Referenced by beginJob(), and produce().

double calib::TimingCalibration::eX
private

Definition at line 88 of file TimingCalibration_module.cc.

Referenced by beginJob(), clearNTuple(), and produce().

double calib::TimingCalibration::eY
private

Definition at line 89 of file TimingCalibration_module.cc.

Referenced by beginJob(), clearNTuple(), and produce().

double calib::TimingCalibration::eZ
private

Definition at line 90 of file TimingCalibration_module.cc.

Referenced by beginJob(), clearNTuple(), and produce().

bool calib::TimingCalibration::fAdjustSpeed
private

adjust fiberspeed based on distance to readout instead of assuming flat speed

Definition at line 71 of file TimingCalibration_module.cc.

Referenced by produce(), and reconfigure().

bool calib::TimingCalibration::fCorrectTimewalk
private

adjust hit times based on timewalk effect for distance to readout

Definition at line 70 of file TimingCalibration_module.cc.

Referenced by produce(), and reconfigure().

std::map<int, std::vector<art::Ptr<caldp::PCHit> > > calib::TimingCalibration::fDCMHitMap
private

Definition at line 75 of file TimingCalibration_module.cc.

Referenced by produce().

bool calib::TimingCalibration::fDebug
private

Add exta debugging info to ntuple.

Definition at line 65 of file TimingCalibration_module.cc.

Referenced by beginJob(), and reconfigure().

float calib::TimingCalibration::fFiberSpeed
private

fixed fiberspeed

Definition at line 67 of file TimingCalibration_module.cc.

Referenced by produce(), and reconfigure().

int calib::TimingCalibration::fMinDCM
private

minimum number of good dcms on a track

Definition at line 64 of file TimingCalibration_module.cc.

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

int calib::TimingCalibration::fMinDCMHits
private

minimum number of hits on a dcm to keep results

Definition at line 63 of file TimingCalibration_module.cc.

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

TTree* calib::TimingCalibration::fOutTree
private

Definition at line 126 of file TimingCalibration_module.cc.

Referenced by beginJob(), and produce().

fhicl::ParameterSet calib::TimingCalibration::fPSetFD
private

Definition at line 128 of file TimingCalibration_module.cc.

Referenced by beginRun(), and reconfigure().

fhicl::ParameterSet calib::TimingCalibration::fPSetND
private

Definition at line 128 of file TimingCalibration_module.cc.

Referenced by beginRun(), and reconfigure().

fhicl::ParameterSet calib::TimingCalibration::fPSetTB
private

Definition at line 128 of file TimingCalibration_module.cc.

Referenced by beginRun(), and reconfigure().

bool calib::TimingCalibration::fRemoveOutlier
private

remove outlier hits in DCMs based on timing resolution

Definition at line 68 of file TimingCalibration_module.cc.

Referenced by produce(), and reconfigure().

int calib::TimingCalibration::fRemoveThreshold
private

number of sigma away from mean to remove hits

Definition at line 69 of file TimingCalibration_module.cc.

Referenced by reconfigure().

std::string calib::TimingCalibration::fTCTrackLabel
private

Where to find calibration tracks.

Definition at line 59 of file TimingCalibration_module.cc.

Referenced by produce(), and reconfigure().

std::string calib::TimingCalibration::fTrackLabel
private

Where to find reco Tracks.

Definition at line 60 of file TimingCalibration_module.cc.

Referenced by produce(), and reconfigure().

int calib::TimingCalibration::maxPl
private

Definition at line 96 of file TimingCalibration_module.cc.

Referenced by beginJob(), clearNTuple(), and produce().

int calib::TimingCalibration::maxPlX
private

Definition at line 100 of file TimingCalibration_module.cc.

Referenced by beginJob(), clearNTuple(), and produce().

int calib::TimingCalibration::maxPlY
private

Definition at line 101 of file TimingCalibration_module.cc.

Referenced by beginJob(), clearNTuple(), and produce().

int calib::TimingCalibration::minPl
private

Definition at line 95 of file TimingCalibration_module.cc.

Referenced by beginJob(), clearNTuple(), and produce().

int calib::TimingCalibration::minPlX
private

Definition at line 98 of file TimingCalibration_module.cc.

Referenced by beginJob(), clearNTuple(), and produce().

int calib::TimingCalibration::minPlY
private

Definition at line 99 of file TimingCalibration_module.cc.

Referenced by beginJob(), clearNTuple(), and produce().

int calib::TimingCalibration::ncellsfitT
private

Definition at line 103 of file TimingCalibration_module.cc.

Referenced by beginJob(), clearNTuple(), and produce().

int calib::TimingCalibration::ncellsfitX
private

Definition at line 104 of file TimingCalibration_module.cc.

Referenced by beginJob(), clearNTuple(), and produce().

int calib::TimingCalibration::ncellsfitY
private

Definition at line 105 of file TimingCalibration_module.cc.

Referenced by beginJob(), clearNTuple(), and produce().

std::vector<float> calib::TimingCalibration::planenum
private

plane number

Definition at line 116 of file TimingCalibration_module.cc.

Referenced by beginJob(), clearNTuple(), and produce().

double calib::TimingCalibration::plength
private

Definition at line 92 of file TimingCalibration_module.cc.

Referenced by beginJob(), clearNTuple(), and produce().

int calib::TimingCalibration::run
private
int calib::TimingCalibration::subrun
private

Definition at line 80 of file TimingCalibration_module.cc.

Referenced by beginJob(), and produce().

double calib::TimingCalibration::sX
private

Definition at line 84 of file TimingCalibration_module.cc.

Referenced by beginJob(), clearNTuple(), and produce().

double calib::TimingCalibration::sY
private

Definition at line 85 of file TimingCalibration_module.cc.

Referenced by beginJob(), clearNTuple(), and produce().

double calib::TimingCalibration::sZ
private

Definition at line 86 of file TimingCalibration_module.cc.

Referenced by beginJob(), clearNTuple(), and produce().


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