All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
hit::GausHitFinderAna Class Reference

Base class for creation of raw signals on wires. More...

Inheritance diagram for hit::GausHitFinderAna:

Public Member Functions

 GausHitFinderAna (fhicl::ParameterSet const &pset)
 

Private Member Functions

void analyze (const art::Event &evt) override
 
void beginJob () override
 

Private Attributes

std::string fHitFinderModuleLabel
 
std::string fLArG4ModuleLabel
 
std::string fCalDataModuleLabel
 
TH1F * fHitResidualAll
 
TH1F * fHitResidualAllAlt
 
TH1F * fNumberOfHitsPerEvent
 
TH2F * fPeakTimeVsWire
 
TTree * fHTree
 
Int_t fRun
 
Int_t fEvt
 
Float_t fWireTotalCharge
 
Int_t fnHits
 
Int_t fWire [kMaxHits]
 
Float_t fStartTime [kMaxHits]
 
Float_t fEndTime [kMaxHits]
 
Float_t fPeakTime [kMaxHits]
 
Float_t fPeakTimeUncert [kMaxHits]
 
Float_t fCharge [kMaxHits]
 
Float_t fChargeUncert [kMaxHits]
 
Int_t fMultiplicity [kMaxHits]
 
Float_t fGOF [kMaxHits]
 
Float_t fTotalHitChargePerEvent
 
Float_t fTruePeakPos [kMaxHits]
 

Detailed Description

Base class for creation of raw signals on wires.

Definition at line 46 of file GausHitFinderAna_module.cc.

Constructor & Destructor Documentation

hit::GausHitFinderAna::GausHitFinderAna ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 94 of file GausHitFinderAna_module.cc.

94  : EDAnalyzer(pset)
95  {
96  fHitFinderModuleLabel = pset.get<std::string>("HitsModuleLabel");
97  fLArG4ModuleLabel = pset.get<std::string>("LArGeantModuleLabel");
98  fCalDataModuleLabel = pset.get<std::string>("CalDataModuleLabel");
99  }

Member Function Documentation

void hit::GausHitFinderAna::analyze ( const art::Event &  evt)
overrideprivate

Definition at line 139 of file GausHitFinderAna_module.cc.

