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

 DriftResponseCalc (fhicl::ParameterSet const &p)
 
virtual ~DriftResponseCalc ()
 
void produce (art::Event &e) override
 
void reconfigure (fhicl::ParameterSet const &p)
 
void beginJob () override
 
void beginRun (art::Run &r) override
 
void endRun (art::Run &r) 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 Member Functions

daqchannelmap::dchan GetChanID (daqchannelmap::plane_t plane, daqchannelmap::cell_t cell, novadaq::cnv::DetId det)
 
void FillPeCorrHits (art::Handle< std::vector< caldp::PCHit > > &cells, std::map< daqchannelmap::dchan, std::vector< double > > &mMeanPe, novadaq::cnv::DetId detid)
 
void CalculateMean (std::vector< double > &chanvector, double &fMean, double &fMeanErr, int &fNHits, double &fRMS)
 
void DrawMean (std::vector< double > &chanvector, TH1F *hpecorr)
 

Private Attributes

std::string fPCHitLabel
 
std::string fQualXYName
 Label of PCHit data. More...
 
std::string fQualZName
 Instance name, XY qual hits. More...
 
std::string fQualAvgName
 Instance name, Z qual hits. More...
 
std::string fFillType
 Instance name, Avg qual hits. More...
 
bool fDrawMeans
 Method for calculating means (which quals to use) More...
 
int fDiBlockNum
 Save response histograms to file, true/false? More...
 
int fDCMNum
 DiBlock Number to use (set to 0 with fDCMNum=0 to run all) More...
 
std::map< daqchannelmap::dchan, std::vector< double > > mMeanPeXY
 DCM Number to use (set to 0 with fDiBlockNum=0 to run all) More...
 
std::map< daqchannelmap::dchan, std::vector< double > > mMeanPeZ
 
std::map< daqchannelmap::dchan, std::vector< double > > mMeanPeAvg
 
std::vector< double > eventTime
 
std::uint32_t minTime
 
std::uint32_t maxTime
 
bool isData
 
std::map< daqchannelmap::dchan, TH1F * > srHistprint
 
TH2F * hMeanDet
 
TH1F * hRMS
 
TH1F * hMeanFrac
 
TH1F * hNHits
 

Detailed Description

Definition at line 51 of file DriftResponseCalc_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::DriftResponseCalc::DriftResponseCalc ( fhicl::ParameterSet const &  p)
explicit

Definition at line 110 of file DriftResponseCalc_module.cc.

References art::InRun.

111 {
112  reconfigure(p);
113 
114  //DriftResponse output produced every Run
115  produces< std::vector<caldp::DriftResponse >, art::InRun >();
116 
117 }
const char * p
Definition: xmltok.h:285
void reconfigure(fhicl::ParameterSet const &p)
calib::DriftResponseCalc::~DriftResponseCalc ( )
virtual

Definition at line 119 of file DriftResponseCalc_module.cc.

120 {
121 }

Member Function Documentation

void calib::DriftResponseCalc::beginJob ( )
overridevirtual

Reimplemented from art::EDProducer.

Definition at line 265 of file DriftResponseCalc_module.cc.

266 {
267 }
void calib::DriftResponseCalc::beginRun ( art::Run r)
overridevirtual

Reimplemented from art::EDProducer.

Definition at line 269 of file DriftResponseCalc_module.cc.

References visualisationForPaperMasterPlot::cmap, geo::GeometryBase::DetId(), geo2elec::diblock, geom(), daqchannelmap::DAQChannelMap::getDCM(), daqchannelmap::DAQChannelMap::getDiBlock(), geo::GeometryBase::GetPlanesByView(), geo::kX, geo::kY, cmap::dataprov::CMap::Map(), cet::sqlite::max(), min(), geo::PlaneGeo::Ncells(), geo::GeometryBase::Plane(), and POTSpillRate::view.

