All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
spacecharge::SpaceChargeICARUS Class Reference

#include <SpaceChargeICARUS.h>

Inheritance diagram for spacecharge::SpaceChargeICARUS:
spacecharge::SpaceCharge

Public Member Functions

 SpaceChargeICARUS (fhicl::ParameterSet const &pset)
 
 SpaceChargeICARUS (SpaceChargeICARUS const &)=delete
 
virtual ~SpaceChargeICARUS ()=default
 
bool Configure (fhicl::ParameterSet const &pset)
 
bool Update (uint64_t ts=0)
 
bool EnableSimSpatialSCE () const override
 
bool EnableSimEfieldSCE () const override
 
bool EnableCalSpatialSCE () const override
 
bool EnableCalEfieldSCE () const override
 
bool EnableCorrSCE () const override
 
geo::Vector_t GetPosOffsets (geo::Point_t const &point) const override
 
geo::Vector_t GetEfieldOffsets (geo::Point_t const &point) const override
 
geo::Vector_t GetCalPosOffsets (geo::Point_t const &point, int const &TPCid) const override
 
geo::Vector_t GetCalPosOffsets (geo::Point_t const &point, geo::TPCID const &TPCid) const
 
geo::Vector_t GetCalEfieldOffsets (geo::Point_t const &point, int const &TPCid=1) const override
 
- Public Member Functions inherited from spacecharge::SpaceCharge
 SpaceCharge (const SpaceCharge &)=delete
 
 SpaceCharge (SpaceCharge &&)=delete
 
SpaceChargeoperator= (const SpaceCharge &)=delete
 
SpaceChargeoperator= (SpaceCharge &&)=delete
 
virtual ~SpaceCharge ()=default
 

Protected Member Functions

void fixCoords (double *xx, double *yy, double *zz) const
 
- Protected Member Functions inherited from spacecharge::SpaceCharge
 SpaceCharge ()=default
 

Protected Attributes

std::vector< TH3F * > SCEhistograms = std::vector<TH3F*>(9)
 
bool fEnableSimSpatialSCE
 
bool fEnableSimEfieldSCE
 
bool fEnableCalSpatialSCE
 
bool fEnableCalEfieldSCE
 
bool fEnableCorrSCE
 
std::string fRepresentationType
 
std::string fInputFilename
 

Detailed Description

Definition at line 38 of file SpaceChargeICARUS.h.

Constructor & Destructor Documentation

spacecharge::SpaceChargeICARUS::SpaceChargeICARUS ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 19 of file SpaceChargeICARUS.cxx.

20 {
21  Configure(pset);
22 }
bool Configure(fhicl::ParameterSet const &pset)
spacecharge::SpaceChargeICARUS::SpaceChargeICARUS ( SpaceChargeICARUS const &  )
delete
virtual spacecharge::SpaceChargeICARUS::~SpaceChargeICARUS ( )
virtualdefault

Member Function Documentation

bool spacecharge::SpaceChargeICARUS::Configure ( fhicl::ParameterSet const &  pset)

Definition at line 24 of file SpaceChargeICARUS.cxx.

