Public Member Functions | Private Member Functions | Private Attributes | List of all members
opdet::LEDCalibrationAna Class Reference
Inheritance diagram for opdet::LEDCalibrationAna:
art::EDAnalyzer art::detail::Analyzer art::detail::LegacyModule art::Observer art::ModuleBase

Public Member Functions

 LEDCalibrationAna (const fhicl::ParameterSet &)
 
void endJob ()
 
void analyze (const art::Event &)
 
- Public Member Functions inherited from art::EDAnalyzer
 EDAnalyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDAnalyzer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Analyzer
virtual ~Analyzer () noexcept
 
 Analyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 Analyzer (Table< Config > const &config)
 
void doBeginJob (SharedResources const &resources)
 
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)
 
- Public Member Functions inherited from art::Observer
 ~Observer () noexcept
 
 Observer (Observer const &)=delete
 
 Observer (Observer &&)=delete
 
Observeroperator= (Observer const &)=delete
 
Observeroperator= (Observer &&)=delete
 
void registerProducts (ProductDescriptions &, ModuleDescription const &)
 
void fillDescriptions (ModuleDescription const &)
 
fhicl::ParameterSetID selectorConfig () const
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
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< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Private Member Functions

uint32_t ShaperToChannel (uint32_t Shaper)
 

Private Attributes

std::string fInputModule
 
uint32_t fTriggerChannel
 
float fCoincThreshold
 
float fMaxTimeMean
 
float fMaxTimeThresh
 
float fAreaDivs
 
float fAreaMin
 
float fAreaMax
 
float fTriggerDelay
 
pmtana::PulseRecoManager fPulseRecoMgr
 
pmtana::AlgoThreshold fThreshAlg
 
pmtana::PedAlgoEdges fPedAlg
 
TTree * fPulseTree
 
TTree * fPulseTreeNonCoinc
 
Float_t fPeak
 
Float_t fPedRMS
 
Float_t fPedMean
 
Float_t fArea
 
Float_t fTBegin
 
Float_t fTEnd
 
Float_t fTMax
 
Float_t fOffset
 
Int_t fEventID
 
Int_t fRunID
 
Int_t fChannel
 
Int_t fShaper
 
bool fMakeNonCoincTree
 
std::map< uint32_t, std::vector< double > > fAreas
 

Additional Inherited Members

- Public Types inherited from art::EDAnalyzer
using WorkerType = WorkerT< EDAnalyzer >
 
using ModuleType = EDAnalyzer
 
- Protected Member Functions inherited from art::Observer
std::string const & processName () const
 
bool wantAllEvents () const noexcept
 
bool wantEvent (ScheduleID id, Event const &e) const
 
