All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SpaceChargeTest_module.cc
Go to the documentation of this file.
1 #ifndef SPACE_CHARGE_TEST
2 #define SPACE_CHARGE_TEST
3 
4 // Framework includes
5 #include "art/Framework/Core/EDAnalyzer.h"
6 #include "art/Framework/Core/ModuleMacros.h"
7 #include "art/Framework/Principal/Event.h"
8 #include "art/Framework/Principal/Handle.h"
9 #include "art/Framework/Principal/Run.h"
10 #include "art/Framework/Principal/SubRun.h"
11 #include "art/Framework/Services/Registry/ServiceHandle.h"
12 #include "art_root_io/TFileService.h"
13 #include "fhiclcpp/ParameterSet.h"
14 
15 // Root includes
16 #include <TH1.h>
17 
18 // Larsoft includes
21 
22 using namespace std;
23 
24 namespace SpaceChargeTools
25 {
26  class SpaceChargeTest;
27 }
28 
29 class SpaceChargeTools::SpaceChargeTest : public art::EDAnalyzer
30 {
31 public:
32 
33  explicit SpaceChargeTest(fhicl::ParameterSet const & p);
34  virtual ~SpaceChargeTest();
35 
36  virtual void beginJob() override;
37  virtual void endJob() override;
38 
39  // Required function
40  void analyze(art::Event const & e) override;
41 
42 private:
43 
44  TH1D *hDx;
45  TH1D *hDy;
46  TH1D *hDz;
47  TH1D *hEx;
48  TH1D *hEy;
49  TH1D *hEz;
50 };
51 
52 SpaceChargeTools::SpaceChargeTest::SpaceChargeTest(fhicl::ParameterSet const & p) : EDAnalyzer(p)
53 {
54 }
55 
57 
59 {
60  // Access ART's TFileService, which will handle creating and writing histograms and n-tuples
61  art::ServiceHandle<art::TFileService> fileServiceHandle;
62 
63  hDx = fileServiceHandle->make<TH1D>("hDx", "", 150, -1.0, 0.6);
64  hDy = fileServiceHandle->make<TH1D>("hDy", "", 150, -6.0, 6.0);
65  hDz = fileServiceHandle->make<TH1D>("hDz", "", 150, -6.0, 6.0);
66  hEx = fileServiceHandle->make<TH1D>("hEx", "", 100, -0.06, 0.06);
67  hEy = fileServiceHandle->make<TH1D>("hEy", "", 100, -0.04, 0.04);
68  hEz = fileServiceHandle->make<TH1D>("hEz", "", 100, -0.04, 0.04);
69 }
70 
72 
74 {
75  int xMin = -206;
76  int xMax = 206;
77  int yMin = -210;
78  int yMax = 210;
79  int zMin = -10;
80  int zMax = 510;
81 
82  auto const* SCE = lar::providerFrom<spacecharge::SpaceChargeService>();
83  cout << "Is Spatial SCE enabled? " << bool(SCE->EnableSimSpatialSCE()) << endl;
84  cout << "Is E-field SCE enabled? " << bool(SCE->EnableSimEfieldSCE()) << endl;
85 
86  int nSkip = 5;
87  for(int iX = xMin; iX <= xMax - nSkip; iX++)
88  {
89  iX = iX + nSkip;
90  for(int iY = yMin; iY <= yMax - nSkip; iY++)
91  {
92  iY = iY + nSkip;
93  for(int iZ = zMin; iZ <= zMax - nSkip; iZ++)
94  {
95  iZ = iZ + nSkip;
96  cout << iX << ", " << iY << ", " << iZ << endl;
97 
98  geo::Point_t point = {double(iX), double(iY), double(iZ)};
99 
100  geo::Vector_t spatialOffsets = SCE->GetPosOffsets(point);
101  if(!((spatialOffsets.X() == spatialOffsets.X()) &&
102  (spatialOffsets.Y() == spatialOffsets.Y()) &&
103  (spatialOffsets.Z() == 0.0)))
104  {
105  hDx->Fill(spatialOffsets.X());
106  hDy->Fill(spatialOffsets.Y());
107  hDz->Fill(spatialOffsets.Z());
108  }
109 
110  geo::Vector_t efieldOffsets = SCE->GetEfieldOffsets(point);
111  if(!((efieldOffsets.X() == efieldOffsets.X()) &&
112  (efieldOffsets.Y() == efieldOffsets.Y()) &&
113  (efieldOffsets.Z() == 0.0)))
114  {
115  hEx->Fill(efieldOffsets.X());
116  hEy->Fill(efieldOffsets.Y());
117  hEz->Fill(efieldOffsets.Z());
118  }
119  }
120  }
121  }
122 }
123 
124 DEFINE_ART_MODULE(SpaceChargeTools::SpaceChargeTest)
125 
126 #endif //SPACE_CHARGE_TEST
void analyze(art::Event const &e) override
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Vector_t
Type for representation of momenta in 3D space.
Definition: geo_vectors.h:164
process_name opflashCryo1 flashfilter analyze
double std(const std::vector< short > &wf, const double ped_mean, size_t start, size_t nsample)
Definition: UtilFunc.cxx:42
Utilities related to art service access.
pdgs p
Definition: selectors.fcl:22
static constexpr bool
SpaceChargeTest(fhicl::ParameterSet const &p)
do i e
TCEvent evt
Definition: DataStructs.cxx:8
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
BEGIN_PROLOG could also be cout