11 #include "art/Framework/Core/EDAnalyzer.h"
12 #include "art/Framework/Core/ModuleMacros.h"
13 #include "art/Framework/Principal/Event.h"
14 #include "art/Framework/Principal/Handle.h"
15 #include "art/Framework/Principal/Run.h"
16 #include "art/Framework/Principal/SubRun.h"
17 #include "canvas/Utilities/InputTag.h"
18 #include "fhiclcpp/ParameterSet.h"
19 #include "messagefacility/MessageLogger/MessageLogger.h"
20 #include "art_root_io/TFileService.h"
21 #include "art/Framework/Services/Registry/ServiceHandle.h"
24 #include "nusimdata/SimulationBase/GTruth.h"
25 #include "nusimdata/SimulationBase/MCTruth.h"
26 #include "nusimdata/SimulationBase/MCParticle.h"
42 #include <TEfficiency.h>
75 void analyze(art::Event
const&
e)
override;
79 bool IsAV(TVector3
const& point);
80 bool IsFV(TVector3
const& point);
133 fGenLabel(
p.get<art::InputTag>(
"GenLabel",
"generator")),
134 fSimLabel(
p.get<art::InputTag>(
"SimLabel",
"largeant")),
135 fCRTHitLabel(
p.get<art::InputTag>(
"CRTHitLabel",
"crthit")),
136 fFidXOut(
p.get<
double>(
"FiducialXOuter", 25.0)),
137 fFidXIn(
p.get<
double>(
"FiducialXInner", 0.0)),
138 fFidYTop(
p.get<
double>(
"FiducialYTop", 25.0)),
139 fFidYBot(
p.get<
double>(
"FiducialYBottom",25.0)),
140 fFidZUp(
p.get<
double>(
"FiducialZUpstream",30.0)),
141 fFidZDown(
p.get<
double>(
"FiducialZDownstream",50.0)),
145 fGeoService = lar::providerFrom<geo::Geometry>();
149 art::ServiceHandle<art::TFileService>
tfs;
151 Double_t bins[14] = {0.2,0.35,0.5,0.65,0.8,0.95,1.1,1.3,1.5,1.75,2.,3.,5.,10.};
152 fVetoEffAV =
new TEfficiency(
"effAV",
"#nu Veto Efficiency (AV)",13,bins);
153 fVetoEffFV =
new TEfficiency(
"effFV",
"#nu Veto Efficiency (FV)",13,bins);
154 fVetoEffAV_tot =
new TEfficiency(
"effAVTot",
"#nu Veto Efficiency (AV)",1,0,2);
155 fVetoEffFV_tot =
new TEfficiency(
"effFVTot",
"#nu Veto Efficiency (FV)",1,0,2);
158 fTree = tfs->make<TTree>(
"VetoTree",
"auto-veto info");
159 fTree->Branch(
"event", &fEvent,
"event/I");
160 fTree->Branch(
"numNu", &fNumNu,
"numNu/I");
161 fTree->Branch(
"nuPDG", &fNuPDG,
"nuPDG/I");
162 fTree->Branch(
"nuE", &fNuE,
"nuE/F");
163 fTree->Branch(
"cc", &fNuCC,
"cc/O");
164 fTree->Branch(
"av", &fNuAV,
"av/O");
165 fTree->Branch(
"fv", &fNuFV,
"fv/O");
166 fTree->Branch(
"nuXYZT", &fNuXYZT);
167 fTree->Branch(
"nuLepE", &fNuLepE,
"nuLepE/D");
168 fTree->Branch(
"nuTheta", &fNuTheta,
"nuTheta/D");
169 fTree->Branch(
"nuMode", &fNuMode,
"nuMode/I");
170 fTree->Branch(
"nuInt", &fNuInt,
"nuInt/I");
171 fTree->Branch(
"nHit", &fNHit,
"numHit/I");
172 fTree->Branch(
"hitReg", &fHitRegs);
173 fTree->Branch(
"hitXYZT", &fHitXYZT);
174 fTree->Branch(
"hitPDG", &fHitPDGs);
175 fTree->Branch(
"nHitPDG", &fNHitPDGs);
176 fTree->Branch(
"hitMaxPDG",&fHitMaxPDG);
177 fTree->Branch(
"dist", &fDist);
178 fTree->Branch(
"delay", &fDelay);
185 auto const& mctruths =
186 *ev.getValidHandle<vector<simb::MCTruth>>(
fGenLabel);
188 auto const& simparticles =
189 *ev.getValidHandle<vector<simb::MCParticle>>(
fSimLabel);
191 auto const& crthits =
192 *ev.getValidHandle<vector<sbn::crt::CRTHit>>(
fCRTHitLabel);
194 map< int, const simb::MCParticle*> particleMap;
198 fNHit = crthits.size();
201 for(
auto const& mctruth : mctruths) {
203 auto const&
nu = mctruth.GetNeutrino();
216 const TLorentzVector nuxyzt = mctruth.GetNeutrino().Nu().Position(0);
217 const TVector3 point = nuxyzt.Vect();
218 fNuXYZT = {nuxyzt.X(), nuxyzt.Y(), nuxyzt.Z(), nuxyzt.T()};
227 for(
auto const& particle : simparticles){
229 particleMap[particle.TrackId()] = &particle;
242 for(
auto const&
hit : crthits) {
243 std::cout <<
"found hit in region, " <<
hit.tagger << std::endl;
251 if(particleMap.find(
id)==particleMap.end())
continue;
252 fHitPDGs.back().push_back(particleMap[
id]->PdgCode());
258 if(maxid<0 || particleMap.find(maxid)==particleMap.end())
261 fHitMaxPDG.push_back(particleMap[maxid]->PdgCode());
265 fDist.push_back(sqrt(dist));
process_name opflashCryo1 flashfilter analyze
bool IsFV(TVector3 const &point)
Utilities related to art service access.
bool IsAV(TVector3 const &point)
void analyze(art::Event const &e) override
TEfficiency * fVetoEffFV_tot
Geometry information for a single TPC.
vector< vector< int > > fHitPDGs
TEfficiency * fVetoEffAV_tot
Geometry information for a single cryostat.
int AuxDetRegionNameToNum(string reg)
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Access the description of detector geometry.
geo::GeometryCore const * fGeoService
CryostatGeo const & Cryostat(geo::CryostatID const &cryoid) const
Returns the specified cryostat.
Description of geometry of one entire detector.
CRTAutoVeto(fhicl::ParameterSet const &p)
bool InFiducialY(double y, double neg_margin, double pos_margin) const
Returns whether TPC fiducial volume contains world y coordinate.
constexpr double dist(const TReal *x, const TReal *y, const unsigned int dimension)
const TPCGeo & TPC(unsigned int itpc) const
Return the itpc'th TPC in the cryostat.
std::vector< int > AllTrueIds(const art::Event &event, const CRTData &data)
int TrueIdFromTotalEnergy(const art::Event &event, const CRTData &data)
art::InputTag fCRTHitLabel
vector< vector< float > > fHitXYZT
art::ServiceHandle< art::TFileService > tfs
bool InFiducialX(double x, double neg_margin, double pos_margin) const
Returns whether TPC fiducial volume contains world x coordinate.
bool InFiducialZ(double z, double neg_margin, double pos_margin) const
Returns whether TPC fiducial volume contains world z coordinate.
bool ContainsPosition(geo::Point_t const &point, double wiggle=1.0) const
Returns whether this volume contains the specified point.
art framework interface to geometry description
BEGIN_PROLOG could also be cout