Public Member Functions | Private Member Functions | Private Attributes | List of all members
shwf::ShowerReco Class Reference
Inheritance diagram for shwf::ShowerReco:
art::EDProducer art::detail::Producer art::detail::LegacyModule art::Modifier art::ModuleBase art::ProductRegistryHelper

Public Member Functions

 ShowerReco (fhicl::ParameterSet const &pset)
 
- Public Member Functions inherited from art::EDProducer
 EDProducer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDProducer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Producer
virtual ~Producer () noexcept
 
 Producer (fhicl::ParameterSet const &)
 
 Producer (Producer const &)=delete
 
 Producer (Producer &&)=delete
 
Produceroperator= (Producer const &)=delete
 
Produceroperator= (Producer &&)=delete
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
- Public Member Functions inherited from art::Modifier
 ~Modifier () noexcept
 
 Modifier ()
 
 Modifier (Modifier const &)=delete
 
 Modifier (Modifier &&)=delete
 
Modifieroperator= (Modifier const &)=delete
 
Modifieroperator= (Modifier &&)=delete
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Private Member Functions

void beginJob ()
 
void beginRun (art::Run &run)
 
void produce (art::Event &evt)
 
void GetVertexAndAnglesFromCluster (art::Ptr< recob::Cluster > clust, unsigned int plane)
 
void LongTransEnergy (geo::GeometryCore const *geom, detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, unsigned int set, std::vector< art::Ptr< recob::Hit >> hitlist)
 
void ClearandResizeVectors (unsigned int nPlanes)
 

Private Attributes

int fRun
 
int fEvent
 
int fSubRun
 
float slope [3]
 
float angle [3]
 
std::string fClusterModuleLabel
 
float ftimetick
 
double fMean_wire_pitch
 
fhicl::ParameterSet fCaloPSet
 
std::vector< double > fRMS_2cm
 
std::vector< int > fNpoints_2cm
 
std::vector< double > fCorr_MeV_2cm
 
std::vector< double > fCorr_Charge_2cm
 
std::vector< int > fNpoints_corr_ADC_2cm
 
std::vector< int > fNpoints_corr_MeV_2cm
 
std::vector< double > fTotChargeADC
 
std::vector< double > fTotChargeMeV
 
std::vector< double > fTotChargeMeV_MIPs
 
std::vector< double > fChargeADC_2cm
 
std::vector< double > fChargeMeV_2cm
 
std::vector< double > fChargeMeV_2cm_refined
 
std::vector< double > fChargeMeV_2cm_axsum
 
std::vector< std::vector< double > > fDistribChargeADC
 
std::vector< std::vector< double > > fDistribChargeMeV
 
std::vector< std::vector< double > > fDistribHalfChargeMeV
 
std::vector< std::vector< double > > fDistribChargeposition
 
std::vector< std::vector< double > > fSingleEvtAngle
 
std::vector< std::vector< double > > fSingleEvtAngleVal
 
std::vector< unsigned int > fWire_vertex
 
std::vector< double > fTime_vertex
 
std::vector< double > fWire_vertexError
 
std::vector< double > fTime_vertexError
 
std::vector< unsigned int > fWire_last
 
std::vector< double > fTime_last
 
std::vector< double > xyz_vertex_fit
 
std::vector< std::vector< double > > fNPitch
 
float Kin_En
 
std::vector< float > vdEdx
 
std::vector< float > vresRange
 
std::vector< float > vdQdx
 
std::vector< float > deadwire
 
float Trk_Length
 
float fTrkPitchC
 
float fdEdxlength
 
float fcalodEdxlength
 
bool fUseArea
 
double xphi
 
double xtheta
 
unsigned int fNPlanes
 
unsigned int fNAngles
 
TTree * ftree_shwf
 
double fWirePitch
 
double fTimeTick
 
double fDriftVelocity
 
double fWireTimetoCmCm
 
std::vector< int > fNhitsperplane
 
std::vector< double > fTotADCperplane
 

Additional Inherited Members

- Public Types inherited from art::EDProducer
using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
- Public Types inherited from art::detail::Producer
template<typename UserConfig , typename KeysToIgnore = void>
using Table = Modifier::Table< UserConfig, KeysToIgnore >
 
- Public Types inherited from art::Modifier
template<typename UserConfig , typename UserKeysToIgnore = void>
using Table = ProducerTable< UserConfig, detail::ModuleConfig, UserKeysToIgnore >
 
- Static Public Member Functions inherited from art::EDProducer
static void commitEvent (EventPrincipal &ep, Event &e)
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Detailed Description

Definition at line 57 of file ShowerReco_module.cc.

Constructor & Destructor Documentation

shwf::ShowerReco::ShowerReco ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 161 of file ShowerReco_module.cc.

161  : EDProducer{pset}
162  {
163  fClusterModuleLabel = pset.get<std::string>("ClusterModuleLabel");
164  fCaloPSet = pset.get<fhicl::ParameterSet>("CaloAlg");
165 
166  fdEdxlength =
167  pset.get<double>("dEdxlength"); // distance that gets used to determine e/gamma separation
169  pset.get<double>("calodEdxlength"); // cutoff distance for hits saved to the calo object.
170  fUseArea = pset.get<bool>("UseArea");
171 
172  produces<std::vector<recob::Shower>>();
173  produces<art::Assns<recob::Shower, recob::Cluster>>();
174  produces<art::Assns<recob::Shower, recob::Hit>>();
175  produces<std::vector<anab::Calorimetry>>();
176  produces<art::Assns<recob::Shower, anab::Calorimetry>>();
177  }
fhicl::ParameterSet fCaloPSet
std::string string
Definition: nybbler.cc:12
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
T get(std::string const &key) const
Definition: ParameterSet.h:271
std::string fClusterModuleLabel

