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

 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 ()
 
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 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

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::FiberCalibration::FiberCalibration ( fhicl::ParameterSet const &  p)
explicit

Definition at line 139 of file FiberCalibration_module.cc.

References reconfigure().

141  {
142  this->reconfigure(pset);
143 
144  produces< std::vector<caldp::TCTrack> >();
145  produces< art::Assns<caldp::TCTrack, rb::Track> >();
146  }
void reconfigure(const fhicl::ParameterSet &pset)
calib::FiberCalibration::~FiberCalibration ( )
virtual

Definition at line 175 of file FiberCalibration_module.cc.

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

Member Function Documentation

void calib::FiberCalibration::beginJob ( )
overridevirtual

Reimplemented from art::EDProducer.

Definition at line 181 of file FiberCalibration_module.cc.

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

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

Reimplemented from art::EDProducer.

Definition at line 228 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.

229  {
231 
232  fhicl::ParameterSet pset;
233  switch(geom->DetId()){
235  pset = fPSetND;
236  break;
238  pset = fPSetFD;
239  break;
241  pset = fPSetTB;
242  break;
243  default:
244  assert(0 && "Unknown detector");
245  }
246 
247  fFitFrac = pset.get< double >("FitFrac");
248  fFitCells = pset.get< int >("FitCells");
249  fAsy = pset.get< double >("Asy");
250  fTrackPlanes = pset.get< int >("TrackPlanes");
251  fFiducialX = pset.get< double >("FiducialX");
252  fFiducialY = pset.get< double >("FiducialY");
253  fFiducialZ = pset.get< double >("FiducialZ");
254  fStartPlaneDiff = pset.get< int >("StartPlaneDiff");
255  fEndPlaneDiff = pset.get< int >("EndPlaneDiff");
256  fTimeRes = pset.get< double >("TimeRes");
257  fMinZ = pset.get< double >("MinZ");
258  fMaxZ = pset.get< double >("MaxZ");
259  fUseLiveGeo = pset.get< bool >("UseLiveGeo");
260  }
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 438 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().

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

Implements art::EDProducer.

Definition at line 263 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, stan::math::fabs(), 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::Event::put(), art::Event::run(), caldp::TCTrack::SetStart(), caldp::TCTrack::SetStop(), caldp::TCTrack::SetTotalLength(), febshutoff_auto::start, rb::Prong::Start(), rb::Track::Stop(), art::Event::subRun(), subrun, sX, sY, sZ, and make_root_from_grid_output::tr.

