Public Member Functions | Private Member Functions | Private Attributes | List of all members
larg4::IonAndScint Class Reference
Inheritance diagram for larg4::IonAndScint:
art::EDProducer art::detail::Producer art::detail::LegacyModule art::Modifier art::ModuleBase art::ProductRegistryHelper

Public Member Functions

 IonAndScint (fhicl::ParameterSet const &pset)
 
void produce (art::Event &event) override
 
void beginJob () override
 
void endJob () override
 
- Public Member Functions inherited from art::EDProducer
 EDProducer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDProducer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Producer
virtual ~Producer () noexcept
 
 Producer (fhicl::ParameterSet const &)
 
 Producer (Producer const &)=delete
 
 Producer (Producer &&)=delete
 
Produceroperator= (Producer const &)=delete
 
Produceroperator= (Producer &&)=delete
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
- Public Member Functions inherited from art::Modifier
 ~Modifier () noexcept
 
 Modifier ()
 
 Modifier (Modifier const &)=delete
 
 Modifier (Modifier &&)=delete
 
Modifieroperator= (Modifier const &)=delete
 
Modifieroperator= (Modifier &&)=delete
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Private Member Functions

std::vector< art::Handle< SimEnergyDepositCollection > > inputCollections (art::Event const &) const
 

Private Attributes

art::InputTag calcTag
 
std::vector< std::stringfInputModuleLabels
 
std::unique_ptr< ISCalcfISAlg
 
CLHEP::HepRandomEngine & fEngine
 
string Instances
 
std::vector< stringinstanceNames
 
bool fSavePriorSCE
 

Additional Inherited Members

- Public Types inherited from art::EDProducer
using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
- Public Types inherited from art::detail::Producer
template<typename UserConfig , typename KeysToIgnore = void>
using Table = Modifier::Table< UserConfig, KeysToIgnore >
 
- Public Types inherited from art::Modifier
template<typename UserConfig , typename UserKeysToIgnore = void>
using Table = ProducerTable< UserConfig, detail::ModuleConfig, UserKeysToIgnore >
 
- Static Public Member Functions inherited from art::EDProducer
static void commitEvent (EventPrincipal &ep, Event &e)
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Detailed Description

Definition at line 51 of file IonAndScint_module.cc.

Constructor & Destructor Documentation

larg4::IonAndScint::IonAndScint ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 80 of file IonAndScint_module.cc.

81  : art::EDProducer{pset}
82  , calcTag{pset.get<art::InputTag>("ISCalcAlg")}
83  , fInputModuleLabels{pset.get<std::vector<std::string>>("InputModuleLabels", {})}
85  ->createEngine(*this, "HepJamesRandom", "NEST", pset, "SeedNEST"))
86  , Instances{
87  pset.get<string>("Instances", "LArG4DetectorServicevolTPCActive"),
88  }
89  , fSavePriorSCE{pset.get<bool>("SavePriorSCE", false)}
90  {
91  std::cout << "IonAndScint Module Construct" << std::endl;
92 
93  if (Instances.empty()) {
94  std::cout << "Produce SimEnergyDeposit in default volume - LArG4DetectorServicevolTPCActive"
95  << std::endl;
96  instanceNames.push_back("LArG4DetectorServicevolTPCActive");
97  }
98  else {
99  std::stringstream input(Instances);
100  string temp;
101  while (std::getline(input, temp, ';')) {
102  instanceNames.push_back(temp);
103  }
104 
105  std::cout << "Produce SimEnergyDeposit in volumes: " << std::endl;
106  for (auto instanceName : instanceNames) {
107  std::cout << " - " << instanceName << std::endl;
108  }
109  }
110 
111  produces<std::vector<sim::SimEnergyDeposit>>();
112  if (fSavePriorSCE) produces<std::vector<sim::SimEnergyDeposit>>("priorSCE");
113  }
CLHEP::HepRandomEngine & fEngine
std::vector< std::string > fInputModuleLabels
static int input(void)
Definition: code.cpp:15695
std::vector< string > instanceNames
QTextStream & endl(QTextStream &s)

