19 #include "cetlib_except/exception.h" 20 #include "canvas/Persistency/Common/FindManyP.h" 21 #include "canvas/Persistency/Common/FindOneP.h" 24 #include "nug4/ParticleNavigation/ParticleList.h" 66 fMinKE (pset.get<
double > (
"MinEnergy" , 0.0) )
68 ,
fMinT (pset.get<
double > (
"MinT",0.0) )
69 ,
fMaxT (pset.get<
double > (
"MaxT") )
74 produces< std::vector<simb::MCTruth> >(
"intime");
75 produces< std::vector<simb::MCTruth> >(
"outtime");
77 std::cout <<
"New Filter!\n";
83 for (
auto const &cryo: geom.IterateCryostats()) {
84 std::array<double, 6> this_cryo_boundaries {};
85 cryo.Boundaries(&this_cryo_boundaries[0]);
92 const TLorentzVector& v4 = part.
Position();
93 const TLorentzVector& p4 = part.
Momentum();
95 double x0[3] = {v4.X(), v4.Y(), v4.Z() };
97 double dx[3] = {p4.Px() / p4.Vect().Mag(), p4.Py() / p4.Vect().Mag(), p4.Pz() / p4.Vect().Mag()};
113 std::array<int, 3> quadrant {};
114 std::array<double, 3> candidatePlane {};
115 std::array<double, 3>
coord {};
117 std::array<double, 3> bound_lo = {{bound[0], bound[2], bound[4]}};
118 std::array<double, 3> bound_hi = {{bound[1], bound[3], bound[5]}};
124 for (
int i = 0; i < 3; i++) {
125 if (x0[i] < bound_lo[i]) {
127 candidatePlane[i] = bound_lo[i];
130 else if (x0[i] > bound_hi[i]) {
132 candidatePlane[i] = bound_hi[i];
141 inside_cryo[i_cryo] =
true;
143 intersects_cryo[i_cryo] =
true;
150 std::array<double, 3> maxT {};
151 for (
int i = 0; i < 3; i++) {
152 if (quadrant[i] != 2 &&
abs(dx[i]) > eps) {
153 maxT[i] = (candidatePlane[i] - x0[i]) / dx[i];
163 for (
int i = 1; i < 3; i++) {
164 if (maxT[whichPlane] < maxT[i]) whichPlane = i;
170 if (maxT[whichPlane] < 0.) {
171 intersects_cryo[i_cryo] =
false;
175 for (
int i = 0; i < 3; i++) {
176 if (whichPlane != i) {
177 coord[i] = x0[i] + maxT[whichPlane] * dx[i];
180 coord[i] = candidatePlane[i];
186 intersects_cryo[i_cryo] =
true;
187 for (
int i = 0; i < 3; i++) {
188 if (
coord[i] < bound_lo[i] ||
coord[i] > bound_hi[i]) {
189 intersects_cryo[i_cryo] =
false;
193 if (intersects_cryo[i_cryo]) {
194 distance_to_cryo[i_cryo] = maxT[whichPlane];
204 if (inside_cryo[i_cryo]) {
208 if (intersects_cryo[i_cryo]){
209 double ptime = (distance_to_cryo[i_cryo] * 1
e-2 ) / (TMath::C()*sqrt(1-
pow(part.
Mass()/part.
E(),2))) ;
210 double totT=part.
T()+ptime*1e9 ;
224 std::unique_ptr< std::vector<simb::MCTruth> > truthInTimePtr(
new std::vector<simb::MCTruth>(1));
225 std::unique_ptr< std::vector<simb::MCTruth> > truthOutOfTimePtr(
new std::vector<simb::MCTruth>(1));
236 auto allmclists = evt.
getMany< std::vector<simb::MCTruth> >();
237 bool keepEvent=
false;
238 for(
size_t mcl = 0; mcl < allmclists.size(); ++mcl){
240 for(
size_t m = 0;
m < mclistHandle->size(); ++
m){
243 for(
int ipart=0;ipart<mct->
NParticles();ipart++){
255 if(kp) truthInTime.
Add(particle);
256 if(!kp) truthOutOfTime.
Add(particle);
double E(const int i=0) const
const TLorentzVector & Position(const int i=0) const
auto coord(Vector &v, unsigned int n) noexcept
Returns an object to manage the coordinate n of a vector.
std::vector< std::array< double, 6 > > fCryostatBoundaries
boundaries of each cryostat
art framework interface to geometry description
#define DEFINE_ART_MODULE(klass)
std::vector< Handle< PROD > > getMany(SelectorBase const &selector=MatchAllSelector{}) const
double T(const int i=0) const
FilterGenInTime(fhicl::ParameterSet const &pset)
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
const simb::MCParticle & GetParticle(int i) const
bool filter(art::Event &)
void Add(simb::MCParticle const &part)
const TLorentzVector & Momentum(const int i=0) const
EDFilter(fhicl::ParameterSet const &pset)
bool KeepParticle(simb::MCParticle const &part) const
Tools and modules for checking out the basics of the Monte Carlo.
Event generator information.