264  {
265 
266  std::unique_ptr< std::vector<caldp::TCTrack> > tctracks(new std::vector<caldp::TCTrack>);
267 
268  std::unique_ptr<art::Assns<caldp::TCTrack, rb::Track> > tcAssns(new art::Assns<caldp::TCTrack, rb::Track>);
269 
272  novadaq::cnv::DetId detId = geom->DetId();
273 
274  //get the cosmic tracks associated with each event
276  evt.getByLabel(fTrackLabel,trackcol);
277 
278  //get associationgs between cosmic tracks and pchits
282 
283  std::vector< art::Ptr<rb::Track> > tracks;
284  art::fill_ptr_vector(tracks, trackcol);
285 
286  //store event info in ntuple
287  run = evt.run();
288  subrun = evt.subRun();
289  event = evt.id().event();
290 
291  //if we are in data use the live geometry to find front and back of the volume.
292  if((geom->DetId() == novadaq::cnv::kFARDET) && (fUseLiveGeo)){
293  fMinZ = livegeom->InstrumentedDetFront();
294  fMaxZ = livegeom->InstrumentedDetBack();
295  }
296 
297  //now loop over the tracks
298  for (unsigned int i=0; i<tracks.size(); ++i){
299 
300  this->clearNTuple();
301 
302  const art::Ptr<rb::Track> tr = tracks.at(i);
303  //if ((tr->NXCell()==0) || (tr->NYCell()==0)) continue;
304  //get the pc hits associated with the cosmic track
305  std::vector<art::Ptr<caldp::PCHit> > pcxy = fmpcxy.at(i);
306  std::vector<art::Ptr<caldp::PCHit> > pcz = fmpcz.at(i);
307  std::vector<art::Ptr<caldp::PCHit> > pcavg = fmpcavg.at(i);
308  //empty pchit container to combine hits from the lists in
309  std::vector<art::Ptr<caldp::PCHit> > pch;
310  //if we failed to get pc hits skip slice
311  if (fmpcxy.isValid()){
312  for (unsigned int j=0; j<pcxy.size(); ++j) pch.push_back(pcxy[j]);
313  }
314  if (fmpcz.isValid()){
315  for (unsigned int j=0; j<pcz.size(); ++j) pch.push_back(pcz[j]);
316  }
317  if (fmpcavg.isValid()){
318  for (unsigned int j=0; j<pcavg.size(); ++j) pch.push_back(pcavg[j]);
319  }
320  //must be at least two pchits with this track
321  if (pch.size() < 2) continue;
322 
323 
324  cosmictr = i; //store track number
325  //passed initial round of cuts, now get track information
326  TVector3 start(tr->Start());
327  TVector3 end(tr->Stop());
328  sX = start.X();
329  sY = start.Y();
330  sZ = start.Z();
331  eX = end.X();
332  eY = end.Y();
333  eZ = end.Z();
334  plength = (end - start).Mag();
335  /*minPl = tr->MinPlane();
336  maxPl = tr->MaxPlane();
337  minCX = tr->MinCell(geo::kX);
338  minCY = tr->MinCell(geo::kY);
339  maxCX = tr->MaxCell(geo::kX);
340  maxCY = tr->MaxCell(geo::kY);
341  ncellsT = tr->NCell();
342  ncellsX = tr->NXCell();
343  ncellsY = tr->NYCell();*/
344 
345  //track quality cuts
346  //muon starpoint must be near either the ceiling or one of the walls of the detector
347  //cut assumes muons cannot enter from bottom of detector
348  //this selects muons that are not stoppers and pass all the way through the detector
349  if ((sX < geom->DetHalfWidth() - fFiducialX) &&
350  (sX > -(geom->DetHalfWidth() - fFiducialX)) &&
351  (sY < geom->DetHalfHeight() - fFiducialY) &&
352  (sZ < fMaxZ - fFiducialZ) &&
353  (sZ > std::max(0.0, fMinZ) + fFiducialZ) ) continue;
354  if ((eX < geom->DetHalfWidth() - fFiducialX) &&
355  (eX > -(geom->DetHalfWidth() - fFiducialX)) &&
356  (eY > -(geom->DetHalfHeight() - fFiducialY)) &&
357  (eZ < fMaxZ - fFiducialZ) &&
358  (eZ > std::max(0.0, fMinZ) + fFiducialZ) ) continue;
359 
360  caldp::TCTrack tc;
361 
362  tc.SetStart(start);
363  tc.SetStop(end);
365 
366  //now loop over cell hits to get the necessary ones for fiber calibration
367  for(unsigned int j=0; j<pch.size(); ++j){
368  //if the hit had a bad timing fit, throw it out
369  //if (!(pch[j]->GoodTime())) continue;
370 
371  //if the distance to readout is less then 0, don't use
372  if (pch[j]->ReadDist() < 0.0) continue;
373 
374  tc.Add(pch[j]);
375 
376  }//end loop over cells
377 
378  ncellscalT = tc.NPCHit();
379  ncellscalX = tc.NXPCHit();
380  ncellscalY = tc.NYPCHit();
381 
382  minPlX = tc.MinPlane(geo::kX);
383  minPlY = tc.MinPlane(geo::kY);
384  maxPlX = tc.MaxPlane(geo::kX);
385  maxPlY = tc.MaxPlane(geo::kY);
386  minPl = tc.MinPlane(geo::kXorY);
387  maxPl = tc.MaxPlane(geo::kXorY);
388 
389  //track must have traveled through a minimum number of planes
390  if ((maxPl-minPl) < fTrackPlanes) continue;
391 
392  //Require the minimum and maximum planes in each view to agree
393  //Cut in place to reduce case of poor reconstruction or view matching
394  //In regions with lots of dead channels this cut would need to be reconsidered
395  if (abs(minPlX-minPlY) > fStartPlaneDiff ) continue;
396  if (abs(maxPlX-maxPlY) > fEndPlaneDiff ) continue;
397 
398  //perform the fit for fiber speed for the track, do NOT drop hits outside specified residual window
399  //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
400  std::vector<double> residuals;
401  double ficept = 0.0;
402  double chisqr = 0.0;
403  fiberspeed = tc.CalculateFiberVelocity(fTimeRes,&residuals, &ficept, &chisqr, detId, false,true);
404 
405  ncellsfitT = residuals.size();
406 
407  //more quality cuts on the fit
408  //make sure cells used in fit are above threshold
409  if (ncellscalT < fFitCells) continue;
410  //make sure cells used in the fit represent a certain fraction of total hits
411  if (((double)ncellsfitT/(double)ncellscalT) < fFitFrac) continue;
412 
413  ncellsfitX = tc.NXPCHit();
414  ncellsfitY = tc.NYPCHit();
415 
416  //cut to check difference between number of x and y cells used in the fit
417  double asy = ((double)(ncellsfitY-ncellsfitX))/((double)(ncellsfitY+ncellsfitX));
418  if (fabs(asy) > fAsy) continue;
419 
420  double dummy=0.0;
421  residuals.clear();
422  beta = tc.CalculateMuonVelocity(&residuals, &dummy, &chisqr, detId, tc.FiberVelocity());
423 
424  tctracks->push_back(tc);
425 
426  util::CreateAssn(*this, evt, *tctracks, tr, *tcAssns);
427 
428  fOutTree->Fill();
429 
430 
431  }//end loop over slices
432 
433  evt.put(std::move(tctracks));
434  evt.put(std::move(tcAssns));
435  }
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.
fvar< T > fabs(const fvar< T > &x)
Definition: fabs.hpp:15
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:464
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 149 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().

150  {
151  fPCHitLabel = pset.get< std::string >("PCHitLabel");
152  fTrackLabel = pset.get< std::string >("TrackLabel");
153  fQualXYLabel = pset.get< std::string >("QualXYLabel");
154  fQualZLabel = pset.get< std::string >("QualZLabel");
155  fQualAvgLabel = pset.get< std::string >("QualAvgLabel");
156  fFitFrac = 0;
157  fFitCells = 0;
158  fAsy = 0;
159  fTrackPlanes = 0;
160  fFiducialX = 0;
161  fFiducialY = 0;
162  fFiducialZ = 0;
163  fStartPlaneDiff = 0;
164  fEndPlaneDiff = 0;
165  fTimeRes = 0;
166  fMinZ = 0;
167  fMaxZ = 0;
168  fUseLiveGeo = false;
169  fPSetND = pset.get<fhicl::ParameterSet>("nd");
170  fPSetFD = pset.get<fhicl::ParameterSet>("fd");
171  fPSetTB = pset.get<fhicl::ParameterSet>("tb");
172  }
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::Consumer::showMissingConsumes ( ) const
protectedinherited

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

void art::Consumer::validateConsumedProduct ( BranchType const  bt,
ProductInfo const &  pi 
)
protectedinherited

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: