20 #include "cetlib_except/exception.h" 63 ,
fMinKE(pset.get<
double>(
"MinEnergy", 0.0))
65 ,
fMinT(pset.get<
double>(
"MinT", 0.0))
66 ,
fMaxT(pset.get<
double>(
"MaxT"))
71 produces<std::vector<simb::MCTruth>>(
"intime");
72 produces<std::vector<simb::MCTruth>>(
"outtime");
74 std::cout <<
"New Filter!\n";
81 std::array<double, 6> this_cryo_boundaries{};
82 cryo.Boundaries(&this_cryo_boundaries[0]);
89 const TLorentzVector& v4 = part.
Position();
90 const TLorentzVector& p4 = part.
Momentum();
92 double x0[3] = {v4.X(), v4.Y(), v4.Z()};
95 p4.Px() / p4.Vect().Mag(), p4.Py() / p4.Vect().Mag(), p4.Pz() / p4.Vect().Mag()};
111 std::array<int, 3> quadrant{};
112 std::array<double, 3> candidatePlane{};
113 std::array<double, 3>
coord{};
115 std::array<double, 3> bound_lo = {{bound[0], bound[2], bound[4]}};
116 std::array<double, 3> bound_hi = {{bound[1], bound[3], bound[5]}};
122 for (
int i = 0; i < 3; i++) {
123 if (x0[i] < bound_lo[i]) {
125 candidatePlane[i] = bound_lo[i];
128 else if (x0[i] > bound_hi[i]) {
130 candidatePlane[i] = bound_hi[i];
139 inside_cryo[i_cryo] =
true;
141 intersects_cryo[i_cryo] =
true;
148 std::array<double, 3> maxT{};
149 for (
int i = 0; i < 3; i++) {
150 if (quadrant[i] != 2 &&
abs(dx[i]) > eps) {
151 maxT[i] = (candidatePlane[i] - x0[i]) / dx[i];
161 for (
int i = 1; i < 3; i++) {
162 if (maxT[whichPlane] < maxT[i]) whichPlane = i;
168 if (maxT[whichPlane] < 0.) {
169 intersects_cryo[i_cryo] =
false;
173 for (
int i = 0; i < 3; i++) {
174 if (whichPlane != i) {
coord[i] = x0[i] + maxT[whichPlane] * dx[i]; }
176 coord[i] = candidatePlane[i];
181 intersects_cryo[i_cryo] =
true;
182 for (
int i = 0; i < 3; i++) {
183 if (
coord[i] < bound_lo[i] ||
coord[i] > bound_hi[i]) { intersects_cryo[i_cryo] =
false; }
186 if (intersects_cryo[i_cryo]) { distance_to_cryo[i_cryo] = maxT[whichPlane]; }
195 if (inside_cryo[i_cryo]) {
return true; }
197 if (intersects_cryo[i_cryo]) {
198 double ptime = (distance_to_cryo[i_cryo] * 1
e-2 ) /
199 (TMath::C() * sqrt(1 - pow(part.
Mass() / part.
E(), 2))) ;
200 double totT = part.
T() + ptime * 1e9 ;
201 if (totT >
fMinT && totT <
fMaxT) {
return true; }
211 std::unique_ptr<std::vector<simb::MCTruth>> truthInTimePtr(
new std::vector<simb::MCTruth>(1));
212 std::unique_ptr<std::vector<simb::MCTruth>> truthOutOfTimePtr(
213 new std::vector<simb::MCTruth>(1));
223 auto allmclists = evt.
getMany<std::vector<simb::MCTruth>>();
224 bool keepEvent =
false;
225 for (
size_t mcl = 0; mcl < allmclists.size(); ++mcl) {
227 for (
size_t m = 0; m < mclistHandle->size(); ++m) {
241 if (kp) truthInTime.
Add(particle);
242 if (!kp) truthOutOfTime.
Add(particle);
256 evt.
put(std::move(truthInTimePtr),
"intime");
257 evt.
put(std::move(truthOutOfTimePtr),
"outtime");
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
constexpr auto abs(T v)
Returns the absolute value of the argument.
Geometry information for a single cryostat.
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
#define DEFINE_ART_MODULE(klass)
double T(const int i=0) const
FilterGenInTime(fhicl::ParameterSet const &pset)
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
Event generator information.
Particle list in DetSim contains Monte Carlo particle information.
Tools and modules for checking out the basics of the Monte Carlo.
art framework interface to geometry description
std::vector< Handle< PROD > > getMany(SelectorBase const &selector=MatchAllSelector{}) const