Member Function Documentation

void shwf::ShowerReco::beginJob ( )
privatevirtual
Todo:
the call to geo->Nplanes() assumes this is a single cryostat and single TPC detector; need to generalize to multiple cryostats and TPCs

Get TFileService and define output Histograms

All-knowing tree with reconstruction information

Reimplemented from art::EDProducer.

Definition at line 181 of file ShowerReco_module.cc.

182  {
184 
185  /// \todo the call to geo->Nplanes() assumes this is a single cryostat and
186  /// single TPC detector; need to generalize to multiple cryostats and
187  /// TPCs
188  fNPlanes = geo->Nplanes();
189  fMean_wire_pitch = geo->WirePitch(); // wire pitch in cm
190 
191  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataForJob();
192  ftimetick = sampling_rate(clockData) / 1000.;
193 
194  /**Get TFileService and define output Histograms*/
196 
197  ftree_shwf = tfs->make<TTree>("ShowerReco",
198  "Results"); /**All-knowing tree with reconstruction information*/
199  ftree_shwf->Branch("run", &fRun, "run/I");
200  ftree_shwf->Branch("subrun", &fSubRun, "subrun/I");
201  ftree_shwf->Branch("event", &fEvent, "event/I");
202  ftree_shwf->Branch("nplanes", &fNPlanes, "nplanes/I");
203  ftree_shwf->Branch("nangles", &fNAngles, "nangles/I");
204  ftree_shwf->Branch("xtheta", &xtheta, "xtheta/D");
205  ftree_shwf->Branch("xphi", &xphi, "xphi/D");
206  ftree_shwf->Branch("ftotChargeADC", "std::vector<double>", &fTotChargeADC);
207  ftree_shwf->Branch("ftotChargeMeV", "std::vector<double>", &fTotChargeMeV);
208  ftree_shwf->Branch("fTotChargeMeV_MIPs", "std::vector<double>", &fTotChargeMeV_MIPs);
209  ftree_shwf->Branch("NPitch", "std::vector< std::vector<double> >", &fNPitch);
210 
211  // this should be temporary - until the omega is sorted out.
212  ftree_shwf->Branch("RMS_2cm", "std::vector<double>", &fRMS_2cm);
213  ftree_shwf->Branch("Npoints_2cm", "std::vector<int>", &fNpoints_2cm);
214  ftree_shwf->Branch("ChargeADC_2cm", "std::vector<double>", &fChargeADC_2cm);
215  ftree_shwf->Branch("ChargeMeV_2cm", "std::vector<double>", &fChargeMeV_2cm);
216  ftree_shwf->Branch("ChargeMeV_2cm_refined", "std::vector<double>", &fChargeMeV_2cm_refined);
217  ftree_shwf->Branch("ChargeMeV_2cm_axsum", "std::vector<double>", &fChargeMeV_2cm_axsum);
218  ftree_shwf->Branch("fNhitsperplane", "std::vector<int>", &fNhitsperplane);
219  ftree_shwf->Branch("fTotADCperplane", "std::vector<double>", &fTotADCperplane);
220  ftree_shwf->Branch(
221  "ChargedistributionADC", "std::vector<std::vector<double>>", &fDistribChargeADC);
222  ftree_shwf->Branch(
223  "ChargedistributionMeV", "std::vector<std::vector<double>>", &fDistribChargeMeV);
224  ftree_shwf->Branch(
225  "DistribHalfChargeMeV", "std::vector<std::vector<double>>", &fDistribHalfChargeMeV);
226  ftree_shwf->Branch(
227  "ChargedistributionPosition", "std::vector<std::vector<double>>", &fDistribChargeposition);
228  ftree_shwf->Branch("xyz_vertex_fit", "std::vector<double>", &xyz_vertex_fit);
229  }
std::vector< double > fTotChargeADC
std::vector< int > fNhitsperplane
std::vector< std::vector< double > > fNPitch
std::vector< std::vector< double > > fDistribChargeMeV
std::vector< double > fTotADCperplane
std::vector< std::vector< double > > fDistribHalfChargeMeV
std::vector< double > fChargeMeV_2cm_refined
geo::Length_t WirePitch(geo::PlaneID const &planeid) const
Returns the distance between two consecutive wires.
std::vector< int > fNpoints_2cm
unsigned int Nplanes(unsigned int tpc=0, unsigned int cstat=0) const
Returns the total number of wire planes in the specified TPC.
std::vector< double > fRMS_2cm
std::vector< double > xyz_vertex_fit
std::vector< double > fChargeMeV_2cm
std::vector< double > fTotChargeMeV_MIPs
std::vector< double > fChargeADC_2cm
std::vector< std::vector< double > > fDistribChargeADC
std::vector< double > fChargeMeV_2cm_axsum
double sampling_rate(DetectorClocksData const &data)
Returns the period of the TPC readout electronics clock.
LArSoft geometry interface.
Definition: ChannelGeo.h:16
std::vector< std::vector< double > > fDistribChargeposition
std::vector< double > fTotChargeMeV
void shwf::ShowerReco::beginRun ( art::Run run)
privatevirtual

Reimplemented from art::EDProducer.

Definition at line 232 of file ShowerReco_module.cc.

