1 #ifndef RECOTOOL_SHOWERRECOALG_CXX 2 #define RECOTOOL_SHOWERRECOALG_CXX 28 std::vector < util::PxPoint > fStartPoint;
29 std::vector < util::PxPoint > fEndPoint;
30 std::vector < double > fOmega2D;
35 std::vector <unsigned char> fPlaneID;
38 for(
auto const & cl : clusters)
40 fStartPoint.push_back(cl.start_point);
41 fEndPoint.push_back(cl.end_point);
42 fOmega2D.push_back(cl.angle_2d);
43 fPlaneID.push_back(cl.plane_id);
45 std::cout <<
" planes : " << cl.plane_id
46 <<
" " << cl.start_point.t
47 <<
" " << cl.start_point.w
48 <<
" " << cl.end_point.t
49 <<
" " << cl.end_point.w
50 <<
" angle2d "<< cl.angle_2d
57 int index_to_use[2]={0,1};
62 for (
size_t ip=0;ip<fPlaneID.size();ip++)
64 double dist = fabs( fEndPoint[ip].
w - fStartPoint[ip].
w );
65 if(dist > best_length )
67 good_length = best_length;
69 index_to_use[1] = index_to_use[0];
72 best_plane = fPlaneID.at(ip);
75 else if(dist > good_length)
84 double xphi=0,xtheta=0;
88 fPlaneID[index_to_use[1]],
89 fOmega2D[index_to_use[0]]*TMath::Pi()/180.,
90 fOmega2D[index_to_use[1]]*TMath::Pi()/180.,
95 std::cout <<
" new angles: " << xphi <<
" " << xtheta << std::endl;
101 fGSer-> GetXYZ(&(fStartPoint[index_to_use[0]]),&(fStartPoint[index_to_use[1]]),xyz);
104 std::cout <<
" XYZ: " << xyz[0] <<
" " << xyz[1] <<
" " << xyz[2] << std::endl;
108 for(
size_t cl_index=0; cl_index < fPlaneID.size(); ++cl_index)
110 int plane = fPlaneID.at(cl_index);
112 if(plane == best_plane) best_length *= newpitch /
fGSer->
WireToCm();
115 std::cout << std::endl <<
" Plane: " << plane << std::endl;
118 double totLowEnergy=0;
119 double totHighEnergy=0;
120 double totMIPEnergy=0;
123 double dEdx_av=0,dedx_final=0;
124 int npoints_first=0, npoints_sec=0;
128 if(fabs(fOmega2D.at(cl_index)) < 90)
131 auto const& hitlist = clusters.at(cl_index).hit_vector;
132 std::vector<util::PxHit> local_hitlist;
133 local_hitlist.reserve(hitlist.size());
135 for(
const auto& theHit : hitlist){
138 double hitElectrons = 0;
172 if(plane < 2) multiplier =2 ;
174 totMIPEnergy += theHit.peak * 0.0061*multiplier;
177 totMIPEnergy += theHit.charge * 0.00336*multiplier;
181 if(
fVerbosity && dEdx_new >1.9 && dEdx_new <2.1)
182 std::cout <<
"dEdx_new " << dEdx_new <<
" " <<dEdx_new/theHit.charge*newpitch <<
" "<< theHit.charge *0.0033*multiplier/newpitch << std::endl;
187 &(fStartPoint.at(cl_index)),
196 double wdist=((theHit.w-fStartPoint.at(cl_index).w)*newpitch)*direction;
199 std::cout <<
" CALORIMETRY:" 200 <<
" Pitch " <<newpitch
201 <<
" dist: " << wdist
202 <<
" dE/dx: " << dEdx_new <<
"MeV/cm " 203 <<
" average: " << totEnergy
205 <<
"total energy" << totEnergy
234 && ((direction==1 && theHit.w > fStartPoint.at(cl_index).w) || (direction==-1 && theHit.w < fStartPoint.at(cl_index).w) )
239 local_hitlist.push_back(theHit);
243 std::cout <<
" CALORIMETRY:" <<
" Pitch " <<newpitch
244 <<
" dist: " << wdist
245 <<
" dE/dx: " << dEdx_new <<
"MeV/cm " 246 <<
" average: " << dEdx_av/npoints_first
247 <<
" hit: wire, time " << theHit.w <<
" " << theHit.t
248 <<
" line,ort " << linedist <<
" " << ortdist
249 <<
" direction " << direction
263 if(npoints_first>0) {
264 mevav2cm=dEdx_av/npoints_first;
269 for(
auto const & theHit : local_hitlist){
283 fRMS_corr+=(dEdx-mevav2cm)*(dEdx-mevav2cm);
291 fRMS_corr=TMath::Sqrt(fRMS_corr/npoints_first);
297 for(
auto const & theHit : local_hitlist){
310 if( ((dEdx > (mevav2cm-fRMS_corr) ) && (dEdx < (mevav2cm+fRMS_corr) ))
320 dedx_final/=npoints_sec;
325 std::cout <<
" total ENERGY, birks: " << totEnergy <<
" MeV " 326 <<
" |average: " << dedx_final << std::endl
327 <<
" Energy: lo:" << totLowEnergy <<
" hi: " << totHighEnergy
328 <<
" MIP corrected " << totMIPEnergy << std::endl;
333 fEnergy[plane] = totEnergy;
334 fMIPEnergy[plane] = totMIPEnergy;
335 fdEdx[plane] = dedx_final;
348 TVector3 vdirs(dirs[0],dirs[1],dirs[2]);
350 TVector3 vxyz(xyz[0], xyz[1], xyz[2]);
virtual ::recob::Shower RecoOneShower(const std::vector< ::showerreco::ShowerCluster_t > &)
Function to reconstruct a shower.
Class def header for a class ShowerRecoAlg.
static const GeometryUtilities * GetME()
Double_t Get2DDistance(Double_t wire1, Double_t time1, Double_t wire2, Double_t time2) const
double dEdx_AREA(art::Ptr< recob::Hit > hit, double pitch, double T0=0) const
::calo::CalorimetryAlg * fCaloAlg
Calorimetry algorithm.
bool _Ecorrection
Boolean -> decide if to use energy correction or not.
static const double DEFAULT_ECorr
void set_total_energy(const std::vector< double > &q)
Double_t TimeToCm() const
Double_t WireToCm() const
util::GeometryUtilities * fGSer
Double_t PitchInView(UInt_t plane, Double_t phi, Double_t theta) const
double ElectronsFromADCArea(double area, unsigned short plane) const
double ElectronsFromADCPeak(double adc, unsigned short plane) const
constexpr double kGeVToElectrons
23.6eV per ion pair, 1e9 eV/GeV
void set_direction(const TVector3 &dir)
bool fVerbosity
Verbosity flag.
void set_length(const double &l)
void set_total_best_plane(const int q)
void set_total_MIPenergy(const std::vector< double > &q)
Int_t GetPointOnLine(Double_t slope, Double_t intercept, Double_t wire1, Double_t time1, Double_t &wireout, Double_t &timeout) const
void GetDirectionCosines(Double_t phi, Double_t theta, Double_t *dirs) const
void set_start_point(const TVector3 &xyz)
double LifetimeCorrection(double time, double T0=0) const
ShowerRecoAlg()
Default constructor.
Int_t Get3DaxisN(Int_t iplane0, Int_t iplane1, Double_t omega0, Double_t omega1, Double_t &phi, Double_t &theta) const
double dEdx_AMP(art::Ptr< recob::Hit > hit, double pitch, double T0=0) const
void set_dedx(const std::vector< double > &q)