4 #include "TGeoManager.h"
7 #include "art/Framework/Core/EDFilter.h"
8 #include "art/Framework/Core/ModuleMacros.h"
9 #include "art/Framework/Principal/Event.h"
17 #include "nusimdata/SimulationBase/MCTruth.h"
24 virtual bool filter(art::Event&
e)
override;
59 bool UsesCRTAuxDets(
const art::Ptr<simb::MCParticle> particle,
const std::vector<unsigned int> &crt_auxdet_vector);
60 bool EntersTPC(
const art::Ptr<simb::MCParticle> particle);
61 std::pair<double, double>
XLimitsTPC(
const art::Ptr<simb::MCParticle> particle);
71 auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataForJob();
72 auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataForJob(clockData);
73 double rw_ticks =
detProp.ReadOutWindowSize();
74 double inv_samp_freq = clockData.TPCClock().Frequency();
93 fPDGs = pset.get<std::vector<int> >(
"PDGs");
94 fMinMomentums = pset.get<std::vector<double> >(
"MinMomentums");
95 fMaxMomentums = pset.get<std::vector<double> >(
"MaxMomentums");
99 fUseTPC = pset.get<
bool>(
"UseTPC");
104 art::Handle<std::vector<simb::MCParticle> > particles;
107 auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(e);
109 for (
unsigned int part_i = 0; part_i < particles->size(); part_i++){
110 const art::Ptr<simb::MCParticle> particle(particles,part_i);
115 double time = particle->T() * 1e-3;
119 std::pair<double, double> xLimits =
XLimitsTPC(particle);
179 double mom = particle->Momentum().Vect().Mag();
180 int pdg = particle->PdgCode();
182 for (
unsigned int particle_i = 0; particle_i <
fPDGs.size(); particle_i++){
189 if (
fPDGs[particle_i]!=0 && pdg!=
fPDGs[particle_i]) matched =
false;
190 if(matched)
return true;
197 art::ServiceHandle<geo::Geometry> geom;
199 for (
unsigned int auxdet_i = 0; auxdet_i < geom->NAuxDets(); auxdet_i++){
202 std::set<std::string> volNames = { volModule->GetName() };
203 std::vector<std::vector<TGeoNode const*> > paths = geom->FindAllVolumePaths(volNames);
205 std::string
path =
"";
206 for (
size_t inode=0; inode<paths.at(0).size(); inode++) {
207 path += paths.at(0).at(inode)->GetName();
208 if (inode < paths.at(0).size() - 1) {
213 TGeoManager* manager = geom->ROOTGeoManager();
214 manager->cd(path.c_str());
216 manager->GetCurrentNode();
217 manager->GetMother(1);
218 TGeoNode* nodeTagger = manager->GetMother(2);
220 std::string taggerName = nodeTagger->GetName();
224 if (taggerName.find(
"TopHigh")!=std::string::npos){
227 else if (taggerName.find(
"TopLow")!=std::string::npos){
230 else if (taggerName.find(
"Bot")!=std::string::npos){
233 else if (taggerName.find(
"South")!=std::string::npos){
236 else if (taggerName.find(
"North")!=std::string::npos){
239 else if (taggerName.find(
"West")!=std::string::npos){
242 else if (taggerName.find(
"East")!=std::string::npos){
246 std::cout <<
"Tagger with name: " << taggerName
247 <<
" does not fit the logic. This should not happen!!!!!!" << std::endl;
264 art::ServiceHandle<geo::Geometry> geom;
270 for (
unsigned int pt_i = 0; pt_i < particle->NumberTrajectoryPoints(); pt_i++){
272 TLorentzVector position_lvector = particle->Position(pt_i);
275 position[0] = position_lvector.X();
276 position[1] = position_lvector.Y();
277 position[2] = position_lvector.Z();
280 unsigned int crt_id = geom->FindAuxDetAtPosition(position);
284 for (
unsigned int crt_i = 0; crt_i < crt_auxdet_vector.size(); crt_i++){
285 if (crt_id == crt_auxdet_vector[crt_i]){
313 int nTrajPoints = particle->NumberTrajectoryPoints();
314 for (
int traj_i = 0; traj_i < nTrajPoints; traj_i++){
315 TVector3 trajPoint(particle->Vx(traj_i), particle->Vy(traj_i), particle->Vz(traj_i));
317 if (trajPoint[0] >= xmin && trajPoint[0] <= xmax && trajPoint[1] >= ymin && trajPoint[1] <= ymax && trajPoint[2] >= zmin && trajPoint[2] <= zmax){
332 double minimum = 99999;
333 double maximum = -99999;
335 int nTrajPoints = particle->NumberTrajectoryPoints();
336 for (
int traj_i = 0; traj_i < nTrajPoints; traj_i++){
337 TVector3 trajPoint(particle->Vx(traj_i), particle->Vy(traj_i), particle->Vz(traj_i));
339 if (trajPoint[0] >= xmin && trajPoint[0] <= xmax && trajPoint[1] >= ymin && trajPoint[1] <= ymax && trajPoint[2] >= zmin && trajPoint[2] <= zmax){
344 return std::make_pair(minimum, maximum);
std::vector< unsigned int > fTopLowCRTAuxDetIDs
bool IsInterestingParticle(const art::Ptr< simb::MCParticle > particle)
Utilities related to art service access.
geo::Length_t DetHalfWidth(geo::TPCID const &tpcid) const
Returns the half width of the active volume of the specified TPC.
LArG4CRTFilter(fhicl::ParameterSet const &pset)
std::vector< unsigned int > fRightCRTAuxDetIDs
std::vector< unsigned int > fLeftCRTAuxDetIDs
std::vector< unsigned int > fTopHighCRTAuxDetIDs
std::vector< unsigned int > fFrontCRTAuxDetIDs
bool EntersTPC(const art::Ptr< simb::MCParticle > particle)
bool UsesCRTAuxDets(const art::Ptr< simb::MCParticle > particle, const std::vector< unsigned int > &crt_auxdet_vector)
virtual bool filter(art::Event &e) override
process_name pandoraGausCryo1 vertexChargeCryo1 vertexStubCryo1 xmin
BEGIN_PROLOG triggeremu_data_config_icarus settings PMTADCthresholds sequence::icarus_stage0_multiTPC_TPC physics sequence::icarus_stage0_EastHits_TPC physics sequence::icarus_stage0_WestHits_TPC physics producers purityana0 caloskimCalorimetryCryoE physics caloskimCalorimetryCryoW physics path
Access the description of detector geometry.
object containing MC truth information necessary for making RawDigits and doing back tracking ...
geo::Length_t DetHalfHeight(geo::TPCID const &tpcid) const
Returns the half height of the active volume of the specified TPC.
art framework interface to geometry description for auxiliary detectors
geo::Length_t DetLength(geo::TPCID const &tpcid) const
Returns the length of the active volume of the specified TPC.
void reconfigure(fhicl::ParameterSet const &pset)
Description of geometry of one entire detector.
std::vector< double > fMinMomentums
const TGeoVolume * TotalVolume() const
std::vector< double > fMaxMomentums
std::pair< double, double > XLimitsTPC(const art::Ptr< simb::MCParticle > particle)
std::string fLArG4ModuleName
virtual void beginJob() override
bool fUseTightReadoutWindow
geo::GeometryCore const * fGeometryService
art framework interface to geometry description
BEGIN_PROLOG could also be cout
std::vector< unsigned int > fBottomCRTAuxDetIDs
std::vector< unsigned int > fBackCRTAuxDetIDs