140  {
141  // ### TTree Run/Event ###
142  fEvt = evt.id().event();
143  fRun = evt.run();
144 
145  art::ServiceHandle<geo::Geometry const> geom;
146  auto const clock_data =
147  art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
148  auto const det_prop =
149  art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(evt, clock_data);
150 
151  art::Handle<std::vector<recob::Wire>> wireVecHandle;
152  evt.getByLabel(fCalDataModuleLabel, wireVecHandle);
153 
154  // Charge directly from wire info
155  float TotWireCharge = 0;
156 
157  for (size_t wireIter = 0; wireIter < wireVecHandle->size(); wireIter++) {
158  art::Ptr<recob::Wire> wire(wireVecHandle, wireIter);
159  std::vector<float> signal(wire->Signal());
160 
161  for (auto timeIter = signal.begin(); timeIter + 2 < signal.end(); timeIter++) {
162 
163  if (*timeIter < 2) { continue; }
164 
165  TotWireCharge += *timeIter;
166  }
167  }
168 
169  fWireTotalCharge = TotWireCharge;
170 
171  // Reconstructed hit information
172  art::Handle<std::vector<recob::Hit>> hitHandle;
173  evt.getByLabel(fHitFinderModuleLabel, hitHandle);
174 
175  std::vector<art::Ptr<recob::Hit>> hits;
176  art::fill_ptr_vector(hits, hitHandle);
177 
178  float TotCharge = 0;
179  int hitCount = 0;
180  fnHits = hitHandle->size();
181  fNumberOfHitsPerEvent->Fill(hitHandle->size());
182 
183  for (size_t numHit = 0; numHit < hitHandle->size(); ++numHit) {
184  // === Finding Channel associated with the hit ===
185  art::Ptr<recob::Hit> hit(hitHandle, numHit);
186 
187  fWire[hitCount] = hit->WireID().Wire;
188  fStartTime[hitCount] = hit->PeakTimeMinusRMS();
189  fEndTime[hitCount] = hit->PeakTimePlusRMS();
190  fPeakTime[hitCount] = hit->PeakTime();
191  fPeakTimeUncert[hitCount] = hit->SigmaPeakTime();
192  fCharge[hitCount] = hit->Integral();
193  fChargeUncert[hitCount] = hit->SigmaIntegral();
194  fMultiplicity[hitCount] = hit->Multiplicity();
195  fGOF[hitCount] = hit->GoodnessOfFit();
196 
197  hitCount++;
198  TotCharge += hit->Integral();
199 
200  fPeakTimeVsWire->Fill(hit->WireID().Wire, hit->PeakTime());
201  } //<---End numHit
202  fTotalHitChargePerEvent = TotCharge;
203 
204  // Truth hit info from BackTracker
205 
206  unsigned int plane = 0;
207  Float_t TruthHitTime = 0, TruthHitCalculated = 0;
208  int count = 0;
209 
210  double time_tick = sampling_rate(clock_data) / 1000.;
211  double drift_velocity = det_prop.DriftVelocity(det_prop.Efield(), det_prop.Temperature());
212 
213  for (size_t nh = 0; nh < hitHandle->size(); nh++) {
214  // === Finding Channel associated with the hit ===
215  art::Ptr<recob::Hit> hitPoint(hitHandle, nh);
216  plane = hitPoint->WireID().Plane;
217 
218  // ===================================================================
219  // Using Track IDE's to locate the XYZ location from truth information
220  // ===================================================================
221  std::vector<sim::TrackIDE> trackides;
222  std::vector<double> xyz;
223  try {
224  art::ServiceHandle<cheat::BackTrackerService const> bt_serv;
225  trackides = bt_serv->HitToTrackIDEs(clock_data, hitPoint);
226  xyz = bt_serv->HitToXYZ(clock_data, hitPoint);
227  }
228  catch (cet::exception const&) {
229  mf::LogWarning("GausHitFinderAna") << "BackTrackerService Failed";
230  continue;
231  }
232 
233  // ==============================================================
234  // Calculating the truth tick position of the hit using 2 methods
235  // Method 1: ConvertXtoTicks from the detector properties package
236  // Method 2: Actually do the calculation myself to double check things
237  // ==============================================================
238 
239  // ### Method 1 ###
240  TruthHitTime = det_prop.ConvertXToTicks(
241  xyz[0], plane, hitPoint->WireID().TPC, hitPoint->WireID().Cryostat);
242 
243  // ### Method 2 ###
244  // ================================================
245  // Establishing the x-position of the current plane
246  // ================================================
247  const double origin[3] = {0.};
248  double pos[3];
249  geom->Plane(plane).LocalToWorld(origin, pos);
250  double planePos_timeCorr = (pos[0] / drift_velocity) * (1. / time_tick) + 60;
251  //<---x position of plane / drift velocity + 60 (Trigger offset)
252 
253  TruthHitCalculated = ((xyz[0]) / (drift_velocity * time_tick)) + planePos_timeCorr;
254 
255  fTruePeakPos[count] = TruthHitTime;
256  count++;
257  double hitresid = ((TruthHitTime - hitPoint->PeakTime()) / hitPoint->SigmaPeakTime());
258  fHitResidualAll->Fill(hitresid);
259 
260  double hitresidAlt =
261  ((TruthHitCalculated - hitPoint->PeakTime()) / hitPoint->SigmaPeakTime());
262  fHitResidualAllAlt->Fill(hitresidAlt);
263 
264  } //<---End nh loop
265 
266  fHTree->Fill();
267  } // end analyze method
unsigned int event
Definition: DataStructs.h:634
unsigned int run
Definition: DataStructs.h:635
process_name hit
Definition: cheaterreco.fcl:51
Float_t fPeakTimeUncert[kMaxHits]
TCEvent evt
Definition: DataStructs.cxx:8
std::size_t count(Cont const &cont)
double sampling_rate(DetectorClocksData const &data)
Returns the period of the TPC readout electronics clock.
constexpr Point origin()
Returns a origin position with a point of the specified type.
Definition: geo_vectors.h:227
void hit::GausHitFinderAna::beginJob ( )
overrideprivate

Definition at line 103 of file GausHitFinderAna_module.cc.

