Public Types | Public Member Functions | Protected Member Functions | Private Attributes | List of all members
calib::FiberCalibration Class Reference
Inheritance diagram for calib::FiberCalibration:
art::EDProducer art::detail::Producer art::detail::LegacyModule art::Modifier art::ModuleBase art::ProductRegistryHelper

Public Types

using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
template<typename UserConfig , typename KeysToIgnore = void>
using Table = Modifier::Table< UserConfig, KeysToIgnore >
 

Public Member Functions

 FiberCalibration (fhicl::ParameterSet const &p)
 
virtual ~FiberCalibration ()
 
void produce (art::Event &e) override
 
void reconfigure (const fhicl::ParameterSet &pset)
 
void beginJob () override
 
void beginRun (art::Run &run) override
 
void clearNTuple ()
 
std::string workerType () const
 
void doBeginJob ()
 
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)
 
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< TconsumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< TmayConsumeView (InputTag const &tag)
 

Protected Member Functions

ConsumesCollector & consumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< Tconsumes (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< TmayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Private Attributes

std::string fPCHitLabel
 Where to find calibration hits. More...
 
std::string fQualXYLabel
 Instance label for hits with xz quality. More...
 
std::string fQualZLabel
 Instance label for hits with z quality. More...
 
std::string fQualAvgLabel
 Instance label for hits with avg quality. More...
 
std::string fTrackLabel
 Where to find Tracks. More...
 
double fFitFrac
 fraction of cells on track kept in final fiber speed fit More...
 
int fFitCells
 number of cells used in final fiber speed fit for a track More...
 
double fAsy
 maximum asymmetry between the x and y cells used in the final fit More...
 
int fTrackPlanes
 number of planes track passes through More...
 
double fFiducialX
 maximum distance in cm muon endpoints can be from detector edge in X More...
 
double fFiducialY
 maximum distance in cm muon endpoints can be from detector edge in Y More...
 
double fFiducialZ
 maximum distance in cm muon endpoints can be from detector edge in Z More...
 
int fStartPlaneDiff
 maximum difference between minimum plane in each view associated with the track More...
 
int fEndPlaneDiff
 maximum difference between maximum plane in each view associated with the track More...
 
double fMinZ
 
double fMaxZ
 hack for minimum z detector boundary for situation were front diblocks are missing More...
 
double fTimeRes
 hack for maximum z in detector, which could be incorrectly calculated depending on missing diblocks More...
 
bool fUseLiveGeo
 use the live geometry to find beginning and ending diblock More...
 
int run
 
int subrun
 
int event
 
int cosmictr
 
float sX
 
float sY
 
float sZ
 
float eX
 
float eY
 
float eZ
 
float plength
 
int minPl
 
int maxPl
 
int minPlX
 
int minPlY
 
int maxPlX
 
int maxPlY
 
int minCX
 
int minCY
 
int maxCX
 
int maxCY
 
int ncellsT
 
int ncellsX
 
int ncellsY
 
int ncellscalT
 
int ncellscalX
 
int ncellscalY
 
int ncellsfitT
 
int ncellsfitX
 
int ncellsfitY
 
float fiberspeed
 
float beta
 
TTree * fOutTree
 
fhicl::ParameterSet fPSetND
 
fhicl::ParameterSet fPSetFD
 
fhicl::ParameterSet fPSetTB
 

Detailed Description

Definition at line 38 of file FiberCalibration_module.cc.

Member Typedef Documentation

Definition at line 17 of file EDProducer.h.

template<typename UserConfig , typename KeysToIgnore = void>
using art::detail::Producer::Table = Modifier::Table<UserConfig, KeysToIgnore>
inherited

Definition at line 25 of file Producer.h.

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

Definition at line 18 of file EDProducer.h.

Constructor & Destructor Documentation

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

Definition at line 139 of file FiberCalibration_module.cc.

References reconfigure().

140  : EDProducer(pset)
141  // Initialize member data here.
142  {
143  this->reconfigure(pset);
144 
145  produces< std::vector<caldp::TCTrack> >();
146  produces< art::Assns<caldp::TCTrack, rb::Track> >();
147  }
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
void reconfigure(const fhicl::ParameterSet &pset)
calib::FiberCalibration::~FiberCalibration ( )
virtual

Definition at line 176 of file FiberCalibration_module.cc.

177  {
178  // Clean up dynamic memory and other resources here.
179  }

Member Function Documentation

void calib::FiberCalibration::beginJob ( )
overridevirtual

Reimplemented from art::EDProducer.

Definition at line 182 of file FiberCalibration_module.cc.

References beta, cosmictr, event, eX, eY, eZ, fiberspeed, fOutTree, maxPl, maxPlX, maxPlY, minPl, minPlX, minPlY, ncellscalT, ncellscalX, ncellscalY, ncellsfitT, ncellsfitX, ncellsfitY, plength, subrun, sX, sY, and sZ.

183  {
184  TH1::SetDefaultSumw2();
185  TH2::SetDefaultSumw2();
186 
188 
189  // define the tree
190  fOutTree = tfs->make<TTree>("FiberCalib","Fiber Calibaration");
191 
192  //define ntuple branches
193  fOutTree->Branch("run", &run, "run/I");
194  fOutTree->Branch("subrun", &subrun, "subrun/I");
195  fOutTree->Branch("event", &event, "event/I");
196  fOutTree->Branch("cosmictr", &cosmictr, "cosmictr/I");
197  fOutTree->Branch("sX", &sX, "sX/F");
198  fOutTree->Branch("sY", &sY, "sY/F");
199  fOutTree->Branch("sZ", &sZ, "sZ/F");
200  fOutTree->Branch("eX", &eX, "eX/F");
201  fOutTree->Branch("eY", &eY, "eY/F");
202  fOutTree->Branch("eZ", &eZ, "eZ/F");
203  fOutTree->Branch("plength", &plength, "plength/F");
204  fOutTree->Branch("minPl", &minPl, "minPl/I");
205  fOutTree->Branch("maxPl", &maxPl, "maxPl/I");
206  fOutTree->Branch("minPlX", &minPlX, "minPlX/I");
207  fOutTree->Branch("maxPlX", &maxPlX, "maxPlX/I");
208  fOutTree->Branch("minPlY", &minPlY, "minPlY/I");
209  fOutTree->Branch("maxPlY", &maxPlY, "maxPlY/I");
210  //fOutTree->Branch("minCX", &minCX, "minCX/I");
211  //fOutTree->Branch("minCY", &minCY, "minCY/I");
212  //fOutTree->Branch("maxCX", &maxCX, "maxCX/I");
213  //fOutTree->Branch("maxCY", &maxCY, "maxCY/I");
214  //fOutTree->Branch("ncellsT", &ncellsT, "ncellsT/I");
215  //fOutTree->Branch("ncellsX", &ncellsX, "ncellsX/I");
216  //fOutTree->Branch("ncellsY", &ncellsY, "ncellsY/I");
217  fOutTree->Branch("ncellscalT", &ncellscalT, "ncellscalT/I");
218  fOutTree->Branch("ncellscalX", &ncellscalX, "ncellscalX/I");
219  fOutTree->Branch("ncellscalY", &ncellscalY, "ncellscalY/I");
220  fOutTree->Branch("ncellsfitT", &ncellsfitT, "ncellsfitT/I");
221  fOutTree->Branch("ncellsfitX", &ncellsfitX, "ncellsfitX/I");
222  fOutTree->Branch("ncellsfitY", &ncellsfitY, "ncellsfitY/I");
223  fOutTree->Branch("fiberspeed", &fiberspeed, "fiberspeed/F");
224  fOutTree->Branch("beta", &beta, "beta/F");
225 
226  }
Definition: run.py:1
void calib::FiberCalibration::beginRun ( art::Run run)
overridevirtual

Reimplemented from art::EDProducer.

Definition at line 229 of file FiberCalibration_module.cc.

References ana::assert(), geo::GeometryBase::DetId(), fAsy, fEndPlaneDiff, fFiducialX, fFiducialY, fFiducialZ, fFitCells, fFitFrac, fMaxZ, fMinZ, fPSetFD, fPSetND, fPSetTB, fStartPlaneDiff, fTimeRes, fTrackPlanes, fUseLiveGeo, geom(), fhicl::ParameterSet::get(), novadaq::cnv::kFARDET, novadaq::cnv::kNEARDET, and novadaq::cnv::kTESTBEAM.

230  {
232 
233  fhicl::ParameterSet pset;
234  switch(geom->DetId()){
236  pset = fPSetND;
237  break;
239  pset = fPSetFD;
240  break;
242  pset = fPSetTB;
243  break;
244  default:
245  assert(0 && "Unknown detector");
246  }
247 
248  fFitFrac = pset.get< double >("FitFrac");
249  fFitCells = pset.get< int >("FitCells");
250  fAsy = pset.get< double >("Asy");
251  fTrackPlanes = pset.get< int >("TrackPlanes");
252  fFiducialX = pset.get< double >("FiducialX");
253  fFiducialY = pset.get< double >("FiducialY");
254  fFiducialZ = pset.get< double >("FiducialZ");
255  fStartPlaneDiff = pset.get< int >("StartPlaneDiff");
256  fEndPlaneDiff = pset.get< int >("EndPlaneDiff");
257  fTimeRes = pset.get< double >("TimeRes");
258  fMinZ = pset.get< double >("MinZ");
259  fMaxZ = pset.get< double >("MaxZ");
260  fUseLiveGeo = pset.get< bool >("UseLiveGeo");
261  }
int fStartPlaneDiff
maximum difference between minimum plane in each view associated with the track
double fFiducialX
maximum distance in cm muon endpoints can be from detector edge in X
int fEndPlaneDiff
maximum difference between maximum plane in each view associated with the track
double fFiducialZ
maximum distance in cm muon endpoints can be from detector edge in Z
bool fUseLiveGeo
use the live geometry to find beginning and ending diblock
int fFitCells
number of cells used in final fiber speed fit for a track
Far Detector at Ash River, MN.
int fTrackPlanes
number of planes track passes through
double fAsy
maximum asymmetry between the x and y cells used in the final fit
double fFitFrac
fraction of cells on track kept in final fiber speed fit
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)
double fTimeRes
hack for maximum z in detector, which could be incorrectly calculated depending on missing diblocks ...
double fFiducialY
maximum distance in cm muon endpoints can be from detector edge in Y
double fMaxZ
hack for minimum z detector boundary for situation were front diblocks are missing ...
void calib::FiberCalibration::clearNTuple ( )