Handle< TriggerResultsgetTriggerResults (Event const &e) const
 
 Observer (fhicl::ParameterSet const &config)
 
 Observer (std::vector< std::string > const &select_paths, std::vector< std::string > const &reject_paths, fhicl::ParameterSet const &config)
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (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< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Detailed Description

Definition at line 42 of file LEDCalibrationAna_module.cc.

Constructor & Destructor Documentation

opdet::LEDCalibrationAna::LEDCalibrationAna ( const fhicl::ParameterSet )

Definition at line 95 of file LEDCalibrationAna_module.cc.

97  {
98  // Indicate that the Input Module comes from .fcl
99  fInputModule = pset.get<std::string>("InputModule");
100  fTriggerChannel = pset.get<uint32_t>("TriggerChannel");
101  fTriggerDelay = pset.get<uint32_t>("TriggerDelay");
102  fCoincThreshold = pset.get<float>("CoincThreshold");
103  fMaxTimeThresh = pset.get<float>("MaxTimeThresh");
104  fMaxTimeMean = pset.get<float>("MaxTimeMean");
105  fAreaMin = pset.get<float>("AreaMin");
106  fAreaMax = pset.get<float>("AreaMax");
107  fAreaDivs = pset.get<float>("AreaDivs");
108  fMakeNonCoincTree = pset.get<bool>("MakeNonCoincTree");
109 
112 
114 
115  fPulseTree = tfs->make<TTree>("fPulseTree", "fPulseTree");
116  fPulseTree->Branch("Area", &fArea, "Area/F");
117  fPulseTree->Branch("Peak", &fPeak, "Peak/F");
118  fPulseTree->Branch("TBegin", &fTBegin, "TBegin/F");
119  fPulseTree->Branch("TEnd", &fTEnd, "TEnd/F");
120  fPulseTree->Branch("TMax", &fTMax, "TMax/F");
121  fPulseTree->Branch("Channel", &fChannel, "Channel/I");
122  fPulseTree->Branch("Shaper", &fShaper, "Shaper/I");
123  fPulseTree->Branch("PedMean", &fPedMean, "PedMean/F");
124  fPulseTree->Branch("PedRMS", &fPedRMS, "PedRMS/F");
125  fPulseTree->Branch("Offset", &fOffset, "Offset/F");
126  fPulseTree->Branch("EventID", &fEventID, "EventID/I");
127  fPulseTree->Branch("RunID", &fRunID, "RunID/I");
128 
129  fPulseTreeNonCoinc = tfs->make<TTree>("fPulseTreeNonCoinc", "fPulseTreeNonCoinc");
130  fPulseTreeNonCoinc->Branch("Area", &fArea, "Area/F");
131  fPulseTreeNonCoinc->Branch("Peak", &fPeak, "Peak/F");
132  fPulseTreeNonCoinc->Branch("TBegin", &fTBegin, "TBegin/F");
133  fPulseTreeNonCoinc->Branch("TEnd", &fTEnd, "TEnd/F");
134  fPulseTreeNonCoinc->Branch("TMax", &fTMax, "TMax/F");
135  fPulseTreeNonCoinc->Branch("Channel", &fChannel, "Channel/I");
136  fPulseTreeNonCoinc->Branch("Shaper", &fShaper, "Shaper/I");
137  fPulseTreeNonCoinc->Branch("PedMean", &fPedMean, "PedMean/F");
138  fPulseTreeNonCoinc->Branch("PedRMS", &fPedRMS, "PedRMS/F");
139  fPulseTreeNonCoinc->Branch("EventID", &fEventID, "EventID/I");
140  fPulseTreeNonCoinc->Branch("RunID", &fRunID, "RunID/I");
141  }
pmtana::AlgoThreshold fThreshAlg
std::string string
Definition: nybbler.cc:12
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
void AddRecoAlgo(pmtana::PMTPulseRecoBase *algo, PMTPedestalBase *ped_algo=nullptr)
A method to set pulse reconstruction algorithm.
pmtana::PulseRecoManager fPulseRecoMgr
void SetDefaultPedAlgo(pmtana::PMTPedestalBase *algo)
A method to set a choice of pedestal estimation method.

Member Function Documentation

void opdet::LEDCalibrationAna::analyze ( const art::Event evt)

Definition at line 215 of file LEDCalibrationAna_module.cc.

216  {
217  auto const clock_data =
219 
220  fRunID = evt.run();
221  fEventID = evt.event();
222 
223  // Create a handle for our vector of pulses
224  art::Handle<std::vector<raw::OpDetWaveform>> OpDetWaveformHandle;
225 
226  // Read in WaveformHandle
227  evt.getByLabel(fInputModule, OpDetWaveformHandle);
228 
229  std::map<uint32_t, std::vector<int>> OrgOpDigitByChannel;
230 
231  for (size_t i = 0; i != OpDetWaveformHandle->size(); ++i) {
232  OrgOpDigitByChannel[ShaperToChannel(OpDetWaveformHandle->at(i).ChannelNumber())].push_back(i);
233  }
234 
235  std::vector<uint32_t> FrameNumbersForTrig;
236  std::vector<uint32_t> TimeSlicesForTrig;
237 
238  for (size_t i = 0; i != OrgOpDigitByChannel[fTriggerChannel].size(); ++i) {
239  double TimeStamp =
240  OpDetWaveformHandle->at(OrgOpDigitByChannel[fTriggerChannel][i]).TimeStamp();
241  uint32_t Frame = clock_data.OpticalClock().Frame(TimeStamp);
242  uint32_t TimeSlice = clock_data.OpticalClock().Sample(TimeStamp);
243  FrameNumbersForTrig.push_back(Frame);
244  TimeSlicesForTrig.push_back(TimeSlice);
245  }
246 
247  for (size_t i = 0; i != OpDetWaveformHandle->size(); ++i) {
248  double TimeStamp = OpDetWaveformHandle->at(i).TimeStamp();
249  uint32_t Frame = clock_data.OpticalClock().Frame(TimeStamp);
250  uint32_t TimeSlice = clock_data.OpticalClock().Sample(TimeStamp);
251  fShaper = OpDetWaveformHandle->at(i).ChannelNumber();
253 
254  if (uint32_t(fChannel) != fTriggerChannel) {
255  for (size_t j = 0; j != FrameNumbersForTrig.size(); ++j) {
256  if ((Frame == FrameNumbersForTrig.at(j)) &&
257  (fabs(TimeSlice - TimeSlicesForTrig.at(j) - fTriggerDelay) < fCoincThreshold)) {
258 
259  const raw::OpDetWaveform& wf = OpDetWaveformHandle->at(i);
260 
261  //fPulseRecoMgr.RecoPulse(wf);
263 
264  size_t NPulses = fThreshAlg.GetNPulse();
265 
266  fOffset = TimeSlice - TimeSlicesForTrig.at(j);
267  //fPedMean = fThreshAlg.PedMean();
268  //fPedRMS = fThreshAlg.PedRms();
269 
270  for (size_t k = 0; k != NPulses; ++k) {
272 
280 
281  fPulseTree->Fill();
282 
283  fAreas[fChannel].push_back(fArea);
284  }
285  else if (fMakeNonCoincTree) {
291 
292  fPulseTreeNonCoinc->Fill();
293  }
294  }
295  }
296  }
297  }
298  }
299  }
pmtana::AlgoThreshold fThreshAlg
EventNumber_t event() const
Definition: DataViewImpl.cc:85
size_t GetNPulse() const
A getter for the number of reconstructed pulses from the input waveform.
pmtana::PulseRecoManager fPulseRecoMgr
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:633
fInnerVessel push_back(Point(-578.400000, 0.000000, 0.000000))
bool Reconstruct(const pmtana::Waveform_t &) const
Implementation of ana_base::analyze method.
RunNumber_t run() const
Definition: DataViewImpl.cc:71
std::map< uint32_t, std::vector< double > > fAreas
uint32_t ShaperToChannel(uint32_t Shaper)
const pulse_param & GetPulse(size_t index=0) const
void opdet::LEDCalibrationAna::endJob ( )
virtual