Member Function Documentation

void larg4::IonAndScint::beginJob ( )
overridevirtual

Reimplemented from art::EDProducer.

Definition at line 117 of file IonAndScint_module.cc.

118  {
119  std::cout << "IonAndScint beginJob." << std::endl;
120  std::cout << "Using " << calcTag.label() << " algorithm to calculate IS." << std::endl;
121 
122  if (calcTag.label() == "Separate")
123  fISAlg = std::make_unique<ISCalcSeparate>();
124  else if (calcTag.label() == "Correlated") {
125  auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService>()->DataForJob();
126  fISAlg = std::make_unique<ISCalcCorrelated>(detProp);
127  }
128  else if (calcTag.label() == "NEST")
129  fISAlg = std::make_unique<ISCalcNESTLAr>(fEngine);
130  else
131  mf::LogWarning("IonAndScint") << "No ISCalculation set, this can't be good.";
132  }
CLHEP::HepRandomEngine & fEngine
std::string const & label() const noexcept
Definition: InputTag.cc:79
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
std::unique_ptr< ISCalc > fISAlg
QTextStream & endl(QTextStream &s)
void larg4::IonAndScint::endJob ( )
overridevirtual

Reimplemented from art::EDProducer.

Definition at line 136 of file IonAndScint_module.cc.

137  {
138  std::cout << "IonAndScint endJob." << std::endl;
139  }
QTextStream & endl(QTextStream &s)
std::vector< art::Handle< SimEnergyDepositCollection > > larg4::IonAndScint::inputCollections ( art::Event const &  e) const
private

Definition at line 143 of file IonAndScint_module.cc.

144  {
145  if (empty(fInputModuleLabels)) {
146  mf::LogDebug("IonAndScint") << "Retrieving all products" << std::endl;
147  return e.getMany<SimEnergyDepositCollection>();
148  }
149 
150  std::vector<art::Handle<SimEnergyDepositCollection>> result;
151 
152  for (auto const & module : fInputModuleLabels) {
153 
154  mf::LogDebug("IonAndScint") << "Retrieving products with module label "
155  << module << std::endl;
156 
157  auto handels = e.getMany<SimEnergyDepositCollection>(art::ModuleLabelSelector(module));
158 
159  if (empty(handels)) {
161  << "IonAndScint module cannot find any SimEnergyDeposits with module label "
162  << module << " as requested in InputModuleLabels. \n";
163  }
164 
165  result.insert(result.end(), handels.begin(), handels.end());
166  }
167 
168  return result;
169  }
static QCString result
std::vector< std::string > fInputModuleLabels
const double e
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.
Definition: StdUtils.h:97
QTextStream & endl(QTextStream &s)
std::vector< sim::SimEnergyDeposit > SimEnergyDepositCollection
void larg4::IonAndScint::produce ( art::Event event)
overridevirtual

Implements art::EDProducer.

Definition at line 173 of file IonAndScint_module.cc.