25 {
26  fEnableSimSpatialSCE = pset.get<bool>("EnableSimSpatialSCE");
27  fEnableSimEfieldSCE = pset.get<bool>("EnableSimEfieldSCE");
28  //fEnableCorrSCE = pset.get<bool>("EnableCorrSCE");
29  fEnableCalSpatialSCE = pset.get<bool>("EnableCalSpatialSCE");
30  fEnableCalEfieldSCE = pset.get<bool>("EnableCalEfieldSCE");
31 
32  std::cout << "Configuring SpaceCharge..." << std::endl;
33 
34  if((fEnableSimSpatialSCE == true) || (fEnableSimEfieldSCE == true)){
35  fRepresentationType = pset.get<std::string>("RepresentationType");
36  fInputFilename = pset.get<std::string>("InputFilename");
37 
38  std::string fname;
39  cet::search_path sp("FW_SEARCH_PATH");
40  sp.find_file(fInputFilename, fname);
41 
42  std::unique_ptr<TFile> infile(new TFile(fname.c_str(), "READ"));
43  if(!infile->IsOpen()){
44  throw cet::exception("SpaceChargeICARUS") << "Could not find the space charge input file '" << fInputFilename << "'!\n";
45  }
46 
47  if(fRepresentationType == "Voxelized_TH3"){
48  std::cout << "begin loading voxelized TH3s..." << std::endl;
49 
50  //Load in histograms
51  TH3F* hTrueFwdX = (TH3F*) infile->Get("TrueFwd_Displacement_X");
52  TH3F* hTrueFwdY = (TH3F*) infile->Get("TrueFwd_Displacement_Y");
53  TH3F* hTrueFwdZ = (TH3F*) infile->Get("TrueFwd_Displacement_Z");
54  TH3F* hTrueBkwdX = (TH3F*) infile->Get("TrueBkwd_Displacement_X");
55  TH3F* hTrueBkwdY = (TH3F*) infile->Get("TrueBkwd_Displacement_Y");
56  TH3F* hTrueBkwdZ = (TH3F*) infile->Get("TrueBkwd_Displacement_Z");
57  TH3F* hTrueEFieldX = (TH3F*) infile->Get("True_ElecField_X");
58  TH3F* hTrueEFieldY = (TH3F*) infile->Get("True_ElecField_Y");
59  TH3F* hTrueEFieldZ = (TH3F*) infile->Get("True_ElecField_Z");
60 
61  //https://root.cern.ch/doc/master/classTH1.html#a0367fe04ae8709fd4b82795d0a5462c3
62  //Set hist directories so they can be referenced elsewhere
63  //This needs to be done because they were read in from ext file
64  //Note this is not a property of the TH3F, so does't survive copying
65  hTrueFwdX->SetDirectory(0);
66  hTrueFwdY->SetDirectory(0);
67  hTrueFwdZ->SetDirectory(0);
68  hTrueBkwdX->SetDirectory(0);
69  hTrueBkwdY->SetDirectory(0);
70  hTrueBkwdZ->SetDirectory(0);
71  hTrueEFieldX->SetDirectory(0);
72  hTrueEFieldY->SetDirectory(0);
73  hTrueEFieldZ->SetDirectory(0);
74 
75  //SCEhistograms can be accessed globally in this script
76  SCEhistograms = {hTrueFwdX, hTrueFwdY, hTrueFwdZ,
77  hTrueBkwdX, hTrueBkwdY, hTrueBkwdZ,
78  hTrueEFieldX, hTrueEFieldY, hTrueEFieldZ};
79 
80 
81  std::cout << "...finished loading TH3s" << std::endl;
82  }
83  infile->Close();
84  }
85  if(fEnableCorrSCE == true){
86  //keeping here (for now) for historic reasons
87  }
88  return true;
89 }
string fname
Definition: demo.py:5
std::vector< TH3F * > SCEhistograms
BEGIN_PROLOG could also be cout
bool spacecharge::SpaceChargeICARUS::EnableCalEfieldSCE ( ) const
overridevirtual

Implements spacecharge::SpaceCharge.

Definition at line 116 of file SpaceChargeICARUS.cxx.

117 {
118  return fEnableCalEfieldSCE;
119 }
bool spacecharge::SpaceChargeICARUS::EnableCalSpatialSCE ( ) const
overridevirtual

Implements spacecharge::SpaceCharge.

Definition at line 110 of file SpaceChargeICARUS.cxx.

111 {
112  return fEnableCalSpatialSCE;
113 }
bool spacecharge::SpaceChargeICARUS::EnableCorrSCE ( ) const
inlineoverridevirtual

Implements spacecharge::SpaceCharge.

Definition at line 56 of file SpaceChargeICARUS.h.

bool EnableCalEfieldSCE() const override
bool EnableCalSpatialSCE() const override
bool spacecharge::SpaceChargeICARUS::EnableSimEfieldSCE ( ) const
overridevirtual

Implements spacecharge::SpaceCharge.

Definition at line 104 of file SpaceChargeICARUS.cxx.

105 {
106  return fEnableSimEfieldSCE;
107 }
bool spacecharge::SpaceChargeICARUS::EnableSimSpatialSCE ( ) const
overridevirtual

Implements spacecharge::SpaceCharge.

Definition at line 98 of file SpaceChargeICARUS.cxx.

99 {
100  return fEnableSimSpatialSCE;
101 }
void spacecharge::SpaceChargeICARUS::fixCoords ( double *  xx,
double *  yy,
double *  zz 
) const
protected

Definition at line 234 of file SpaceChargeICARUS.cxx.