Reimplemented from art::EDAnalyzer.

Definition at line 145 of file LEDCalibrationAna_module.cc.

146  {
148 
149  for (auto it = fAreas.begin(); it != fAreas.end(); ++it) {
150  uint32_t Channel = it->first;
151 
152  std::stringstream histname;
153  histname.flush();
154  histname << "ch" << Channel << "area";
155 
156  TH1D* HistArea = tfs->make<TH1D>(
157  histname.str().c_str(), histname.str().c_str(), fAreaDivs, fAreaMin, fAreaMax);
158 
159  for (size_t j = 0; j != it->second.size(); ++j) {
160  HistArea->Fill(it->second.at(j));
161  }
162 
163  std::stringstream fitname;
164  fitname.flush();
165  fitname << "ch" << Channel << "fit";
166 
167  double Max = HistArea->GetMaximum();
168  double Mid = HistArea->GetBinContent(fAreaDivs / 2.);
169 
170  TF1* GausFit = new TF1(fitname.str().c_str(), "gaus(0)+gaus(3)+gaus(6)", fAreaMin, fAreaMax);
171 
172  GausFit->SetParameters(Mid,
173  (fAreaMin + fAreaMax) / 2.,
174  (fAreaMax - fAreaMin) / 2.,
175  Max,
176  0,
177  (fAreaMin + fAreaMax) / 8.,
178  Max / 5.,
179  0,
180  (fAreaMin + fAreaMax) / 4.);
181 
182  GausFit->SetParLimits(0, 0, 1.1 * Max);
183  GausFit->SetParLimits(1, 0, fAreaMax);
184  GausFit->SetParLimits(2, 0, fAreaMax);
185 
186  GausFit->SetParLimits(3, 0, 1.1 * Max);
187  GausFit->FixParameter(4, 0);
188  GausFit->SetParLimits(5, 0, (fAreaMin + fAreaMax) / 2.);
189 
190  GausFit->SetParLimits(6, 0, 1.1 * Max);
191  GausFit->FixParameter(7, 0);
192  GausFit->SetParLimits(8, 0, (fAreaMin + fAreaMax) / 2.);
193 
194  HistArea->Fit(GausFit);
195 
196  double Mean = GausFit->GetParameter(1);
197  double Width = GausFit->GetParameter(2);
198 
199  double MeanErr = GausFit->GetParError(1);
200  double WidthErr = GausFit->GetParError(2);
201 
202  double NPE = pow(Mean, 2) / pow(Width, 2);
203  double SPEScale = Mean / NPE;
204 
205  double NPEError = NPE * pow(2. * (pow(MeanErr / Mean, 2) + pow(WidthErr / Width, 2)), 0.5);
206  double SPEError = SPEScale * pow(2. * pow(WidthErr / Width, 2) + pow(MeanErr / Mean, 2), 0.5);
207 
208  std::cout << "Channel " << Channel << ":\tSPE Scale \t" << SPEScale << "\t +/- \t" << SPEError
209  << ",\t NPE \t" << NPE << "\t +/- \t" << NPEError << std::endl;
210  }
211  }
constexpr T pow(T x)
Definition: pow.h:72
double Width(Resonance_t res)
resonance width (GeV)
std::map< uint32_t, std::vector< double > > fAreas
QTextStream & endl(QTextStream &s)
uint32_t opdet::LEDCalibrationAna::ShaperToChannel ( uint32_t  Shaper)
private