104  {
105  art::ServiceHandle<art::TFileService const> tfs;
106  fHitResidualAll = tfs->make<TH1F>("fHitResidualAll", "Hit Residual All", 1600, -400, 400);
107  fHitResidualAllAlt = tfs->make<TH1F>("fHitResidualAllAlt", "Hit Residual All", 1600, -400, 400);
109  tfs->make<TH1F>("fNumberOfHitsPerEvent", "Number of Hits in Each Event", 10000, 0, 10000);
111  tfs->make<TH2F>("fPeakTimeVsWire", "Peak Time vs Wire Number", 3200, 0, 3200, 9500, 0, 9500);
112 
113  fHTree = tfs->make<TTree>("HTree", "HTree");
114  fHTree->Branch("Evt", &fEvt, "Evt/I");
115  fHTree->Branch("Run", &fRun, "Run/I");
116  fHTree->Branch("WireTotalCharge", &fWireTotalCharge, "WireTotalCharge/F");
117 
118  // === Hit Info ===
119  fHTree->Branch("nHits", &fnHits, "nHits/I");
120  fHTree->Branch("Wire", &fWire, "Wire[nHits]/I");
121  fHTree->Branch("StartTime", &fStartTime, "fStartTime[nHits]/F");
122  fHTree->Branch("EndTime", &fEndTime, "fEndTime[nHits]/F");
123  fHTree->Branch("PeakTime", &fPeakTime, "fPeakTime[nHits]/F");
124  fHTree->Branch("PeakTimeUncert", &fPeakTimeUncert, "fPeakTimeUncert[nHits]/F");
125  fHTree->Branch("Charge", &fCharge, "fCharge[nHits]/F");
126  fHTree->Branch("ChargeUncert", &fChargeUncert, "fChargeUncert[nHits]/F");
127  fHTree->Branch("Multiplicity", &fMultiplicity, "fMultiplicity[nHits]/I");
128  fHTree->Branch("GOF", &fGOF, "fGOF[nHits]/F");
129 
130  // === Total Hit Information ===
131  fHTree->Branch("TotalHitChargePerEvent", &fTotalHitChargePerEvent, "TotalHitChargePerEvent/F");
132 
133  // === Truth Hit Information from BackTrackerService ===
134  fHTree->Branch("TruePeakPos", &fTruePeakPos, "fTruePeakPos[nHits]/F");
135  }
Float_t fPeakTimeUncert[kMaxHits]
art::ServiceHandle< art::TFileService > tfs

Member Data Documentation

std::string hit::GausHitFinderAna::fCalDataModuleLabel
private

Definition at line 56 of file GausHitFinderAna_module.cc.

Float_t hit::GausHitFinderAna::fCharge[kMaxHits]
private

Definition at line 80 of file GausHitFinderAna_module.cc.

Float_t hit::GausHitFinderAna::fChargeUncert[kMaxHits]
private

Definition at line 81 of file GausHitFinderAna_module.cc.

Float_t hit::GausHitFinderAna::fEndTime[kMaxHits]
private

Definition at line 77 of file GausHitFinderAna_module.cc.

Int_t hit::GausHitFinderAna::fEvt
private

Definition at line 68 of file GausHitFinderAna_module.cc.

Float_t hit::GausHitFinderAna::fGOF[kMaxHits]
private

Definition at line 83 of file GausHitFinderAna_module.cc.

std::string hit::GausHitFinderAna::fHitFinderModuleLabel
private

Definition at line 54 of file GausHitFinderAna_module.cc.

TH1F* hit::GausHitFinderAna::fHitResidualAll
private

Definition at line 58 of file GausHitFinderAna_module.cc.

TH1F* hit::GausHitFinderAna::fHitResidualAllAlt
private

Definition at line 59 of file GausHitFinderAna_module.cc.

TTree* hit::GausHitFinderAna::fHTree
private

Definition at line 64 of file GausHitFinderAna_module.cc.

std::string hit::GausHitFinderAna::fLArG4ModuleLabel
private

Definition at line 55 of file GausHitFinderAna_module.cc.

Int_t hit::GausHitFinderAna::fMultiplicity[kMaxHits]
private

Definition at line 82 of file GausHitFinderAna_module.cc.

Int_t hit::GausHitFinderAna::fnHits
private

Definition at line 74 of file GausHitFinderAna_module.cc.

TH1F* hit::GausHitFinderAna::fNumberOfHitsPerEvent
private

Definition at line 60 of file GausHitFinderAna_module.cc.

Float_t hit::GausHitFinderAna::fPeakTime[kMaxHits]
private

Definition at line 78 of file GausHitFinderAna_module.cc.

Float_t hit::GausHitFinderAna::fPeakTimeUncert[kMaxHits]
private

Definition at line 79 of file GausHitFinderAna_module.cc.

TH2F* hit::GausHitFinderAna::fPeakTimeVsWire
private

Definition at line 61 of file GausHitFinderAna_module.cc.

Int_t hit::GausHitFinderAna::fRun
private

Definition at line 67 of file GausHitFinderAna_module.cc.

Float_t hit::GausHitFinderAna::fStartTime[kMaxHits]
private

Definition at line 76 of file GausHitFinderAna_module.cc.

Float_t hit::GausHitFinderAna::fTotalHitChargePerEvent
private

Definition at line 86 of file GausHitFinderAna_module.cc.

Float_t hit::GausHitFinderAna::fTruePeakPos[kMaxHits]
private

Definition at line 89 of file GausHitFinderAna_module.cc.

Int_t hit::GausHitFinderAna::fWire[kMaxHits]
private

Definition at line 75 of file GausHitFinderAna_module.cc.

Float_t hit::GausHitFinderAna::fWireTotalCharge
private

Definition at line 71 of file GausHitFinderAna_module.cc.


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