234  {
235  //handle the edge cases by projecting SCE corrections onto boundaries
236  *xx = abs(*xx);
237  if(*xx<61.94){*xx=61.94;}
238  if(*xx>358.489){*xx=358.489;}
239  if(*yy<-181.86){*yy=-181.86;}
240  if(*yy>134.96){*yy=134.96;}
241  if(*zz<-894.951){*zz=-894.951;}
242  if(*zz>894.9509){*zz=894.9509;}
243 }
T abs(T value)
geo::Vector_t spacecharge::SpaceChargeICARUS::GetCalEfieldOffsets ( geo::Point_t const &  point,
int const &  TPCid = 1 
) const
inlineoverridevirtual

Implements spacecharge::SpaceCharge.

Definition at line 66 of file SpaceChargeICARUS.h.

66 { return {0.,0.,0.}; }
geo::Vector_t spacecharge::SpaceChargeICARUS::GetCalPosOffsets ( geo::Point_t const &  point,
int const &  TPCid 
) const
overridevirtual

Implements spacecharge::SpaceCharge.

Definition at line 166 of file SpaceChargeICARUS.cxx.

167 {
168  std::vector<double> theCalPosOffsets;
169  //make copies of const vars to modify
170  double xx=point.X(), yy=point.Y(), zz=point.Z();
171  int tpcid = TPCid;
172 
173  if(fRepresentationType == "Voxelized_TH3"){
174  //handle OOAV by projecting edge cases
175  //also only have map for positive cryostat (assume symmetry)
176  //need to invert coordinates for cryo0
177  double corr=1.;
178  if(xx<0){
179  corr=-1.0;
180  }
181 
182  bool x_is_pos = xx > 0;
183 
184  fixCoords(&xx, &yy, &zz); //bring into AV and x = abs(x)
185  //handle the depositions that was reconstructed in the wrong TPC
186  //hard code in the cathode faces (got from dump_icarus_geometry.fcl)
187  //
188  //Gray Putnam: update this check to the split-wire Geometry
189  if (x_is_pos && (tpcid == 0 || tpcid == 1) && xx > 210.14 ) { xx = 210.14; }
190  if (x_is_pos && (tpcid == 2 || tpcid == 3) && xx < 210.29 ) { xx = 210.29; }
191 
192  if (!x_is_pos && (tpcid == 2 || tpcid == 3) && xx > 210.14 ) { xx = 210.14; }
193  if (!x_is_pos && (tpcid == 0 || tpcid == 1) && xx < 210.29 ) { xx = 210.29; }
194 
195  double offset_x=0., offset_y=0., offset_z=0.;
196  offset_x = corr*SCEhistograms.at(3)->Interpolate(xx,yy,zz);
197  offset_y = SCEhistograms.at(4)->Interpolate(xx,yy,zz);
198  offset_z = SCEhistograms.at(5)->Interpolate(xx,yy,zz);
199  theCalPosOffsets = {offset_x, offset_y, offset_z};
200  }else{
201  theCalPosOffsets.resize(3, 0.0);
202  }
203 
204  return { theCalPosOffsets[0], theCalPosOffsets[1], theCalPosOffsets[2] };
205 }
void fixCoords(double *xx, double *yy, double *zz) const
std::vector< TH3F * > SCEhistograms
geo::Vector_t spacecharge::SpaceChargeICARUS::GetCalPosOffsets ( geo::Point_t const &  point,
geo::TPCID const &  TPCid 
) const

Definition at line 207 of file SpaceChargeICARUS.cxx.

208 {
209  return GetCalPosOffsets(point, TPCid.TPC);
210 }
geo::Vector_t GetCalPosOffsets(geo::Point_t const &point, int const &TPCid) const override
geo::Vector_t spacecharge::SpaceChargeICARUS::GetEfieldOffsets ( geo::Point_t const &  point) const
overridevirtual

Implements spacecharge::SpaceCharge.

Definition at line 213 of file SpaceChargeICARUS.cxx.

