22 #include "nusimdata/SimulationBase/MCParticle.h"
25 #include "art/Framework/Core/EDAnalyzer.h"
26 #include "art/Framework/Principal/Event.h"
27 #include "art/Framework/Principal/Handle.h"
28 #include "art_root_io/TFileService.h"
29 #include "canvas/Persistency/Common/FindManyP.h"
34 #include "fhiclcpp/ParameterSet.h"
35 #include "fhiclcpp/types/Table.h"
36 #include "fhiclcpp/types/Atom.h"
54 Name(
"SimModuleLabel"),
55 Comment(
"tag of detector simulation data product")
60 Comment(
"tag of CRT hit producer data product")
64 Name(
"CRTTrackLabel"),
65 Comment(
"tag of CRT track producer data product")
69 Name(
"TPCTrackLabel"),
70 Comment(
"tag of TPC track producer data product")
75 Comment(
"Print information about what's going on")
83 Name(
"CRTTrackMatch"),
97 virtual void analyze(
const art::Event& event)
override;
100 virtual void endJob()
override;
127 , fSimModuleLabel (config().SimModuleLabel())
128 , fCRTHitLabel (config().CRTHitLabel())
129 , fCRTTrackLabel (config().CRTTrackLabel())
131 , fVerbose (config().
Verbose())
132 , fCRTHitMatch (config().CRTHitMatch())
133 , fCRTTrackMatch (config().CRTTrackMatch())
143 if(
fVerbose)
std::cout<<
"----------------- Running CRT t0 tagging example -------------------"<<std::endl;
153 std::cout<<
"============================================"<<std::endl
154 <<
"Run = "<<
event.run()<<
", SubRun = "<<
event.subRun()<<
", Event = "<<
event.id().event()<<std::endl
155 <<
"============================================"<<std::endl;
163 auto particleHandle =
event.getValidHandle<std::vector<simb::MCParticle>>(
fSimModuleLabel);
165 std::map<int, simb::MCParticle> particles;
166 for (
auto const& particle: (*particleHandle)){
167 int partID = particle.TrackId();
168 particles[partID] = particle;
172 auto crtHitHandle =
event.getValidHandle<std::vector<sbn::crt::CRTHit>>(
fCRTHitLabel);
173 std::vector<sbn::crt::CRTHit> crtHits;
174 for(
auto const&
hit : (*crtHitHandle)){
175 crtHits.push_back(
hit);
179 auto crtTrackHandle =
event.getValidHandle<std::vector<sbn::crt::CRTTrack>>(
fCRTTrackLabel);
180 std::vector<sbn::crt::CRTTrack> crtTracks;
181 for(
auto const&
track : (*crtTrackHandle)){
182 crtTracks.push_back(
track);
186 auto tpcTrackHandle =
event.getValidHandle<std::vector<recob::Track>>(
fTPCTrackLabel);
189 art::FindManyP<recob::Hit> findManyHits(tpcTrackHandle, event,
fTPCTrackLabel);
195 auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(event);
196 auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(event, clockData);
199 for (
auto const& tpcTrack : (*tpcTrackHandle)){
201 std::vector<art::Ptr<recob::Hit>> hits = findManyHits.at(tpcTrack.ID());
205 if(particles.find(trackTrueID) == particles.end())
continue;
208 if(!(
std::abs(particles[trackTrueID].PdgCode()) == 13 && particles[trackTrueID].Mother() == 0))
continue;
211 double trueTime = particles[trackTrueID].T() * 1
e-3;
228 if(trackT0 == -99999){
248 <<
"-- CRT hit matching:\n"
251 <<
"-- CRT track matching:\n"
fhicl::Atom< art::InputTag > CRTHitLabel
fhicl::Atom< art::InputTag > TPCTrackLabel
art::EDAnalyzer::Table< Config > Parameters
virtual void analyze(const art::Event &event) override
virtual void beginJob() override
fhicl::Atom< art::InputTag > CRTTrackLabel
Declaration of signal hit object.
process_name use argoneut_mc_hitfinder track
fhicl::Table< CRTTrackMatchAlg::Config > CRTTrackMatch
art::InputTag fCRTHitLabel
name of CRT hit producer
fhicl::Atom< art::InputTag > SimModuleLabel
RunningT0Tagging(Parameters const &config)
art::InputTag fSimModuleLabel
name of detsim producer
BEGIN_PROLOG vertical distance to the surface Name
int TrueParticleIDFromTotalRecoHits(detinfo::DetectorClocksData const &clockData, const std::vector< art::Ptr< recob::Hit > > &hits, bool rollup_unsaved_ids=1)
CRTT0MatchAlg fCRTHitMatch
CRT hit - TPC track matching algorithms.
BEGIN_PROLOG don t mess with this TPCTrackLabel
Provides recob::Track data product.
CRTTrackMatchAlg fCRTTrackMatch
CRT track - TPC track matching algorithms.
double T0FromCRTHits(detinfo::DetectorPropertiesData const &detProp, recob::Track tpcTrack, std::vector< sbn::crt::CRTHit > crtHits, const art::Event &event)
bool fVerbose
print information about what's going on
fhicl::Atom< bool > Verbose
virtual void endJob() override
stream1 can override from command line with o or output services user sbnd
double T0FromCRTTracks(detinfo::DetectorPropertiesData const &detProp, recob::Track tpcTrack, std::vector< sbn::crt::CRTTrack > crtTracks, const art::Event &event)
art::InputTag fTPCTrackLabel
name of TPC track producer
art::InputTag fCRTTrackLabel
name of CRT track producer
fhicl::Table< CRTT0MatchAlg::Config > CRTHitMatch
BEGIN_PROLOG could also be cout