Public Member Functions | Private Attributes | List of all members
photrans::FiberBrightness Class Reference

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N20-10-26/PhotonTransport/FiberBrightness.h"

Public Member Functions

 FiberBrightness (fhicl::ParameterSet const &pset, art::ActivityRegistry &reg)
 
 ~FiberBrightness ()
 
void preBeginRun (art::Run const &run)
 
double getBrightness (unsigned int plane, unsigned int cell) const
 
unsigned int getBrightnessIndex (unsigned int plane, unsigned int cell) const
 
unsigned int NumberBrightnessBins () const
 
bool IsModeled () const
 

Private Attributes

const BrightnessLevelfLevel
 
bool fLevelInitAttempted
 
std::string fBrightnessLabel
 
bool fReadFromFile
 
std::string fBrightnessFile_ND
 Relative path to the ND brightness correction file. More...
 
std::string fBrightnessFile_FD
 Relative path to the FD brightness correction file. More...
 
std::string fBrightnessMapName
 
std::string fBrightnessValueName
 
std::string fBrightnessValueMapName
 
art::ServiceHandle< ds::DetectorServicefDet
 

Detailed Description

Definition at line 16 of file FiberBrightness.h.

Constructor & Destructor Documentation

photrans::FiberBrightness::FiberBrightness ( fhicl::ParameterSet const &  pset,
art::ActivityRegistry reg 
)

Definition at line 9 of file FiberBrightness_service.cc.

References fBrightnessFile_FD, fBrightnessFile_ND, fBrightnessLabel, fBrightnessMapName, fBrightnessValueMapName, fBrightnessValueName, fLevelInitAttempted, fReadFromFile, fhicl::ParameterSet::get(), preBeginRun(), and art::ActivityRegistry::sPreBeginRun.

11  : fLevel(0)
12  {
13  fBrightnessLabel = pset.get< std::string >("BrightnessLabel");
14  fReadFromFile = pset.get< bool >("ReadFromFile");
15  fLevelInitAttempted = false;
16 
17  if (fReadFromFile) {
18  fBrightnessMapName = pset.get< std::string >("BrightnessMapName");
19  fBrightnessValueName = pset.get< std::string >("BrightnessValueName");
20  fBrightnessValueMapName = pset.get< std::string >("BrightnessValueMapName");
21 
22  fBrightnessFile_ND = pset.get< std::string >("BrightnessFile_ND");
23  fBrightnessFile_FD = pset.get< std::string >("BrightnessFile_FD");
24  }
25 
27  }
const BrightnessLevel * fLevel
void preBeginRun(art::Run const &run)
std::string fBrightnessValueMapName
GlobalSignal< detail::SignalResponseType::FIFO, void(Run const &)> sPreBeginRun
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
std::string fBrightnessFile_FD
Relative path to the FD brightness correction file.
std::string fBrightnessFile_ND
Relative path to the ND brightness correction file.
photrans::FiberBrightness::~FiberBrightness ( )

Definition at line 30 of file FiberBrightness_service.cc.

References fLevel, and fReadFromFile.

31  {
32  if(fReadFromFile) delete fLevel;
33  }
const BrightnessLevel * fLevel

Member Function Documentation

double photrans::FiberBrightness::getBrightness ( unsigned int  plane,
unsigned int  cell 
) const

Definition at line 36 of file FiberBrightness_service.cc.

References fLevel, photrans::BrightnessLevel::getBrightnessLevel(), and IsModeled().

38  {
39  if( this->IsModeled() )
41  else
42  return 1.0;
43  }
const BrightnessLevel * fLevel
double getBrightnessLevel(unsigned int plane, unsigned int cell) const
unsigned int photrans::FiberBrightness::getBrightnessIndex ( unsigned int  plane,
unsigned int  cell 
) const
bool photrans::FiberBrightness::IsModeled ( ) const

Definition at line 66 of file FiberBrightness_service.cc.

References om::cerr, allTimeWatchdog::endl, fLevel, and fLevelInitAttempted.

Referenced by getBrightness(), getBrightnessIndex(), and NumberBrightnessBins().

67  {
69  std::cerr << "Do not use the FiberBrightness service before beginRun!"
70  << std::endl;
71  std::abort();
72  }
73  return fLevel;
74  }
const BrightnessLevel * fLevel
OStream cerr
Definition: OStream.cxx:7
unsigned int photrans::FiberBrightness::NumberBrightnessBins ( ) const

Definition at line 56 of file FiberBrightness_service.cc.

References fLevel, IsModeled(), and photrans::BrightnessLevel::NumberBrightnessBins().

Referenced by calib::ThresholdAna::beginRun(), calib::MakeAttenuationProfiles::beginRun(), and calib::Calibrator::postBeginRun().

57  {
58  if( this->IsModeled() )
59  return fLevel->NumberBrightnessBins();
60  else
61  return 1;
62  }
const BrightnessLevel * fLevel
unsigned int NumberBrightnessBins() const
void photrans::FiberBrightness::preBeginRun ( art::Run const &  run)

