All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Types | Public Member Functions | Private Attributes | List of all members
sbnd::CRTHitRecoAna Class Reference
Inheritance diagram for sbnd::CRTHitRecoAna:

Classes

struct  Config
 

Public Types

using Parameters = art::EDAnalyzer::Table< Config >
 

Public Member Functions

 CRTHitRecoAna (Parameters const &config)
 
virtual void beginJob () override
 
virtual void analyze (const art::Event &event) override
 
virtual void endJob () override
 

Private Attributes

art::InputTag fSimModuleLabel
 name of detsim producer More...
 
art::InputTag fCRTHitLabel
 name of CRT hit producer More...
 
bool fVerbose
 print information about what's going on More...
 
bool fVeryVerbose
 print more information about what's going on More...
 
bool fPlot
 plot tracks More...
 
int fPlotTrackID
 id of track to plot More...
 
double fMinAngleNpePlot
 Maximum angle for plotting Npe per hit. More...
 
TH1D * hNpeAngleCut
 
std::map< std::string, TH1D * > hHitTime
 
std::map< std::string, TH1D * > hNpe
 
std::map< std::string, TH1D * > hAngle
 
std::map< std::string, TH1D * > hRecoSipmDist
 
std::map< std::string, TH1D * > hTrueSipmDist
 
std::map< std::string, TH1D * > hEffWidthTotal
 
std::map< std::string, TH1D * > hEffWidthReco
 
std::map< std::string, TH1D * > hEffLengthTotal
 
std::map< std::string, TH1D * > hEffLengthReco
 
std::map< std::string, TH2D * > hTrueRecoSipmDist
 
std::map< std::string, TH2D * > hNpeAngle
 
std::map< std::string, TH2D * > hNpeSipmDist
 
std::map< std::string, TH2D * > hNpeStripDist
 
CRTGeoAlg fCrtGeo
 
CRTEventDisplay evd
 
CRTBackTracker fCrtBackTrack
 

Detailed Description

Definition at line 63 of file CRTHitRecoAna_module.cc.

Member Typedef Documentation

using sbnd::CRTHitRecoAna::Parameters = art::EDAnalyzer::Table<Config>

Definition at line 117 of file CRTHitRecoAna_module.cc.

Constructor & Destructor Documentation

sbnd::CRTHitRecoAna::CRTHitRecoAna ( Parameters const &  config)
explicit

Definition at line 169 of file CRTHitRecoAna_module.cc.

170  : EDAnalyzer(config)
171  , fSimModuleLabel (config().SimModuleLabel())
172  , fCRTHitLabel (config().CRTHitLabel())
173  , fVerbose (config().Verbose())
174  , fVeryVerbose (config().VeryVerbose())
175  , fPlot (config().Plot())
176  , fPlotTrackID (config().PlotTrackID())
177  , fMinAngleNpePlot (config().MinAngleNpePlot())
178  , evd (config().Evd())
179  , fCrtBackTrack (config().CrtBackTrack())
180  {
181 
182  }
BEGIN_PROLOG Verbose
bool fVerbose
print information about what&#39;s going on
int fPlotTrackID
id of track to plot
bool fVeryVerbose
print more information about what&#39;s going on
double fMinAngleNpePlot
Maximum angle for plotting Npe per hit.
art::InputTag fCRTHitLabel
name of CRT hit producer
art::InputTag fSimModuleLabel
name of detsim producer

Member Function Documentation

void sbnd::CRTHitRecoAna::analyze ( const art::Event &  event)
overridevirtual

Definition at line 214 of file CRTHitRecoAna_module.cc.

215  {
216 
217  // Fetch basic event info
218  if(fVerbose){
219  std::cout<<"============================================"<<std::endl
220  <<"Run = "<<event.run()<<", SubRun = "<<event.subRun()<<", Event = "<<event.id().event()<<std::endl
221  <<"============================================"<<std::endl;
222  }
223 
224  //----------------------------------------------------------------------------------------------------------
225  // GETTING PRODUCTS
226  //----------------------------------------------------------------------------------------------------------
227  // Retrieve all the truth info in the events
228  auto particleHandle = event.getValidHandle<std::vector<simb::MCParticle>>(fSimModuleLabel);
229 
230  // Get all the CRT hits
231  auto crtHitHandle = event.getValidHandle<std::vector<sbn::crt::CRTHit>>(fCRTHitLabel);
232 
233  // Get hit to data associations
234  art::FindManyP<sbnd::crt::CRTData> findManyData(crtHitHandle, event, fCRTHitLabel);
235 
236  fCrtBackTrack.Initialize(event);
237 
238  //----------------------------------------------------------------------------------------------------------
239  // TRUTH MATCHING
240  //----------------------------------------------------------------------------------------------------------
241  std::map<int, std::vector<sbn::crt::CRTHit>> crtHits;
242  double minHitTime = 99999;
243  double maxHitTime = -99999;
244  int ht_i = 0;
245  for(auto const& hit : (*crtHitHandle)){
246  int trueId = fCrtBackTrack.TrueIdFromHitId(event, ht_i);
247  ht_i++;
248  if(trueId == -99999) continue;
249  crtHits[trueId].push_back(hit);
250  double hitTime = (double)(int)hit.ts1_ns * 1e-3;
251  if(hitTime < minHitTime) minHitTime = hitTime;
252  if(hitTime > maxHitTime) maxHitTime = hitTime;
253  }
254 
255  //----------------------------------------------------------------------------------------------------------
256  // EFFICIENCIES
257  //----------------------------------------------------------------------------------------------------------
258  // Fill a map of true particles
259  std::map<int, simb::MCParticle> particles;
260  for (auto const& particle: (*particleHandle)){
261  int partId = particle.TrackId();
262  particles[partId] = particle;
263 
264  // Only consider particles within the time limit of the generated CRT hits
265  double time = particle.T() * 1e-3;
266  if(time < minHitTime || time > maxHitTime) continue;
267 
268  if(!(std::abs(particle.PdgCode()) == 13 && particle.Mother()==0)) continue;
269 
270  std::vector<std::string> stripNames = fCrtGeo.CrossesStrips(particle);
271 
272  for(auto const& stripName : stripNames){
273  std::string tagger = fCrtGeo.GetTaggerName(stripName);
274  if(!fCrtGeo.ValidCrossingPoint(tagger, particle)) continue;
275  geo::Point_t cross = fCrtGeo.StripCrossingPoint(stripName, particle);
276  double sipmDist = fCrtGeo.DistanceBetweenSipms(cross, stripName);
277  double stripDist = fCrtGeo.DistanceDownStrip(cross, stripName);
278  hEffWidthTotal[tagger]->Fill(sipmDist);
279  hEffLengthTotal[tagger]->Fill(stripDist);
280 
281  //Loop over crt hits
282  if(crtHits.find(partId) == crtHits.end()) continue;
283  bool match = false;
284  for(size_t i = 0; i < crtHits[partId].size(); i++){
285  //If you find a hit on the same tagger then fill
286  if(crtHits[partId][i].tagger == tagger) match = true;
287  }
288 
289  if(!match) continue;
290  hEffWidthReco[tagger]->Fill(sipmDist);
291  hEffLengthReco[tagger]->Fill(stripDist);
292  }
293  }
294 
295  //----------------------------------------------------------------------------------------------------------
296  // CRT HIT ANALYSIS
297  //----------------------------------------------------------------------------------------------------------
298  int hit_i = 0;
299  for(auto const& hit : (*crtHitHandle)){
300  std::string tagger = hit.tagger;
301 
302  // Calculate the time of the CRT hit in us
303  double time = (double)(int)hit.ts1_ns * 1e-3;
304  hHitTime[tagger]->Fill(time);
305 
306  geo::Point_t hitPos {hit.x_pos, hit.y_pos, hit.z_pos};
307 
308  // Get the data associated with the hit
309  std::vector<art::Ptr<sbnd::crt::CRTData>> data = findManyData.at(hit_i);
310 
311  // Get all the strips from the crt hit
312  std::vector<std::string> stripNames;
313  for(auto const& dat : data){
314  std::string name = fCrtGeo.ChannelToStripName(dat->Channel());
315  if(std::find(stripNames.begin(), stripNames.end(), name) == stripNames.end())
316  stripNames.push_back(name);
317  }
318 
319  // Match hit to true track
320  int trueId = fCrtBackTrack.TrueIdFromHitId(event, hit_i);
321  hit_i++;
322  if(particles.find(trueId) == particles.end()) continue;
323  if(!(std::abs(particles[trueId].PdgCode()) == 13 && particles[trueId].Mother()==0)) continue;
324 
325  // Calculate the angle to the tagger
326  double angle = TMath::Pi()/2. - fCrtGeo.AngleToTagger(tagger, particles[trueId]);
327  if(angle > fMinAngleNpePlot && tagger != "volTaggerBot_0") hNpeAngleCut->Fill(hit.peshit);
328  hNpe[tagger]->Fill(hit.peshit);
329  hAngle[tagger]->Fill(angle);
330  hNpeAngle[tagger]->Fill(angle, hit.peshit);
331 
332  // Calculate the true distance from the channel
333  for(auto const& stripName : stripNames){
334  // Calculate the reconstructed position between sipms
335  double hitDist = fCrtGeo.DistanceBetweenSipms(hitPos, stripName);
336  hRecoSipmDist[tagger]->Fill(hitDist);
337 
338  // Calculate the true position between the sipms
339  geo::Point_t truePos = fCrtGeo.StripCrossingPoint(stripName, particles[trueId]);
340  double trueDist = fCrtGeo.DistanceBetweenSipms(truePos, stripName);
341  hTrueSipmDist[tagger]->Fill(trueDist);
342  hTrueRecoSipmDist[tagger]->Fill(trueDist, hitDist);
343 
344  // Fill the number of pe as a function of distances
345  hNpeSipmDist[tagger]->Fill(trueDist, hit.peshit);
346  double stripDist = fCrtGeo.DistanceDownStrip(truePos, stripName);
347  hNpeStripDist[tagger]->Fill(stripDist, hit.peshit);
348  }
349 
350  }
351 
352  if(fPlot){
353  evd.SetDrawCrtData(true);
354  evd.SetDrawCrtHits(true);
355  evd.SetDrawCrtTracks(true);
356  if(fVeryVerbose) evd.SetPrint(true);
357  if(fPlotTrackID != -99999) evd.SetTrueId(fPlotTrackID);
358  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(event);
359  evd.Draw(clockData, event);
360  }
361 
362  } // CRTHitRecoAna::analyze()
std::map< std::string, TH2D * > hNpeAngle
void Draw(detinfo::DetectorClocksData const &clockData, const art::Event &event)
bool fVerbose
print information about what&#39;s going on
std::map< std::string, TH1D * > hEffLengthReco
geo::Point_t StripCrossingPoint(std::string stripName, const simb::MCParticle &particle)
std::map< std::string, TH2D * > hTrueRecoSipmDist
process_name hit
Definition: cheaterreco.fcl:51
int fPlotTrackID
id of track to plot
std::map< std::string, TH1D * > hRecoSipmDist
bool fVeryVerbose
print more information about what&#39;s going on
double fMinAngleNpePlot
Maximum angle for plotting Npe per hit.
int TrueIdFromHitId(const art::Event &event, int hit_i)
std::map< std::string, TH1D * > hHitTime
T abs(T value)
std::map< std::string, TH1D * > hNpe
std::map< std::string, TH1D * > hAngle
art::InputTag fCRTHitLabel
name of CRT hit producer
std::map< std::string, TH1D * > hEffWidthTotal
std::string ChannelToStripName(size_t channel) const
double DistanceDownStrip(geo::Point_t position, std::string stripName) const
std::string GetTaggerName(std::string name) const
std::vector< std::string > CrossesStrips(const simb::MCParticle &particle)
double AngleToTagger(std::string taggerName, const simb::MCParticle &particle)
std::map< std::string, TH1D * > hTrueSipmDist
void SetDrawCrtTracks(bool tf)
std::map< std::string, TH1D * > hEffLengthTotal
std::map< std::string, TH2D * > hNpeStripDist
std::map< std::string, TH2D * > hNpeSipmDist
do i e
then echo fcl name
finds tracks best matching by angle
std::map< std::string, TH1D * > hEffWidthReco
void SetDrawCrtHits(bool tf)
Vector cross(Vector const &a, Vector const &b)
Return cross product of two vectors.
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
Definition: geo_vectors.h:184
bool ValidCrossingPoint(std::string taggerName, const simb::MCParticle &particle)
void SetDrawCrtData(bool tf)
BEGIN_PROLOG could also be cout
art::InputTag fSimModuleLabel
name of detsim producer
double DistanceBetweenSipms(geo::Point_t position, size_t channel) const
void sbnd::CRTHitRecoAna::beginJob ( )
overridevirtual

Definition at line 184 of file CRTHitRecoAna_module.cc.

185  {
186  // Access tfileservice to handle creating and writing histograms
187  art::ServiceHandle<art::TFileService> tfs;
188  // Define histograms
189  hNpeAngleCut = tfs->make<TH1D>("NpeAngleCut", "", 60, 0, 600);
190  for(size_t i = 0; i < fCrtGeo.NumTaggers(); i++){
191  std::string tagger = fCrtGeo.GetTagger(i).name;
192  hRecoSipmDist[tagger] = tfs->make<TH1D>(Form("RecoSipmDist_%s", tagger.c_str()), "", 40, -2, 13);
193  hTrueSipmDist[tagger] = tfs->make<TH1D>(Form("TrueSipmDist_%s", tagger.c_str()), "", 40, -2, 13);
194  hHitTime[tagger] = tfs->make<TH1D>(Form("HitTime_%s", tagger.c_str()), "", 40, -2000, 3000);
195  hNpe[tagger] = tfs->make<TH1D>(Form("Npe_%s", tagger.c_str()), "", 60, 0, 600);
196  hAngle[tagger] = tfs->make<TH1D>(Form("Angle_%s", tagger.c_str()), "", 40, 0, 1.6);
197 
198  hEffWidthTotal[tagger] = tfs->make<TH1D>(Form("EffWidthTotal_%s", tagger.c_str()), "", 20, 0, 11.2);
199  hEffWidthReco[tagger] = tfs->make<TH1D>(Form("EffWidthReco_%s", tagger.c_str()), "", 20, 0, 11.2);
200  hEffLengthTotal[tagger] = tfs->make<TH1D>(Form("EffLengthTotal_%s", tagger.c_str()), "", 20, 0, 450);
201  hEffLengthReco[tagger] = tfs->make<TH1D>(Form("EffLengthReco_%s", tagger.c_str()), "", 20, 0, 450);
202 
203  hTrueRecoSipmDist[tagger] = tfs->make<TH2D>(Form("TrueRecoSipmDist_%s", tagger.c_str()), "", 30, -2, 13, 30, -2, 13);
204  hNpeAngle[tagger] = tfs->make<TH2D>(Form("NpeAngle_%s", tagger.c_str()), "", 30, 0, 1.6, 30, 0, 600);
205  hNpeSipmDist[tagger] = tfs->make<TH2D>(Form("NpeSipmDist_%s", tagger.c_str()), "", 30, 0, 11.2, 30, 0, 600);
206  hNpeStripDist[tagger] = tfs->make<TH2D>(Form("NpeStripDist_%s", tagger.c_str()), "", 30, 0, 450, 30, 0, 600);
207  }
208 
209  // Initial output
210  std::cout<<"----------------- CRT Hit Reco Ana Module -------------------"<<std::endl;
211 
212  }// CRTHitRecoAna::beginJob()
std::map< std::string, TH2D * > hNpeAngle
std::map< std::string, TH1D * > hEffLengthReco
CRTTaggerGeo GetTagger(std::string taggerName) const
std::map< std::string, TH2D * > hTrueRecoSipmDist
std::map< std::string, TH1D * > hRecoSipmDist
std::map< std::string, TH1D * > hHitTime
std::map< std::string, TH1D * > hNpe
std::map< std::string, TH1D * > hAngle
std::map< std::string, TH1D * > hEffWidthTotal
std::map< std::string, TH1D * > hTrueSipmDist
std::map< std::string, TH1D * > hEffLengthTotal
std::map< std::string, TH2D * > hNpeStripDist
std::map< std::string, TH2D * > hNpeSipmDist
art::ServiceHandle< art::TFileService > tfs
std::map< std::string, TH1D * > hEffWidthReco
BEGIN_PROLOG could also be cout
void sbnd::CRTHitRecoAna::endJob ( )
overridevirtual

Definition at line 364 of file CRTHitRecoAna_module.cc.

364  {
365 
366  } // CRTHitRecoAna::endJob()

Member Data Documentation

CRTEventDisplay sbnd::CRTHitRecoAna::evd
private

Definition at line 163 of file CRTHitRecoAna_module.cc.

CRTBackTracker sbnd::CRTHitRecoAna::fCrtBackTrack
private

Definition at line 164 of file CRTHitRecoAna_module.cc.

CRTGeoAlg sbnd::CRTHitRecoAna::fCrtGeo
private

Definition at line 162 of file CRTHitRecoAna_module.cc.

art::InputTag sbnd::CRTHitRecoAna::fCRTHitLabel
private

name of CRT hit producer

Definition at line 135 of file CRTHitRecoAna_module.cc.

double sbnd::CRTHitRecoAna::fMinAngleNpePlot
private

Maximum angle for plotting Npe per hit.

Definition at line 140 of file CRTHitRecoAna_module.cc.

bool sbnd::CRTHitRecoAna::fPlot
private

plot tracks

Definition at line 138 of file CRTHitRecoAna_module.cc.

int sbnd::CRTHitRecoAna::fPlotTrackID
private

id of track to plot

Definition at line 139 of file CRTHitRecoAna_module.cc.

art::InputTag sbnd::CRTHitRecoAna::fSimModuleLabel
private

name of detsim producer

Definition at line 134 of file CRTHitRecoAna_module.cc.

bool sbnd::CRTHitRecoAna::fVerbose
private

print information about what's going on

Definition at line 136 of file CRTHitRecoAna_module.cc.

bool sbnd::CRTHitRecoAna::fVeryVerbose
private

print more information about what's going on

Definition at line 137 of file CRTHitRecoAna_module.cc.

std::map<std::string, TH1D*> sbnd::CRTHitRecoAna::hAngle
private

Definition at line 147 of file CRTHitRecoAna_module.cc.

std::map<std::string, TH1D*> sbnd::CRTHitRecoAna::hEffLengthReco
private

Definition at line 154 of file CRTHitRecoAna_module.cc.

std::map<std::string, TH1D*> sbnd::CRTHitRecoAna::hEffLengthTotal
private

Definition at line 153 of file CRTHitRecoAna_module.cc.

std::map<std::string, TH1D*> sbnd::CRTHitRecoAna::hEffWidthReco
private

Definition at line 152 of file CRTHitRecoAna_module.cc.

std::map<std::string, TH1D*> sbnd::CRTHitRecoAna::hEffWidthTotal
private

Definition at line 151 of file CRTHitRecoAna_module.cc.

std::map<std::string, TH1D*> sbnd::CRTHitRecoAna::hHitTime
private

Definition at line 145 of file CRTHitRecoAna_module.cc.

std::map<std::string, TH1D*> sbnd::CRTHitRecoAna::hNpe
private

Definition at line 146 of file CRTHitRecoAna_module.cc.

std::map<std::string,TH2D*> sbnd::CRTHitRecoAna::hNpeAngle
private

Definition at line 157 of file CRTHitRecoAna_module.cc.

TH1D* sbnd::CRTHitRecoAna::hNpeAngleCut
private

Definition at line 143 of file CRTHitRecoAna_module.cc.

std::map<std::string,TH2D*> sbnd::CRTHitRecoAna::hNpeSipmDist
private

Definition at line 158 of file CRTHitRecoAna_module.cc.

std::map<std::string,TH2D*> sbnd::CRTHitRecoAna::hNpeStripDist
private

Definition at line 159 of file CRTHitRecoAna_module.cc.

std::map<std::string, TH1D*> sbnd::CRTHitRecoAna::hRecoSipmDist
private

Definition at line 148 of file CRTHitRecoAna_module.cc.

std::map<std::string,TH2D*> sbnd::CRTHitRecoAna::hTrueRecoSipmDist
private

Definition at line 156 of file CRTHitRecoAna_module.cc.

std::map<std::string, TH1D*> sbnd::CRTHitRecoAna::hTrueSipmDist
private

Definition at line 149 of file CRTHitRecoAna_module.cc.


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