3 #include "fhiclcpp/ParameterSet.h"
4 #include "art/Utilities/ToolMacros.h"
5 #include "art/Framework/Services/Registry/ServiceHandle.h"
6 #include "art_root_io/TFileService.h"
7 #include "art/Framework/Core/ModuleMacros.h"
8 #include "art_root_io/TFileDirectory.h"
9 #include "messagefacility/MessageLogger/MessageLogger.h"
19 #include "TProfile2D.h"
44 using HitPtrVec = std::vector<art::Ptr<recob::Hit>>;
64 void configure(fhicl::ParameterSet
const & pset)
override;
72 void initializeHists(art::ServiceHandle<art::TFileService>&,
const std::string&)
override;
79 void endJob(
int numEvents)
override;
143 fGeometry = lar::providerFrom<geo::Geometry>();
148 mf::LogInfo(
"BasicHitAnalysis") <<
"BasicHitAnalysis configured\n";
153 BasicHitAnalysis::~BasicHitAnalysis()
163 void BasicHitAnalysis::configure(fhicl::ParameterSet
const & pset)
165 fLocalDirName = pset.get<std::string>(
"LocalDirName", std::string(
"wow"));
170 void BasicHitAnalysis::initializeHists(art::ServiceHandle<art::TFileService>&
tfs,
const std::string& dirName)
173 art::TFileDirectory
dir = tfs->mkdir(dirName.c_str());
181 fDriftTimes[0] = dir.make<TH1D>(
"DriftTime0",
";time(ticks)", 2048, 0., 4096.);
182 fDriftTimes[1] = dir.make<TH1D>(
"DriftTime1",
";time(ticks)", 2048, 0., 4096.);
183 fDriftTimes[2] = dir.make<TH1D>(
"DriftTime2",
";time(ticks)", 2048, 0., 4096.);
185 fHitsByTime[0] = dir.make<TH1D>(
"HitsByTime0",
";Tick", 1024, 0., 4096.);
186 fHitsByTime[1] = dir.make<TH1D>(
"HitsByTime1",
";Tick", 1024, 0., 4096.);
187 fHitsByTime[2] = dir.make<TH1D>(
"HitsByTime2",
";Tick", 1024, 0., 4096.);
189 fPulseHeight[0] = dir.make<TH1D>(
"PulseHeight0",
"PH (ADC)", 300, 0., 150.);
190 fPulseHeight[1] = dir.make<TH1D>(
"PulseHeight1",
"PH (ADC)", 300, 0., 150.);
191 fPulseHeight[2] = dir.make<TH1D>(
"PulseHeight2",
"PH (ADC)", 300, 0., 150.);
198 fPulseHeightMulti[0] = dir.make<TH1D>(
"PulseHeightM0",
"PH (ADC)", 300, 0., 150.);
199 fPulseHeightMulti[1] = dir.make<TH1D>(
"PulseHeightM1",
"PH (ADC)", 300, 0., 150.);
200 fPulseHeightMulti[2] = dir.make<TH1D>(
"PulseHeightM2",
"PH (ADC)", 300, 0., 150.);
201 fPulseHeightLong[0] = dir.make<TH1D>(
"PulseHeightL0",
"PH (ADC)", 300, 0., 150.);
202 fPulseHeightLong[1] = dir.make<TH1D>(
"PulseHeightL1",
"PH (ADC)", 300, 0., 150.);
203 fPulseHeightLong[2] = dir.make<TH1D>(
"PulseHeightL2",
"PH (ADC)", 300, 0., 150.);
204 fChi2DOF[0] = dir.make<TH1D>(
"Chi2DOF0",
"Chi2DOF", 502, -1., 250.);
205 fChi2DOF[1] = dir.make<TH1D>(
"Chi2DOF1",
"Chi2DOF", 502, -1., 250.);
206 fChi2DOF[2] = dir.make<TH1D>(
"Chi2DOF2",
"Chi2DOF", 502, -1., 250.);
207 fNumDegFree[0] = dir.make<TH1D>(
"NumDegFree0",
"NDF", 200, 0., 200.);
208 fNumDegFree[1] = dir.make<TH1D>(
"NumDegFree1",
"NDF", 200, 0., 200.);
209 fNumDegFree[2] = dir.make<TH1D>(
"NumDegFree2",
"NDF", 200, 0., 200.);
210 fChi2DOFSingle[0] = dir.make<TH1D>(
"Chi2DOFS0",
"Chi2DOF", 502, -1., 250.);
211 fChi2DOFSingle[1] = dir.make<TH1D>(
"Chi2DOFS1",
"Chi2DOF", 502, -1., 250.);
212 fChi2DOFSingle[2] = dir.make<TH1D>(
"Chi2DOFS2",
"Chi2DOF", 502, -1., 250.);
213 fHitMult[0] = dir.make<TH1D>(
"HitMult0",
"# hits", 15, 0., 15.);
214 fHitMult[1] = dir.make<TH1D>(
"HitMult1",
"# hits", 15, 0., 15.);
215 fHitMult[2] = dir.make<TH1D>(
"HitMult2",
"# hits", 15, 0., 15.);
216 fHitCharge[0] = dir.make<TH1D>(
"HitCharge0",
"Charge", 1000, 0., 2000.);
217 fHitCharge[1] = dir.make<TH1D>(
"HitCharge1",
"Charge", 1000, 0., 2000.);
218 fHitCharge[2] = dir.make<TH1D>(
"HitCharge2",
"Charge", 1000, 0., 2000.);
219 fHitChargeSingle[0] = dir.make<TH1D>(
"HitChargeS0",
"Charge", 1000, 0., 2000.);
220 fHitChargeSingle[1] = dir.make<TH1D>(
"HitChargeS1",
"Charge", 1000, 0., 2000.);
221 fHitChargeSingle[2] = dir.make<TH1D>(
"HitChargeS2",
"Charge", 1000, 0., 2000.);
222 fHitChargeMulti[0] = dir.make<TH1D>(
"HitChargeM0",
"Charge", 1000, 0., 2000.);
223 fHitChargeMulti[1] = dir.make<TH1D>(
"HitChargeM1",
"Charge", 1000, 0., 2000.);
224 fHitChargeMulti[2] = dir.make<TH1D>(
"HitChargeM2",
"Charge", 1000, 0., 2000.);
225 fHitChargeLong[0] = dir.make<TH1D>(
"HitChargeL0",
"Charge", 1000, 0., 2000.);
226 fHitChargeLong[1] = dir.make<TH1D>(
"HitChargeL1",
"Charge", 1000, 0., 2000.);
227 fHitChargeLong[2] = dir.make<TH1D>(
"HitChargeL2",
"Charge", 1000, 0., 2000.);
228 fFitWidth[0] = dir.make<TH1D>(
"FitWidth0",
"Width", 100, 0., 20.);
229 fFitWidth[1] = dir.make<TH1D>(
"FitWidth1",
"Width", 100, 0., 20.);
230 fFitWidth[2] = dir.make<TH1D>(
"FitWidth2",
"Width", 100, 0., 20.);
231 fFitWidthSingle[0] = dir.make<TH1D>(
"FitWidthS0",
"Width", 100, 0., 20.);
232 fFitWidthSingle[1] = dir.make<TH1D>(
"FitWidthS1",
"Width", 100, 0., 20.);
233 fFitWidthSingle[2] = dir.make<TH1D>(
"FitWidthS2",
"Width", 100, 0., 20.);
234 fFitWidthMulti[0] = dir.make<TH1D>(
"FitWidthM0",
"Width", 100, 0., 20.);
235 fFitWidthMulti[1] = dir.make<TH1D>(
"FitWidthM1",
"Width", 100, 0., 20.);
236 fFitWidthMulti[2] = dir.make<TH1D>(
"FitWidthM2",
"Width", 100, 0., 20.);
237 fFitWidthLong[0] = dir.make<TH1D>(
"FitWidthL0",
"Width", 100, 0., 20.);
238 fFitWidthLong[1] = dir.make<TH1D>(
"FitWidthL1",
"Width", 100, 0., 20.);
239 fFitWidthLong[2] = dir.make<TH1D>(
"FitWidthL2",
"Width", 100, 0., 20.);
240 fHitSumADC[0] = dir.make<TH1D>(
"SumADC0",
"Sum ADC", 1000, 0., 2000.);
241 fHitSumADC[1] = dir.make<TH1D>(
"SumADC1",
"Sum ADC", 1000, 0., 2000.);
242 fHitSumADC[2] = dir.make<TH1D>(
"SumADC2",
"Sum ADC", 1000, 0., 2000.);
244 fNDFVsChi2[0] = dir.make<TH2D>(
"NDFVsChi20",
";NDF;Chi2", 50, 0., 50., 101, -1., 100.);
245 fNDFVsChi2[1] = dir.make<TH2D>(
"NDFVsChi21",
";NDF;Chi2", 50, 0., 50., 101, -1., 100.);
246 fNDFVsChi2[2] = dir.make<TH2D>(
"NDFVsChi22",
";NDF;Chi2", 50, 0., 50., 101, -1., 100.);
248 fPulseHVsWidth[0] = dir.make<TH2D>(
"PHVsWidth0",
";PH;Width", 100, 0., 100., 100, 0., 20.);
249 fPulseHVsWidth[1] = dir.make<TH2D>(
"PHVsWidth1",
";PH;Width", 100, 0., 100., 100, 0., 20.);
250 fPulseHVsWidth[2] = dir.make<TH2D>(
"PHVsWidth2",
";PH;Width", 100, 0., 100., 100, 0., 20.);
252 fPulseHVsCharge[0] = dir.make<TH2D>(
"PHVsChrg0",
";PH;Q", 100, 0., 100., 100, 0., 2000.);
253 fPulseHVsCharge[1] = dir.make<TH2D>(
"PHVsChrg1",
";PH;Q", 100, 0., 100., 100, 0., 2000.);
254 fPulseHVsCharge[2] = dir.make<TH2D>(
"PHVsChrg2",
";PH;Q", 100, 0., 100., 100, 0., 2000.);
256 fPulseHVsHitNo[0] = dir.make<TProfile>(
"PHVsNo0",
";Hit #;PH", 1000, 0., 1000., 0., 100.);
257 fPulseHVsHitNo[1] = dir.make<TProfile>(
"PHVsNo1",
";Hit #;PH", 1000, 0., 1000., 0., 100.);
258 fPulseHVsHitNo[2] = dir.make<TProfile>(
"PHVsNo2",
";Hit #;PH", 1000, 0., 1000., 0., 100.);
260 fChargeVsHitNo[0] = dir.make<TProfile>(
"QVsNo0",
";Hit No;Q", 1000, 0., 1000., 0., 2000.);
261 fChargeVsHitNo[1] = dir.make<TProfile>(
"QVsNo1",
";Hit No;Q", 1000, 0., 1000., 0., 2000.);
262 fChargeVsHitNo[2] = dir.make<TProfile>(
"QVsNo2",
";Hit No;Q", 1000, 0., 1000., 0., 2000.);
264 fChargeVsHitNoS[0] = dir.make<TProfile>(
"QVsNoS0",
";Hit No;Q", 1000, 0., 1000., 0., 2000.);
265 fChargeVsHitNoS[1] = dir.make<TProfile>(
"QVsNoS1",
";Hit No;Q", 1000, 0., 1000., 0., 2000.);
266 fChargeVsHitNoS[2] = dir.make<TProfile>(
"QVsNoS2",
";Hit No;Q", 1000, 0., 1000., 0., 2000.);
268 fBadWPulseHeight = dir.make<TH1D>(
"BWPulseHeight",
"PH (ADC)", 300, 0., 150.);
269 fBadWPulseHVsWidth = dir.make<TH2D>(
"BWPHVsWidth",
";PH;Width", 100, 0., 100., 100, 0., 10.);
272 fSPHvsIdx[0] = dir.make<TH2D>(
"SPHVsIdx0",
";PH;Idx", 30, 0., 30., 100, 0., 100.);
273 fSPHvsIdx[1] = dir.make<TH2D>(
"SPHVsIdx1",
";PH;Idx", 30, 0., 30., 100, 0., 100.);
274 fSPHvsIdx[2] = dir.make<TH2D>(
"SPHVsIdx2",
";PH;Idx", 30, 0., 30., 100, 0., 100.);
276 fSWidVsIdx[0] = dir.make<TH2D>(
"SWidsIdx0",
";Width;Idx", 30, 0., 30., 100, 0., 10.);
277 fSWidVsIdx[1] = dir.make<TH2D>(
"SWidsIdx1",
";Width;Idx", 30, 0., 30., 100, 0., 10.);
278 fSWidVsIdx[2] = dir.make<TH2D>(
"SWidsIdx2",
";Width;Idx", 30, 0., 30., 100, 0., 10.);
280 f1PPHvsWid[0] = dir.make<TH2D>(
"1PPHVsWid0",
";PH;Width", 100, 0., 100., 100, 0., 10.);
281 f1PPHvsWid[1] = dir.make<TH2D>(
"1PPHVsWid1",
";PH;Width", 100, 0., 100., 100, 0., 10.);
282 f1PPHvsWid[2] = dir.make<TH2D>(
"1PPHVsWid2",
";PH;Width", 100, 0., 100., 100, 0., 10.);
284 fSPPHvsWid[0] = dir.make<TH2D>(
"SPPHVsWid0",
";PH;Width", 100, 0., 100., 100, 0., 10.);
285 fSPPHvsWid[1] = dir.make<TH2D>(
"SPPHVsWid1",
";PH;Width", 100, 0., 100., 100, 0., 10.);
286 fSPPHvsWid[2] = dir.make<TH2D>(
"SPPHVsWid2",
";PH;Width", 100, 0., 100., 100, 0., 10.);
288 fSOPHvsWid[0] = dir.make<TH2D>(
"SOPHVsWid0",
";PH;Width", 100, 0., 100., 100, 0., 10.);
289 fSOPHvsWid[1] = dir.make<TH2D>(
"SOPHVsWid1",
";PH;Width", 100, 0., 100., 100, 0., 10.);
290 fSOPHvsWid[2] = dir.make<TH2D>(
"SOPHVsWid2",
";PH;Width", 100, 0., 100., 100, 0., 10.);
292 fPHRatVsIdx[0] = dir.make<TH2D>(
"PHRatVsIdx0",
";PHRat;Idx", 30, 0., 30., 51, 0., 1.02);
293 fPHRatVsIdx[1] = dir.make<TH2D>(
"PHRatVsIdx1",
";PHRat;Idx", 30, 0., 30., 51, 0., 1.02);
294 fPHRatVsIdx[2] = dir.make<TH2D>(
"PHRatVsIdx2",
";PHRat;Idx", 30, 0., 30., 51, 0., 1.02);
299 void BasicHitAnalysis::fillHistograms(
const HitPtrVec& hitPtrVec)
const
302 size_t nHitsPerView[] = {0,0,0};
305 std::vector<const recob::Hit*> hitSnippetVec;
308 for(
const auto& hitPtr : hitPtrVec)
312 float chi2DOF = std::min(hitPtr->GoodnessOfFit(),float(249.8));
313 int numDOF = hitPtr->DegreesOfFreedom();
314 int hitMult = hitPtr->Multiplicity();
315 float peakTime = std::min(
float(3199.),hitPtr->PeakTime());
316 float charge = hitPtr->Integral();
317 float sumADC = hitPtr->SummedADC();
318 float hitPH = std::min(hitPtr->PeakAmplitude(),float(149.8));
319 float hitSigma = hitPtr->RMS();
321 size_t plane = wireID.
Plane;
322 size_t wire = wireID.
Wire;
330 nHitsPerView[plane]++;
334 fPulseHeight[plane]->Fill(std::min(
float(149.5),hitPH), 1.);
339 fFitWidth[plane]->Fill(std::min(
float(19.99),hitSigma), 1.);
350 fPulseHVsWidth[plane]->Fill(std::min(
float(99.9),hitPH), std::min(
float(19.99),hitSigma), 1.);
351 fPulseHVsCharge[plane]->Fill(std::min(
float(99.9),hitPH), std::min(
float(1999.),charge), 1.);
353 if (plane == 2 && hitPH < 5 && hitSigma < 2.2)
355 std::cout <<
"++> Plane: " << plane <<
", wire: " << wire <<
", peakTime: " << peakTime <<
", ph: " << hitPH <<
", w: " << hitSigma << std::endl;
358 fBadWPulseHVsWidth->Fill(std::min(
float(99.9),hitPH), std::min(
float(9.99),hitSigma), 1.);
373 fFitWidthLong[plane]->Fill(std::min(
float(19.99),hitSigma), 1.);
379 if (!hitSnippetVec.empty() && hitSnippetVec.back()->LocalIndex() >= hitPtr->LocalIndex())
382 if (hitSnippetVec.size() > 1)
385 std::sort(hitSnippetVec.begin(),hitSnippetVec.end(),[](
const auto*
left,
const auto*
right){
return left->PeakAmplitude() >
right->PeakAmplitude();});
387 float maxPulseHeight = hitSnippetVec.front()->PeakAmplitude();
391 for(
size_t idx = 0; idx < hitSnippetVec.size(); idx++)
393 float pulseHeight = hitSnippetVec.at(idx)->PeakAmplitude();
394 float pulseWid = hitSnippetVec.at(idx)->RMS();
395 float pulseHeightRatio = pulseHeight / maxPulseHeight;
397 size_t plane = hitSnippetVec.at(idx)->WireID().Plane;
399 fSPHvsIdx[plane]->Fill(idx, std::min(
float(99.9),pulseHeight), 1.);
400 fSWidVsIdx[plane]->Fill(idx, std::min(
float(9.99),pulseWid), 1.);
401 fPHRatVsIdx[plane]->Fill(idx, pulseHeightRatio, 1.);
403 if (idx == 0)
fSPPHvsWid[plane]->Fill(std::min(
float(99.9),pulseHeight), std::min(
float(9.99),pulseWid), 1.);
404 else fSOPHvsWid[plane]->Fill(std::min(
float(99.9),pulseHeight), std::min(
float(9.99),pulseWid), 1.);
409 float pulseHeight = hitSnippetVec.front()->PeakAmplitude();
410 float pulseWid = hitSnippetVec.front()->RMS();
411 size_t plane = hitSnippetVec.front()->WireID().Plane;
413 f1PPHvsWid[plane]->Fill(std::min(
float(99.9),pulseHeight), std::min(
float(9.99),pulseWid), 1.);
416 hitSnippetVec.clear();
419 hitSnippetVec.push_back(hitPtr.get());
426 void BasicHitAnalysis::endJob(
int numEvents)
431 double normFactor(1./numEvents);
void configure(fhicl::ParameterSet const &pset) override
TProfile * fPulseHVsHitNo[3]
std::vector< art::Ptr< recob::Hit >> HitPtrVec
TProfile * fChargeVsHitNo[3]
Utilities related to art service access.
void fillHistograms(const HitPtrVec &) const override
Interface for filling histograms.
TH1D * fPulseHeightSingle[3]
TH1D * fPulseHeightLong[3]
Declaration of signal hit object.
TH1D * fFitWidthSingle[3]
std::string fLocalDirName
Fraction for truncated mean.
BasicHitAnalysis(fhicl::ParameterSet const &pset)
Constructor.
std::map< int, ViewHitMap > TrackViewHitMap
WireID_t Wire
Index of the wire within its plane.
TProfile * fChargeVsHitNoS[3]
Scale(size_t pos, T factor) -> Scale< T >
TH1D * fHitChargeSingle[3]
unsigned int Nwires(unsigned int p, unsigned int tpc=0, unsigned int cstat=0) const
Returns the total number of wires in the specified plane.
std::vector< TH1D * > fHitsByWire
TH1D * fPulseHeightMulti[3]
unsigned int Nplanes(unsigned int tpc=0, unsigned int cstat=0) const
Returns the total number of wire planes in the specified TPC.
void initializeHists(art::ServiceHandle< art::TFileService > &, const std::string &) override
Interface for initializing the histograms to be filled.
const geo::GeometryCore * fGeometry
pointer to Geometry service
TH1D * fPulseHeightMultiMax[3]
PlaneID_t Plane
Index of the plane within its TPC.
Description of geometry of one entire detector.
~BasicHitAnalysis()
Destructor.
std::map< size_t, HitPtrVec > ViewHitMap
TH1D * fHitChargeMulti[3]
TH2D * fBadWPulseHVsWidth
TH2D * fPulseHVsCharge[3]
void endJob(int numEvents) override
Interface for method to executve at the end of run processing.
constexpr WireID()=default
Default constructor: an invalid TPC ID.
art::ServiceHandle< art::TFileService > tfs
art framework interface to geometry description
BEGIN_PROLOG could also be cout