214 {
215  //chiefly utilized by larsim, ISCalculationSeparate
216  //the magnitude of the Efield is most important
217  std::vector<double> theEfieldOffsets;
218  double xx=point.X(), yy=point.Y(), zz=point.Z();
219  double offset_x=0., offset_y=0., offset_z=0.;
220 
221  if(fRepresentationType == "Voxelized_TH3"){
222  //handle OOAV by projecting edge cases
223  //also only have map for positive cryostat (assume symmetry)
224  fixCoords(&xx, &yy, &zz);
225  offset_x = SCEhistograms.at(6)->Interpolate(xx, yy, zz);
226  offset_y = SCEhistograms.at(7)->Interpolate(xx, yy, zz);
227  offset_z = SCEhistograms.at(8)->Interpolate(xx, yy, zz);
228 
229  theEfieldOffsets = {offset_x, offset_y, offset_z};
230  }
231  return { theEfieldOffsets[0], theEfieldOffsets[1], theEfieldOffsets[2] };
232 }
void fixCoords(double *xx, double *yy, double *zz) const
std::vector< TH3F * > SCEhistograms
geo::Vector_t spacecharge::SpaceChargeICARUS::GetPosOffsets ( geo::Point_t const &  point) const
overridevirtual

Implements spacecharge::SpaceCharge.

Definition at line 126 of file SpaceChargeICARUS.cxx.

127 {
128  std::vector<double> thePosOffsets;
129  double xx=point.X(), yy=point.Y(), zz=point.Z();
130  double cryo_corr=1., tpc_corr=1.;
131 
132  if(fRepresentationType == "Voxelized_TH3"){
133  //handle OOAV by projecting edge cases
134  //also only have map for positive cryostat (assume symmetry)
135  //need to invert coordinates for cryo0 (cryo_corr)
136 
137  //in larsim, this is how the offsets are used in DriftElectronstoPlane_module
138  // DriftDistance += -1.0 * thePosOffsets[0]
139  // thus need to apply correction to TPCs "left" of cryostat (tpc_corr)
140  // cathode spans x=210.14 and x=210.29 in pos cryostat
141  if(xx>0){
142  cryo_corr=1.0;
143  if(xx<210.14){
144  tpc_corr=-1.0;
145  }
146  }else{
147  cryo_corr=-1.0;
148  if(xx<-210.29){
149  tpc_corr=-1.0;
150  }
151  }
152  fixCoords(&xx, &yy, &zz); //bring into AV and x = abs(x)
153  double offset_x=0., offset_y=0., offset_z=0.;
154  offset_x = tpc_corr*cryo_corr*SCEhistograms.at(0)->Interpolate(xx,yy,zz);
155  offset_y = SCEhistograms.at(1)->Interpolate(xx,yy,zz);
156  offset_z = SCEhistograms.at(2)->Interpolate(xx,yy,zz);
157  thePosOffsets = {offset_x, offset_y, offset_z};
158  }else{
159  thePosOffsets.resize(3, 0.0);
160  }
161 
162  return { thePosOffsets[0], thePosOffsets[1], thePosOffsets[2] };
163 }
void fixCoords(double *xx, double *yy, double *zz) const
std::vector< TH3F * > SCEhistograms
bool spacecharge::SpaceChargeICARUS::Update ( uint64_t  ts = 0)

Definition at line 91 of file SpaceChargeICARUS.cxx.

92 {
93  if (ts == 0){return false;}
94  return true;
95 }

Member Data Documentation

bool spacecharge::SpaceChargeICARUS::fEnableCalEfieldSCE
protected

Definition at line 82 of file SpaceChargeICARUS.h.

bool spacecharge::SpaceChargeICARUS::fEnableCalSpatialSCE
protected

Definition at line 81 of file SpaceChargeICARUS.h.

bool spacecharge::SpaceChargeICARUS::fEnableCorrSCE
protected

Definition at line 83 of file SpaceChargeICARUS.h.

bool spacecharge::SpaceChargeICARUS::fEnableSimEfieldSCE
protected

Definition at line 80 of file SpaceChargeICARUS.h.

bool spacecharge::SpaceChargeICARUS::fEnableSimSpatialSCE
protected

Definition at line 79 of file SpaceChargeICARUS.h.

std::string spacecharge::SpaceChargeICARUS::fInputFilename
protected

Definition at line 85 of file SpaceChargeICARUS.h.

std::string spacecharge::SpaceChargeICARUS::fRepresentationType
protected

Definition at line 84 of file SpaceChargeICARUS.h.

std::vector<TH3F*> spacecharge::SpaceChargeICARUS::SCEhistograms = std::vector<TH3F*>(9)
protected

Definition at line 74 of file SpaceChargeICARUS.h.


The documentation for this class was generated from the following files: