LArSoft  v07_13_02
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 {
108  /*************************************************************/
109  /* WARNING */
110  /*************************************************************/
111  /* The dQdx information in recob::Track has been deprecated */
112  /* since 2016 and in 11/2018 the recob::Track interface was */
113  /* changed and DQdxAtPoint and NumberdQdx were removed. */
114  /* Therefore the code below is now commented out */
115  /* (note that it was most likely not functional anyways). */
116  /* For any issue please contact: larsoft-team@fnal.gov */
117  /*************************************************************/
118  /*
119  art::Handle< std::vector<recob::Track> > trackHandle;
120  evt.getByLabel(fTrackModuleLabel, trackHandle);
121  std::vector< art::Ptr<recob::Track> > tracks;
122  art::fill_ptr_vector(tracks, trackHandle);
123 
124  auto const* dp = lar::providerFrom<detinfo::DetectorPropertiesService>();
125 
126  //create anab::Calorimetry objects and make association with recob::Track
127  std::unique_ptr< std::vector<anab::Calorimetry> > calorimetrycol(new std::vector<anab::Calorimetry>);
128  std::unique_ptr< art::Assns<recob::Track, anab::Calorimetry> > assn(new art::Assns<recob::Track, anab::Calorimetry>);
129 
130  art::FindMany<recob::Hit> fmht(trackHandle, evt, fTrackModuleLabel);
131 
132  // loop over the tracks
133  for(size_t t = 0; t < tracks.size(); ++t){
134 
135  art::Ptr<recob::Track> trk = tracks.at(t);
136 
137  double viewPitch = 0.;
138  try{
139  viewPitch = lar::util::TrackPitchInView(*trk, fCollectionView);
140  }
141  catch( cet::exception &e){
142  mf::LogWarning("GeneralCalorimetry") << "caught exception "
143  << e
144  << "\n pitch now set to 0";
145  }
146 
147  // loop over the track trajectory to get the kinetic energy,
148  // residual range and the dQdx
149  float kineticEnergy = 0.;
150  std::vector<float> vdEdx;
151  std::vector<float> vresRange;
152  std::vector<float> vdQdx;
153  std::vector<float> deadwire; //residual range for dead wires
154 
155  // Check that the number of trajectory points and number of dQdx for the
156  // collection view are the same
157  if( trk->NumberTrajectoryPoints() != trk->NumberdQdx(fCollectionView) )
158  throw cet::exception("GeneralCalorimetry") << "inconsistent number of track trajectory "
159  << " and dQdx points\n";
160 
161  if (trk->NumberTrajectoryPoints()>2){
162  for(size_t p = 1; p < trk->NumberTrajectoryPoints()-1; ++p){
163  if (!trk->DQdxAtPoint(p, fCollectionView)) continue;
164  vresRange.push_back(trk->Length(p));
165  vdQdx.push_back(trk->DQdxAtPoint(p, fCollectionView));
166  //vdEdx.push_back(vdQdx.back() * fADCToElectrons/util::kGeVToElectrons*1000);
167  vdEdx.push_back(caloAlg.dEdx_AMP(vdQdx.back(),
168  dp->ConvertXToTicks(trk->LocationAtPoint(p).X(),fCollectionPlane,0,0),
169  fCollectionPlane));
170  kineticEnergy += vdEdx.back(); // \todo should this be converted from electrons to energy?
171  std::cout<<vresRange.back()<<" "<<vdQdx.back()<<" "<<vdEdx.back()<<std::endl;
172  }
173 
174  geo::PlaneID planeID(0,0,fCollectionPlane);
175  calorimetrycol->push_back(anab::Calorimetry(kineticEnergy,
176  vdEdx,
177  vdQdx,
178  vresRange,
179  deadwire,
180  trk->Length(),
181  viewPitch,
182  planeID));
183 
184  util::CreateAssn(*this, evt, *calorimetrycol, trk, *assn);
185 
186  }
187  }// end of loop over all tracks
188 
189  if (calorimetrycol->size()){
190  evt.put(std::move(calorimetrycol));
191  evt.put(std::move(assn));
192  }
193 
194  */
195  /*************************************************************/
196  return;
197 }
198 
199 namespace calo{
200 
202 
203 } // end namespace
204 
double fADCToElectrons
filled using the detinfo::DetectorPropertiesService service
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
SigType_t SignalType(geo::PlaneID const &pid) const
Returns the type of signal on the channels of specified TPC plane.
unsigned int Nplanes(unsigned int tpc=0, unsigned int cstat=0) const
Returns the total number of wire planes in the specified TPC.
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:42
Provides recob::Track data product.
parameter set interface
T get(std::string const &key) const
Definition: ParameterSet.h:231
geo::View_t fCollectionView
view of the collection plane
void reconfigure(fhicl::ParameterSet const &pset)
The data type to uniquely identify a TPC.
Definition: geo_types.h:195
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.
TCEvent evt
Definition: DataStructs.cxx:5
art::ServiceHandle< geo::Geometry > fGeo
std::string fTrackModuleLabel
module creating the track objects and assns to hits
Namespace collecting geometry-related classes utilities.
Utility functions to extract information from recob::Track.
art framework interface to geometry description
calorimetry
Encapsulate the construction of a single detector plane.
Signal from collection planes.
Definition: geo_types.h:93