LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
MultiEMShowers_module.cc
Go to the documentation of this file.
1 // Class: MultiEMShowers
3 // Module Type: analyzer
4 // File: MultiEMShowers_module.cc
5 // Author: dorota.stefan@cern.ch robert.sulej@cern.ch
7 
15 #include "fhiclcpp/ParameterSet.h"
20 
22 
30 
34 
35 #include <memory>
36 
38 
39 // ROOT includes
40 #include "TTree.h"
41 #include "TLorentzVector.h"
42 #include "TMathBase.h"
43 
44 namespace ems {
45  class MCinfo;
46  class MultiEMShowers;
47 }
48 
50 {
51  public:
52  MCinfo(const art::Event& evt);
53  void Info(const art::Event& evt);
54  void Findtpcborders(const art::Event& evt);
55 
56  int GetNgammas() const { return fNgammas; }
57 
58  double GetMompi0() const { return fMompi0; }
59  double GetMomGamma1() const { return fGammamom1; }
60  double GetMomGamma2() const { return fGammamom2; }
61 
62  double GetCosine() { return fCosine; }
63 
64  TVector3 const & GetPrimary() const { return fPrimary; }
65  TVector3 const & GetPospi0() const { return fPi0pos; }
66  TVector3 const & GetPosgamma1() const { return fConvgamma1; }
67  TVector3 const & GetPosgamma2() const { return fConvgamma2; }
68 
69  TVector3 const & GetDirgamma1() const { return fDirgamma1; }
70  TVector3 const & GetDirgamma2() const { return fDirgamma2; }
71 
72  bool const & IsInside1() const { return fInside1; }
73  bool const & IsInside2() const { return fInside2; }
74 
75  bool const & IsCompton() const { return fCompton; }
76 
77  private:
78  bool insideFidVol(const TLorentzVector& pvtx) const;
79  double fMinx; double fMaxx;
80  double fMiny; double fMaxy;
81  double fMinz; double fMaxz;
82 
83  double fFidVolCut;
84 
85  int fNgammas;
86 
87  double fMompi0;
88  double fGammamom1;
89  bool fInside1;
90  double fGammamom2;
91  bool fInside2;
92 
93  double fCosine;
94 
95  bool fCompton;
96 
97  TVector3 fPrimary;
98  TVector3 fPi0pos;
99  TVector3 fConvgamma1;
100  TVector3 fConvgamma2;
101  TVector3 fDirgamma1;
102  TVector3 fDirgamma2;
103 };
104 
106 fFidVolCut(2.0)
107 {
108  Info(evt);
109  Findtpcborders(evt);
110 }
111 
113 {
115 
116  fMinx = geom->IterateTPCs().begin()->MinX();
117  fMiny = geom->IterateTPCs().begin()->MinY();
118  fMinz = geom->IterateTPCs().begin()->MinZ();
119  fMaxx = geom->IterateTPCs().begin()->MaxX();
120  fMaxy = geom->IterateTPCs().begin()->MaxY();
121  fMaxz = geom->IterateTPCs().begin()->MaxZ();
122 
123  for (const geo::TPCGeo& tpcg: geom->IterateTPCs())
124  {
125  if (tpcg.MinX() < fMinx) fMinx = tpcg.MinX();
126  if (tpcg.MaxX() > fMaxx) fMaxx = tpcg.MaxX();
127  if (tpcg.MinY() < fMiny) fMiny = tpcg.MinY();
128  if (tpcg.MaxY() > fMaxy) fMaxy = tpcg.MaxY();
129  if (tpcg.MinZ() < fMinz) fMinz = tpcg.MinZ();
130  if (tpcg.MaxZ() > fMaxz) fMaxz = tpcg.MaxZ();
131  }
132 }
133 
135 {
136  fMompi0 = 0.0; fPi0pos.SetXYZ(0,0,0);
137  fNgammas = 0;
138  fCosine = 0.0;
139  fInside1 = false; fInside2 = false;
140  fCompton = false;
141 
142  fGammamom1 = 0.0; fGammamom2 = 0.0;
143  fConvgamma1.SetXYZ(0,0,0); fConvgamma2.SetXYZ(0,0,0);
144  fDirgamma1.SetXYZ(0,0,0); fDirgamma2.SetXYZ(0,0,0);
145 
147  const sim::ParticleList& plist = pi_serv->ParticleList();
148  for (sim::ParticleList::const_iterator ipar = plist.begin(); ipar != plist.end(); ++ipar)
149  {
150  const simb::MCParticle* particle = ipar->second;
151 
152  if (particle->Process() != "primary") continue;
153 
154  TLorentzVector posvec = particle->Position();
155  TVector3 pose(posvec.X(), posvec.Y(), posvec.Z());
156  fPrimary = pose;
157 
158 
159  if (particle->PdgCode() == 111)
160  {
161  fMompi0 = particle->P();
162 
163  TLorentzVector posvec3 = particle->Position();
164  TVector3 pospi0(posvec3.X(), posvec3.Y(), posvec3.Z());
165  fPi0pos = pospi0;
166 
167  if (particle->NumberDaughters() != 2) continue;
168 
169  const simb::MCParticle* daughter1 = pi_serv->TrackIdToParticle_P(particle->Daughter(0));
170  if (daughter1->PdgCode() != 22) continue;
171 
172  const simb::MCParticle* daughter2 = pi_serv->TrackIdToParticle_P(particle->Daughter(1));
173  if (daughter2->PdgCode() != 22) continue;
174 
175  fNgammas = particle->NumberDaughters();
176  TLorentzVector mom1 = pi_serv->TrackIdToParticle_P(particle->Daughter(0))->Momentum();
177  TLorentzVector mom2 = pi_serv->TrackIdToParticle_P(particle->Daughter(1))->Momentum();
178 
179  // compton process
180  if (daughter1->EndProcess() == "phot") fCompton = true;
181  if (daughter2->EndProcess() == "phot") fCompton = true;
182 
183  TVector3 mom1vec3(mom1.Px(), mom1.Py(), mom1.Pz());
184  fGammamom1 = pi_serv->TrackIdToParticle_P(particle->Daughter(0))->P();
185  TVector3 mom2vec3(mom2.Px(), mom2.Py(), mom2.Pz());
186  fGammamom2 = pi_serv->TrackIdToParticle_P(particle->Daughter(1))->P();
187 
188  TLorentzVector pos1 = pi_serv->TrackIdToParticle_P(particle->Daughter(0))->EndPosition();
189  TLorentzVector pos2 = pi_serv->TrackIdToParticle_P(particle->Daughter(1))->EndPosition();
190 
191  if (insideFidVol(pos1)) fInside1 = true;
192  if (insideFidVol(pos2)) fInside2 = true;
193 
194 
195  fConvgamma1.SetXYZ(pos1.X(), pos1.Y(), pos1.Z());
196  fConvgamma2.SetXYZ(pos2.X(), pos2.Y(), pos2.Z());
197 
198  TVector3 vecnorm1 = mom1vec3.Unit();
199  fDirgamma1 = vecnorm1;
200  TVector3 vecnorm2 = mom2vec3.Unit();
201  fDirgamma2 = vecnorm2;
202 
204  }
205  else
206  {
207  fNgammas = particle->NumberDaughters();
208  }
209  }
210 }
211 
212 bool ems::MCinfo::insideFidVol(const TLorentzVector& pvtx) const
213 {
214 
215  bool inside = false;
216  //x
217  double dista = fabs(fMinx - pvtx.X());
218  double distb = fabs(pvtx.X() - fMaxx);
219  if ((pvtx.X() > fMinx) && (pvtx.X() < fMaxx) &&
220  (dista > fFidVolCut) && (distb > fFidVolCut)) inside = true;
221  //y
222  dista = fabs(fMaxy - pvtx.Y());
223  distb = fabs(pvtx.Y() - fMiny);
224  if (inside && (pvtx.Y() > fMiny) && (pvtx.Y() < fMaxy) &&
225  (dista > fFidVolCut) && (distb > fFidVolCut)) inside = true;
226  else inside = false;
227 
228  //z
229  dista = fabs(fMaxz - pvtx.Z());
230  distb = fabs(pvtx.Z() - fMinz);
231  if (inside && (pvtx.Z() > fMinz) && (pvtx.Z() < fMaxz) &&
232  (dista > fFidVolCut) && (distb > fFidVolCut)) inside = true;
233  else inside = false;
234 
235  return inside;
236 }
237 
239 public:
240  explicit MultiEMShowers(fhicl::ParameterSet const & p);
241 
242  MultiEMShowers(MultiEMShowers const &) = delete;
243  MultiEMShowers(MultiEMShowers &&) = delete;
244  MultiEMShowers & operator = (MultiEMShowers const &) = delete;
245  MultiEMShowers & operator = (MultiEMShowers &&) = delete;
246 
247  void beginJob() override;
248  void endJob() override;
249 
250  void analyze(art::Event const & e) override;
251 
252  void reconfigure(fhicl::ParameterSet const& p);
253 
254 private:
255  bool convCluster(art::Event const & evt);
256  double getMinDist(std::vector< art::Ptr<recob::Hit> > const & v,
257  TVector3 const & convmc,
258  size_t view, size_t tpc, size_t cryo);
263 
264  // ROOT
265  TTree* fEvTree;
267  int fNGroups;
268 
269  // mc
270  double fPi0mom;
271  double fGmom1;
272  double fGmom2;
273  double fMcth;
274  int fNgammas;
276  int fEvComp;
278  int fEvInput;
279  TVector3 fGdir1;
280  TVector3 fGdir2;
281  TVector3 fPrimary;
282 
283  //reco
284  int fEvReco;
286  int fEv2Good;
287  int fCountph;
289 
290  TTree* fShTree;
291  TTree* fRecoTree;
292  double fStartX; double fStartY; double fStartZ;
293  double fDedxZ; double fDedxV; double fDedxU;
294  double fMCrecovtx; double fMCrecoTh;
295  double fMCrecovtxgood; double fMCrecoThgood;
296  double fRecth; double fRecthgood;
297  double fDistConvrecomc1; double fDistConvrecomc2;
298  double fGdirmcreco1; double fGdirmcreco2;
299  double fGdirmcreco1good; double fGdirmcreco2good;
300 
306 };
307 
308 
310  :
311  EDAnalyzer(p)
312 {
313  fConvGood = 0;
314  fConvWrong = 0;
315  fConvBothGood = 0;
316  fEvFidVol = 0;
317  fEvComp = 0;
318  fEvGMomCut = 0;
319  fEvReco = 0;
320  fEvInput = 0;
321  fEv2Groups = 0;
322  fEv2Good = 0;
323  reconfigure(p);
324 }
325 
327 {
328  fHitsModuleLabel = p.get< art::InputTag >("HitsModuleLabel");
329  fCluModuleLabel = p.get< art::InputTag >("ClustersModuleLabel");
330  fTrk3DModuleLabel = p.get< art::InputTag >("Trk3DModuleLabel");
331  fVtxModuleLabel = p.get< art::InputTag >("VtxModuleLabel");
332  fShsModuleLabel = p.get< art::InputTag >("ShsModuleLabel");
333 
334  return;
335 }
336 
338 {
340 
341  fEvTree = tfs->make<TTree>("MultiShowers", "showers3d");
342  fEvTree->Branch("fEvNumber", &fEvNumber, "fEvNumber/I");
343  fEvTree->Branch("fNGroups", &fNGroups, "fNGroups/I");
344  fEvTree->Branch("fPi0mom", &fPi0mom, "fPi0mom/D");
345  fEvTree->Branch("fNgammas", &fNgammas, "fNgammas/I");
346  fEvTree->Branch("fGmom1", &fGmom1, "fGmom1/D");
347  fEvTree->Branch("fGmom2", &fGmom2, "fGmom2/D");
348  fEvTree->Branch("fMcth", &fMcth, "fMcth/D");
349  fEvTree->Branch("fRecth", &fRecth, "fRecth/D");
350  fEvTree->Branch("fMCrecovtx", &fMCrecovtx, "fMCrecovtx/D");
351  fEvTree->Branch("fMCrecoTh", &fMCrecoTh, "fMCrecoTh/D");
352  fEvTree->Branch("fConvGood", &fConvGood, "fConvGood/I");
353  fEvTree->Branch("fConvWrong", &fConvWrong, "fConvWrong/I");
354  fEvTree->Branch("fConvBothGood", &fConvBothGood, "fConvBothGood/I");
355  fEvTree->Branch("fGammasInside", &fGammasInside, "fGammasInside/I");
356  fEvTree->Branch("fCountph", &fCountph, "fCountph/I");
357  fEvTree->Branch("fCountreco", &fCountreco, "fCountreco/I");
358 
359  fRecoTree = tfs->make<TTree>("Cascades", "conv points");
360  fRecoTree->Branch("fRecth", &fRecth, "fRecth/D");
361  fRecoTree->Branch("fMCrecovtx", &fMCrecovtx, "fMCrecovtx/D");
362  fRecoTree->Branch("fMCrecoTh", &fMCrecoTh, "fMCrecoTh/D");
363  fRecoTree->Branch("fRecthgood", &fRecthgood, "fRecthgood/D");
364  fRecoTree->Branch("fMCrecovtxgood", &fMCrecovtxgood, "fMCrecovtxgood/D");
365  fRecoTree->Branch("fMCrecoThgood", &fMCrecoThgood, "fMCrecoThgood/D");
366  fRecoTree->Branch("fGdirmcreco1", &fGdirmcreco1, "fGdirmcreco1/D");
367  fRecoTree->Branch("fGdirmcreco2", &fGdirmcreco2, "fGdirmcreco2/D");
368  fRecoTree->Branch("fGdirmcreco1good", &fGdirmcreco1good, "fGdirmcreco1good/D");
369  fRecoTree->Branch("fGdirmcreco2good", &fGdirmcreco2good, "fGdirmcreco2good/D");
370 
371  fShTree = tfs->make<TTree>("Shower", "conv point");
372 
373  fShTree->Branch("fStartX", &fStartX, "fStartX/D");
374  fShTree->Branch("fStartY", &fStartY, "fStartY/D");
375  fShTree->Branch("fStartZ", &fStartZ, "fStartZ/D");
376  fShTree->Branch("fDedxZ", &fDedxZ, "fDedxZ/D");
377  fShTree->Branch("fDedxV", &fDedxV, "fDedxV/D");
378  fShTree->Branch("fDedxU", &fDedxU, "fDedxU/D");
379 }
380 
382 {
383  mf::LogInfo log("MultiEMShower");
384  log << "******************** fEvFidVol = " << fEvFidVol << "\n";
385  log << "******************** fEvGMomCut = " << fEvGMomCut << "\n";
386  log << "******************** fEvComp = " << fEvComp << "\n";
387  log << "******************** fEvReco = " << fEvReco << "\n";
388  log << "******************** fEvInput = " << fEvInput << "\n";
389  log << "******************** fEv2Groups = " << fEv2Groups << "\n";
390  log << "******************** fEv2Good = " << fEv2Good << "\n";
391  if (fEvInput)
392  log << "******************** reco % = " << double(fEvReco)/double(fEvInput) << "\n";
393 }
394 
396 {
397  fEvNumber = e.id().event();
398  fNGroups = 0;
399  fStartX = 0.0; fStartY = 0.0; fStartZ = 0.0;
400  fPi0mom = 0.0; fNgammas = 0;
401  fDistConvrecomc1 = 0.0; fDistConvrecomc2 = 0.0;
402  fMCrecovtx = -400.0;
403  fMCrecovtxgood = -400.0;
404  fRecth = -400.0;
405  fRecthgood = -400.0;
406  fMCrecoTh = -400.0;
407  fMCrecoThgood = -400.0;
408  fGammasInside = 0;
409  fCountph = 0;
410  fCountreco = 0;
411  fGdirmcreco1 = 0.0;
412  fGdirmcreco2 = 0.0;
413  fGdirmcreco1good = 0.0;
414  fGdirmcreco2good = 0.0;
415  fDedxZ = 0.0; fDedxV = 0.0; fDedxU = 0.0;
416 
417  ems::MCinfo mc(e);
418  fPrimary = mc.GetPrimary();
419  fPi0mom = mc.GetMompi0();
420  fGmom1 = mc.GetMomGamma1();
421  fGmom2 = mc.GetMomGamma2();
422  fGdir1 = mc.GetDirgamma1();
423  fGdir2 = mc.GetDirgamma2();
424  fNgammas = mc.GetNgammas();
425  TVector3 pospi0 = mc.GetPospi0();
426 
427  double cosinemc = mc.GetCosine();
428  fMcth = 180.0F * (std::acos(cosinemc)) / TMath::Pi();
429  TVector3 convp[2];
430  convp[0] = mc.GetPosgamma1();
431  convp[1] = mc.GetPosgamma2();
432  const double maxdist = 2.0; //cm
433 
434  // check whether two photons are inside fid vol
435  if (mc.IsInside1() && mc.IsInside2())
436  {
437  fGammasInside = 1;
438  fEvFidVol++;
439  }
440 
441  if ((fGmom1 > 0.1) && (fGmom2 > 0.1)) fEvGMomCut++;
442 
443  if (mc.IsCompton()) fEvComp++;
444 
449  art::Handle< std::vector<recob::Hit> > hitListHandle;
450  if (e.getByLabel(fShsModuleLabel, shsListHandle) &&
451  e.getByLabel(fTrk3DModuleLabel, trkListHandle) &&
452  e.getByLabel(fVtxModuleLabel, vtxListHandle) &&
453  e.getByLabel(fCluModuleLabel, cluListHandle) &&
454  e.getByLabel(fHitsModuleLabel, hitListHandle))
455  {
456  art::FindManyP< recob::Cluster > cluFromShs(shsListHandle, e, fShsModuleLabel);
457  art::FindManyP< recob::Cluster > cluFromTrk(trkListHandle, e, fTrk3DModuleLabel);
458  art::FindManyP< recob::Vertex > vtxFromTrk(trkListHandle, e, fVtxModuleLabel);
459  art::FindManyP< recob::Hit > hitFromClu(cluListHandle, e, fCluModuleLabel);
460 
461  fNGroups = shsListHandle->size();
462 
463  fCountph = 0;
464  if (fNgammas == 2) // pi0
465  {
466  int idph = -1;
467  for (size_t s = 0; s < shsListHandle->size(); ++s)
468  {
469  const recob::Shower& sh = (*shsListHandle)[s];
470  double mindist = maxdist; bool found = false;
471 
472  for (int i = 0; i < fNgammas; ++i)
473  {
474  double dist = sqrt(pma::Dist2(sh.ShowerStart(), convp[i]));
475  if ((dist < mindist) && (idph != i))
476  { mindist = dist; idph = i; found = true; }
477  }
478  if (found) { fConvGood++; fCountph++; }
479  else { fConvWrong++; }
480  }
481  if (fCountph == 2) fConvBothGood++;
482 
483  // plot a few variables if there are 2 showers
484  if (fCountph == 2)
485  for (size_t s = 0; s < shsListHandle->size(); ++s)
486  {
487  const recob::Shower& sh = (*shsListHandle)[s];
488  TVector3 pos = sh.ShowerStart();
489  fStartX = pos.X(); fStartY = pos.Y(); fStartZ = pos.Z();
490  std::vector<double> const& vecdedx = sh.dEdx();
491 
492  if (vecdedx.size() == 3)
493  {
494  fDedxZ = vecdedx[0]; fDedxV = vecdedx[1]; fDedxU = vecdedx[2];
495  }
496 
497  fShTree->Fill();
498  }
499  }
500  else // other than pi0
501  {
502  for (size_t s = 0; s < shsListHandle->size(); ++s)
503  {
504  const recob::Shower& sh = (*shsListHandle)[s];
505  double mindist = maxdist;
506 
507  double dist = sqrt(pma::Dist2(sh.ShowerStart(), fPrimary));
508  if (dist < mindist)
509  {
510  TVector3 pos = sh.ShowerStart();
511  fStartX = pos.X(); fStartY = pos.Y(); fStartZ = pos.Z();
512  std::vector<double> vecdedx = sh.dEdx();
513  if (vecdedx.size() == 3)
514  {
515  fDedxZ = vecdedx[0]; fDedxV = vecdedx[1]; fDedxU = vecdedx[2];
516  }
517  }
518 
519  fShTree->Fill();
520  }
521  }
522  // compute the crossing point
523 
524  //cut from mc and clusters
525 
526  if (mc.IsInside1() && mc.IsInside2() && (fGmom1 > 0.1) && (fGmom2 > 0.1) && (!mc.IsCompton()) && convCluster(e))
527  {
528  fCountreco = 1;
529  if (fNGroups == 2) fEv2Groups++;
530  if ((fNGroups == 2) && (fCountph == 2)) fEv2Good++;
531  // cut from reco
532  //if (countph == 2)
533  if (fNGroups == 2)
534  {
535  std::vector< std::pair<TVector3, TVector3> > lines;
536  const recob::Shower& sh1 = (*shsListHandle)[0];
537  const recob::Shower& sh2 = (*shsListHandle)[1];
538 
539  std::pair<TVector3, TVector3> frontback1(sh1.ShowerStart(), sh1.ShowerStart() + sh1.Direction());
540  std::pair<TVector3, TVector3> frontback2(sh2.ShowerStart(), sh2.ShowerStart() + sh2.Direction());
541  lines.push_back(frontback1); lines.push_back(frontback2);
542 
543  TVector3 result;
544  pma::SolveLeastSquares3D(lines, result); // mse.
545 
546  double dist1_0 = pma::Dist2(result, sh1.ShowerStart());
547  double dist2_0 = pma::Dist2(result, sh1.ShowerStart() + sh1.Direction());
548  double dist1_1 = pma::Dist2(result, sh2.ShowerStart());
549  double dist2_1 = pma::Dist2(result, sh2.ShowerStart() + sh2.Direction());
550  if ((dist1_0 > dist2_0) || (dist1_1 > dist2_1)) {}
551  else
552  {
553  fMCrecovtx = std::sqrt(pma::Dist2(pospi0, result));
554 
555  if (fCountph == 2) fMCrecovtxgood = fMCrecovtx;
556 
557  double cosine_reco = sh1.Direction() * sh2.Direction();
558  fRecth = 180.0F * (std::acos(cosine_reco)) / TMath::Pi();
559 
560  fGdirmcreco1 = fGdir1 * sh1.Direction();
561  fGdirmcreco2 = fGdir2 * sh2.Direction();
562  if (fCountph == 2)
563  {
566  }
567 
568  if (fCountph == 2) fRecthgood = fRecth;
569 
570  fMCrecoTh = fRecth - fMcth;
571 
572  if (fCountph == 2) fMCrecoThgood = fMCrecoTh;
573 
574  fEvReco++;
575  fRecoTree->Fill();
576  }
577  }
578  fEvInput++;
579  //fRecoTree->Fill();
580  }
581  }
582 
583  fEvTree->Fill();
584 }
585 
586 // true if there are clusters corresponding to mc conversion points
588 {
589  ems::MCinfo mc(evt);
590  TVector3 convp[2];
591  convp[0] = mc.GetPosgamma1();
592  convp[1] = mc.GetPosgamma2();
593 
594  double vtx[3] = {convp[0].X(), convp[0].Y(), convp[0].Z()};
595 
597  geo::TPCID idtpc = geom->FindTPCAtPosition(vtx);
598  size_t cryoid = geom->FindCryostatAtPosition(vtx);
599 
600  art::Handle< std::vector<recob::Hit> > hitListHandle;
602 
603  //map: conversion point, vec of id clusters in each view
604  std::map < size_t, std::vector< size_t > > used;
605 
606 
607  art::FindManyP< recob::Hit > fbc(cluListHandle, evt, fCluModuleLabel);
608 
609  double maxdist = 1.0; // 1 cm
610  if (geom->HasTPC(idtpc))
611  {
612  const geo::CryostatGeo& cryostat = geom->Cryostat(cryoid);
613  if (evt.getByLabel(fHitsModuleLabel, hitListHandle) &&
614  evt.getByLabel(fCluModuleLabel, cluListHandle))
615  {
616  size_t conv = 0;
617  while (conv < 2)
618  {
619  for (size_t view = 0; view < cryostat.MaxPlanes(); view++)
620  {
621 
622  double mindist = maxdist; int clid = 0;
623  for (size_t c = 0; c < cluListHandle->size(); ++c)
624  {
625 
626  bool exist = false;
627  for (auto const & ids : used)
628  for (auto i : ids.second)
629  if (i == c) exist = true;
630  if (exist) continue;
631 
632  std::vector< art::Ptr<recob::Hit> > hits = fbc.at(c);
633  if (hits.size() < 20) continue;
634  if (hits[0]->WireID().Plane != view) continue;
635 
636  double dist = getMinDist(hits, convp[conv], view, idtpc.TPC, cryoid);
637  if (dist < mindist)
638  {
639  mindist = dist;
640  clid = c;
641  }
642  }
643  if (mindist < maxdist) used[conv].push_back(clid);
644  }
645  conv++;
646  }
647  }
648  }
649  bool result = false;
650 
651  if (used.size() > 1)
652  for (auto const & ids : used)
653  {
654  if (ids.second.size() > 1) result = true;
655  else {result = false; break;}
656  }
657 
658  return result;
659 }
660 
662  TVector3 const & convmc,
663  size_t view, size_t tpc, size_t cryo)
664 {
665  double mindist = 9999;
666  // MC vertex projected to view
667  TVector2 proj = pma::GetProjectionToPlane(convmc, view, tpc, cryo);
668 
669  // loop over hits to find the closest to MC 2d vtx
670  for (size_t h = 0; h < v.size(); ++h)
671  {
672  if ((v[h]->WireID().Plane == view) &&
673  (v[h]->WireID().TPC == tpc))
674  {
675  TVector2 hpoint = pma::WireDriftToCm(v[h]->WireID().Wire, v[h]->PeakTime(), view, tpc, cryo);
676 
677  double dist = pma::Dist2(proj, hpoint);
678  if (dist < mindist)
679  {
680  mindist = dist;
681  }
682  }
683  }
684 
685  return mindist;
686 }
687 
689 
Float_t s
Definition: plot.C:23
const simb::MCParticle * TrackIdToParticle_P(int const &id)
const TVector3 & ShowerStart() const
Definition: Shower.h:192
TVector3 const & GetDirgamma2() const
const TLorentzVector & Position(const int i=0) const
Definition: MCParticle.h:223
int PdgCode() const
Definition: MCParticle.h:216
unsigned int MaxPlanes() const
Returns the largest number of planes among the TPCs in this cryostat.
Implementation of the Projection Matching Algorithm.
double Dist2(const TVector2 &v1, const TVector2 &v2)
Definition: Utilities.cxx:19
bool const & IsInside2() const
void Findtpcborders(const art::Event &evt)
MultiEMShowers(fhicl::ParameterSet const &p)
Declaration of signal hit object.
list_type::const_iterator const_iterator
Definition: ParticleList.h:132
Geometry information for a single TPC.
Definition: TPCGeo.h:37
void analyze(art::Event const &e) override
bool convCluster(art::Event const &evt)
Geometry information for a single cryostat.
Definition: CryostatGeo.h:36
std::string Process() const
Definition: MCParticle.h:219
bool const & IsCompton() const
double GetMomGamma2() const
int NumberDaughters() const
Definition: MCParticle.h:221
double GetMompi0() const
int Daughter(const int i) const
Definition: MCParticle.cxx:112
geo::TPCID FindTPCAtPosition(double const worldLoc[3]) const
Returns the ID of the TPC at specified location.
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:265
void hits()
Definition: readHits.C:15
const std::vector< double > & dEdx() const
Definition: Shower.h:203
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:42
std::string EndProcess() const
Definition: MCParticle.h:220
void beginJob()
Definition: Breakpoints.cc:14
TVector3 const & GetPosgamma1() const
IteratorBox< TPC_iterator,&GeometryCore::begin_TPC,&GeometryCore::end_TPC > IterateTPCs() const
Enables ranged-for loops on all TPCs of the detector.
double P(const int i=0) const
Definition: MCParticle.h:238
T get(std::string const &key) const
Definition: ParameterSet.h:231
int GetNgammas() const
iterator begin()
Definition: ParticleList.h:305
CryostatGeo const & Cryostat(geo::CryostatID const &cryoid) const
Returns the specified cryostat.
const TVector3 & Direction() const
Definition: Shower.h:189
double SolveLeastSquares3D(const std::vector< std::pair< TVector3, TVector3 > > &lines, TVector3 &result)
Definition: Utilities.cxx:187
The data type to uniquely identify a TPC.
Definition: geo_types.h:195
Declaration of cluster object.
Provides recob::Track data product.
TVector3 const & GetPrimary() const
TVector3 const & GetDirgamma1() const
Definition: DirOfGamma.h:18
bool HasTPC(geo::TPCID const &tpcid) const
Returns whether we have the specified TPC.
Implementation of the Projection Matching Algorithm.
T * make(ARGS...args) const
Utility object to perform functions of association.
TVector3 const & GetPospi0() const
double GetMomGamma1() const
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
TVector2 WireDriftToCm(unsigned int wire, float drift, unsigned int plane, unsigned int tpc, unsigned int cryo)
Definition: Utilities.cxx:307
double getMinDist(std::vector< art::Ptr< recob::Hit > > const &v, TVector3 const &convmc, size_t view, size_t tpc, size_t cryo)
MCinfo(const art::Event &evt)
TVector2 GetProjectionToPlane(const TVector3 &p, unsigned int plane, unsigned int tpc, unsigned int cryo)
Definition: Utilities.cxx:291
Float_t proj
Definition: plot.C:34
bool const & IsInside1() const
EventNumber_t event() const
Definition: EventID.h:117
TPCID_t TPC
Index of the TPC within its cryostat.
Definition: geo_types.h:203
void Info(const art::Event &evt)
Float_t e
Definition: plot.C:34
TVector3 const & GetPosgamma2() const
recob::tracking::Plane Plane
Definition: TrackState.h:17
geo::CryostatID::CryostatID_t FindCryostatAtPosition(geo::Point_t const &worldLoc) const
Returns the index of the cryostat at specified location.
EventID id() const
Definition: Event.h:56
bool insideFidVol(const TLorentzVector &pvtx) const
void reconfigure(fhicl::ParameterSet const &p)