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/Framework/Services/Registry/ServiceHandle.h"
29 #include "art_root_io/TFileService.h"
30 #include "art/Framework/Core/ModuleMacros.h"
31 #include "canvas/Persistency/Common/FindManyP.h"
32 #include "canvas/Utilities/Exception.h"
37 #include "messagefacility/MessageLogger/MessageLogger.h"
38 #include "fhiclcpp/ParameterSet.h"
39 #include "fhiclcpp/types/Table.h"
40 #include "fhiclcpp/types/Atom.h"
47 #include "TGraphAsymmErrors.h"
73 Name(
"SimModuleLabel"),
74 Comment(
"tag of detector simulation data product")
79 Comment(
"tag of CRT hit product")
84 Comment(
"Print information about what's going on")
89 Comment(
"Print detailed information about every track")
103 Name(
"MinAngleNpePlot"),
104 Comment(
"Minimum angle for plotting Npe per hit")
107 fhicl::Table<CRTEventDisplay::Config>
Evd {
112 Name(
"CrtBackTrack"),
126 virtual void analyze(
const art::Event& event)
override;
129 virtual void endJob()
override;
146 std::map<std::string, TH1D*>
hNpe;
171 , fSimModuleLabel (config().SimModuleLabel())
172 , fCRTHitLabel (config().CRTHitLabel())
173 , fVerbose (config().
Verbose())
174 , fVeryVerbose (config().VeryVerbose())
175 , fPlot (config().Plot())
176 , fPlotTrackID (config().PlotTrackID())
177 , fMinAngleNpePlot (config().MinAngleNpePlot())
178 , evd (config().Evd())
179 , fCrtBackTrack (config().CrtBackTrack())
187 art::ServiceHandle<art::TFileService>
tfs;
189 hNpeAngleCut = tfs->make<TH1D>(
"NpeAngleCut",
"", 60, 0, 600);
192 hRecoSipmDist[tagger] = tfs->make<TH1D>(Form(
"RecoSipmDist_%s", tagger.c_str()),
"", 40, -2, 13);
193 hTrueSipmDist[tagger] = tfs->make<TH1D>(Form(
"TrueSipmDist_%s", tagger.c_str()),
"", 40, -2, 13);
194 hHitTime[tagger] = tfs->make<TH1D>(Form(
"HitTime_%s", tagger.c_str()),
"", 40, -2000, 3000);
195 hNpe[tagger] = tfs->make<TH1D>(Form(
"Npe_%s", tagger.c_str()),
"", 60, 0, 600);
196 hAngle[tagger] = tfs->make<TH1D>(Form(
"Angle_%s", tagger.c_str()),
"", 40, 0, 1.6);
198 hEffWidthTotal[tagger] = tfs->make<TH1D>(Form(
"EffWidthTotal_%s", tagger.c_str()),
"", 20, 0, 11.2);
199 hEffWidthReco[tagger] = tfs->make<TH1D>(Form(
"EffWidthReco_%s", tagger.c_str()),
"", 20, 0, 11.2);
200 hEffLengthTotal[tagger] = tfs->make<TH1D>(Form(
"EffLengthTotal_%s", tagger.c_str()),
"", 20, 0, 450);
201 hEffLengthReco[tagger] = tfs->make<TH1D>(Form(
"EffLengthReco_%s", tagger.c_str()),
"", 20, 0, 450);
203 hTrueRecoSipmDist[tagger] = tfs->make<TH2D>(Form(
"TrueRecoSipmDist_%s", tagger.c_str()),
"", 30, -2, 13, 30, -2, 13);
204 hNpeAngle[tagger] = tfs->make<TH2D>(Form(
"NpeAngle_%s", tagger.c_str()),
"", 30, 0, 1.6, 30, 0, 600);
205 hNpeSipmDist[tagger] = tfs->make<TH2D>(Form(
"NpeSipmDist_%s", tagger.c_str()),
"", 30, 0, 11.2, 30, 0, 600);
206 hNpeStripDist[tagger] = tfs->make<TH2D>(Form(
"NpeStripDist_%s", tagger.c_str()),
"", 30, 0, 450, 30, 0, 600);
210 std::cout<<
"----------------- CRT Hit Reco Ana Module -------------------"<<std::endl;
219 std::cout<<
"============================================"<<std::endl
220 <<
"Run = "<<
event.run()<<
", SubRun = "<<
event.subRun()<<
", Event = "<<
event.id().event()<<std::endl
221 <<
"============================================"<<std::endl;
228 auto particleHandle =
event.getValidHandle<std::vector<simb::MCParticle>>(
fSimModuleLabel);
231 auto crtHitHandle =
event.getValidHandle<std::vector<sbn::crt::CRTHit>>(
fCRTHitLabel);
234 art::FindManyP<sbnd::crt::CRTData> findManyData(crtHitHandle, event,
fCRTHitLabel);
241 std::map<int, std::vector<sbn::crt::CRTHit>> crtHits;
242 double minHitTime = 99999;
243 double maxHitTime = -99999;
245 for(
auto const&
hit : (*crtHitHandle)){
248 if(trueId == -99999)
continue;
249 crtHits[trueId].push_back(
hit);
250 double hitTime = (double)(
int)
hit.ts1_ns * 1
e-3;
251 if(hitTime < minHitTime) minHitTime = hitTime;
252 if(hitTime > maxHitTime) maxHitTime = hitTime;
259 std::map<int, simb::MCParticle> particles;
260 for (
auto const& particle: (*particleHandle)){
261 int partId = particle.TrackId();
262 particles[partId] = particle;
265 double time = particle.T() * 1
e-3;
266 if(time < minHitTime || time > maxHitTime)
continue;
268 if(!(
std::abs(particle.PdgCode()) == 13 && particle.Mother()==0))
continue;
272 for(
auto const& stripName : stripNames){
282 if(crtHits.find(partId) == crtHits.end())
continue;
284 for(
size_t i = 0; i < crtHits[partId].size(); i++){
286 if(crtHits[partId][i].tagger == tagger) match =
true;
299 for(
auto const&
hit : (*crtHitHandle)){
303 double time = (double)(
int)
hit.ts1_ns * 1
e-3;
309 std::vector<art::Ptr<sbnd::crt::CRTData>> data = findManyData.at(hit_i);
312 std::vector<std::string> stripNames;
313 for(
auto const&
dat : data){
315 if(std::find(stripNames.begin(), stripNames.end(),
name) == stripNames.end())
316 stripNames.push_back(name);
322 if(particles.find(trueId) == particles.end())
continue;
323 if(!(
std::abs(particles[trueId].PdgCode()) == 13 && particles[trueId].Mother()==0))
continue;
328 hNpe[tagger]->Fill(
hit.peshit);
329 hAngle[tagger]->Fill(angle);
333 for(
auto const& stripName : stripNames){
358 auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(event);
std::map< std::string, TH2D * > hNpeAngle
void Draw(detinfo::DetectorClocksData const &clockData, const art::Event &event)
virtual void analyze(const art::Event &event) override
bool fVerbose
print information about what's going on
std::map< std::string, TH1D * > hEffLengthReco
virtual void beginJob() override
CRTTaggerGeo GetTagger(std::string taggerName) const
art::EDAnalyzer::Table< Config > Parameters
fhicl::Table< CRTEventDisplay::Config > Evd
geo::Point_t StripCrossingPoint(std::string stripName, const simb::MCParticle &particle)
std::map< std::string, TH2D * > hTrueRecoSipmDist
int fPlotTrackID
id of track to plot
std::map< std::string, TH1D * > hRecoSipmDist
bool fVeryVerbose
print more information about what's going on
double fMinAngleNpePlot
Maximum angle for plotting Npe per hit.
int TrueIdFromHitId(const art::Event &event, int hit_i)
fhicl::Atom< bool > VeryVerbose
fhicl::Atom< art::InputTag > CRTHitLabel
void Initialize(const art::Event &event)
std::map< std::string, TH1D * > hHitTime
std::map< std::string, TH1D * > hNpe
std::map< std::string, TH1D * > hAngle
art::InputTag fCRTHitLabel
name of CRT hit producer
fhicl::Table< CRTBackTracker::Config > CrtBackTrack
std::map< std::string, TH1D * > hEffWidthTotal
CRTHitRecoAna(Parameters const &config)
std::string ChannelToStripName(size_t channel) const
double DistanceDownStrip(geo::Point_t position, std::string stripName) const
BEGIN_PROLOG vertical distance to the surface Name
size_t NumTaggers() const
Definition of data types for geometry description.
std::string GetTaggerName(std::string name) const
fhicl::Atom< int > PlotTrackID
std::vector< std::string > CrossesStrips(const simb::MCParticle &particle)
fhicl::Atom< double > MinAngleNpePlot
double AngleToTagger(std::string taggerName, const simb::MCParticle &particle)
std::map< std::string, TH1D * > hTrueSipmDist
void SetDrawCrtTracks(bool tf)
std::map< std::string, TH1D * > hEffLengthTotal
std::map< std::string, TH2D * > hNpeStripDist
std::map< std::string, TH2D * > hNpeSipmDist
stream1 can override from command line with o or output services user sbnd
finds tracks best matching by angle
virtual void endJob() override
art::ServiceHandle< art::TFileService > tfs
std::map< std::string, TH1D * > hEffWidthReco
void SetDrawCrtHits(bool tf)
CRTBackTracker fCrtBackTrack
fhicl::Atom< bool > Verbose
Vector cross(Vector const &a, Vector const &b)
Return cross product of two vectors.
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
bool ValidCrossingPoint(std::string taggerName, const simb::MCParticle &particle)
void SetDrawCrtData(bool tf)
BEGIN_PROLOG could also be cout
art::InputTag fSimModuleLabel
name of detsim producer
fhicl::Atom< art::InputTag > SimModuleLabel
double DistanceBetweenSipms(geo::Point_t position, size_t channel) const