Definition at line 439 of file FiberCalibration_module.cc.

References beta, DEFINE_ART_MODULE(), eX, eY, eZ, fiberspeed, maxCX, maxCY, maxPl, minCX, minCY, minPl, ncellscalT, ncellscalX, ncellscalY, ncellsfitT, ncellsfitX, ncellsfitY, ncellsT, ncellsX, ncellsY, plength, sX, sY, and sZ.

Referenced by produce().

439  {
440 
441  //track start coordinate
442  sX = -999.0;
443  sY = -999.0;
444  sZ = -999.0;
445  //track end coordinate
446  eX = -999.0;
447  eY = -999.0;
448  eZ = -999.0;
449  //pathlength variables
450  plength = -5.0;
451  //min, max plane
452  minPl = -5;
453  maxPl = -5;
454  //min, max cell
455  minCX = -5;
456  minCY = -5;
457  maxCX = -5;
458  maxCY = -5;
459  //number of cells
460  ncellsT = 0;
461  ncellsX = 0;
462  ncellsY = 0;
463  //number of cells with good timing and calibrated
464  ncellscalT = 0;
465  ncellscalX = 0;
466  ncellscalY = 0;
467  //number of cells used in final fiber speed fit
468  ncellsfitT = 0;
469  ncellsfitX = 0;
470  ncellsfitY = 0;
471  //fit parameters
472  fiberspeed = -99.0;
473  beta = -5.0;
474 
475 
476  }
template<typename T , BranchType BT>
ProductToken< T > art::ModuleBase::consumes ( InputTag const &  tag)
protectedinherited

