25 #include "art_root_io/TFileService.h" 86 std::map<uint32_t, std::vector<double>>
fAreas;
115 fPulseTree = tfs->make<TTree>(
"fPulseTree",
"fPulseTree");
148 for (
auto it =
fAreas.begin(); it !=
fAreas.end(); ++it) {
149 uint32_t Channel = it->first;
151 std::stringstream histname;
153 histname <<
"ch" << Channel <<
"area";
155 TH1D* HistArea = tfs->make<TH1D>(
158 for (
size_t j = 0; j != it->second.size(); ++j) {
159 HistArea->Fill(it->second.at(j));
162 std::stringstream fitname;
164 fitname <<
"ch" << Channel <<
"fit";
166 double Max = HistArea->GetMaximum();
167 double Mid = HistArea->GetBinContent(
fAreaDivs / 2.);
169 TF1* GausFit =
new TF1(fitname.str().c_str(),
"gaus(0)+gaus(3)+gaus(6)",
fAreaMin,
fAreaMax);
171 GausFit->SetParameters(Mid,
181 GausFit->SetParLimits(0, 0, 1.1 * Max);
182 GausFit->SetParLimits(1, 0,
fAreaMax);
183 GausFit->SetParLimits(2, 0,
fAreaMax);
185 GausFit->SetParLimits(3, 0, 1.1 * Max);
186 GausFit->FixParameter(4, 0);
187 GausFit->SetParLimits(5, 0, (fAreaMin +
fAreaMax) / 2.);
189 GausFit->SetParLimits(6, 0, 1.1 * Max);
190 GausFit->FixParameter(7, 0);
191 GausFit->SetParLimits(8, 0, (fAreaMin +
fAreaMax) / 2.);
193 HistArea->Fit(GausFit);
195 double Mean = GausFit->GetParameter(1);
196 double Width = GausFit->GetParameter(2);
198 double MeanErr = GausFit->GetParError(1);
199 double WidthErr = GausFit->GetParError(2);
201 double NPE = pow(Mean, 2) / pow(Width, 2);
202 double SPEScale = Mean / NPE;
204 double NPEError = NPE * pow(2. * (pow(MeanErr / Mean, 2) + pow(WidthErr / Width, 2)), 0.5);
205 double SPEError = SPEScale * pow(2. * pow(WidthErr / Width, 2) + pow(MeanErr / Mean, 2), 0.5);
207 std::cout <<
"Channel " << Channel <<
":\tSPE Scale \t" << SPEScale <<
"\t +/- \t" << SPEError
208 <<
",\t NPE \t" << NPE <<
"\t +/- \t" << NPEError << std::endl;
215 auto const clock_data =
227 std::map<uint32_t, std::vector<int>> OrgOpDigitByChannel;
229 for (
size_t i = 0; i != OpDetWaveformHandle->size(); ++i) {
230 OrgOpDigitByChannel[
ShaperToChannel(OpDetWaveformHandle->at(i).ChannelNumber())].push_back(i);
233 std::vector<uint32_t> FrameNumbersForTrig;
234 std::vector<uint32_t> TimeSlicesForTrig;
236 for (
size_t i = 0; i != OrgOpDigitByChannel[
fTriggerChannel].size(); ++i) {
238 OpDetWaveformHandle->at(OrgOpDigitByChannel[
fTriggerChannel][i]).TimeStamp();
239 uint32_t Frame = clock_data.OpticalClock().Frame(TimeStamp);
240 uint32_t TimeSlice = clock_data.OpticalClock().Sample(TimeStamp);
241 FrameNumbersForTrig.push_back(Frame);
242 TimeSlicesForTrig.push_back(TimeSlice);
245 for (
size_t i = 0; i != OpDetWaveformHandle->size(); ++i) {
246 double TimeStamp = OpDetWaveformHandle->at(i).TimeStamp();
247 uint32_t Frame = clock_data.OpticalClock().Frame(TimeStamp);
248 uint32_t TimeSlice = clock_data.OpticalClock().Sample(TimeStamp);
249 fShaper = OpDetWaveformHandle->at(i).ChannelNumber();
253 for (
size_t j = 0; j != FrameNumbersForTrig.size(); ++j) {
254 if ((Frame == FrameNumbersForTrig.at(j)) &&
264 fOffset = TimeSlice - TimeSlicesForTrig.at(j);
268 for (
size_t k = 0; k != NPulses; ++k) {
302 static std::map<uint32_t, uint32_t> ShaperToChannelMap;
303 if (ShaperToChannelMap.size() == 0) {
306 for (
size_t i = 0; i != 40; ++i) {
307 ShaperToChannelMap[i] = i;
311 return ShaperToChannelMap[Shaper];
pmtana::AlgoThreshold fThreshAlg
Utilities related to art service access.
EDAnalyzer(fhicl::ParameterSet const &pset)
void AddRecoAlgo(pmtana::PMTPulseRecoBase *algo, PMTPedestalBase *ped_algo=nullptr)
A method to set pulse reconstruction algorithm.
pure virtual base interface for detector clocks
void analyze(const art::Event &)
size_t GetNPulse() const
A getter for the number of reconstructed pulses from the input waveform.
pmtana::PulseRecoManager fPulseRecoMgr
#define DEFINE_ART_MODULE(klass)
bool Reconstruct(const pmtana::Waveform_t &) const
Implementation of ana_base::analyze method.
T get(std::string const &key) const
EventNumber_t event() const
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Class definition file of AlgoThreshold.
void SetDefaultPedAlgo(pmtana::PMTPedestalBase *algo)
A method to set a choice of pedestal estimation method.
std::map< uint32_t, std::vector< double > > fAreas
TTree * fPulseTreeNonCoinc
Class def header for a class ElecClock.
Class definition file of PMTPulseRecoBase.
Class definition file of PedAlgoEdges.
uint32_t ShaperToChannel(uint32_t Shaper)
LEDCalibrationAna(const fhicl::ParameterSet &)
const pulse_param & GetPulse(size_t index=0) const
Class definition file of PulseRecoManager.
pmtana::PedAlgoEdges fPedAlg