33 #include "canvas/Persistency/Common/FindManyP.h" 39 #include "art_root_io/TFileService.h" 48 #include "TLorentzVector.h" 85 const std::vector< recob::Hit > & hits)
const;
93 const std::vector < recob::TrackHitMeta const* > &
data);
100 const std::vector< recob::Hit > & hits)
const;
115 const std::vector< recob::Hit > & hits)
const;
175 file.open(
"dump.txt");
186 fTree = tfs->make<TTree>(
"calibration",
"calibration tree");
212 fTree->Branch(
"fT0", &
fT0,
"fT0/D");
214 fTreeEntries = tfs->make<TTree>(
"entries",
"entries tree");
252 for (
auto const&
p : *particleHandle)
255 if ((
p.Process() ==
"primary") && flag)
258 fEkGen = (std::sqrt(
p.P()*
p.P() +
p.Mass()*
p.Mass()) -
p.Mass()) * 1000;
284 std::unordered_map<int, bool> hitIDE;
287 const art::FindManyP< recob::Hit > hitsFromCluster(cluResults->dataHandle(),
e, cluResults->dataTag());
289 for (
size_t c = 0;
c < cluResults->size(); ++
c)
291 for (
size_t h = 0;
h < hitsFromCluster.at(
c).size(); ++
h)
295 hitIDE[hitsFromCluster.at(
c)[
h].key()] =
false;
304 art::FindManyP< recob::PFParticle > pfpFromTrack(trkHandle, e,
fTrackModuleLabel);
307 const art::FindManyP< recob::Hit > hitsFromTracks(trkHandle, e,
fTrackModuleLabel);
308 const art::FindManyP<recob::Hit, recob::TrackHitMeta> fmthm(trkHandle, e,
fTrackModuleLabel);
313 for (
size_t t = 0;
t < trkHandle->size(); ++
t)
315 auto vhit = fmthm.at(
t);
316 auto vmeta = fmthm.data(
t);
319 for (
size_t h = 0;
h < hitsFromTracks.at(
t).size(); ++
h)
323 hitIDE[hitsFromTracks.at(
t)[
h].key()] =
true;
327 int nplanes = calFromTracks.at(
t).size();
329 for (
size_t p = 0;
p < pfpFromTrack.at(
t).size(); ++
p)
331 int pdg = pfpFromTrack.at(
t)[
p]->PdgCode();
333 if ((pdg != 11) && (pdg != -11))
341 for (
size_t h = 0;
h < hitsFromTracks.at(
t).size(); ++
h)
353 for (
size_t h = 0;
h < hitsFromTracks.at(
t).size(); ++
h)
371 const art::FindManyP< recob::Hit > hitsFromCluster(cluResults->dataHandle(),
e, cluResults->dataTag());
374 for (
size_t c = 0;
c < cluResults->size(); ++
c)
378 std::array< float, MVA_LENGTH > cnn_out = cluResults->getOutput(
c);
379 double p_trk_or_sh = cnn_out[0] + cnn_out[1];
381 if (p_trk_or_sh > 0) pdg = cnn_out[1] / p_trk_or_sh;
383 for (
size_t h = 0;
h < hitsFromCluster.at(
c).size(); ++
h)
385 if (hitIDE[hitsFromCluster.at(
c)[
h].key()] ==
false)
387 hitIDE[hitsFromCluster.at(
c)[
h].key()] =
true;
421 const std::vector < recob::TrackHitMeta const* > &
data)
425 if (!hits.size())
return ekin;
428 for (
size_t h = 0;
h < hits.size(); ++
h)
430 double dqadc = hits[
h]->Integral();
431 if (!std::isnormal(dqadc) || (dqadc < 0)) dqadc = 0.0;
433 unsigned short plane = hits[
h]->WireID().Plane;
434 unsigned short time = hits[
h]->PeakTime();
440 if ((
fdx > 0) && (
fdQ > 0))
448 else if ((
fdx == 0) && (
fdQ > 0))
463 const std::vector< recob::Hit > & hits)
const 465 if (!hits.size())
return 0.0;
468 for (
size_t h = 0;
h < hits.size(); ++
h)
470 double dqadc = hits[
h].Integral();
471 if (!std::isnormal(dqadc) || (dqadc < 0))
continue;
473 unsigned short plane = hits[
h].WireID().Plane;
476 double tdrift = hits[
h].PeakTime();
482 if (!std::isnormal(dq) || (dq < 0))
continue;
498 if (!std::isnormal(dqadc) || (dqadc < 0)) dqadc = 0.0;
506 if (!std::isnormal(dq) || (dq < 0)) dq = 0.0;
516 if (!std::isnormal(dqadc) || (dqadc < 0)) dqadc = 0.0;
522 double correllifetime = 1;
524 if (!std::isnormal(dq) || (dq < 0)) dq = 0.0;
536 if (simchannelHandle)
538 for (
auto const&
channel : (*simchannelHandle) )
543 auto const& timeSlices =
channel.TDCIDEMap();
544 for (
auto const& timeSlice : timeSlices )
547 auto const& energyDeposits = timeSlice.second;
549 for (
auto const& energyDeposit : energyDeposits )
551 double energy = energyDeposit.energy;
552 int trackID = energyDeposit.trackID;
558 else if (trackID > 0)
572 if (!pdg) pdg = particle.
PdgCode();
575 if ((pdg == 11) || (pdg == -11) || (pdg == 22)) enEM +=
energy;
594 if (simchannelHandle)
596 for (
auto const&
channel : (*simchannelHandle) )
601 auto const& timeSlices =
channel.TDCIDEMap();
602 for (
auto const& timeSlice : timeSlices )
605 auto const& energyDeposits = timeSlice.second;
607 for (
auto const& energyDeposit : energyDeposits )
610 int trackID = energyDeposit.trackID;
616 else if (trackID > 0)
630 if (!pdg) pdg = particle.
PdgCode();
633 if ((pdg == 11) || (pdg == -11) || (pdg == 22)) enEM +=
energy;
650 const std::vector< recob::Hit > & hits)
const 652 double totemhit = 0.0;
655 const std::vector< sim::SimChannel > &
channels = *simChannelHandle;
657 for (
auto const &
hit: hits)
660 auto hitChannelNumber =
hit.Channel();
662 double hitEn = 0.0;
double hitEnSh = 0;
664 for (
auto const &
channel: channels)
666 if (
channel.Channel() != hitChannelNumber)
continue;
670 auto const& timeSlices =
channel.TDCIDEMap();
671 for (
auto const& timeSlice : timeSlices )
673 int time = timeSlice.first;
677 auto const& energyDeposits = timeSlice.second;
679 for (
auto const& energyDeposit : energyDeposits )
681 int trackID = energyDeposit.trackID;
689 else if (trackID > 0)
703 if (!pdg) pdg = particle.
PdgCode();
706 if ((pdg == 11) || (pdg == -11) || (pdg == 22)) hitEnSh +=
energy;
716 ratio = hitEnSh / hitEn;
736 if (simchannelHandle)
739 for (
auto const &
channel : (*simchannelHandle) )
744 auto const& timeSlices =
channel.TDCIDEMap();
745 for (
auto const& timeSlice : timeSlices)
748 auto const & energyDeposits = timeSlice.second;
750 for (
auto const & energyDeposit : energyDeposits)
752 double energy = energyDeposit.energy;
753 int trackID = energyDeposit.trackID;
756 else if (trackID > 0)
765 if ((pdg == 11) || (pdg == -11) || (pdg == 22)) {}
771 else {
mf::LogWarning(
"TrainingDataAlg") <<
"PARTICLE NOT FOUND"; }
788 if (simchannelHandle)
791 for (
auto const &
channel : (*simchannelHandle) )
796 auto const& timeSlices =
channel.TDCIDEMap();
797 for (
auto const& timeSlice : timeSlices)
800 auto const & energyDeposits = timeSlice.second;
802 for (
auto const & energyDeposit : energyDeposits)
805 int trackID = energyDeposit.trackID;
808 else if (trackID > 0)
817 if ((pdg == 11) || (pdg == -11) || (pdg == 22)) {}
823 else {
mf::LogWarning(
"TrainingDataAlg") <<
"PARTICLE NOT FOUND"; }
838 const std::vector< recob::Hit > & hits)
const 840 double tothadhit = 0.0;
843 const std::vector< sim::SimChannel > &
channels = *simChannelHandle;
845 for (
auto const &
hit: hits)
848 auto hitChannelNumber =
hit.Channel();
850 double hitEn = 0.0;
double hitEnTrk = 0;
852 for (
auto const &
channel : channels)
854 if (
channel.Channel() != hitChannelNumber)
continue;
858 auto const& timeSlices =
channel.TDCIDEMap();
859 for (
auto const& timeSlice : timeSlices)
861 int time = timeSlice.first;
865 auto const & energyDeposits = timeSlice.second;
867 for (
auto const & energyDeposit : energyDeposits)
869 int trackID = energyDeposit.trackID;
875 else if (trackID > 0)
883 if ((pdg == 11) || (pdg == -11) || (pdg == 22)) {}
884 else {hitEnTrk +=
energy;}
886 else {
mf::LogWarning(
"TrainingDataAlg") <<
"PARTICLE NOT FOUND"; }
896 ratio = hitEnTrk / hitEn;
code to link reconstructed objects back to the MC truth information
Store parameters for running LArG4.
geo::GeometryCore const * fGeometry
HadCal(fhicl::ParameterSet const &p)
std::string fHitModuleLabel
Container of LAr voxel information.
Handle< PROD > getHandle(SelectorBase const &) const
geo::WireID WireID() const
void analyze(art::Event const &e) override
double GetEdepHitsMeV(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const std::vector< recob::Hit > &hits) const
std::string fTrackModuleLabel
float Integral() const
Integral under the calibrated signal waveform of the hit, in tick x ADC units.
EDAnalyzer(fhicl::ParameterSet const &pset)
std::string fSimulationLabel
void reconfigure(fhicl::ParameterSet const &p)
art framework interface to geometry description
double fEdepHADcorr_ellifetime_reco
std::string fCalorimetryModuleLabel
art::InputTag fNNetModuleLabel
double ElectronsFromADCArea(double area, unsigned short plane) const
double GetEhitMeVcorrel(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const recob::Hit &hit) const
std::string fClusterModuleLabel
HadCal & operator=(HadCal const &)=delete
Encapsulates the information we want store for a voxel.
#define DEFINE_ART_MODULE(klass)
T get(std::string const &key) const
double GetEdepHADAtt_MC(art::Event const &e) const
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
General LArSoft Utilities.
PlaneID_t Plane
Index of the plane within its TPC.
Description of geometry of one entire detector.
View_t View(geo::PlaneID const &pid) const
Returns the view (wire orientation) on the channels of specified TPC plane.
Detector simulation of raw signals on wires.
double GetEhitMeV(const recob::Hit &hit) const
float PeakTime() const
Time of the signal peak, in tick units.
Declaration of signal hit object.
Contains all timing reference information for the detector.
calo::CalorimetryAlg fCalorimetryAlg
double GetEdepEM_MC(art::Event const &e) const
std::unordered_map< int, const simb::MCParticle * > fParticleMap
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
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
EventNumber_t event() const
double GetEdepHADhAtt_MC(art::Event const &e, detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const std::vector< recob::Hit > &hits) const
Access the description of detector geometry.
2D representation of charge deposited in the TDC/wire plane
auto const & get(AssnsNode< L, R, D > const &r)
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.
double GetEdepEMhAtt_MC(art::Event const &e, detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const std::vector< recob::Hit > &hits) const
double GetEdepHAD_MC(art::Event const &e) const
static std::unique_ptr< MVAReader > create(const art::Event &evt, const art::InputTag &tag)
double GeVToElectrons() const
double GetEdepEMAtt_MC(art::Event const &e) const
double GetEkinMeV(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const std::vector< art::Ptr< recob::Hit > > &hits, const std::vector< recob::TrackHitMeta const * > &data)
double fEdepEMcorr_ellifetime_reco