All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions
sbnd::CosmicIdUtils Namespace Reference

Functions

std::pair< std::vector< double >
, std::vector< double > > 
FakeTpcFlashes (std::vector< simb::MCParticle > particles)
 
bool BeamFlash (std::vector< double > flashes, double beamTimeMin, double beamTimeMax)
 

Function Documentation

bool sbnd::CosmicIdUtils::BeamFlash ( std::vector< double >  flashes,
double  beamTimeMin,
double  beamTimeMax 
)

Definition at line 77 of file CosmicIdUtils.cc.

77  {
78  //
79  bool beamFlash = false;
80  std::sort(flashes.begin(), flashes.end());
81  // Loop over flashes in tpc 0
82  for(size_t i = 0; i < flashes.size(); i++){
83  double time = flashes[i];
84  if(time > beamTimeMin && time < beamTimeMax) beamFlash = true;
85  }
86 
87  return beamFlash;
88  }
std::pair< std::vector< double >, std::vector< double > > sbnd::CosmicIdUtils::FakeTpcFlashes ( std::vector< simb::MCParticle >  particles)

Definition at line 8 of file CosmicIdUtils.cc.

8  {
9  //
10  TPCGeoAlg fTpcGeo;
11 
12  // Create fake flashes in each tpc
13  std::vector<double> fakeTpc0Flashes;
14  std::vector<double> fakeTpc1Flashes;
15 
16  // FIXME probably shouldn't be here
17  //double readoutWindowMuS = fDetectorClocks->TPCTick2Time((double)fDetectorProperties->ReadOutWindowSize()); // [us]
18  //double driftTimeMuS = fTpcGeo.MaxX()/fDetectorProperties->DriftVelocity(); // [us]
19 
20  // Loop over all true particles
21  for (auto const particle: particles){
22 
23  // Get particle info
24  int pdg = std::abs(particle.PdgCode());
25  double time = particle.T() * 1e-3;
26 
27  //Check if time is in reconstructible window
28  //if(time < -driftTimeMuS || time > readoutWindowMuS) continue;
29  //Check if particle is visible, electron, muon, proton, pion, kaon, photon
30  if(!(pdg==13||pdg==11||pdg==22||pdg==2212||pdg==211||pdg==321||pdg==111)) continue;
31 
32  //Loop over the trajectory
33  int npts = particle.NumberTrajectoryPoints();
34  double TPC0Energy = 0;
35  double TPC1Energy = 0;
36  for(int i = 1; i < npts; i++){
37  geo::Point_t pt;
38  pt.SetX(particle.Vx(i)); pt.SetY(particle.Vy(i)); pt.SetZ(particle.Vz(i));
39  if(!fTpcGeo.InFiducial(pt, 0, 0)) continue;
40  // Add up the energy deposited in each tpc
41  if(pt.X() <= 0) TPC0Energy += particle.E(i-1) - particle.E(i);
42  else TPC1Energy += particle.E(i-1) - particle.E(i);
43  }
44  // If the total energy deposited is > 10 MeV then create fake flash
45  if(TPC0Energy > 0.01) fakeTpc0Flashes.push_back(time);
46  else if(TPC1Energy > 0.01) fakeTpc1Flashes.push_back(time);
47  }
48 
49  std::sort(fakeTpc0Flashes.begin(), fakeTpc0Flashes.end());
50  double previousTime = -99999;
51  // Loop over flashes in tpc 0
52  for(size_t i = 0; i < fakeTpc0Flashes.size(); i++){
53  double time = fakeTpc0Flashes[i];
54  // Combine flashes within 0.01 us
55  if(std::abs(time-previousTime) < 0.01){
56  fakeTpc0Flashes.erase(fakeTpc0Flashes.begin()+i);
57  }
58  else previousTime = time;
59  }
60 
61  std::sort(fakeTpc1Flashes.begin(), fakeTpc1Flashes.end());
62  previousTime = -99999;
63  // Loop over flashes in tpc 1
64  for(size_t i = 0; i < fakeTpc1Flashes.size(); i++){
65  double time = fakeTpc1Flashes[i];
66  // Combine flashes within 0.01 us
67  if(std::abs(time-previousTime) < 0.01){
68  fakeTpc1Flashes.erase(fakeTpc1Flashes.begin()+i);
69  }
70  else previousTime = time;
71  }
72 
73  return std::make_pair(fakeTpc0Flashes, fakeTpc1Flashes);
74  }
var pdg
Definition: selectors.fcl:14
T abs(T value)
do i e
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
Definition: geo_vectors.h:184