233  {
234  auto const* geom = lar::providerFrom<geo::Geometry>();
235  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataForJob();
236  auto const detProp =
238 
239  fWirePitch = geom->WirePitch(); // wire pitch in cm
240  fTimeTick = sampling_rate(clockData) / 1000.;
241  fDriftVelocity = detProp.DriftVelocity(detProp.Efield(), detProp.Temperature());
243  }
double sampling_rate(DetectorClocksData const &data)
Returns the period of the TPC readout electronics clock.
void shwf::ShowerReco::ClearandResizeVectors ( unsigned int  nPlanes)
private
void shwf::ShowerReco::GetVertexAndAnglesFromCluster ( art::Ptr< recob::Cluster clust,
unsigned int  plane 
)
private

Actual routine that reconstruct the shower

Definition at line 814 of file ShowerReco_module.cc.

816  {
817  // convert to cm/cm units needed in the calculation
818  angle[plane] = clust->StartAngle();
819  slope[plane] = std::tan(clust->StartAngle());
820  fWire_vertex[plane] = clust->StartWire();
821  fTime_vertex[plane] = clust->StartTick();
822 
823  fWire_vertexError[plane] = clust->SigmaStartWire(); // wire coordinate of vertex for each plane
824  fTime_vertexError[plane] = clust->SigmaStartTick(); // time coordinate of vertex for each plane
825 
826  fWire_last[plane] = clust->EndWire(); // wire coordinate of last point for each plane
827  fTime_last[plane] = clust->EndTick();
828  }
std::vector< double > fTime_last
std::vector< double > fWire_vertexError
float StartWire() const
Returns the wire coordinate of the start of the cluster.
Definition: Cluster.h:286
std::vector< double > fTime_vertex
float EndTick() const
Returns the tick coordinate of the end of the cluster.
Definition: Cluster.h:342
std::vector< unsigned int > fWire_last
float StartAngle() const
Returns the starting angle of the cluster.
Definition: Cluster.h:475
std::vector< double > fTime_vertexError
float SigmaStartWire() const
Returns the uncertainty on wire coordinate of the start of the cluster.
Definition: Cluster.h:306
float SigmaStartTick() const
Returns the uncertainty on tick coordinate of the start of the cluster.
Definition: Cluster.h:315
float StartTick() const
Returns the tick coordinate of the start of the cluster.
Definition: Cluster.h:297
std::vector< unsigned int > fWire_vertex
float EndWire() const
Returns the wire coordinate of the end of the cluster.
Definition: Cluster.h:329
void shwf::ShowerReco::LongTransEnergy ( geo::GeometryCore const *  geom,
detinfo::DetectorClocksData const &  clockData,
detinfo::DetectorPropertiesData const &  detProp,
unsigned int  set,
std::vector< art::Ptr< recob::Hit >>  hitlist 
)
private

third loop to get only points inside of 1RMS of value.

Definition at line 613 of file ShowerReco_module.cc.