174  {
175  std::cout << "IonAndScint Module Producer" << std::endl;
176 
177  std::vector<art::Handle<SimEnergyDepositCollection>> edepHandle = inputCollections(event);
178 
179  if (empty(edepHandle)) {
180  std::cout << "IonAndScint Module Cannot Retrive SimEnergyDeposit" << std::endl;
181  return;
182  }
183 
184  auto sce = lar::providerFrom<spacecharge::SpaceChargeService>();
185  auto const detProp =
187 
188  auto simedep = std::make_unique<std::vector<sim::SimEnergyDeposit>>();
189  auto simedep1 = std::make_unique<std::vector<sim::SimEnergyDeposit>>(); // for prior-SCE depos
190  for (auto edeps : edepHandle) {
191  // Do some checking before we proceed
192  if (!edeps.isValid()) {
193  std::cout << "!edeps.isValid()" << std::endl;
194  continue;
195  }
196 
197  auto index = std::find(
198  instanceNames.begin(), instanceNames.end(), edeps.provenance()->productInstanceName());
199  if (index == instanceNames.end()) {
200  std::cout << "Skip SimEnergyDeposit in: " << edeps.provenance()->productInstanceName()
201  << std::endl;
202  continue;
203  }
204 
205  std::cout << "SimEnergyDeposit input module: " << edeps.provenance()->moduleLabel()
206  << ", instance name: " << edeps.provenance()->productInstanceName() << std::endl;
207 
208  for (sim::SimEnergyDeposit const& edepi : *edeps) {
209  auto const isCalcData = fISAlg->CalcIonAndScint(detProp, edepi);
210 
211  int ph_num = round(isCalcData.numPhotons);
212  int ion_num = round(isCalcData.numElectrons);
213  float scintyield = isCalcData.scintillationYieldRatio;
214  float edep_tmp = edepi.Energy();
215  geo::Point_t startPos_tmp = edepi.Start();
216  geo::Point_t endPos_tmp = edepi.End();
217  double startTime_tmp = edepi.StartT();
218  double endTime_tmp = edepi.EndT();
219  int trackID_tmp = edepi.TrackID();
220  int pdgCode_tmp = edepi.PdgCode();
221 
222  if (sce->EnableSimSpatialSCE()) {
223  auto posOffsetsStart =
224  sce->GetPosOffsets({edepi.StartX(), edepi.StartY(), edepi.StartZ()});
225  auto posOffsetsEnd = sce->GetPosOffsets({edepi.EndX(), edepi.EndY(), edepi.EndZ()});
226  startPos_tmp =
227  geo::Point_t{(float)(edepi.StartX() - posOffsetsStart.X()), //x should be subtracted
228  (float)(edepi.StartY() + posOffsetsStart.Y()),
229  (float)(edepi.StartZ() + posOffsetsStart.Z())};
230  endPos_tmp =
231  geo::Point_t{(float)(edepi.EndX() - posOffsetsEnd.X()), //x should be subtracted
232  (float)(edepi.EndY() + posOffsetsEnd.Y()),
233  (float)(edepi.EndZ() + posOffsetsEnd.Z())};
234  }
235 
236  simedep->emplace_back(ph_num,
237  ion_num,
238  scintyield,
239  edep_tmp,
240  startPos_tmp,
241  endPos_tmp,
242  startTime_tmp,
243  endTime_tmp,
244  trackID_tmp,
245  pdgCode_tmp);
246 
247  if (fSavePriorSCE) {
248  simedep1->emplace_back(ph_num,
249  ion_num,
250  scintyield,
251  edepi.Energy(),
252  edepi.Start(),
253  edepi.End(),
254  edepi.StartT(),
255  edepi.EndT(),
256  edepi.TrackID(),
257  edepi.PdgCode());
258  }
259 
260  }
261  }
262  event.put(std::move(simedep));
263  if (fSavePriorSCE) event.put(std::move(simedep1), "priorSCE");
264  }
def move(depos, offset)
Definition: depos.py:107
std::vector< string > instanceNames
std::vector< art::Handle< SimEnergyDepositCollection > > inputCollections(art::Event const &) const
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
Energy deposition in the active material.
std::unique_ptr< ISCalc > fISAlg
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.
Definition: StdUtils.h:97
QTextStream & endl(QTextStream &s)

Member Data Documentation

art::InputTag larg4::IonAndScint::calcTag
private

Definition at line 63 of file IonAndScint_module.cc.

CLHEP::HepRandomEngine& larg4::IonAndScint::fEngine
private

Definition at line 73 of file IonAndScint_module.cc.

std::vector<std::string> larg4::IonAndScint::fInputModuleLabels
private

Definition at line 70 of file IonAndScint_module.cc.

std::unique_ptr<ISCalc> larg4::IonAndScint::fISAlg
private

Definition at line 72 of file IonAndScint_module.cc.

bool larg4::IonAndScint::fSavePriorSCE
private

Definition at line 76 of file IonAndScint_module.cc.

std::vector<string> larg4::IonAndScint::instanceNames
private

Definition at line 75 of file IonAndScint_module.cc.

string larg4::IonAndScint::Instances
private

Definition at line 74 of file IonAndScint_module.cc.


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