Definition at line 78 of file FiberBrightness_service.cc.

References DEFINE_ART_SERVICE, ds::DetectorService::DetId(), art::Handle< T >::failedToGet(), fBrightnessFile_FD, fBrightnessFile_ND, fBrightnessLabel, fBrightnessMapName, fBrightnessValueMapName, fBrightnessValueName, fDet, cet::search_path::find_file(), fLevel, fLevelInitAttempted, fReadFromFile, art::DataViewImpl::getByLabel(), novadaq::cnv::kFARDET, novadaq::cnv::kNEARDET, LOG_DEBUG, and LOG_INFO.

Referenced by FiberBrightness().

79  {
80  fLevelInitAttempted = true;
81 
82  if( !fReadFromFile ){
84  run.getByLabel(fBrightnessLabel, hlevel);
85 
86  if( hlevel.failedToGet() ){
87 
88  LOG_DEBUG("FiberBrightness")
89  << "Unable to get brightness levels from the Run record label: "
91  << ".\n Reading from file is disabled. Assume there is no brightness "
92  << "information available.";
93 
94  return;
95  } // end no valid handle found
96  else{
97  fLevel = &(*hlevel);
98 
99  return;
100  } // end found a valid handle
101  } // end if we are getting the brightness from the file
102 
103  if(fLevel){
104  return; // already loaded from previous run
105  }
106 
107  cet::search_path sp("FW_SEARCH_PATH");
108  std::string brightness_file;
109 
111  sp.find_file(fBrightnessFile_FD, brightness_file);
112  else if(fDet->DetId(run) == novadaq::cnv::kNEARDET)
113  sp.find_file(fBrightnessFile_ND, brightness_file);
114 
115  struct stat sb;
116  if ( brightness_file.empty() || stat(brightness_file.c_str(), &sb) != 0 )
117  throw cet::exception("NoBrightnessFile")
118  << "fiber brightness histo file " << brightness_file
119  << " not found!\n" << __FILE__ << ":" << __LINE__ << "\n";
120 
121  // constructor decides if initialized value is a path or an environment variable
122  fLevel = new BrightnessLevel(brightness_file,
126 
127  LOG_INFO("FiberBrightness")
128  << "No Fiber brightness product found with label: "
130  << ".\n Reading from file is enabled. Now read from file: "
131  << brightness_file
132  << ".\n";
133 
134  return;
135  }
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
novadaq::cnv::DetId DetId() const
What detector are we in?
const BrightnessLevel * fLevel
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
Far Detector at Ash River, MN.
std::string fBrightnessValueMapName
Near Detector in the NuMI cavern.
Definition: run.py:1
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
std::string fBrightnessFile_FD
Relative path to the FD brightness correction file.
std::string fBrightnessFile_ND
Relative path to the ND brightness correction file.
#define LOG_INFO(stream)
Definition: Messenger.h:144
bool failedToGet() const
Definition: Handle.h:196
art::ServiceHandle< ds::DetectorService > fDet

Member Data Documentation

std::string photrans::FiberBrightness::fBrightnessFile_FD
private

Relative path to the FD brightness correction file.

Definition at line 34 of file FiberBrightness.h.

Referenced by FiberBrightness(), and preBeginRun().

std::string photrans::FiberBrightness::fBrightnessFile_ND
private

Relative path to the ND brightness correction file.

Definition at line 33 of file FiberBrightness.h.

Referenced by FiberBrightness(), and preBeginRun().

std::string photrans::FiberBrightness::fBrightnessLabel
private

Definition at line 31 of file FiberBrightness.h.

Referenced by FiberBrightness(), and preBeginRun().

std::string photrans::FiberBrightness::fBrightnessMapName
private

Definition at line 35 of file FiberBrightness.h.

Referenced by FiberBrightness(), and preBeginRun().

std::string photrans::FiberBrightness::fBrightnessValueMapName
private

Definition at line 37 of file FiberBrightness.h.

Referenced by FiberBrightness(), and preBeginRun().

std::string photrans::FiberBrightness::fBrightnessValueName
private

Definition at line 36 of file FiberBrightness.h.

Referenced by FiberBrightness(), and preBeginRun().

art::ServiceHandle<ds::DetectorService> photrans::FiberBrightness::fDet
private

Definition at line 39 of file FiberBrightness.h.

Referenced by preBeginRun().

const BrightnessLevel* photrans::FiberBrightness::fLevel
private
bool photrans::FiberBrightness::fLevelInitAttempted
private

Definition at line 30 of file FiberBrightness.h.

Referenced by FiberBrightness(), IsModeled(), and preBeginRun().

bool photrans::FiberBrightness::fReadFromFile
private

Definition at line 32 of file FiberBrightness.h.

Referenced by FiberBrightness(), preBeginRun(), and ~FiberBrightness().


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