Definition at line 55 of file ModuleBase.h.

References art::ModuleBase::collector_, art::ConsumesCollector::consumes(), T, and getGoodRuns4SAM::tag.

56  {
57  return collector_.consumes<T, BT>(tag);
58  }
ConsumesCollector collector_
Definition: ModuleBase.h:50
ProductToken< T > consumes(InputTag const &)
double T
Definition: Xdiff_gwt.C:5
ConsumesCollector& art::ModuleBase::consumesCollector ( )
protectedinherited
template<typename T , BranchType BT>
void art::ModuleBase::consumesMany ( )
protectedinherited

Definition at line 69 of file ModuleBase.h.

References art::ModuleBase::collector_, art::ConsumesCollector::consumesMany(), and T.

70  {
71  collector_.consumesMany<T, BT>();
72  }
ConsumesCollector collector_
Definition: ModuleBase.h:50
double T
Definition: Xdiff_gwt.C:5
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::ModuleBase::consumesView ( InputTag const &  )
protectedinherited
template<typename T , BranchType BT>
ViewToken<T> art::ModuleBase::consumesView ( InputTag const &  tag)
inherited

Definition at line 62 of file ModuleBase.h.

References art::ModuleBase::collector_, art::ConsumesCollector::consumesView(), T, and getGoodRuns4SAM::tag.

63  {
64  return collector_.consumesView<T, BT>(tag);
65  }
ConsumesCollector collector_
Definition: ModuleBase.h:50
ViewToken< Element > consumesView(InputTag const &)
double T
Definition: Xdiff_gwt.C:5
void art::detail::Producer::doBeginJob ( )
inherited
bool art::detail::Producer::doBeginRun ( RunPrincipal rp,
ModuleContext const &  mc 
)
inherited
bool art::detail::Producer::doBeginSubRun ( SubRunPrincipal srp,
ModuleContext const &  mc 
)
inherited
void art::detail::Producer::doEndJob ( )
inherited
bool art::detail::Producer::doEndRun ( RunPrincipal rp,
ModuleContext const &  mc 
)
inherited
bool art::detail::Producer::doEndSubRun ( SubRunPrincipal srp,
ModuleContext const &  mc 
)
inherited
bool art::detail::Producer::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 
)
inherited
void art::detail::Producer::doRespondToCloseInputFile ( FileBlock const &  fb)
inherited
void art::detail::Producer::doRespondToCloseOutputFiles ( FileBlock const &  fb)
inherited
void art::detail::Producer::doRespondToOpenInputFile ( FileBlock const &  fb)
inherited
void art::detail::Producer::doRespondToOpenOutputFiles ( FileBlock const &  fb)
inherited
std::array<std::vector<ProductInfo>, NumBranchTypes> const& art::ModuleBase::getConsumables ( ) const
inherited
template<typename T , BranchType BT>
ProductToken< T > art::ModuleBase::mayConsume ( InputTag const &  tag)
protectedinherited

Definition at line 76 of file ModuleBase.h.

References art::ModuleBase::collector_, art::ConsumesCollector::mayConsume(), T, and getGoodRuns4SAM::tag.

77  {
78  return collector_.mayConsume<T, BT>(tag);
79  }
ProductToken< T > mayConsume(InputTag const &)
ConsumesCollector collector_
Definition: ModuleBase.h:50
double T
Definition: Xdiff_gwt.C:5
template<typename T , BranchType BT>
void art::ModuleBase::mayConsumeMany ( )
protectedinherited

