43 #include "canvas/Persistency/Common/FindManyP.h" 49 #include "art_root_io/TFileService.h" 56 #include "TLorentzVector.h" 105 bool Has(std::vector<int> v,
int i)
const;
114 void Make_dEdx( std::vector< double > &
dEdx,
115 std::vector< double > & range,
116 const std::vector< proto::bHitInfo > & hits,
119 int GetClosestBeamTrkId()
const;
121 void SetBeamWindowEnd();
159 std::vector< art::Ptr<simb::MCParticle> >
fSimlist;
181 fCalorimetryAlg(p.
get<
fhicl::ParameterSet>(
"CalorimetryAlg"))
203 fTree = tfs->make<TTree>(
"calibration",
"calibration tree");
210 fDataTree = tfs->make<TTree>(
"Data",
"dE/dx info");
227 fX0 = p.
get<
double>(
"BeamPosX");
228 fY0 = p.
get<
double>(
"BeamPosY");
229 fZ0 = p.
get<
double>(
"BeamPosZ");
237 fPdg = p.
get< std::vector<int> >(
"Pdg");
248 std::vector< art::Ptr<simb::MCParticle> > simlist;
251 if (mcparticleHandle)
254 std::map< int, const simb::MCParticle* > particleMap;
255 for (
auto const& particle : simlist)
257 particleMap[particle->TrackId()] = &*particle;
260 fSimPdg = particleMap.begin()->second->PdgCode();
261 fT0 = particleMap.begin()->second->T();
267 && (particleMap.size() == 1)
268 && (particleMap.begin()->second->EndProcess() !=
"ProtonInelastic"))
288 && (particleMap.begin()->second->EndProcess() ==
"Decay")
289 && (particleMap.begin()->second->NumberDaughters() == 2)
290 && (particleMap.size() == 6))
292 bool kaonmodedcy =
false;
294 for (
auto const &
p : particleMap)
296 if ((
p.second->PdgCode() == 321) ||
297 (
p.second->PdgCode() == -13) ||
298 (
p.second->PdgCode() == 14))
304 if (count == 3)
break;
315 && (particleMap.begin()->second->EndProcess() ==
"Decay"))
378 if (hitFromTrk.size() && (idt > -1))
381 if ((*
fTrkListHandle)[idt].End().Z() < (*fTrkListHandle)[idt].Vertex().Z())
384 auto vhit = hitFromTrk.at(idt);
385 auto vmeta = hitFromTrk.data(idt);
387 for (
size_t h = 0;
h < vhit.size(); ++
h)
389 int view = vhit[
h]->WireID().Plane;
393 size_t idx = vmeta[
h]->Index();
394 double tdrift = vhit[
h]->PeakTime();
395 double dx = vmeta[
h]->Dx();
396 double dqadc = vhit[
h]->Integral();
397 int wire = vhit[
h]->WireID().Wire;
402 fTrk2InfoMap[idt][view].emplace_back(idx, dx, dq, wire);
407 std::vector< double >
dEdx, range;
408 auto const &
info = trkEntry.second;
411 for (
size_t i = 0; i < dEdx.size(); ++i)
430 auto const & trk0 = (*fTrkListHandle)[0];
432 if (trk0.End().Z() < trk0.Vertex().Z())
445 auto const &
trk = (*fTrkListHandle)[
t];
448 if (
trk.End().Z() <
trk.Vertex().Z())
462 if (dist2 < mindist2) {mindist2 = dist2; idt =
t;}
470 if (!hits.size())
return;
472 dEdx.clear(); range.clear();
474 int i0 = hits.size() - 1;
int i1 = -1;
int di = -1;
479 double r0 = 0.0;
double r1 = 0.0;
double r = 0.0;
483 while ((i0 != i1) && (r < rmax))
486 while ((i0 != i1) && (dx <= minDx))
497 if ((de > 0.0) && (dx > 0.0) && (r < rmax))
499 dEdx.push_back(de/dx);
510 if (simchannelHandle)
512 for (
auto const&
channel : (*simchannelHandle) )
515 auto const& timeSlices =
channel.TDCIDEMap();
516 for (
auto const& timeSlice : timeSlices )
519 auto const& energyDeposits = timeSlice.second;
521 for (
auto const& energyDeposit : energyDeposits )
541 unsigned short plane =
fHitlist[
h]->WireID().Plane;
542 if (plane !=
geo::kZ)
continue;
545 if (!std::isnormal(dqadc) || (dqadc < 0))
continue;
553 if (!std::isnormal(dq) || (dq < 0))
continue;
563 for (
auto c : v)
if (
c == i)
return true;
573 double dx = dz * tan(
fThXZ * (TMath::Pi() / 180.0));
574 double dy = dz * tan(
fThYZ * (TMath::Pi() / 180.0));
def analyze(root, level, gtrees, gbranches, doprint)
calo::CalorimetryAlg fCalorimetryAlg
Store parameters for running LArG4.
std::string fVertexModuleLabel
std::vector< art::Ptr< recob::Hit > > fHitlist
std::vector< art::Ptr< simb::MCParticle > > fSimlist
art::Handle< std::vector< recob::Track > > fTrkListHandle
double Dist2(const TVector2 &v1, const TVector2 &v2)
Handle< PROD > getHandle(SelectorBase const &) const
std::string fShowerModuleLabel
std::string fClusterModuleLabel
Planes which measure Z direction.
int GetClosestBeamTrkId() const
std::string fTrackModuleLabel
art framework interface to geometry description
double ElectronsFromADCArea(double area, unsigned short plane) const
std::string fHitsModuleLabel
double dEdx(float dqdx, float Efield)
#define DEFINE_ART_MODULE(klass)
TH1D * fMomentumStartHist
virtual void reconfigure(fhicl::ParameterSet const &pset)
double GetEdepHits(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp) const
std::vector< art::Ptr< recob::Vertex > > fVertexlist
T get(std::string const &key) const
General LArSoft Utilities.
std::string fSimulationLabel
geo::GeometryCore const * fGeometry
ECalibration(fhicl::ParameterSet const &p)
Description of geometry of one entire detector.
bHitInfo(size_t i, double x, double e, int w)
void Make_dEdx(std::vector< double > &dEdx, std::vector< double > &range, const std::vector< proto::bHitInfo > &hits, double rmax) const
void analyze(art::Event const &e) override
void beginRun(const art::Run &run) override
Implementation of the Projection Matching Algorithm.
Declaration of signal hit object.
double GetEdepMC(art::Event const &e) const
Contains all timing reference information for the detector.
Provides recob::Track data product.
double dEdx_AREA(detinfo::DetectorClocksData const &clock_data, detinfo::DetectorPropertiesData const &det_prop, recob::Hit const &hit, double pitch, double T0=0) const
bool Has(std::vector< int > v, int i) const
EventNumber_t event() const
Access the description of detector geometry.
bool EvMCselect(art::Event const &e)
std::vector< art::Ptr< recob::Track > > fTracklist
void reconfigure(fhicl::ParameterSet const &p)
auto const & get(AssnsNode< L, R, D > const &r)
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
double LifetimeCorrection(detinfo::DetectorClocksData const &clock_data, detinfo::DetectorPropertiesData const &det_prop, double time, double T0=0) const
Collection of Physical constants used in LArSoft.
std::vector< art::Ptr< recob::Shower > > fShslist
std::map< size_t, std::vector< proto::bHitInfo >[3] > fTrk2InfoMap
double GeVToElectrons() const
std::string fCalorimetryModuleLabel