17 #include <unordered_map>
40 hitDataTree.reserve(trees.size());
43 hitData.reserve(trees.size());
46 for (
auto const& t : trees) {
47 hitDataTree.push_back(t);
51 for (
size_t i = 0; i < hitData.size(); ++i)
52 hitDataTree[i]->
Branch(hitDataTree[i]->GetName(),
"recob::Hit", &(hitData[i]));
58 wireDataTree->Branch(
"event", &wireData.event,
"event/i");
59 wireDataTree->Branch(
"run", &wireData.run,
"run/i");
60 wireDataTree->Branch(
"channel", &wireData.channel,
"channel/i");
61 wireDataTree->Branch(
"plane", &wireData.plane,
"plane/i");
62 wireDataTree->Branch(
"roi_index", &wireData.range_index,
"roi_index/i");
63 wireDataTree->Branch(
"roi_start", &wireData.range_start,
"roi_start/i");
64 wireDataTree->Branch(
"roi_size", &wireData.range_size,
"roi_size/i");
65 wireDataTree->Branch(
"roi_charge", &wireData.integrated_charge,
"roi_charge/F");
66 wireDataTree->Branch(
"roi_peak_charge", &wireData.peak_charge,
"roi_peak_charge/F");
67 wireDataTree->Branch(
"roi_peak_time", &wireData.peak_time,
"roi_peak_time/F");
68 wireDataTree->Branch(
"nHitModules", &wireData.NHitModules,
"nHitModules/I");
69 wireDataTree->Branch(
"HitModuleLabels", &wireData.HitModuleLabels);
70 wireDataTree->Branch(
"NHits", &wireData.NHits);
71 wireDataTree->Branch(
"Hits_IntegratedCharge", &wireData.Hits_IntegratedCharge);
72 wireDataTree->Branch(
"Hits_AverageCharge", &wireData.Hits_AverageCharge);
73 wireDataTree->Branch(
"Hits_PeakCharge", &wireData.Hits_PeakCharge);
74 wireDataTree->Branch(
"Hits_Peak", &wireData.Hits_PeakTime);
75 wireDataTree->Branch(
"Hits_wAverageCharge", &wireData.Hits_wAverageCharge);
76 wireDataTree->Branch(
"Hits_wAverageTime", &wireData.Hits_wAverageTime);
77 wireDataTree->Branch(
"Hits_MeanMultiplicity", &wireData.Hits_MeanMultiplicity);
79 wireDataTree->Branch(
"NMCHits", &wireData.NMCHits);
80 wireDataTree->Branch(
"MCHits_IntegratedCharge", &wireData.MCHits_IntegratedCharge);
81 wireDataTree->Branch(
"MCHits_AverageCharge", &wireData.MCHits_AverageCharge);
82 wireDataTree->Branch(
"MCHits_PeakCharge", &wireData.MCHits_PeakCharge);
83 wireDataTree->Branch(
"MCHits_Peak", &wireData.MCHits_PeakTime);
84 wireDataTree->Branch(
"MCHits_wAverageCharge", &wireData.MCHits_wAverageCharge);
85 wireDataTree->Branch(
"MCHits_wAverageTime", &wireData.MCHits_wAverageTime);
92 HitProcessingQueue.clear();
93 wireData.NHitModules = 0;
99 std::string
const& HitModuleLabel)
102 HitProcessingQueue.push_back(std::make_pair(std::cref(HitVector), std::cref(AssocVector)));
110 std::vector<sim::MCHitCollection>
const& MCHitCollectionVector,
117 InitWireData(event, run);
118 for (
size_t iwire = 0; iwire < WireVector.size(); iwire++)
119 FillWireInfo(WireVector[iwire], iwire, MCHitCollectionVector, AssocVector[iwire], clock_data);
126 wireData.event = event;
135 wireData.NMCHits = 0;
136 wireData.MCHits_IntegratedCharge = 0;
137 wireData.MCHits_AverageCharge = 0;
138 wireData.MCHits_PeakCharge = -999;
139 wireData.MCHits_PeakTime = 0;
140 wireData.MCHits_wAverageCharge = 0;
141 wireData.MCHits_wAverageTime = 0;
143 wireData.NHits.assign(wireData.NHitModules, 0);
144 wireData.Hits_IntegratedCharge.assign(wireData.NHitModules, 0);
145 wireData.Hits_AverageCharge.assign(wireData.NHitModules, 0);
146 wireData.Hits_PeakCharge.assign(wireData.NHitModules, -999);
147 wireData.Hits_PeakTime.assign(wireData.NHitModules, 0);
148 wireData.Hits_wAverageCharge.assign(wireData.NHitModules, 0);
149 wireData.Hits_wAverageTime.assign(wireData.NHitModules, 0);
150 wireData.Hits_MeanMultiplicity.assign(wireData.NHitModules, 0);
151 wireData.Hits.clear();
152 wireData.Hits.resize(wireData.NHitModules);
158 std::vector<sim::MCHitCollection>
const& MCHitCollectionVector,
159 std::vector<int>
const& thisAssocVector,
163 wireData.channel = wire.
Channel();
164 wireData.plane = wire.
View();
165 unsigned int range_index = 0;
169 wireData.range_index = range_index;
170 wireData.range_start = range.begin_index();
171 wireData.range_size = range.size();
173 ClearWireDataHitInfo();
175 ProcessROI(range, WireIndex, MCHitCollectionVector, thisAssocVector, clock_data);
185 float& charge_peak_time)
192 for (
auto const&
value : range) {
194 if (
value > charge_peak) {
196 charge_peak_time = (float)counter;
205 std::vector<sim::MCHitCollection>
const& MCHitCollectionVector,
206 std::vector<int>
const& thisAssocVector,
210 ROIInfo(range, wireData.integrated_charge, wireData.peak_charge, wireData.peak_time);
217 for (
size_t iter = 0; iter < HitProcessingQueue.size(); iter++)
218 FindAndStoreHitsInRange(HitProcessingQueue[iter].
first,
219 HitProcessingQueue[iter].
second.at(WireIndex),
224 FindAndStoreMCHitsInRange(MCHitCollectionVector,
230 wireDataTree->Fill();
235 std::vector<int>
const& HitsOnWire,
236 size_t hitmodule_iter,
237 size_t begin_wire_tdc,
241 wireData.Hits_PeakCharge[hitmodule_iter] = -999;
243 for (
auto const& hit_index : HitsOnWire) {
244 recob::Hit const& thishit = HitVector.at(hit_index);
250 FillHitInfo(thishit, wireData.Hits[hitmodule_iter]);
251 wireData.NHits[hitmodule_iter]++;
252 wireData.Hits_IntegratedCharge[hitmodule_iter] += thishit.
Integral();
254 if (thishit.
PeakAmplitude() > wireData.Hits_PeakCharge[hitmodule_iter]) {
255 wireData.Hits_PeakCharge[hitmodule_iter] = thishit.
PeakAmplitude();
256 wireData.Hits_PeakTime[hitmodule_iter] = thishit.
PeakTime();
259 wireData.Hits_wAverageCharge[hitmodule_iter] += thishit.
Integral() * thishit.
Integral();
260 wireData.Hits_wAverageTime[hitmodule_iter] += thishit.
Integral() * thishit.
PeakTime();
261 wireData.Hits_MeanMultiplicity[hitmodule_iter] += thishit.
Multiplicity();
263 *(hitData.at(hitmodule_iter)) = thishit;
264 (hitDataTree.at(hitmodule_iter))->Fill();
267 wireData.Hits_AverageCharge[hitmodule_iter] =
268 wireData.Hits_IntegratedCharge[hitmodule_iter] / wireData.NHits[hitmodule_iter];
269 wireData.Hits_wAverageCharge[hitmodule_iter] =
270 wireData.Hits_wAverageCharge[hitmodule_iter] / wireData.Hits_IntegratedCharge[hitmodule_iter];
271 wireData.Hits_wAverageTime[hitmodule_iter] =
272 wireData.Hits_wAverageTime[hitmodule_iter] / wireData.Hits_IntegratedCharge[hitmodule_iter];
274 wireData.Hits_MeanMultiplicity[hitmodule_iter] /= wireData.NHits[hitmodule_iter];
279 std::vector<sim::MCHitCollection>
const& MCHitCollectionVector,
280 std::vector<int>
const& HitsOnWire,
281 size_t begin_wire_tdc,
286 wireData.MCHits_PeakCharge = -999;
288 for (
auto const& hit_index : HitsOnWire) {
292 std::unordered_map<int, unsigned int> nmchits_per_trackID_map;
293 for (
auto const& thishit : thismchitcol) {
300 if (clock_data.
TPCTDC2Tick(thishit.PeakTime() - thishit.PeakWidth()) < begin_wire_tdc ||
301 clock_data.
TPCTDC2Tick(thishit.PeakTime() + thishit.PeakWidth()) > end_wire_tdc)
304 nmchits_per_trackID_map[thishit.PartTrackId()] += 1;
305 wireData.MCHits_IntegratedCharge += thishit.Charge();
307 if (thishit.Charge(
true) > wireData.MCHits_PeakCharge) {
308 wireData.MCHits_PeakCharge = thishit.Charge(
true);
309 wireData.MCHits_PeakTime = clock_data.
TPCTDC2Tick(thishit.PeakTime());
312 wireData.MCHits_wAverageCharge += thishit.Charge() * thishit.Charge();
313 wireData.MCHits_wAverageTime += thishit.Charge() * clock_data.
TPCTDC2Tick(thishit.PeakTime());
316 wireData.NMCHits = nmchits_per_trackID_map.size();
318 wireData.MCHits_AverageCharge = wireData.MCHits_IntegratedCharge / wireData.NMCHits;
319 wireData.MCHits_wAverageCharge =
320 wireData.MCHits_wAverageCharge / wireData.MCHits_IntegratedCharge;
321 wireData.MCHits_wAverageTime = wireData.MCHits_wAverageTime / wireData.MCHits_IntegratedCharge;
328 HitInfoVector.emplace_back(hit.
PeakTime(),
void LoadHitAssocPair(std::vector< recob::Hit > const &, std::vector< std::vector< int >> const &, std::string const &)
void SetHitDataTree(std::vector< TTree * > &trees)
void ProcessROI(lar::sparse_vector< float >::datarange_t const &, int, std::vector< sim::MCHitCollection > const &, std::vector< int > const &, detinfo::DetectorClocksData const &)
void FillHitInfo(recob::Hit const &, std::vector< HitInfo > &)
float RMS() const
RMS of the hit shape, in tick units.
hit::HitAnaAlgException hitanaalgexception
std::pair< double, bool > Branch(double hnl_mass, double ue4, double um4, double rand)
void ClearWireDataHitInfo()
float SigmaPeakAmplitude() const
Uncertainty on estimated amplitude of the hit at its peak, in ADC units.
float SigmaIntegral() const
const range_list_t & get_ranges() const
Returns the internal list of non-void ranges.
float Integral() const
Integral under the calibrated signal waveform of the hit, in tick x ADC units.
size_type begin_index() const
Returns the first absolute index included in the range.
float GoodnessOfFit() const
Degrees of freedom in the determination of the hit signal shape (-1 by default)
short int Multiplicity() const
How many hits could this one be shared with.
double TPCTDC2Tick(double const tdc) const
Given electronics clock count [tdc] returns TPC time-tick.
pure virtual base interface for detector clocks
std::array< float, 2 > HitVector(const recob::Hit &hit, const geo::GeometryCore *geo, const detinfo::DetectorPropertiesData &dprop)
void SetWireDataTree(TTree *)
float PeakAmplitude() const
The estimated amplitude of the hit at its peak, in ADC units.
process_name is maximum options services RecoDrawingOptions rawDigitFilterTPC3 services RecoDrawingOptions decon1DroiTPC3 services RecoDrawingOptions HitModuleLabels
geo::View_t View() const
Returns the view the channel belongs to.
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
auto counter(T begin, T end)
Returns an object to iterate values from begin to end in a range-for loop.
raw::ChannelID_t Channel() const
Returns the ID of the channel (or InvalidChannelID)
const RegionsOfInterest_t & SignalROI() const
Returns the list of regions of interest.
void AnalyzeWires(std::vector< recob::Wire > const &, std::vector< sim::MCHitCollection > const &, std::vector< std::vector< int >> const &, detinfo::DetectorClocksData const &, unsigned int, unsigned int)
raw::TDCtick_t StartTick() const
Initial tdc tick for hit.
float PeakTimeMinusRMS(float sigmas=+1.) const
raw::TDCtick_t EndTick() const
Final tdc tick for hit.
float PeakTime() const
Time of the signal peak, in tick units.
size_type size() const
Returns the size of the range.
void InitWireData(unsigned int, unsigned int)
Contains all timing reference information for the detector.
std::vector< art::Ptr< recob::Wire > > WireVector
Class holding the regions of interest of signal from a channel.
Range class, with range and data.
float SigmaPeakTime() const
Uncertainty for the signal peak, in tick units.
2D representation of charge deposited in the TDC/wire plane
float PeakTimePlusRMS(float sigmas=+1.) const
Returns a time sigmas RMS away from the peak time.
void FindAndStoreHitsInRange(std::vector< recob::Hit > const &, std::vector< int > const &, size_t, size_t, size_t)
void ROIInfo(lar::sparse_vector< float >::datarange_t const &, float &, float &, float &)
void FindAndStoreMCHitsInRange(std::vector< sim::MCHitCollection > const &, std::vector< int > const &, size_t, size_t, detinfo::DetectorClocksData const &)
void FillWireInfo(recob::Wire const &, int, std::vector< sim::MCHitCollection > const &, std::vector< int > const &, detinfo::DetectorClocksData const &)