TrackInfo_module.cc
Go to the documentation of this file.
1 /////////////////////////////////////////////////////////
2 /// \brief Track information
3 /// \author Leo Aliaga laliaga@fnal.gov
4 ////////////////////////////////////////////////////////
5 #include <string>
6 
12 #include "fhiclcpp/ParameterSet.h"
14 
15 #include "TrackInfo/TrackInfoFxs.h"
16 #include "TrackInfo/TrackInfoObj.h"
17 #include "Geometry/Geometry.h"
18 #include "Geometry/LiveGeometry.h"
19 #include "MCCheater/BackTracker.h"
20 #include "NovaDAQConventions/DAQConventions.h"
21 #include "RecoBase/CellHit.h"
22 #include "RecoBase/Cluster.h"
23 #include "RecoBase/Track.h"
24 #include "TimingFit/TimingFitAlg.h"
25 #include "Utilities/AssociationUtil.h"
27 #include "CVN/func/Result.h"
30 
31 #include "TFile.h"
32 #include "TMVA/Reader.h"
33 
34 namespace trackinfo {
35 
36  class TrackInfo : public art::EDProducer {
37  public:
38  explicit TrackInfo(fhicl::ParameterSet const & pset);
39  virtual ~TrackInfo();
40 
41  void produce (art::Event & evt);
42 
43  protected:
44  void Init();
45 
47  bpfit::dEdxCalculator fdEdxCalc; ///< helper class for computing dEdx values
48  double fdxTOL; ///< cut off value for dx, if dx is less than this, don't compute dE/dx
52  };
53 }
54 
55 
56 namespace trackinfo
57 {
58 
59  //----------------------------------------------------------------------
62  fdxTOL (pset.get<double> ("dxTOL")),
63  fSlicerLabel (pset.get< std::string >("SlicerLabel")),
64  fTrackLabel (pset.get< std::string >("TrackLabel")){
65  produces< std::vector<trackinfo::TrackInfoObj> >();
66  produces< art::Assns<trackinfo::TrackInfoObj, rb::Track> >();
67  }
68 
69 
70  //----------------------------------------------------------------------
72  if(fTrackInfoFxs) delete fTrackInfoFxs;
73  }
74 
75  //-------------------------------------------------------------------
76  void TrackInfo::Init(){
78  }
79 
80  //-------------------------------------------------------------------
82 
83  Init();
88  evt.getByLabel(fSlicerLabel,slicevec);
90 
91  if(slicevec->empty()) {
92  mf::LogWarning ("No Slices")<<"No Slices in the input file";
93  return;
94  }
95  art::FindManyP<rb::Track> trackAssnList(slicevec, evt, fTrackLabel);
96  std::unique_ptr< std::vector<trackinfo::TrackInfoObj> > outputObjects(new std::vector<trackinfo::TrackInfoObj>);
97  std::unique_ptr< art::Assns<trackinfo::TrackInfoObj, rb::Track> > assoc(new art::Assns<trackinfo::TrackInfoObj, rb::Track>);
98 
99  for(size_t i = 0; i < slicevec->size(); ++i){
100  art::Ptr<rb::Cluster> slice(slicevec,i);
101 
102  if(slice->IsNoise()) {
103  continue;
104  }
105 
106  const std::vector< art::Ptr<rb::Track> > sliceTracks = trackAssnList.at(i);
107  for(size_t iTrack = 0; iTrack < sliceTracks.size(); ++iTrack){
108  trackinfo::TrackInfoObj trackinfoobj;
109  art::Ptr<rb::Track> track = sliceTracks[iTrack];
110 
111  // ignore bad track
112  double tdx = track->Dir().X();
113  double tdy = track->Dir().Y();
114  double tdz = track->Dir().Z();
115  bool bad_track_dir = (tdx < -1) || (tdx > 1) ||
116  (tdy < -1) || (tdy > 1) ||
117  (tdz < -1) || (tdz > 1);
118  if(bad_track_dir){
119  outputObjects->push_back(trackinfoobj);
120  util::CreateAssn(*this,evt,*(outputObjects.get()),track,*(assoc.get()));
121  continue;
122  }
123 
124  //We are only interested on the dE,dx and s info from dEdxCalculator:
125  const int fake_pdg = 13;
126  fdEdxCalc.computeDEDX(track,fake_pdg);
127  std::vector<double> dE, dx, s;
128  fdEdxCalc.getDE(dE,fdxTOL);
129  fdEdxCalc.getDX(dx,fdxTOL);
130  fdEdxCalc.getS( s ,fdxTOL);
131  trackinfoobj.SetAvedEdxTrackLast10cm( fTrackInfoFxs->getAveTrackdEdxEnd(dE, dx, s, track->TotalLength(), 10.) );
132  trackinfoobj.SetAvedEdxTrackLast20cm( fTrackInfoFxs->getAveTrackdEdxEnd(dE, dx, s, track->TotalLength(), 20.) );
133  trackinfoobj.SetAvedEdxTrackLast30cm( fTrackInfoFxs->getAveTrackdEdxEnd(dE, dx, s, track->TotalLength(), 30.) );
134  trackinfoobj.SetAvedEdxTrackLast40cm( fTrackInfoFxs->getAveTrackdEdxEnd(dE, dx, s, track->TotalLength(), 40.) );
135  outputObjects->push_back(trackinfoobj);
136  util::CreateAssn(*this,evt,*(outputObjects.get()),track,*(assoc.get()));
137 
138  } // end of loop over tracks on slice
139 
140  } //loop over slices
141 
142  evt.put(std::move(outputObjects));
143  evt.put(std::move(assoc));
144 
145  } //end produce
146 
147 } //end namespace
148 
back track the reconstruction to the simulation
static bool CreateAssn(art::EDProducer const &prod, art::Event &evt, std::vector< T > &a, art::Ptr< U > b, art::Assns< T, U > &assn, size_t indx=UINT_MAX, std::string const &instance=std::string())
Create a 1 to 1 association between a new product and one already in the event.
void SetAvedEdxTrackLast20cm(float AvedEdxTrackLast20cm_val)
Definition: TrackInfoObj.h:25
void SetAvedEdxTrackLast30cm(float AvedEdxTrackLast30cm_val)
Definition: TrackInfoObj.h:26
Definition: event.h:19
bpfit::dEdxCalculator fdEdxCalc
helper class for computing dEdx values
void getS(std::vector< double > &stemp, double dxTol)
void computeDEDX(art::Ptr< rb::Track > &track, int pdg=13)
Compute dE/dx for all cells along this track and the fitsum object that went with it...
double fdxTOL
cut off value for dx, if dx is less than this, don&#39;t compute dE/dx
DEFINE_ART_MODULE(TestTMapFile)
double dE
void SetAvedEdxTrackLast40cm(float AvedEdxTrackLast40cm_val)
Definition: TrackInfoObj.h:27
Calculates dE/dx in cells passed through by a track.
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
virtual double TotalLength() const
Length (cm) of all the track segments.
Definition: Track.cxx:213
const XML_Char * s
Definition: expat.h:262
trackinfo::TrackInfoFxs * fTrackInfoFxs
double dx[NP][NC]
Result for CVN.
Encapsulate the geometry of one entire detector (near, far, ndos)
virtual TVector3 Dir() const
Unit vector describing prong direction.
Definition: Prong.h:77
TrackInfo(fhicl::ParameterSet const &pset)
float getAveTrackdEdxEnd(std::vector< double > &dEtemp, std::vector< double > &dxtemp, std::vector< double > &stemp, double trk_len, double wanted_dist)
void SetAvedEdxTrackLast10cm(float AvedEdxTrackLast10cm_val)
Definition: TrackInfoObj.h:24
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
Track information.
Definition: FillReco.h:12
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
void produce(art::Event &evt)
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
void geom(int which=0)
Definition: geom.C:163
std::string fCosmicTrackLabel
bool IsNoise() const
Is the noise flag set?
Definition: Cluster.h:163
void getDE(std::vector< double > &dEtemp, double dxTol)
...can also get the individual results...
Encapsulate the geometry of one entire detector (near, far, ndos)
void getDX(std::vector< double > &dxtemp, double dxTol)