Definition at line 303 of file LEDCalibrationAna_module.cc.

304  {
305  static std::map<uint32_t, uint32_t> ShaperToChannelMap;
306  if (ShaperToChannelMap.size() == 0) {
307 
308  // temporary
309  for (size_t i = 0; i != 40; ++i) {
310  ShaperToChannelMap[i] = i;
311  }
312  }
313 
314  return ShaperToChannelMap[Shaper];
315  }

Member Data Documentation

Float_t opdet::LEDCalibrationAna::fArea
private

Definition at line 72 of file LEDCalibrationAna_module.cc.

float opdet::LEDCalibrationAna::fAreaDivs
private

Definition at line 59 of file LEDCalibrationAna_module.cc.

float opdet::LEDCalibrationAna::fAreaMax
private

Definition at line 61 of file LEDCalibrationAna_module.cc.

float opdet::LEDCalibrationAna::fAreaMin
private

Definition at line 60 of file LEDCalibrationAna_module.cc.

std::map<uint32_t, std::vector<double> > opdet::LEDCalibrationAna::fAreas
private

Definition at line 86 of file LEDCalibrationAna_module.cc.

Int_t opdet::LEDCalibrationAna::fChannel
private

Definition at line 79 of file LEDCalibrationAna_module.cc.

float opdet::LEDCalibrationAna::fCoincThreshold
private

Definition at line 56 of file LEDCalibrationAna_module.cc.

Int_t opdet::LEDCalibrationAna::fEventID
private

Definition at line 77 of file LEDCalibrationAna_module.cc.

std::string opdet::LEDCalibrationAna::fInputModule
private

Definition at line 54 of file LEDCalibrationAna_module.cc.

bool opdet::LEDCalibrationAna::fMakeNonCoincTree
private

Definition at line 84 of file LEDCalibrationAna_module.cc.

float opdet::LEDCalibrationAna::fMaxTimeMean
private

Definition at line 57 of file LEDCalibrationAna_module.cc.

float opdet::LEDCalibrationAna::fMaxTimeThresh
private

Definition at line 58 of file LEDCalibrationAna_module.cc.

Float_t opdet::LEDCalibrationAna::fOffset
private

Definition at line 76 of file LEDCalibrationAna_module.cc.

Float_t opdet::LEDCalibrationAna::fPeak
private

Definition at line 69 of file LEDCalibrationAna_module.cc.

pmtana::PedAlgoEdges opdet::LEDCalibrationAna::fPedAlg
private

Definition at line 66 of file LEDCalibrationAna_module.cc.

Float_t opdet::LEDCalibrationAna::fPedMean
private

Definition at line 71 of file LEDCalibrationAna_module.cc.

Float_t opdet::LEDCalibrationAna::fPedRMS
private

Definition at line 70 of file LEDCalibrationAna_module.cc.

pmtana::PulseRecoManager opdet::LEDCalibrationAna::fPulseRecoMgr
private

Definition at line 64 of file LEDCalibrationAna_module.cc.

TTree* opdet::LEDCalibrationAna::fPulseTree
private

Definition at line 67 of file LEDCalibrationAna_module.cc.

TTree* opdet::LEDCalibrationAna::fPulseTreeNonCoinc
private

Definition at line 68 of file LEDCalibrationAna_module.cc.

Int_t opdet::LEDCalibrationAna::fRunID
private

Definition at line 78 of file LEDCalibrationAna_module.cc.

Int_t opdet::LEDCalibrationAna::fShaper
private

Definition at line 80 of file LEDCalibrationAna_module.cc.

Float_t opdet::LEDCalibrationAna::fTBegin
private

Definition at line 73 of file LEDCalibrationAna_module.cc.

Float_t opdet::LEDCalibrationAna::fTEnd
private

Definition at line 74 of file LEDCalibrationAna_module.cc.

pmtana::AlgoThreshold opdet::LEDCalibrationAna::fThreshAlg
private

Definition at line 65 of file LEDCalibrationAna_module.cc.

Float_t opdet::LEDCalibrationAna::fTMax
private

Definition at line 75 of file LEDCalibrationAna_module.cc.

uint32_t opdet::LEDCalibrationAna::fTriggerChannel
private

Definition at line 55 of file LEDCalibrationAna_module.cc.

float opdet::LEDCalibrationAna::fTriggerDelay
private

Definition at line 62 of file LEDCalibrationAna_module.cc.


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