LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
GeneralCalorimetry_module.cc
Go to the documentation of this file.
1 //
3 // GeneralCalorimetry module based on Calorimetry module
4 // but does not assume anything about which view is collection vs induction
5 //
6 // This algorithm is designed to perform the calorimetric reconstruction
7 // of the 3D reconstructed tracks
8 //
9 // brebel@fnal.gov
11 extern "C" {
12 #include <sys/types.h>
13 #include <sys/stat.h>
14 }
15 #include <vector>
16 #include <string>
17 #include <algorithm>
18 
28 #include "lardata/ArtDataHelper/TrackUtils.h" // lar::util::TrackPitchInView()
29 
30 // Framework includes
35 #include "fhiclcpp/ParameterSet.h"
43 
45 namespace calo {
46 
48 
49  public:
50 
51  explicit GeneralCalorimetry(fhicl::ParameterSet const& pset);
52 
53  void reconfigure(fhicl::ParameterSet const& pset);
54  void produce(art::Event& evt);
55 
56  private:
57 
58  std::string fTrackModuleLabel;
59  double fADCToElectrons;
61  unsigned int fCollectionPlane;
63 
65 
66 
67  }; // class GeneralCalorimetry
68 
69 }
70 
71 //-------------------------------------------------
74  , fCollectionPlane(0)
75  , caloAlg(pset.get< fhicl::ParameterSet >("CaloAlg"))
76 {
77  auto const* dp = lar::providerFrom<detinfo::DetectorPropertiesService>();
78  fADCToElectrons = 1./dp->ElectronsToADC();
79 
80  // determine the view of the collection plane
81  // just look at one cryostat, the first TPC and loop over those
82  // planes
83  geo::TPCID FirstTPC(0, 0);
84  for(unsigned int p = 0; p < fGeo->Nplanes(FirstTPC); ++p){
85  geo::PlaneID planeid{ FirstTPC, p };
86  if(fGeo->SignalType(planeid) == geo::kCollection){
87  fCollectionView = fGeo->View(planeid);
88  fCollectionPlane = p;
89  }
90  }
91 
92  this->reconfigure(pset);
93 
94  produces< std::vector<anab::Calorimetry> >();
95  produces< art::Assns<recob::Track, anab::Calorimetry> >();
96 }
97 
98 //------------------------------------------------------------------------------------//
100 {
101  fTrackModuleLabel = pset.get< std::string >("TrackModuleLabel");
102  return;
103 }
104 
105 //------------------------------------------------------------------------------------//
107 {
109  evt.getByLabel(fTrackModuleLabel, trackHandle);
110  std::vector< art::Ptr<recob::Track> > tracks;
111  art::fill_ptr_vector(tracks, trackHandle);
112 
113  auto const* dp = lar::providerFrom<detinfo::DetectorPropertiesService>();
114 
115  //create anab::Calorimetry objects and make association with recob::Track
116  std::unique_ptr< std::vector<anab::Calorimetry> > calorimetrycol(new std::vector<anab::Calorimetry>);
117  std::unique_ptr< art::Assns<recob::Track, anab::Calorimetry> > assn(new art::Assns<recob::Track, anab::Calorimetry>);
118 
119  art::FindMany<recob::Hit> fmht(trackHandle, evt, fTrackModuleLabel);
120 
121  // loop over the tracks
122  for(size_t t = 0; t < tracks.size(); ++t){
123 
124  art::Ptr<recob::Track> trk = tracks.at(t);
125 
126  double viewPitch = 0.;
127  try{
128  viewPitch = lar::util::TrackPitchInView(*trk, fCollectionView);
129  }
130  catch( cet::exception &e){
131  mf::LogWarning("GeneralCalorimetry") << "caught exception "
132  << e
133  << "\n pitch now set to 0";
134  }
135 
136  // loop over the track trajectory to get the kinetic energy,
137  // residual range and the dQdx
138  double kineticEnergy = 0.;
139  std::vector<double> vdEdx;
140  std::vector<double> vresRange;
141  std::vector<double> vdQdx;
142  std::vector<double> deadwire; //residual range for dead wires
143 
144  // Check that the number of trajectory points and number of dQdx for the
145  // collection view are the same
147  throw cet::exception("GeneralCalorimetry") << "inconsistent number of track trajectory "
148  << " and dQdx points\n";
149 
150  if (trk->NumberTrajectoryPoints()>2){
151  for(size_t p = 1; p < trk->NumberTrajectoryPoints()-1; ++p){
152  if (!trk->DQdxAtPoint(p, fCollectionView)) continue;
153  vresRange.push_back(trk->Length(p));
154  vdQdx.push_back(trk->DQdxAtPoint(p, fCollectionView));
155  //vdEdx.push_back(vdQdx.back() * fADCToElectrons/util::kGeVToElectrons*1000);
156  vdEdx.push_back(caloAlg.dEdx_AMP(vdQdx.back(),
157  dp->ConvertXToTicks(trk->LocationAtPoint(p)[0],fCollectionPlane,0,0),
159  kineticEnergy += vdEdx.back(); // \todo should this be converted from electrons to energy?
160  std::cout<<vresRange.back()<<" "<<vdQdx.back()<<" "<<vdEdx.back()<<std::endl;
161  }
162 
163  geo::PlaneID planeID(0,0,fCollectionPlane);
164  calorimetrycol->push_back(anab::Calorimetry(kineticEnergy,
165  vdEdx,
166  vdQdx,
167  vresRange,
168  deadwire,
169  trk->Length(),
170  viewPitch,
171  planeID));
172 
173  util::CreateAssn(*this, evt, *calorimetrycol, trk, *assn);
174 
175  }
176  }// end of loop over all tracks
177 
178  if (calorimetrycol->size()){
179  evt.put(std::move(calorimetrycol));
180  evt.put(std::move(assn));
181  }
182 
183  return;
184 }
185 
186 namespace calo{
187 
189 
190 } // end namespace
191 
TVector3 LocationAtPoint(unsigned int p) const
Covariance matrices are either set or not.
Definition: Track.h:241
double fADCToElectrons
filled using the detinfo::DetectorPropertiesService service
const double & DQdxAtPoint(unsigned int p, geo::View_t view=geo::kUnknown) const
Covariance matrices are either set or not.
Definition: Track.cxx:80
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
GeneralCalorimetry(fhicl::ParameterSet const &pset)
Unknown view.
Definition: geo_types.h:83
Declaration of signal hit object.
The data type to uniquely identify a Plane.
Definition: geo_types.h:250
size_t NumberTrajectoryPoints() const
Various functions related to the presence and the number of (valid) points.
Definition: Track.h:109
SigType_t SignalType(geo::PlaneID const &pid) const
Returns the type of signal on the channels of specified TPC plane.
size_t NumberdQdx(geo::View_t view=geo::kUnknown) const
Covariance matrices are either set or not.
Definition: Track.cxx:67
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
unsigned int Nplanes(unsigned int tpc=0, unsigned int cstat=0) const
Returns the total number of wire planes in the specified TPC.
double Length(size_t p=0) const
Access to various track properties.
Definition: Track.h:174
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:42
parameter set interface
T get(std::string const &key) const
Definition: ParameterSet.h:231
geo::View_t fCollectionView
view of the collection plane
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.
void reconfigure(fhicl::ParameterSet const &pset)
The data type to uniquely identify a TPC.
Definition: geo_types.h:195
Provides recob::Track data product.
View_t View(geo::PlaneID const &pid) const
Returns the view (wire orientation) on the channels of specified TPC plane.
unsigned int fCollectionPlane
plane of the collection plane
Utility object to perform functions of association.
Encapsulate the construction of a single detector plane.
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
double TrackPitchInView(recob::Track const &track, geo::View_t view, size_t trajectory_point=0)
Provides projected wire pitch for the view.
Definition: TrackUtils.cxx:76
art::ServiceHandle< geo::Geometry > fGeo
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:464
std::string fTrackModuleLabel
module creating the track objects and assns to hits
Float_t e
Definition: plot.C:34
Namespace collecting geometry-related classes utilities.
Utility functions to extract information from recob::Track.
double dEdx_AMP(art::Ptr< recob::Hit > hit, double pitch, double T0=0) const
art framework interface to geometry description
calorimetry
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
Encapsulate the construction of a single detector plane.
Signal from collection planes.
Definition: geo_types.h:93