Definition at line 90 of file ModuleBase.h.

References art::ModuleBase::collector_, art::ConsumesCollector::mayConsumeMany(), and T.

91  {
93  }
ConsumesCollector collector_
Definition: ModuleBase.h:50
double T
Definition: Xdiff_gwt.C:5
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::ModuleBase::mayConsumeView ( InputTag const &  )
protectedinherited
template<typename T , BranchType BT>
ViewToken<T> art::ModuleBase::mayConsumeView ( InputTag const &  tag)
inherited

Definition at line 83 of file ModuleBase.h.

References art::ModuleBase::collector_, art::ConsumesCollector::mayConsumeView(), T, and getGoodRuns4SAM::tag.

84  {
85  return collector_.mayConsumeView<T, BT>(tag);
86  }
ConsumesCollector collector_
Definition: ModuleBase.h:50
ViewToken< Element > mayConsumeView(InputTag const &)
double T
Definition: Xdiff_gwt.C:5
ModuleDescription const& art::ModuleBase::moduleDescription ( ) const
inherited
void calib::FiberCalibration::produce ( art::Event e)
overridevirtual

Implements art::EDProducer.

Definition at line 264 of file FiberCalibration_module.cc.

References abs(), caldp::TCTrack::Add(), beta, caldp::TCTrack::CalculateFiberVelocity(), caldp::TCTrack::CalculateMuonVelocity(), clearNTuple(), cosmictr, util::CreateAssn(), geo::GeometryBase::DetHalfHeight(), geo::GeometryBase::DetHalfWidth(), geo::GeometryBase::DetId(), runNovaSAM::detId, APDHVSetting::dummy, febshutoff_auto::end, art::EventID::event(), eX, eY, eZ, fAsy, fEndPlaneDiff, fFiducialX, fFiducialY, fFiducialZ, fFitCells, fFitFrac, fiberspeed, caldp::TCTrack::FiberVelocity(), art::fill_ptr_vector(), fMaxZ, fMinZ, fOutTree, fPCHitLabel, fQualAvgLabel, fQualXYLabel, fQualZLabel, fStartPlaneDiff, fTimeRes, fTrackLabel, fTrackPlanes, fUseLiveGeo, geom(), art::DataViewImpl::getByLabel(), MECModelEnuComparisons::i, art::Event::id(), geo::LiveGeometry::InstrumentedDetBack(), geo::LiveGeometry::InstrumentedDetFront(), calib::j, novadaq::cnv::kFARDET, geo::kX, geo::kXorY, geo::kY, Mag(), std::max(), maxPl, caldp::TCTrack::MaxPlane(), maxPlX, maxPlY, minPl, caldp::TCTrack::MinPlane(), minPlX, minPlY, ncellscalT, ncellscalX, ncellscalY, ncellsfitT, ncellsfitX, ncellsfitY, caldp::TCTrack::NPCHit(), caldp::TCTrack::NXPCHit(), caldp::TCTrack::NYPCHit(), plength, art::DataViewImpl::put(), art::DataViewImpl::run(), caldp::TCTrack::SetStart(), caldp::TCTrack::SetStop(), caldp::TCTrack::SetTotalLength(), febshutoff_auto::start, rb::Prong::Start(), rb::Track::Stop(), subrun, art::DataViewImpl::subRun(), sX, sY, sZ, and make_root_from_grid_output::tr.