618  {
619  // alogorithm for energy vs dx of the shower (roto-translation) COLLECTION
620  // VIEW
621 
623 
624  double totCnrg = 0,
625  totCnrg_corr = 0; // tot enegry of the shower in collection
626 
627  double time;
628  unsigned int wire = 0, plane = fNPlanes - 1;
629 
630  double mevav2cm = 0.;
631  double sum = 0.;
632  double npoints_calo = 0;
633 
634  int direction = -1;
635 
636  //override direction if phi (XZ angle) is less than 90 degrees
637  if (fabs(xphi) < 90) direction = 1;
638 
639  //variables to check whether a hit is close to the shower axis.
640  double ortdist, linedist;
641  double wire_on_line, time_on_line;
642 
643  //get effective pitch using 3D angles
644  util::GeometryUtilities const gser{*geom, clockData, detProp};
645  double newpitch = gser.PitchInView(plane, xphi, xtheta);
646 
647  using lar::to_element;
648  using ranges::views::transform;
649  for (auto const& hit : hitlist | transform(to_element)) {
650  time = hit.PeakTime();
651  wire = hit.WireID().Wire;
652  plane = hit.WireID().Plane;
653 
654  double dEdx_new;
655 
656  if (fUseArea) { dEdx_new = calalg.dEdx_AREA(clockData, detProp, hit, newpitch); }
657  else // this will hopefully go away, once all of the calibration factors
658  // are calculated.
659  {
660  dEdx_new = calalg.dEdx_AMP(clockData, detProp, hit, newpitch);
661  }
662 
663  //calculate total energy.
664  totCnrg_corr += dEdx_new;
665 
666  // calculate the wire,time coordinates of the hit projection on to the 2D shower axis
667  gser.GetPointOnLine(slope[plane] / fWireTimetoCmCm,
668  fWire_vertex[plane],
669  fTime_vertex[plane],
670  wire,
671  time,
672  wire_on_line,
673  time_on_line);
674  linedist =
675  gser.Get2DDistance(wire_on_line, time_on_line, fWire_vertex[plane], fTime_vertex[plane]);
676  ortdist = gser.Get2DDistance(wire_on_line, time_on_line, wire, time);
677 
678  //calculate the distance from the vertex using the effective pitch metric
679  double wdist = (((double)wire - (double)fWire_vertex[plane]) * newpitch) *
680  direction; //wdist is always positive
681 
682  if ((wdist < fcalodEdxlength) && (wdist > 0.2)) {
683 
684  vdEdx.push_back(dEdx_new);
685  vresRange.push_back(fabs(wdist));
686  vdQdx.push_back(hit.PeakAmplitude() / newpitch);
687  Trk_Length = wdist;
688  fTrkPitchC = fNPitch[set][plane];
689  Kin_En += dEdx_new * newpitch;
690  npoints_calo++;
691  sum += dEdx_new;
692 
693  if (wdist < fdEdxlength &&
694  ((direction == 1 && wire > fWire_vertex[plane]) // take no hits before vertex
695  // (depending on direction)
696  || (direction == -1 && wire < fWire_vertex[plane])) &&
697  ortdist < 4.5 && linedist < fdEdxlength) {
698  fChargeMeV_2cm[set] += dEdx_new;
699  fNpoints_2cm[set]++;
700  }
701 
702  // fill out for 4cm preshower
703 
704  fDistribChargeMeV[set].push_back(dEdx_new); // vector with the first De/Dx points
705  fDistribChargeposition[set].push_back(
706  wdist); // vector with the first De/Dx points' positions
707 
708  } // end inside range if statement
709 
710  } // end first loop on hits.
711 
712  auto const signalType =
713  hitlist.empty() ? geo::kMysteryType : geom->SignalType(hitlist.front()->WireID());
714 
715  if (signalType == geo::kCollection) {
716  fTotChargeADC[set] = totCnrg * newpitch;
717  fTotChargeMeV[set] = totCnrg_corr * newpitch;
718  }
719 
720  // calculate average dE/dx
721  if (fNpoints_2cm[set] > 0) { mevav2cm = fChargeMeV_2cm[set] / fNpoints_2cm[set]; }
722 
723  // second loop to calculate RMS
724  for (auto const& hit : hitlist | transform(to_element)) {
725  time = hit.PeakTime();
726  wire = hit.WireID().Wire;
727  plane = hit.WireID().Plane;
728  double dEdx = 0;
729 
730  if (fUseArea) { dEdx = calalg.dEdx_AREA(clockData, detProp, hit, newpitch); }
731  else // this will hopefully go away, once all of the calibration factors
732  // are calculated.
733  {
734  dEdx = calalg.dEdx_AMP(clockData, detProp, hit, newpitch);
735  }
736 
737  gser.GetPointOnLine(slope[plane] / fWireTimetoCmCm,
738  fWire_vertex[plane],
739  fTime_vertex[plane],
740  wire,
741  time,
742  wire_on_line,
743  time_on_line);
744  linedist =
745  gser.Get2DDistance(wire_on_line, time_on_line, fWire_vertex[plane], fTime_vertex[plane]);
746  ortdist = gser.Get2DDistance(wire_on_line, time_on_line, wire, time);
747 
748  double wdist = (((double)wire - (double)fWire_vertex[plane]) * newpitch) * direction;
749 
750  if ((wdist < fcalodEdxlength) && (wdist > 0.2)) {
751  if (wdist < fdEdxlength &&
752  ((direction == 1 && wire > fWire_vertex[plane]) ||
753  (direction == -1 && wire < fWire_vertex[plane])) &&
754  ortdist < 4.5 && linedist < fdEdxlength) {
755  fRMS_2cm[set] += (dEdx - mevav2cm) * (dEdx - mevav2cm);
756  }
757 
758  } // end if on correct hits.
759  } // end RMS_calculating loop.
760 
761  if (fNpoints_2cm[set] > 0) { fRMS_2cm[set] = TMath::Sqrt(fRMS_2cm[set] / fNpoints_2cm[set]); }
762 
763  /// third loop to get only points inside of 1RMS of value.
764 
765  for (auto const& hit : hitlist | transform(to_element)) {
766  time = hit.PeakTime();
767  wire = hit.WireID().Wire;
768  plane = hit.WireID().Plane;
769 
770  double dEdx = 0;
771  if (fUseArea) { dEdx = calalg.dEdx_AREA(clockData, detProp, hit, newpitch); }
772  else // this will hopefully go away, once all of the calibration factors
773  // are calculated.
774  {
775  dEdx = calalg.dEdx_AMP(clockData, detProp, hit, newpitch);
776  }
777 
778  gser.GetPointOnLine(slope[plane] / fWireTimetoCmCm,
779  fWire_vertex[plane],
780  fTime_vertex[plane],
781  wire,
782  time,
783  wire_on_line,
784  time_on_line);
785  linedist =
786  gser.Get2DDistance(wire_on_line, time_on_line, fWire_vertex[plane], fTime_vertex[plane]);
787  ortdist = gser.Get2DDistance(wire_on_line, time_on_line, wire, time);
788 
789  double wdist = (((double)wire - (double)fWire_vertex[plane]) * newpitch) * direction;
790 
791  if ((wdist < fcalodEdxlength) && (wdist > 0.2 &&
792  ((direction == 1 && wire > fWire_vertex[plane]) ||
793  (direction == -1 && wire < fWire_vertex[plane])) &&
794  ortdist < 4.5 && linedist < fdEdxlength)) {
795  if (wdist < fdEdxlength) {
796  if (((dEdx > (mevav2cm - fRMS_2cm[set])) && (dEdx < (mevav2cm + fRMS_2cm[set]))) ||
797  (newpitch > 0.3 * fdEdxlength)) {
798  fCorr_MeV_2cm[set] += dEdx;
799  fNpoints_corr_MeV_2cm[set]++;
800  }
801 
802  } // end if on good hits
803  }
804  } // end of third loop on hits
805 
806  if (fNpoints_corr_MeV_2cm[set] > 0) {
809  }
810  }
fhicl::ParameterSet fCaloPSet
std::vector< double > fTotChargeADC
constexpr to_element_t to_element
Definition: ToElement.h:24
Who knows?
Definition: geo_types.h:147
std::vector< std::vector< double > > fNPitch
std::vector< std::vector< double > > fDistribChargeMeV
std::vector< int > fNpoints_corr_MeV_2cm
std::vector< double > fTime_vertex
std::vector< double > fChargeMeV_2cm_refined
std::vector< float > vdEdx
Double_t PitchInView(UInt_t plane, Double_t phi, Double_t theta) const
std::vector< float > vdQdx
std::vector< int > fNpoints_2cm
double dEdx(float dqdx, float Efield)
Definition: doAna.cpp:21
std::vector< float > vresRange
std::vector< double > fRMS_2cm
Detector simulation of raw signals on wires.
std::vector< double > fCorr_MeV_2cm
std::vector< double > fChargeMeV_2cm
std::vector< std::vector< double > > fDistribChargeposition
std::vector< unsigned int > fWire_vertex
std::vector< double > fTotChargeMeV
Signal from collection planes.
Definition: geo_types.h:146
void shwf::ShowerReco::produce ( art::Event evt)
privatevirtual