270 {
271 
272  //Automatic assumption = we are running MC
273  isData = false;
274 
275  //We want to be able to handle any time possible.
278 
279  //Check if map of XY hits is filled; if not, define vectors for all maps.
280  //NOTE: Geometry service features dictate this must go in beginRun instead of beginJob.
281  if (mMeanPeXY.size()==0){
282 
283  //Geometry service:
285 
286  //Channel map service:
288 
289  //Detector identity:
290  novadaq::cnv::DetId detid = geom->DetId();
291 
292  //Plane, cell, channel ID output:
293  unsigned int planeid;
294  unsigned int cellid;
295  daqchannelmap::dchan chanid;
296 
297  //---Must make vector (for PCHits) for each FEB in detector.
298 
299  //Loop over X and Y views:
300  for (int view = geo::kX; view <= geo::kY; ++view){
301 
302  //Grab set of planes in that view from geometry
303  const std::set<unsigned int> planeSet =
305 
306  //Iterate over std:set of planes:
307  std::set<unsigned int >::iterator planeIter;
308  for (planeIter = planeSet.begin(); planeIter != planeSet.end(); ++planeIter){
309 
310  //Grab plane number for this entry
311  planeid = *planeIter;
312 
313  //Loop over cells in that plane:
314  for (unsigned int icx = 0; icx < geom->Plane(planeid)->Ncells(); ++icx){
315 
316  //Cell number is loop entry
317  cellid = icx;
318 
319  //Find FEB and create ID describing FEB and plane:
320  chanid = GetChanID(planeid,cellid,detid);
321 
322  //Check to see if running this diblock and dcm:
323  daqchannelmap::diblock_t diblock = cmap->Map()->getDiBlock(chanid);
324  daqchannelmap::dcm_id_t dcmnum = cmap->Map()->getDCM(chanid);
325 
326  //Are we supposed to run this DCM and DiBlock, according to fcl settings?
327  if ( ((fDiBlockNum>=0&&diblock==(unsigned int)fDiBlockNum)||fDiBlockNum<0) &&
328  ((fDCMNum>=0&&dcmnum==(unsigned int)fDCMNum)||fDCMNum<0) ){
329 
330  //Define new vector of hits for each map if FEB entry doesn't already exist.
331  if (mMeanPeXY.find(chanid) == mMeanPeXY.end()) {
332 
333  mMeanPeXY.insert(std::pair<daqchannelmap::dchan,std::vector<double> >(chanid,std::vector<double>()));
334  mMeanPeZ.insert(std::pair<daqchannelmap::dchan,std::vector<double> >(chanid,std::vector<double>()));
335  mMeanPeAvg.insert(std::pair<daqchannelmap::dchan,std::vector<double> >(chanid,std::vector<double>()));
336  }
337  }
338 
339  }//end cell loop
340  }//end plane loop
341  }//end view loop
342 
343  } else {
344 
345  //Clear out vectors for individual channels to start with:
346 
347  daqchannelmap::dchan channum;
348  std::map< daqchannelmap::dchan, std::vector<double> >::iterator chanIter;
349  for (chanIter = mMeanPeXY.begin(); chanIter != mMeanPeXY.end(); ++chanIter) {
350  channum = chanIter->first;
351  mMeanPeXY[channum].clear();
352  mMeanPeZ[channum].clear();
353  mMeanPeAvg[channum].clear();
354  }
355 
356  }
357 }
std::map< daqchannelmap::dchan, std::vector< double > > mMeanPeZ
diblock
print "ROW IS " print row
Definition: geo2elec.py:31
int fDiBlockNum
Save response histograms to file, true/false?
Vertical planes which measure X.
Definition: PlaneGeo.h:28
unsigned int Ncells() const
Number of cells in this plane.
Definition: PlaneGeo.h:43
const daqchannelmap::DAQChannelMap * Map() const
Definition: CMap.h:57
int fDCMNum
DiBlock Number to use (set to 0 with fDCMNum=0 to run all)
const PlaneGeo * Plane(unsigned int i) const
Horizontal planes which measure Y.
Definition: PlaneGeo.h:29
std::map< daqchannelmap::dchan, std::vector< double > > mMeanPeAvg
std::map< daqchannelmap::dchan, std::vector< double > > mMeanPeXY
DCM Number to use (set to 0 with fDiBlockNum=0 to run all)
novadaq::cnv::DetId DetId() const
Prefer ds::DetectorService::DetId() instead.
Definition: GeometryBase.h:243
uint32_t dcm_id_t
Type for DCM number, counts from 1.
static float min(const float a, const float b, const float c)
Definition: absgeo.cxx:45
const std::set< unsigned int > & GetPlanesByView(View_t v=kXorY) const
void geom(int which=0)
Definition: geom.C:163
uint32_t diblock_t
Type for diblocks and blocks.
dcm_id_t getDCM(dchan daqchan) const
Decode the dcm ID from a dchan.
daqchannelmap::dchan GetChanID(daqchannelmap::plane_t plane, daqchannelmap::cell_t cell, novadaq::cnv::DetId det)
uint32_t dchan
< DAQ Channel Map Package
T max(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:68
diblock_t getDiBlock(dchan daqchan) const
Decode the diblock ID from a dchan.
void calib::DriftResponseCalc::CalculateMean ( std::vector< double > &  chanvector,
double &  fMean,
double &  fMeanErr,
int fNHits,
double &  fRMS 
)
private

Function returns truncated mean (fMean), error on mean (fMeanErr), number of hits in truncated mean (fNHits), and RMS of response (fRMS) for vector of PECorrs for a single channel.

Definition at line 212 of file DriftResponseCalc_module.cc.

References MECModelEnuComparisons::i, makeTrainCVSamples::int, and std::sqrt().

212  {
213  ///Function returns truncated mean (fMean), error on mean (fMeanErr), number of hits in truncated mean (fNHits), and RMS of
214  ///response (fRMS) for vector of PECorrs for a single channel.
215 
216  //Initialize all to 0:
217  fNHits = 0;
218  fMean = 0;
219  fMeanErr = 0;
220 
221  //Sort the list:
222  std::sort(chanvector.begin(),chanvector.end());
223 
224  //Find boundary of the smallest 90% of hits
225  fNHits = (int)(chanvector.size()*9/10);
226 
227  //Return if there are too few hits in the final list
228  if (fNHits<=1) return;
229 
230  //Loop over the vector and calculate sum of hits
231  double dsum=0;
232  int i=0;
233  for (i=0; i<fNHits; ++i) dsum += chanvector[i];
234 
235  //Also number of hits, for use as double in math
236  double dnhits = (double)fNHits;
237 
238  //Calculate the mean:
239  fMean=dsum/dnhits;
240 
241  //Sum up difference from mean squared:
242  double dsumvar2=0;
243  for (i=0; i<fNHits; ++i) dsumvar2 += (chanvector[i]-fMean)*(chanvector[i]-fMean);
244 
245  //Unbiased estimate of true variance:
246  double dstdvar = sqrt(dsumvar2/(dnhits - 1));
247 
248  //Estimate of uncertainty on mean:
249  fMeanErr = dstdvar/sqrt(dnhits);
250  fRMS = dstdvar;
251 }
T sqrt(T number)
Definition: d0nt_math.hpp:156
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
void calib::DriftResponseCalc::DrawMean ( std::vector< double > &  chanvector,
TH1F *  hpecorr 
)
private

Definition at line 253 of file DriftResponseCalc_module.cc.

References MECModelEnuComparisons::i, and makeTrainCVSamples::int.

253  {
254 
255  //Sort the list and grab bottom 90% of events:
256  std::sort(chanvector.begin(),chanvector.end());
257  int nhits = (int)(chanvector.size()*9/10);
258 
259  //Fill the histogram
260  for (int i=0; i<nhits; ++i) hpecorr->Fill(chanvector[i]);
261 
262 }
void calib::DriftResponseCalc::endRun ( art::Run r)
overridevirtual

Reimplemented from art::EDProducer.

Definition at line 404 of file DriftResponseCalc_module.cc.

References caldp::DriftResponse::AddChannelResponse(), caldp::DriftResponse::CheckForChannel(), DEFINE_ART_MODULE(), febshutoff_auto::end, geom(), geo::GeometryBase::GetPlanesByView(), makeTrainCVSamples::int, calib::kAverage, geo::kX, calib::kXYAdjacents, geo::kY, calib::kZAdjacents, art::TFileDirectory::make(), nplanes, art::Run::put(), art::Run::run(), and string.

405 {
406 
407  //Geometry service:
409 
410  //Some information for histograms:
411  const std::set<unsigned int> planeSetX = geom->GetPlanesByView(geo::kX);
412  const std::set<unsigned int> planeSetY = geom->GetPlanesByView(geo::kY);
413  int nplanes = planeSetX.size() + planeSetY.size();
414 
415  //---Summary histograms for this run--------------//
416 
418 
419  hMeanDet = tfs->make<TH2F>("hMeanDet",
420  "Response Plane vs. FEB; Plane Number; FEB",
421  nplanes+1,0,nplanes+1,3,0,3.);
422 
423  hRMS = tfs->make<TH1F>("hRMS",
424  "RMS of Truncated Response; RMS of Truncated Response (PE); Modules",
425  100,0,100.);
426 
427  hMeanFrac = tfs->make<TH1F>("hMeanFrac",
428  "Fractional Error on Mean; Frac Error on Mean; Modules",
429  100,0,0.10);
430 
431  hNHits = tfs->make<TH1F>("hNHits",
432  "Number of Hits in FEB; Number of Hits in FEB; Modules",
433  1000,0,50000.);
434 
435  //-----------------------------------------------//
436 
437  //Ptr to DriftResp information:
438  std::unique_ptr<std::vector<caldp::DriftResponse > >fDriftResponse(new std::vector<caldp::DriftResponse >);
439 
440  //Run-specific values for Drift response
441  int fRun = r.run();
442 
443  //To be changed with Jon Paley's updated info
444  //art::Timestamp fStart = r.beginTime();
445  //art::Timestamp fEnd = r.endTime();
446 
447  caldp::DriftResponse driftresp(fRun,minTime,maxTime);
448 
449  //Remaining DriftResponse values to be calculated for each FEB:
450  double fMean =0;
451  double fRMS =0;
452  double fMeanErr=0;
453  int fNHits =0;
454  int fChanId =0;
455 
456  int FEBcount=0;
457  int prevplane=-1;
458  std::ofstream myfile;
459  if (fDrawMeans) {
460  myfile.open ("chaninfo.txt");
461  }
462 
464 
465  //Iterate over map of channels -> XY hits to start with.
466  std::map< daqchannelmap::dchan, std::vector<double> >::iterator chanIter;
467  for (chanIter = mMeanPeXY.begin(); chanIter != mMeanPeXY.end(); ++chanIter) {
468 
469  //Grab ID and vector for XY:
470  fChanId=chanIter->first;
471  std::vector<double> chanvector;
472 
473 
474  if (fFillType=="Successive"||fFillType=="Exclusive"){
475 
476  //vector of XY hits:
477  chanvector=chanIter->second;
478 
479  //Calculate mean, error on mean, rms, and number of hits for XY hits
480  fPathQual = calib::kXYAdjacents;
481  CalculateMean(chanvector,fMean,fMeanErr,fNHits,fRMS);
482 
483  //Not enough statistics. Add the Z hits.
484  if (fMean==0||(fMean>0&&fMeanErr/fMean>0.03)){
485  if (fFillType=="Exclusive") chanvector.clear();
486  chanvector.insert(chanvector.end(),
487  (mMeanPeZ.at(fChanId)).begin(),
488  (mMeanPeZ.at(fChanId)).end());
489 
490  //Re-calculate mean, etc. with Z hits added
491  fPathQual = calib::kZAdjacents;
492  CalculateMean(chanvector,fMean,fMeanErr,fNHits,fRMS);
493 
494  //Not enough statistics. Add the Avg hits.
495  if (fMean==0||(fMean>0&&fMeanErr/fMean>0.03)){
496  if (fFillType=="Exclusive") chanvector.clear();
497  chanvector.insert(chanvector.end(),
498  (mMeanPeAvg.at(fChanId)).begin(),
499  (mMeanPeAvg.at(fChanId)).end());
500 
501  //Re-calculate mean, etc. with Avg hits added
502  fPathQual = calib::kAverage;
503  CalculateMean(chanvector,fMean,fMeanErr,fNHits,fRMS);
504 
505 
506  }//(End calc with added Avg hits)
507 
508  }//(End calc with added Z hits)
509 
510  } else if (fFillType=="XY"){
511 
512  //Vector from iterator:
513  chanvector=chanIter->second;
514 
515  //Calculate mean, error on mean, and number of hits for XY hits:
516  fPathQual = calib::kXYAdjacents;
517  CalculateMean(chanvector,fMean,fMeanErr,fNHits,fRMS);
518 
519  } else if (fFillType=="Z"){
520 
521  //Z vector from other map:
522  chanvector.insert(chanvector.end(),
523  (mMeanPeZ.at(fChanId)).begin(),
524  (mMeanPeZ.at(fChanId)).end());
525 
526  //Calculate mean, error on mean, and number of hits for Z hits:
527  fPathQual = calib::kZAdjacents;
528  CalculateMean(chanvector,fMean,fMeanErr,fNHits,fRMS);
529 
530  } else if (fFillType=="Avg"){
531 
532  //Avg vector from other map:
533  chanvector.insert(chanvector.end(),
534  (mMeanPeAvg.at(fChanId)).begin(),
535  (mMeanPeAvg.at(fChanId)).end());
536 
537  //Calculate mean, error on mean, and number of hits for Avg hits:
538  fPathQual = calib::kAverage;
539  CalculateMean(chanvector,fMean,fMeanErr,fNHits,fRMS);
540 
541  }
542 
543  //Final calibrated value is not good enough:
544  if (fNHits==0){
545  fMean=-1;
546  fMeanErr=-1;
547  fRMS=-1;
548  }//(End failed calibration)
549 
550  if (fDrawMeans) {
551 
552  myfile << "//--------Statistics for ChanId=" << fChanId << " (initial size=" << chanvector.size() << ")\n";
553  myfile << "// Mean=" << fMean << "+/-" << fMeanErr << " RMS=" << fRMS << " n=" << fNHits << " qual=" << fPathQual <<"\n";
554 
555  std::string histname = Form("h_r%d_id%d",fRun,fChanId);
556 
557  srHistprint[fChanId] = tfs->make<TH1F>(Form("%s",histname.c_str()),
558  "Truncated PECorr;PECorr;Number of Hits",
559  200,0.,200.);
560  DrawMean(chanvector,srHistprint[fChanId]);
561 
562  }
563 
564  //Fill 2D response plot for (plane vs FEB)
565  int planefill = (int)(fChanId/1e6);
566  if (planefill==prevplane){
567  FEBcount++;
568  } else { FEBcount=0; }
569  prevplane=planefill;
570  if (fMean>0) {
571  hMeanDet->SetBinContent(planefill+1,FEBcount+1,fMean);
572  hMeanFrac->Fill(fMeanErr/fMean);
573  hRMS->Fill(fRMS);
574  hNHits->Fill(fNHits);
575  }
576 
577  //---Insert channel response-----//
578  if (!driftresp.CheckForChannel(fChanId))
579  driftresp.AddChannelResponse(fChanId,fMean,fMeanErr,fRMS,fNHits);
580 
581  }//(End calc over entries in XY hit map)
582 
583  fDriftResponse->push_back(driftresp);
584 
585  //Add the DriftResponse structure.
586  r.put(std::move(fDriftResponse));
587  if (fDrawMeans) myfile.close();
588 
589 }
std::map< daqchannelmap::dchan, std::vector< double > > mMeanPeZ
Structure to hold drift response in a single channel at a single time.
Definition: DriftResponse.h:36
std::string fFillType
Instance name, Avg qual hits.
Vertical planes which measure X.
Definition: PlaneGeo.h:28
void DrawMean(std::vector< double > &chanvector, TH1F *hpecorr)
art::ProductID put(std::unique_ptr< PROD > &&)
Definition: Run.h:149
RunNumber_t run() const
Definition: Run.h:47
Horizontal planes which measure Y.
Definition: PlaneGeo.h:29
std::map< daqchannelmap::dchan, std::vector< double > > mMeanPeAvg
std::map< daqchannelmap::dchan, std::vector< double > > mMeanPeXY
DCM Number to use (set to 0 with fDiBlockNum=0 to run all)
EPathQuality
Methods used to estimate path length of a track through a cell.
Definition: CalibUtil.h:40
bool fDrawMeans
Method for calculating means (which quals to use)
std::map< daqchannelmap::dchan, TH1F * > srHistprint
int nplanes
Definition: geom.C:145
T * make(ARGS...args) const
const std::set< unsigned int > & GetPlanesByView(View_t v=kXorY) const
void geom(int which=0)
Definition: geom.C:163
void CalculateMean(std::vector< double > &chanvector, double &fMean, double &fMeanErr, int &fNHits, double &fRMS)
enum BeamMode string
void calib::DriftResponseCalc::FillPeCorrHits ( art::Handle< std::vector< caldp::PCHit > > &  cells,
std::map< daqchannelmap::dchan, std::vector< double > > &  mMeanPe,
novadaq::cnv::DetId  detid 
)
private

Adds PECorr to vector for correct channel.

Definition at line 163 of file DriftResponseCalc_module.cc.

References caldp::PCHit::Cell(), getBrightness::cell, calib::Calibrator::GetAttenScale(), MECModelEnuComparisons::i, caldp::PCHit::Path(), caldp::PCHit::PE(), caldp::PCHit::Plane(), rb::CellHit::SetCell(), rawdata::RawDigit::SetMC(), rb::CellHit::SetPlane(), and caldp::PCHit::W().

163  {
164  ///Adds PECorr to vector for correct channel.
165 
166  daqchannelmap::dchan chanid; //Channel ID
167  double fPeCorr=-1; //PECorr value to insert
168  double attencorr = 1.0;
169  size_t i=0;
170 
171  //Calibrator necessary to get Atten information
173 
174  //Loop over PCHits:
175  for (i = 0; i < cells->size(); ++i){
176 
177  const caldp::PCHit *cell = &cells->at(i);
178 
179  //Go to the next hit if something strange happened with path calculation:
180  if (cell->Path()<=0) continue;
181 
182  //Get the unique channel ID:
183  chanid = GetChanID(cell->Plane(),cell->Cell(),detid);
184 
185  //Check if channel was added to map:
186  if (mMeanPe.find(chanid) != mMeanPe.end() ) {
187 
188  //Make mock cellhit for use in Attenuation Calibrator
189  rb::CellHit cellhit;
190  cellhit.SetPlane(cell->Plane());
191  cellhit.SetCell(cell->Cell());
192 
193  //Set hit as data or MC
194  if (!isData) cellhit.SetMC();
195 
196  //Attenuation constant for this hit:
197  attencorr = calibrator->GetAttenScale(cellhit, cell->W());
198 
199  //Skip this hit if cell is not calibrated.
200  if (attencorr<=0) continue;
201 
202  //Correct the PE hit for Attenuation and Path length and add to vector:
203  fPeCorr = cell->PE()*attencorr/cell->Path();
204  mMeanPe[chanid].push_back(fPeCorr);
205 
206  }//End "if channel found in map"
207 
208  }//End cell loop
209 
210 }
int Cell() const
Return cell value.
Definition: PCHit.h:26
"Pre-calibration hit". Common input to calibration procedures
Definition: PCHit.h:16
float Path() const
Return Path value.
Definition: PCHit.h:40
void SetPlane(unsigned short plane)
Definition: CellHit.h:53
float W() const
Return W value.
Definition: PCHit.h:42
void SetCell(unsigned short cell)
Definition: CellHit.h:52
float PE() const
Return PE value.
Definition: PCHit.h:38
double GetAttenScale(rb::CellHit const &cellhit, double w)
for PE->PECorr conversion
int Plane() const
Return plane value.
Definition: PCHit.h:24
void SetMC(bool isMC=true)
Definition: RawDigit.h:106
A rawdata::RawDigit with channel information decoded.
Definition: CellHit.h:27
daqchannelmap::dchan GetChanID(daqchannelmap::plane_t plane, daqchannelmap::cell_t cell, novadaq::cnv::DetId det)
uint32_t dchan
< DAQ Channel Map Package
seed_t art::EngineCreator::get_seed_value ( fhicl::ParameterSet const &  pset,
char const  key[] = "seed",
seed_t const  implicit_seed = -1 
)
inherited
daqchannelmap::dchan calib::DriftResponseCalc::GetChanID ( daqchannelmap::plane_t  plane,
daqchannelmap::cell_t  cell,
novadaq::cnv::DetId  det 
)
private

Returns unique ID, channel number for pixel 0 in corresponding FEB

Definition at line 138 of file DriftResponseCalc_module.cc.

References visualisationForPaperMasterPlot::cmap, febshutoff_auto::dcm, geo2elec::diblock, daqchannelmap::DAQChannelMap::encodeDChan(), daqchannelmap::DAQChannelMap::encodeLChan(), daqchannelmap::DAQChannelMap::getDCM(), daqchannelmap::DAQChannelMap::getDiBlock(), daqchannelmap::DAQChannelMap::getFEB(), and cmap::dataprov::CMap::Map().

138  {
139  ///Returns unique ID, channel number for pixel 0 in corresponding FEB
140 
141  //Channel map service:
143 
144  //---Find and assign a unique ID number to the current FEB---//
145  //Get the DAQ channel ID for this cell/plane/det:
146  daqchannelmap::lchan logchannel = cmap->Map()->encodeLChan(det, plane, cell);
147  daqchannelmap::dchan daqchannel = cmap->Map()->encodeDChan(logchannel);
148  //Get the DiBlock number for this DAQ channel:
149  daqchannelmap::diblock_t diblock = cmap->Map()->getDiBlock(daqchannel);
150  //Get the DMC for this DAQ channel:
151  daqchannelmap::dcm_id_t dcm = cmap->Map()->getDCM(daqchannel);
152  //Get the FEB position for this DAQ channel:
153  daqchannelmap::feb_t dcmlink = cmap->Map()->getFEB(daqchannel);
154 
155  //Pixel 0 is the unique channel ID:
156  daqchannelmap::dchan chanid = cmap->Map()->encodeDChan(det, diblock, dcm, dcmlink, 0);
157 
158  //Return unique ID for FEB:
159  return chanid;
160 
161 }
diblock
print "ROW IS " print row
Definition: geo2elec.py:31
const daqchannelmap::DAQChannelMap * Map() const
Definition: CMap.h:57
lchan encodeLChan(int detId, plane_t plane, cell_t cell) const
uint32_t feb_t
Type for DCM link port. Counts from 0.
uint32_t dcm_id_t
Type for DCM number, counts from 1.
uint32_t diblock_t
Type for diblocks and blocks.
dcm_id_t getDCM(dchan daqchan) const
Decode the dcm ID from a dchan.
dchan encodeDChan(int detID, diblock_t diblock, dcm_id_t dcm, feb_t feb, pixel_t pixel) const
uint32_t dchan
< DAQ Channel Map Package
diblock_t getDiBlock(dchan daqchan) const
Decode the diblock ID from a dchan.
feb_t getFEB(dchan daqchan) const
Decode the feb id from a dchan.
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::DriftResponseCalc::produce ( art::Event e)
overridevirtual

Implements art::EDProducer.

Definition at line 360 of file DriftResponseCalc_module.cc.

References geo::GeometryBase::DetId(), geom(), art::DataViewImpl::getByLabel(), art::Event::time(), and art::Timestamp::timeHigh().

361 {
362 
363  //Check if this is Data:
364  //if (e.isRealData()) isData = true;
365 
366  //Geometry service
368 
369  //Grab detector ID from geometry
370  novadaq::cnv::DetId detid = geom->DetId();
371 
372  //---Grab collections of PCHits for each path quality--//
373  //Highest XY quality events:
375  e.getByLabel(fPCHitLabel, fQualXYName, cellsxy);
376  //Medium Z quality events:
378  e.getByLabel(fPCHitLabel, fQualZName, cellsz);
379  //Lowest Avg quality events:
381  e.getByLabel(fPCHitLabel, fQualAvgName, cellsavg);
382 
383  //Uncomment to access track/hit association:
384  //art::FindOne<rb::Track> fa(cellsxy, e, art::InputTag("caliblist", fQualXYName));
385 
386  //Update min and max times. This should later be edited with Jon Paley's info.
387  std::uint32_t evtTimeS = e.time().timeHigh();
388  eventTime.push_back(evtTimeS);
389  if (evtTimeS>maxTime) maxTime = evtTimeS;
390  if (evtTimeS<minTime) minTime = evtTimeS;
391 
392  //Fill all cell types!
393  FillPeCorrHits(cellsxy,mMeanPeXY,detid);
394  FillPeCorrHits(cellsz,mMeanPeZ,detid);
395  FillPeCorrHits(cellsavg,mMeanPeAvg,detid);
396 
397  //Uncomment to access association information, add own code.
398  // if(fa.at(i).isValid()){
399  // std::cout << "Track cells=" << fa.at(i).ref().NCell() << std::endl;
400  // }
401 
402 }//End produce function
std::map< daqchannelmap::dchan, std::vector< double > > mMeanPeZ
constexpr std::uint32_t timeHigh() const
Definition: Timestamp.h:35
std::string fQualXYName
Label of PCHit data.
void FillPeCorrHits(art::Handle< std::vector< caldp::PCHit > > &cells, std::map< daqchannelmap::dchan, std::vector< double > > &mMeanPe, novadaq::cnv::DetId detid)
std::map< daqchannelmap::dchan, std::vector< double > > mMeanPeAvg
std::map< daqchannelmap::dchan, std::vector< double > > mMeanPeXY
DCM Number to use (set to 0 with fDiBlockNum=0 to run all)
novadaq::cnv::DetId DetId() const
Prefer ds::DetectorService::DetId() instead.
Definition: GeometryBase.h:243
std::string fQualAvgName
Instance name, Z qual hits.
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
std::string fQualZName
Instance name, XY qual hits.
void geom(int which=0)
Definition: geom.C:163
Timestamp time() const
Definition: Event.h:61
void calib::DriftResponseCalc::reconfigure ( fhicl::ParameterSet const &  p)

Definition at line 124 of file DriftResponseCalc_module.cc.

References fhicl::ParameterSet::get(), and string.

125 {
126  fPCHitLabel = pset.get< std::string >("PCHitLabel"); //Label of PCHitList module
127  fQualXYName = pset.get< std::string >("QualXYName"); //Instance label, "XY" quality hits
128  fQualZName = pset.get< std::string >("QualZName"); //Instance label, "Z" quality hits
129  fQualAvgName = pset.get< std::string >("QualAvgName");//Instance label, "Avg" quality hits
130  fDrawMeans = pset.get< bool >("DrawMeans"); //Do or do not save mean histos
131  fFillType = pset.get< std::string >("FillType"); //How to calc means
132  fDiBlockNum = pset.get< int >("DiBlockNum"); //Number of DiBlock to run (if = 0, run all)
133  fDCMNum = pset.get< int >("DCMNum"); //Number of DiBlock to run (if = 0, run all)
134 
135 }
std::string fFillType
Instance name, Avg qual hits.
int fDiBlockNum
Save response histograms to file, true/false?
std::string fQualXYName
Label of PCHit data.
int fDCMNum
DiBlock Number to use (set to 0 with fDCMNum=0 to run all)
std::string fQualAvgName
Instance name, Z qual hits.
bool fDrawMeans
Method for calculating means (which quals to use)
std::string fQualZName
Instance name, XY qual hits.
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<double> calib::DriftResponseCalc::eventTime
private

Definition at line 94 of file DriftResponseCalc_module.cc.

int calib::DriftResponseCalc::fDCMNum
private

DiBlock Number to use (set to 0 with fDCMNum=0 to run all)

Definition at line 86 of file DriftResponseCalc_module.cc.

int calib::DriftResponseCalc::fDiBlockNum
private

Save response histograms to file, true/false?

Definition at line 85 of file DriftResponseCalc_module.cc.

bool calib::DriftResponseCalc::fDrawMeans
private

Method for calculating means (which quals to use)

Definition at line 84 of file DriftResponseCalc_module.cc.

std::string calib::DriftResponseCalc::fFillType
private

Instance name, Avg qual hits.

Definition at line 83 of file DriftResponseCalc_module.cc.

std::string calib::DriftResponseCalc::fPCHitLabel
private

Definition at line 79 of file DriftResponseCalc_module.cc.

std::string calib::DriftResponseCalc::fQualAvgName
private

Instance name, Z qual hits.

Definition at line 82 of file DriftResponseCalc_module.cc.

std::string calib::DriftResponseCalc::fQualXYName
private

Label of PCHit data.

Definition at line 80 of file DriftResponseCalc_module.cc.

std::string calib::DriftResponseCalc::fQualZName
private

Instance name, XY qual hits.

Definition at line 81 of file DriftResponseCalc_module.cc.

TH2F* calib::DriftResponseCalc::hMeanDet
private

Definition at line 103 of file DriftResponseCalc_module.cc.

TH1F* calib::DriftResponseCalc::hMeanFrac
private

Definition at line 105 of file DriftResponseCalc_module.cc.

TH1F* calib::DriftResponseCalc::hNHits
private

Definition at line 106 of file DriftResponseCalc_module.cc.

TH1F* calib::DriftResponseCalc::hRMS
private

Definition at line 104 of file DriftResponseCalc_module.cc.

bool calib::DriftResponseCalc::isData
private

Definition at line 99 of file DriftResponseCalc_module.cc.

std::uint32_t calib::DriftResponseCalc::maxTime
private

Definition at line 96 of file DriftResponseCalc_module.cc.

std::uint32_t calib::DriftResponseCalc::minTime
private

Definition at line 95 of file DriftResponseCalc_module.cc.

std::map< daqchannelmap::dchan, std::vector<double> > calib::DriftResponseCalc::mMeanPeAvg
private

Definition at line 91 of file DriftResponseCalc_module.cc.

std::map< daqchannelmap::dchan, std::vector<double> > calib::DriftResponseCalc::mMeanPeXY
private

DCM Number to use (set to 0 with fDiBlockNum=0 to run all)

Definition at line 89 of file DriftResponseCalc_module.cc.

std::map< daqchannelmap::dchan, std::vector<double> > calib::DriftResponseCalc::mMeanPeZ
private

Definition at line 90 of file DriftResponseCalc_module.cc.

std::map<daqchannelmap::dchan, TH1F*> calib::DriftResponseCalc::srHistprint
private

Definition at line 102 of file DriftResponseCalc_module.cc.


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