265  {
266 
267  std::unique_ptr< std::vector<caldp::TCTrack> > tctracks(new std::vector<caldp::TCTrack>);
268 
269  std::unique_ptr<art::Assns<caldp::TCTrack, rb::Track> > tcAssns(new art::Assns<caldp::TCTrack, rb::Track>);
270 
273  novadaq::cnv::DetId detId = geom->DetId();
274 
275  //get the cosmic tracks associated with each event
277  evt.getByLabel(fTrackLabel,trackcol);
278 
279  //get associationgs between cosmic tracks and pchits
283 
284  std::vector< art::Ptr<rb::Track> > tracks;
285  art::fill_ptr_vector(tracks, trackcol);
286 
287  //store event info in ntuple
288  run = evt.run();
289  subrun = evt.subRun();
290  event = evt.id().event();
291 
292  //if we are in data use the live geometry to find front and back of the volume.
293  if((geom->DetId() == novadaq::cnv::kFARDET) && (fUseLiveGeo)){
294  fMinZ = livegeom->InstrumentedDetFront();
295  fMaxZ = livegeom->InstrumentedDetBack();
296  }
297 
298  //now loop over the tracks
299  for (unsigned int i=0; i<tracks.size(); ++i){
300 
301  this->clearNTuple();
302 
303  const art::Ptr<rb::Track> tr = tracks.at(i);
304  //if ((tr->NXCell()==0) || (tr->NYCell()==0)) continue;
305  //get the pc hits associated with the cosmic track
306  std::vector<art::Ptr<caldp::PCHit> > pcxy = fmpcxy.at(i);
307  std::vector<art::Ptr<caldp::PCHit> > pcz = fmpcz.at(i);
308  std::vector<art::Ptr<caldp::PCHit> > pcavg = fmpcavg.at(i);
309  //empty pchit container to combine hits from the lists in
310  std::vector<art::Ptr<caldp::PCHit> > pch;
311  //if we failed to get pc hits skip slice
312  if (fmpcxy.isValid()){
313  for (unsigned int j=0; j<pcxy.size(); ++j) pch.push_back(pcxy[j]);
314  }
315  if (fmpcz.isValid()){
316  for (unsigned int j=0; j<pcz.size(); ++j) pch.push_back(pcz[j]);
317  }
318  if (fmpcavg.isValid()){
319  for (unsigned int j=0; j<pcavg.size(); ++j) pch.push_back(pcavg[j]);
320  }
321  //must be at least two pchits with this track
322  if (pch.size() < 2) continue;
323 
324 
325  cosmictr = i; //store track number
326  //passed initial round of cuts, now get track information
327  TVector3 start(tr->Start());
328  TVector3 end(tr->Stop());
329  sX = start.X();
330  sY = start.Y();
331  sZ = start.Z();
332  eX = end.X();
333  eY = end.Y();
334  eZ = end.Z();
335  plength = (end - start).Mag();
336  /*minPl = tr->MinPlane();
337  maxPl = tr->MaxPlane();
338  minCX = tr->MinCell(geo::kX);
339  minCY = tr->MinCell(geo::kY);
340  maxCX = tr->MaxCell(geo::kX);
341  maxCY = tr->MaxCell(geo::kY);
342  ncellsT = tr->NCell();
343  ncellsX = tr->NXCell();
344  ncellsY = tr->NYCell();*/
345 
346  //track quality cuts
347  //muon starpoint must be near either the ceiling or one of the walls of the detector
348  //cut assumes muons cannot enter from bottom of detector
349  //this selects muons that are not stoppers and pass all the way through the detector
350  if ((sX < geom->DetHalfWidth() - fFiducialX) &&
351  (sX > -(geom->DetHalfWidth() - fFiducialX)) &&
352  (sY < geom->DetHalfHeight() - fFiducialY) &&
353  (sZ < fMaxZ - fFiducialZ) &&
354  (sZ > std::max(0.0, fMinZ) + fFiducialZ) ) continue;
355  if ((eX < geom->DetHalfWidth() - fFiducialX) &&
356  (eX > -(geom->DetHalfWidth() - fFiducialX)) &&
357  (eY > -(geom->DetHalfHeight() - fFiducialY)) &&
358  (eZ < fMaxZ - fFiducialZ) &&
359  (eZ > std::max(0.0, fMinZ) + fFiducialZ) ) continue;
360 
361  caldp::TCTrack tc;
362 
363  tc.SetStart(start);
364  tc.SetStop(end);
366 
367  //now loop over cell hits to get the necessary ones for fiber calibration
368  for(unsigned int j=0; j<pch.size(); ++j){
369  //if the hit had a bad timing fit, throw it out
370  //if (!(pch[j]->GoodTime())) continue;
371 
372  //if the distance to readout is less then 0, don't use
373  if (pch[j]->ReadDist() < 0.0) continue;
374 
375  tc.Add(pch[j]);
376 
377  }//end loop over cells
378 
379  ncellscalT = tc.NPCHit();
380  ncellscalX = tc.NXPCHit();
381  ncellscalY = tc.NYPCHit();
382 
383  minPlX = tc.MinPlane(geo::kX);
384  minPlY = tc.MinPlane(geo::kY);
385  maxPlX = tc.MaxPlane(geo::kX);
386  maxPlY = tc.MaxPlane(geo::kY);
387  minPl = tc.MinPlane(geo::kXorY);
388  maxPl = tc.MaxPlane(geo::kXorY);
389 
390  //track must have traveled through a minimum number of planes
391  if ((maxPl-minPl) < fTrackPlanes) continue;
392 
393  //Require the minimum and maximum planes in each view to agree
394  //Cut in place to reduce case of poor reconstruction or view matching
395  //In regions with lots of dead channels this cut would need to be reconsidered
396  if (abs(minPlX-minPlY) > fStartPlaneDiff ) continue;
397  if (abs(maxPlX-maxPlY) > fEndPlaneDiff ) continue;
398 
399  //perform the fit for fiber speed for the track, do NOT drop hits outside specified residual window
400  //NOTE: When DCMs are in sync this can be configured to drop outlying hits and calculate the fiber speed. This is not desired when calculating dcm offsets
401  std::vector<double> residuals;
402  double ficept = 0.0;
403  double chisqr = 0.0;
404  fiberspeed = tc.CalculateFiberVelocity(fTimeRes,&residuals, &ficept, &chisqr, detId, false,true);
405 
406  ncellsfitT = residuals.size();
407 
408  //more quality cuts on the fit
409  //make sure cells used in fit are above threshold
410  if (ncellscalT < fFitCells) continue;
411  //make sure cells used in the fit represent a certain fraction of total hits
412  if (((double)ncellsfitT/(double)ncellscalT) < fFitFrac) continue;
413 
414  ncellsfitX = tc.NXPCHit();
415  ncellsfitY = tc.NYPCHit();
416 
417  //cut to check difference between number of x and y cells used in the fit
418  double asy = ((double)(ncellsfitY-ncellsfitX))/((double)(ncellsfitY+ncellsfitX));
419  if (fabs(asy) > fAsy) continue;
420 
421  double dummy=0.0;
422  residuals.clear();
423  beta = tc.CalculateMuonVelocity(&residuals, &dummy, &chisqr, detId, tc.FiberVelocity());
424 
425  tctracks->push_back(tc);
426 
427  util::CreateAssn(evt, *tctracks, tr, *tcAssns);
428 
429  fOutTree->Fill();
430 
431 
432  }//end loop over slices
433 
434  evt.put(std::move(tctracks));
435  evt.put(std::move(tcAssns));
436  }
T max(const caf::Proxy< T > &a, T b)
double CalculateFiberVelocity(double timeResid, std::vector< double > *resids, double *icept, double *chisqr, novadaq::cnv::DetId detectorID, bool removeHits=false, bool overwrite=false)
Definition: TCTrack.cxx:292
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.
std::string fTrackLabel
Where to find Tracks.
virtual void SetStop(TVector3 stop)
set track stop point
Definition: TCTrack.h:94
X or Y views.
Definition: PlaneGeo.h:30
int fStartPlaneDiff
maximum difference between minimum plane in each view associated with the track
double fFiducialX
maximum distance in cm muon endpoints can be from detector edge in X
Vertical planes which measure X.
Definition: PlaneGeo.h:28
std::string fPCHitLabel
Where to find calibration hits.
void abs(TH1 *hist)
virtual void SetStart(TVector3 start)
set track start point
Definition: TCTrack.h:92
int fEndPlaneDiff
maximum difference between maximum plane in each view associated with the track
double fFiducialZ
maximum distance in cm muon endpoints can be from detector edge in Z
bool fUseLiveGeo
use the live geometry to find beginning and ending diblock
int fFitCells
number of cells used in final fiber speed fit for a track
virtual TVector3 Start() const
Definition: Prong.h:73
double FiberVelocity() const
return the velocity of the optical fiber, measured for this track
Definition: TCTrack.h:99
int MaxPlane(geo::View_t view) const
return max plane number in the specified view
Definition: TCTrack.cxx:140
Horizontal planes which measure Y.
Definition: PlaneGeo.h:29
std::string fQualXYLabel
Instance label for hits with xz quality.
Far Detector at Ash River, MN.
int fTrackPlanes
number of planes track passes through
virtual void Add(const art::Ptr< caldp::PCHit > &pchit)
add a pchit to the track
Definition: TCTrack.cxx:25
double fAsy
maximum asymmetry between the x and y cells used in the final fit
double fFitFrac
fraction of cells on track kept in final fiber speed fit
double InstrumentedDetFront()
get instrumented detector front of downstream part
virtual void SetTotalLength(double length)
set track total length
Definition: TCTrack.h:96
novadaq::cnv::DetId DetId() const
Prefer ds::DetectorService::DetId() instead.
Definition: GeometryBase.h:243
int evt
unsigned int NPCHit(geo::View_t view) const
return the number of hits in a view
Definition: TCTrack.cxx:43
double InstrumentedDetBack()
get instrumented detector back of downstream part
const double j
Definition: BetheBloch.cxx:29
double DetHalfHeight() const
Definition: run.py:1
unsigned int NXPCHit() const
return number of hits in x view
Definition: TCTrack.h:37
double DetHalfWidth() const
void geom(int which=0)
Definition: geom.C:163
float Mag() const
std::string fQualZLabel
Instance label for hits with z quality.
double fTimeRes
hack for maximum z in detector, which could be incorrectly calculated depending on missing diblocks ...
double CalculateMuonVelocity(std::vector< double > *resids, double *icept, double *chisqr, novadaq::cnv::DetId detectorID, double fiberVel=9999.0) const
Definition: TCTrack.cxx:371
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:291
std::string fQualAvgLabel
Instance label for hits with avg quality.
double fFiducialY
maximum distance in cm muon endpoints can be from detector edge in Y
int MinPlane(geo::View_t view) const
return min plane number in the specified view
Definition: TCTrack.cxx:120
unsigned int NYPCHit() const
return number of hits in y view
Definition: TCTrack.h:39
double fMaxZ
hack for minimum z detector boundary for situation were front diblocks are missing ...
void calib::FiberCalibration::reconfigure ( const fhicl::ParameterSet pset)

Definition at line 150 of file FiberCalibration_module.cc.

References fAsy, fEndPlaneDiff, fFiducialX, fFiducialY, fFiducialZ, fFitCells, fFitFrac, fMaxZ, fMinZ, fPCHitLabel, fPSetFD, fPSetND, fPSetTB, fQualAvgLabel, fQualXYLabel, fQualZLabel, fStartPlaneDiff, fTimeRes, fTrackLabel, fTrackPlanes, fUseLiveGeo, fhicl::ParameterSet::get(), and string.

Referenced by FiberCalibration().

151  {
152  fPCHitLabel = pset.get< std::string >("PCHitLabel");
153  fTrackLabel = pset.get< std::string >("TrackLabel");
154  fQualXYLabel = pset.get< std::string >("QualXYLabel");
155  fQualZLabel = pset.get< std::string >("QualZLabel");
156  fQualAvgLabel = pset.get< std::string >("QualAvgLabel");
157  fFitFrac = 0;
158  fFitCells = 0;
159  fAsy = 0;
160  fTrackPlanes = 0;
161  fFiducialX = 0;
162  fFiducialY = 0;
163  fFiducialZ = 0;
164  fStartPlaneDiff = 0;
165  fEndPlaneDiff = 0;
166  fTimeRes = 0;
167  fMinZ = 0;
168  fMaxZ = 0;
169  fUseLiveGeo = false;
170  fPSetND = pset.get<fhicl::ParameterSet>("nd");
171  fPSetFD = pset.get<fhicl::ParameterSet>("fd");
172  fPSetTB = pset.get<fhicl::ParameterSet>("tb");
173  }
std::string fTrackLabel
Where to find Tracks.
int fStartPlaneDiff
maximum difference between minimum plane in each view associated with the track
double fFiducialX
maximum distance in cm muon endpoints can be from detector edge in X
std::string fPCHitLabel
Where to find calibration hits.
int fEndPlaneDiff
maximum difference between maximum plane in each view associated with the track
double fFiducialZ
maximum distance in cm muon endpoints can be from detector edge in Z
bool fUseLiveGeo
use the live geometry to find beginning and ending diblock
int fFitCells
number of cells used in final fiber speed fit for a track
std::string fQualXYLabel
Instance label for hits with xz quality.
int fTrackPlanes
number of planes track passes through
double fAsy
maximum asymmetry between the x and y cells used in the final fit
double fFitFrac
fraction of cells on track kept in final fiber speed fit
T get(std::string const &key) const
Definition: ParameterSet.h:231
std::string fQualZLabel
Instance label for hits with z quality.
double fTimeRes
hack for maximum z in detector, which could be incorrectly calculated depending on missing diblocks ...
std::string fQualAvgLabel
Instance label for hits with avg quality.
double fFiducialY
maximum distance in cm muon endpoints can be from detector edge in Y
double fMaxZ
hack for minimum z detector boundary for situation were front diblocks are missing ...
enum BeamMode string
void art::ModuleBase::setModuleDescription ( ModuleDescription const &  )
inherited
void art::ModuleBase::sortConsumables ( std::string const &  current_process_name)
inherited
std::string art::EDProducer::workerType ( ) const
inherited

Member Data Documentation

float calib::FiberCalibration::beta
private

Definition at line 118 of file FiberCalibration_module.cc.

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

int calib::FiberCalibration::cosmictr
private

Definition at line 80 of file FiberCalibration_module.cc.

Referenced by beginJob(), and produce().

int calib::FiberCalibration::event
private

Definition at line 79 of file FiberCalibration_module.cc.

Referenced by beginJob().

float calib::FiberCalibration::eX
private

Definition at line 86 of file FiberCalibration_module.cc.

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

float calib::FiberCalibration::eY
private

Definition at line 87 of file FiberCalibration_module.cc.

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

float calib::FiberCalibration::eZ
private

Definition at line 88 of file FiberCalibration_module.cc.

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

double calib::FiberCalibration::fAsy
private

maximum asymmetry between the x and y cells used in the final fit

Definition at line 62 of file FiberCalibration_module.cc.

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

int calib::FiberCalibration::fEndPlaneDiff
private

maximum difference between maximum plane in each view associated with the track

Definition at line 68 of file FiberCalibration_module.cc.

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

double calib::FiberCalibration::fFiducialX
private

maximum distance in cm muon endpoints can be from detector edge in X

Definition at line 64 of file FiberCalibration_module.cc.

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

double calib::FiberCalibration::fFiducialY
private

maximum distance in cm muon endpoints can be from detector edge in Y

Definition at line 65 of file FiberCalibration_module.cc.

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

double calib::FiberCalibration::fFiducialZ
private

maximum distance in cm muon endpoints can be from detector edge in Z

Definition at line 66 of file FiberCalibration_module.cc.

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

int calib::FiberCalibration::fFitCells
private

number of cells used in final fiber speed fit for a track

Definition at line 61 of file FiberCalibration_module.cc.

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

double calib::FiberCalibration::fFitFrac
private

fraction of cells on track kept in final fiber speed fit

Definition at line 60 of file FiberCalibration_module.cc.

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

float calib::FiberCalibration::fiberspeed
private

Definition at line 116 of file FiberCalibration_module.cc.

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

double calib::FiberCalibration::fMaxZ
private

hack for minimum z detector boundary for situation were front diblocks are missing

Definition at line 70 of file FiberCalibration_module.cc.

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

double calib::FiberCalibration::fMinZ
private

Definition at line 69 of file FiberCalibration_module.cc.

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

TTree* calib::FiberCalibration::fOutTree
private

Definition at line 121 of file FiberCalibration_module.cc.

Referenced by beginJob(), and produce().

std::string calib::FiberCalibration::fPCHitLabel
private

Where to find calibration hits.

Definition at line 53 of file FiberCalibration_module.cc.

Referenced by produce(), and reconfigure().

fhicl::ParameterSet calib::FiberCalibration::fPSetFD
private

Definition at line 123 of file FiberCalibration_module.cc.

Referenced by beginRun(), and reconfigure().

fhicl::ParameterSet calib::FiberCalibration::fPSetND
private

Definition at line 123 of file FiberCalibration_module.cc.

Referenced by beginRun(), and reconfigure().

fhicl::ParameterSet calib::FiberCalibration::fPSetTB
private

Definition at line 123 of file FiberCalibration_module.cc.

Referenced by beginRun(), and reconfigure().

std::string calib::FiberCalibration::fQualAvgLabel
private

Instance label for hits with avg quality.

Definition at line 56 of file FiberCalibration_module.cc.

Referenced by produce(), and reconfigure().

std::string calib::FiberCalibration::fQualXYLabel
private

Instance label for hits with xz quality.

Definition at line 54 of file FiberCalibration_module.cc.

Referenced by produce(), and reconfigure().

std::string calib::FiberCalibration::fQualZLabel
private

Instance label for hits with z quality.

Definition at line 55 of file FiberCalibration_module.cc.

Referenced by produce(), and reconfigure().

int calib::FiberCalibration::fStartPlaneDiff
private

maximum difference between minimum plane in each view associated with the track

Definition at line 67 of file FiberCalibration_module.cc.

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

double calib::FiberCalibration::fTimeRes
private

hack for maximum z in detector, which could be incorrectly calculated depending on missing diblocks

number of sigma timing resolution used to keep/reject hits in speed fit

Definition at line 72 of file FiberCalibration_module.cc.

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

std::string calib::FiberCalibration::fTrackLabel
private

Where to find Tracks.

Definition at line 57 of file FiberCalibration_module.cc.

Referenced by produce(), and reconfigure().

int calib::FiberCalibration::fTrackPlanes
private

number of planes track passes through

Definition at line 63 of file FiberCalibration_module.cc.

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

bool calib::FiberCalibration::fUseLiveGeo
private

use the live geometry to find beginning and ending diblock

Definition at line 73 of file FiberCalibration_module.cc.

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

int calib::FiberCalibration::maxCX
private

Definition at line 101 of file FiberCalibration_module.cc.

Referenced by clearNTuple().

int calib::FiberCalibration::maxCY
private

Definition at line 102 of file FiberCalibration_module.cc.

Referenced by clearNTuple().

int calib::FiberCalibration::maxPl
private

Definition at line 93 of file FiberCalibration_module.cc.

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

int calib::FiberCalibration::maxPlX
private

Definition at line 96 of file FiberCalibration_module.cc.

Referenced by beginJob(), and produce().

int calib::FiberCalibration::maxPlY
private

Definition at line 97 of file FiberCalibration_module.cc.

Referenced by beginJob(), and produce().

int calib::FiberCalibration::minCX
private

Definition at line 99 of file FiberCalibration_module.cc.

Referenced by clearNTuple().

int calib::FiberCalibration::minCY
private

Definition at line 100 of file FiberCalibration_module.cc.

Referenced by clearNTuple().

int calib::FiberCalibration::minPl
private

Definition at line 92 of file FiberCalibration_module.cc.

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

int calib::FiberCalibration::minPlX
private

Definition at line 94 of file FiberCalibration_module.cc.

Referenced by beginJob(), and produce().

int calib::FiberCalibration::minPlY
private

Definition at line 95 of file FiberCalibration_module.cc.

Referenced by beginJob(), and produce().

int calib::FiberCalibration::ncellscalT
private

Definition at line 108 of file FiberCalibration_module.cc.

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

int calib::FiberCalibration::ncellscalX
private

Definition at line 109 of file FiberCalibration_module.cc.

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

int calib::FiberCalibration::ncellscalY
private

Definition at line 110 of file FiberCalibration_module.cc.

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

int calib::FiberCalibration::ncellsfitT
private

Definition at line 112 of file FiberCalibration_module.cc.

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

int calib::FiberCalibration::ncellsfitX
private

Definition at line 113 of file FiberCalibration_module.cc.

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

int calib::FiberCalibration::ncellsfitY
private

Definition at line 114 of file FiberCalibration_module.cc.

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

int calib::FiberCalibration::ncellsT
private

Definition at line 104 of file FiberCalibration_module.cc.

Referenced by clearNTuple().

int calib::FiberCalibration::ncellsX
private

Definition at line 105 of file FiberCalibration_module.cc.

Referenced by clearNTuple().

int calib::FiberCalibration::ncellsY
private

Definition at line 106 of file FiberCalibration_module.cc.

Referenced by clearNTuple().

float calib::FiberCalibration::plength
private

Definition at line 90 of file FiberCalibration_module.cc.

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

int calib::FiberCalibration::run
private
int calib::FiberCalibration::subrun
private

Definition at line 78 of file FiberCalibration_module.cc.

Referenced by beginJob(), and produce().

float calib::FiberCalibration::sX
private

Definition at line 82 of file FiberCalibration_module.cc.

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

float calib::FiberCalibration::sY
private

Definition at line 83 of file FiberCalibration_module.cc.

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

float calib::FiberCalibration::sZ
private

Definition at line 84 of file FiberCalibration_module.cc.

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


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