Get Clusters

Todo:
really need to determine the values of the arguments of the recob::Shower ctor

Implements art::EDProducer.

Definition at line 351 of file ShowerReco_module.cc.

352  {
353  auto const* geom = lar::providerFrom<geo::Geometry>();
354  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
355  auto const detProp =
357 
358  util::GeometryUtilities const gser{*geom, clockData, detProp};
359  fNPlanes = geom->Nplanes();
360  auto Shower3DVector = std::make_unique<std::vector<recob::Shower>>();
361  auto cassn = std::make_unique<art::Assns<recob::Shower, recob::Cluster>>();
362  auto hassn = std::make_unique<art::Assns<recob::Shower, recob::Hit>>();
363  auto calorimetrycol = std::make_unique<std::vector<anab::Calorimetry>>();
364  auto calassn = std::make_unique<art::Assns<anab::Calorimetry, recob::Shower>>();
365 
366  /**Get Clusters*/
367 
368  art::Handle<std::vector<recob::Cluster>> clusterListHandle;
369  evt.getByLabel(fClusterModuleLabel, clusterListHandle);
370 
372  evt.getByLabel(fClusterModuleLabel, clusterAssociationHandle);
373 
374  art::FindManyP<recob::Hit> fmh(clusterListHandle, evt, fClusterModuleLabel);
375 
376  fRun = evt.id().run();
377  fSubRun = evt.id().subRun();
378  fEvent = evt.id().event();
379 
380  // find all the hits associated to all the clusters (once and for all);
381  // the index of the query matches the index of the cluster in the collection
382  // (conveniently carried around in its art pointer)
383  art::FindManyP<recob::Hit> ClusterHits(clusterListHandle, evt, fClusterModuleLabel);
384 
385  std::vector<art::PtrVector<recob::Cluster>>::const_iterator clusterSet =
386  clusterAssociationHandle->begin();
387  // loop over vector of vectors (each size of NPlanes) and reconstruct showers from each of those
388  for (size_t iClustSet = 0; iClustSet < clusterAssociationHandle->size(); iClustSet++) {
389 
390  const art::PtrVector<recob::Cluster> CurrentClusters = (*(clusterSet++));
391 
392  // do some error checking - i.e. are the clusters themselves present.
393  if (clusterListHandle->size() < 2 || CurrentClusters.size() < 2) {
394  ftree_shwf->Fill();
395  return;
396  }
397 
399 
400  std::vector<std::vector<art::Ptr<recob::Hit>>> hitlist_all;
401  hitlist_all.resize(fNPlanes);
402 
403  for (size_t iClust = 0; iClust < CurrentClusters.size(); iClust++) {
404  art::Ptr<recob::Cluster> const& pclust = CurrentClusters[iClust];
405 
406  // get all the hits for this cluster;
407  // pclust is a art::Ptr to the original cluster collection stored in the event;
408  // its key corresponds to its index in the collection
409  // (and therefore to the index in the query)
410  std::vector<art::Ptr<recob::Hit>> const& hitlist = ClusterHits.at(pclust.key());
411 
412  unsigned int p(0); //c=channel, p=plane, w=wire
413 
414  if (hitlist.size() == 0) continue;
415 
416  p = (*hitlist.begin())->WireID().Plane;
417  // get vertex position and slope information to start with - ii is the
418  // posistion of the correct cluster:
420 
421  double ADCcharge = 0;
422  //loop over cluster hits
423  for (art::Ptr<recob::Hit> const& hit : hitlist) {
424  p = hit->WireID().Plane;
425  hitlist_all[p].push_back(hit);
426  ADCcharge += hit->PeakAmplitude();
427  }
428  fNhitsperplane[p] = hitlist_all[p].size();
429  fTotADCperplane[p] = ADCcharge;
430  } // End loop on clusters.
431  // Now I have the Hitlists and the relevent clusters parameters saved.
432 
433  // find best set:
434  unsigned int bp1 = 0, bp2 = 0;
435  double minerror1 = 99999999, minerror2 = 9999999;
436  for (unsigned int ii = 0; ii < fNPlanes; ++ii) {
437  double locerror =
439  fTime_vertexError[ii] * fTime_vertexError[ii]; // time coordinate of vertex for each plane
440 
441  if (minerror1 >= locerror) // the >= sign is to favorize collection
442  {
443  minerror1 = locerror;
444  bp1 = ii;
445  }
446  }
447  for (unsigned int ij = 0; ij < fNPlanes; ++ij) {
448  double locerror =
450  fTime_vertexError[ij] * fTime_vertexError[ij]; // time coordinate of vertex for each plane
451 
452  if (minerror2 >= locerror && ij != bp1) {
453  minerror2 = locerror;
454  bp2 = ij;
455  }
456  }
457 
458  gser.Get3DaxisN(bp1, bp2, angle[bp1], angle[bp2], xphi, xtheta);
459 
460  ///////////////////////////////////////////////////////////
461  const double origin[3] = {0.};
462  std::vector<std::vector<double>> position;
463  double fTimeTick = sampling_rate(clockData) / 1000.;
464  double fDriftVelocity = detProp.DriftVelocity(detProp.Efield(), detProp.Temperature());
465  // get starting positions for all planes
466  for (unsigned int xx = 0; xx < fNPlanes; xx++) {
467  double pos1[3];
468  geom->Plane(xx).LocalToWorld(origin, pos1);
469  std::vector<double> pos2;
470  pos2.push_back(pos1[0]);
471  pos2.push_back(pos1[1]);
472  pos2.push_back(pos1[2]);
473  position.push_back(pos2);
474  }
475  // Assuming there is no problem ( and we found the best pair that comes
476  // close in time ) we try to get the Y and Z coordinates for the start of
477  // the shower.
478  try {
479  int chan1 = geom->PlaneWireToChannel(bp1, fWire_vertex[bp1], 0);
480  int chan2 = geom->PlaneWireToChannel(bp2, fWire_vertex[bp2], 0);
481 
482  double y, z;
483  geom->ChannelsIntersect(chan1, chan2, y, z);
484 
485  xyz_vertex_fit[1] = y;
486  xyz_vertex_fit[2] = z;
487  xyz_vertex_fit[0] =
488  (fTime_vertex[bp1] - trigger_offset(clockData)) * fDriftVelocity * fTimeTick +
489  position[0][0];
490  }
491  catch (cet::exception const& e) {
492  mf::LogWarning("ShowerReco") << "caught exception \n" << e;
493  xyz_vertex_fit[1] = 0;
494  xyz_vertex_fit[2] = 0;
495  xyz_vertex_fit[0] = 0;
496  }
497 
498  // if collection is not best plane, project starting point from that
499  if (bp1 != fNPlanes - 1 && bp2 != fNPlanes - 1) {
500  double pos[3];
501  unsigned int wirevertex;
502 
503  geom->Plane(fNPlanes - 1).LocalToWorld(origin, pos);
504 
505  pos[1] = xyz_vertex_fit[1];
506  pos[2] = xyz_vertex_fit[2];
507  wirevertex = geom->NearestWire(pos, fNPlanes - 1);
508 
509  double drifttick =
510  (xyz_vertex_fit[0] / detProp.DriftVelocity(detProp.Efield(), detProp.Temperature())) *
511  (1. / fTimeTick);
512  fWire_vertex[fNPlanes - 1] = wirevertex; // wire coordinate of vertex for each plane
513  fTime_vertex[fNPlanes - 1] =
514  drifttick -
515  (pos[0] / detProp.DriftVelocity(detProp.Efield(), detProp.Temperature())) *
516  (1. / fTimeTick) +
517  trigger_offset(clockData);
518  }
519 
520  if (fabs(xphi) < 5.) {
521  xtheta = gser.Get3DSpecialCaseTheta(
522  bp1, bp2, fWire_last[bp1] - fWire_vertex[bp1], fWire_last[bp2] - fWire_vertex[bp2]);
523  }
524 
525  // zero the arrays just to make sure
526  for (unsigned int i = 0; i < fNAngles; ++i) {
527  fTotChargeADC[i] = 0;
528  fTotChargeMeV[i] = 0;
529  fTotChargeMeV_MIPs[i] = 0;
530  fNpoints_corr_ADC_2cm[i] = 0;
531  fNpoints_corr_MeV_2cm[i] = 0;
532 
533  fRMS_2cm[i] = 0;
534  fNpoints_2cm[i] = 0;
535 
536  fCorr_MeV_2cm[i] = 0;
537  fCorr_Charge_2cm[i] = 0;
538 
539  fChargeADC_2cm[i] = 0; //Initial charge in ADC/cm for each plane angle calculation 4cm
540  fChargeMeV_2cm[i] = 0; //initial charge in MeV/cm for each angle calculation first 4cm
541  }
542 
543  // do loop and choose Collection. With ful calorimetry can do all.
544  if (!(fabs(xphi) > 89 && fabs(xphi) < 91)) // do not calculate pitch for extreme angles
545  LongTransEnergy(geom,
546  clockData,
547  detProp,
548  0,
549  hitlist_all[fNPlanes - 1]); // temporary only plane 2.
550 
551  //////create spacepoints, and direction cosines for Shower creation
552 
553  // make an art::PtrVector of the clusters
555  for (unsigned int i = 0; i < clusterListHandle->size(); ++i) {
556  art::Ptr<recob::Cluster> prod(clusterListHandle, i);
557  prodvec.push_back(prod);
558  }
559 
560  //create a singleSpacePoint at vertex.
561  std::vector<recob::SpacePoint> spcpts;
562 
563  //get direction cosines and set them for the shower
564  // TBD determine which angle to use for the actual shower
565  double fPhi = xphi;
566  double fTheta = xtheta;
567 
568  TVector3 dcosVtx(
569  TMath::Cos(fPhi * TMath::Pi() / 180) * TMath::Sin(fTheta * TMath::Pi() / 180),
570  TMath::Cos(fTheta * TMath::Pi() / 180),
571  TMath::Sin(fPhi * TMath::Pi() / 180) * TMath::Sin(fTheta * TMath::Pi() / 180));
572  /// \todo really need to determine the values of the arguments of the
573  /// recob::Shower ctor
574  // fill with bogus values for now
575  TVector3 dcosVtxErr(util::kBogusD, util::kBogusD, util::kBogusD);
576  recob::Shower singShower;
577  singShower.set_direction(dcosVtx);
578  singShower.set_direction_err(dcosVtxErr);
579 
580  Shower3DVector->push_back(singShower);
581  // associate the shower with its clusters
582  util::CreateAssn(evt, *Shower3DVector, prodvec, *cassn);
583 
584  // get the hits associated with each cluster and associate those with the shower
585  for (size_t p = 0; p < prodvec.size(); ++p) {
586  std::vector<art::Ptr<recob::Hit>> hits = fmh.at(p);
587  util::CreateAssn(evt, *Shower3DVector, hits, *hassn);
588  }
589 
590  geo::PlaneID planeID(0, 0, fNPlanes - 1);
591  calorimetrycol->emplace_back(
593 
595 
596  art::ProductID aid = evt.getProductID<std::vector<recob::Shower>>();
597  art::Ptr<recob::Shower> aptr(aid, 0, evt.productGetter(aid));
598  ssvec.push_back(aptr);
599 
600  util::CreateAssn(evt, *calorimetrycol, ssvec, *calassn);
601  ftree_shwf->Fill();
602  } // end loop on Vectors of "Associated clusters"
603 
604  evt.put(std::move(Shower3DVector));
605  evt.put(std::move(cassn));
606  evt.put(std::move(hassn));
607  evt.put(std::move(calorimetrycol));
608  evt.put(std::move(calassn));
609  }
std::vector< double > fWire_vertexError
std::vector< double > fTotChargeADC
std::vector< double > fCorr_Charge_2cm
void set_direction_err(const TVector3 &dir_e)
Definition: Shower.h:136
ProductID getProductID(std::string const &instance_name="") const
Definition: DataViewImpl.h:338
std::vector< int > fNhitsperplane
The data type to uniquely identify a Plane.
Definition: geo_types.h:472
std::vector< int > fNpoints_corr_MeV_2cm
std::vector< double > fTime_vertex
std::vector< double > fTotADCperplane
std::vector< unsigned int > fWire_last
std::vector< float > vdEdx
RunNumber_t run() const
Definition: EventID.h:98
void GetVertexAndAnglesFromCluster(art::Ptr< recob::Cluster > clust, unsigned int plane)
std::vector< float > vdQdx
std::vector< int > fNpoints_2cm
std::vector< double > fTime_vertexError
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:633
void set_direction(const TVector3 &dir)
Definition: Shower.h:135
const double e
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
void push_back(Ptr< U > const &p)
Definition: PtrVector.h:435
std::vector< float > vresRange
def move(depos, offset)
Definition: depos.py:107
EDProductGetter const * productGetter(ProductID const pid) const
key_type key() const noexcept
Definition: Ptr.h:216
p
Definition: test.py:223
std::vector< double > fRMS_2cm
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: DataViewImpl.h:686
bool CreateAssn(PRODUCER const &prod, art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t indx=UINT_MAX)
Creates a single one-to-one association.
reference at(size_type n)
Definition: PtrVector.h:359
size_type size() const
Definition: PtrVector.h:302
Detector simulation of raw signals on wires.
std::vector< double > fCorr_MeV_2cm
std::string fClusterModuleLabel
std::vector< double > xyz_vertex_fit
std::vector< double > fChargeMeV_2cm
std::vector< double > fTotChargeMeV_MIPs
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
std::vector< double > fChargeADC_2cm
std::vector< float > deadwire
int trigger_offset(DetectorClocksData const &data)
EventNumber_t event() const
Definition: EventID.h:116
void LongTransEnergy(geo::GeometryCore const *geom, detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, unsigned int set, std::vector< art::Ptr< recob::Hit >> hitlist)
constexpr double kBogusD
obviously bogus double value
void ClearandResizeVectors(unsigned int nPlanes)
double sampling_rate(DetectorClocksData const &data)
Returns the period of the TPC readout electronics clock.
std::vector< int > fNpoints_corr_ADC_2cm
std::vector< unsigned int > fWire_vertex
SubRunNumber_t subRun() const
Definition: EventID.h:110
EventID id() const
Definition: Event.cc:34
constexpr Point origin()
Returns a origin position with a point of the specified type.
Definition: geo_vectors.h:227
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
std::vector< double > fTotChargeMeV

Member Data Documentation

float shwf::ShowerReco::angle[3]
private

Definition at line 80 of file ShowerReco_module.cc.

std::vector<float> shwf::ShowerReco::deadwire
private

Definition at line 137 of file ShowerReco_module.cc.

float shwf::ShowerReco::fcalodEdxlength
private

Definition at line 142 of file ShowerReco_module.cc.

fhicl::ParameterSet shwf::ShowerReco::fCaloPSet
private

Definition at line 87 of file ShowerReco_module.cc.

std::vector<double> shwf::ShowerReco::fChargeADC_2cm
private

Definition at line 101 of file ShowerReco_module.cc.

std::vector<double> shwf::ShowerReco::fChargeMeV_2cm
private

Definition at line 102 of file ShowerReco_module.cc.

std::vector<double> shwf::ShowerReco::fChargeMeV_2cm_axsum
private

Definition at line 105 of file ShowerReco_module.cc.

std::vector<double> shwf::ShowerReco::fChargeMeV_2cm_refined
private

Definition at line 104 of file ShowerReco_module.cc.

std::string shwf::ShowerReco::fClusterModuleLabel
private

Definition at line 82 of file ShowerReco_module.cc.

std::vector<double> shwf::ShowerReco::fCorr_Charge_2cm
private

Definition at line 92 of file ShowerReco_module.cc.

std::vector<double> shwf::ShowerReco::fCorr_MeV_2cm
private

Definition at line 91 of file ShowerReco_module.cc.

float shwf::ShowerReco::fdEdxlength
private

Definition at line 140 of file ShowerReco_module.cc.

std::vector<std::vector<double> > shwf::ShowerReco::fDistribChargeADC
private

Definition at line 107 of file ShowerReco_module.cc.

std::vector<std::vector<double> > shwf::ShowerReco::fDistribChargeMeV
private

Definition at line 109 of file ShowerReco_module.cc.

std::vector<std::vector<double> > shwf::ShowerReco::fDistribChargeposition
private

Definition at line 112 of file ShowerReco_module.cc.

std::vector<std::vector<double> > shwf::ShowerReco::fDistribHalfChargeMeV
private

Definition at line 110 of file ShowerReco_module.cc.

double shwf::ShowerReco::fDriftVelocity
private

Definition at line 153 of file ShowerReco_module.cc.

int shwf::ShowerReco::fEvent
private

Definition at line 77 of file ShowerReco_module.cc.

double shwf::ShowerReco::fMean_wire_pitch
private

Definition at line 86 of file ShowerReco_module.cc.

unsigned int shwf::ShowerReco::fNAngles
private

Definition at line 147 of file ShowerReco_module.cc.

std::vector<int> shwf::ShowerReco::fNhitsperplane
private

Definition at line 156 of file ShowerReco_module.cc.

std::vector<std::vector<double> > shwf::ShowerReco::fNPitch
private

Definition at line 130 of file ShowerReco_module.cc.

unsigned int shwf::ShowerReco::fNPlanes
private

Definition at line 146 of file ShowerReco_module.cc.

std::vector<int> shwf::ShowerReco::fNpoints_2cm
private

Definition at line 90 of file ShowerReco_module.cc.

std::vector<int> shwf::ShowerReco::fNpoints_corr_ADC_2cm
private

Definition at line 94 of file ShowerReco_module.cc.

std::vector<int> shwf::ShowerReco::fNpoints_corr_MeV_2cm
private

Definition at line 95 of file ShowerReco_module.cc.

std::vector<double> shwf::ShowerReco::fRMS_2cm
private

Definition at line 89 of file ShowerReco_module.cc.

int shwf::ShowerReco::fRun
private

Definition at line 77 of file ShowerReco_module.cc.

std::vector<std::vector<double> > shwf::ShowerReco::fSingleEvtAngle
private

Definition at line 114 of file ShowerReco_module.cc.

std::vector<std::vector<double> > shwf::ShowerReco::fSingleEvtAngleVal
private

Definition at line 115 of file ShowerReco_module.cc.

int shwf::ShowerReco::fSubRun
private

Definition at line 77 of file ShowerReco_module.cc.

std::vector<double> shwf::ShowerReco::fTime_last
private

Definition at line 124 of file ShowerReco_module.cc.

std::vector<double> shwf::ShowerReco::fTime_vertex
private

Definition at line 118 of file ShowerReco_module.cc.

std::vector<double> shwf::ShowerReco::fTime_vertexError
private

Definition at line 121 of file ShowerReco_module.cc.

float shwf::ShowerReco::ftimetick
private

Definition at line 84 of file ShowerReco_module.cc.

double shwf::ShowerReco::fTimeTick
private

Definition at line 152 of file ShowerReco_module.cc.

std::vector<double> shwf::ShowerReco::fTotADCperplane
private

Definition at line 157 of file ShowerReco_module.cc.

std::vector<double> shwf::ShowerReco::fTotChargeADC
private

Definition at line 97 of file ShowerReco_module.cc.

std::vector<double> shwf::ShowerReco::fTotChargeMeV
private

Definition at line 98 of file ShowerReco_module.cc.

std::vector<double> shwf::ShowerReco::fTotChargeMeV_MIPs
private

Definition at line 99 of file ShowerReco_module.cc.

TTree* shwf::ShowerReco::ftree_shwf
private

Definition at line 148 of file ShowerReco_module.cc.

float shwf::ShowerReco::fTrkPitchC
private

Definition at line 139 of file ShowerReco_module.cc.

bool shwf::ShowerReco::fUseArea
private

Definition at line 143 of file ShowerReco_module.cc.

std::vector<unsigned int> shwf::ShowerReco::fWire_last
private

Definition at line 123 of file ShowerReco_module.cc.

std::vector<unsigned int> shwf::ShowerReco::fWire_vertex
private

Definition at line 117 of file ShowerReco_module.cc.

std::vector<double> shwf::ShowerReco::fWire_vertexError
private

Definition at line 120 of file ShowerReco_module.cc.

double shwf::ShowerReco::fWirePitch
private

Definition at line 151 of file ShowerReco_module.cc.

double shwf::ShowerReco::fWireTimetoCmCm
private

Definition at line 154 of file ShowerReco_module.cc.

float shwf::ShowerReco::Kin_En
private

Definition at line 133 of file ShowerReco_module.cc.

float shwf::ShowerReco::slope[3]
private

Definition at line 79 of file ShowerReco_module.cc.

float shwf::ShowerReco::Trk_Length
private

Definition at line 138 of file ShowerReco_module.cc.

std::vector<float> shwf::ShowerReco::vdEdx
private

Definition at line 134 of file ShowerReco_module.cc.

std::vector<float> shwf::ShowerReco::vdQdx
private

Definition at line 136 of file ShowerReco_module.cc.

std::vector<float> shwf::ShowerReco::vresRange
private

Definition at line 135 of file ShowerReco_module.cc.

double shwf::ShowerReco::xphi
private

Definition at line 145 of file ShowerReco_module.cc.

double shwf::ShowerReco::xtheta
private

Definition at line 145 of file ShowerReco_module.cc.

std::vector<double> shwf::ShowerReco::xyz_vertex_fit
private

Definition at line 127 of file ShowerReco_module.cc.


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