Skip to content

Commit

Permalink
fixed size_t error in benchmarks cxx files, added preliminary larsoft…
Browse files Browse the repository at this point in the history
… integration
  • Loading branch information
infophysics committed Sep 8, 2024
1 parent 37fb492 commit a88edfa
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 2 deletions.
2 changes: 1 addition & 1 deletion benchmarks/LArNESTFluctuationBenchmarks.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ int main(int argc, char* argv[])
}

// set up energy steps
int num_energy_steps = 50000;
size_t num_energy_steps = 50000;
std::vector<double> energy_vals;
double start_val = .1;
double end_val = 1000;
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/LArNESTMeanYieldsBenchmarks.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ int main(int argc, char* argv[])
}

// set up energy steps
int num_energy_steps = 50000;
size_t num_energy_steps = 50000;
std::vector<double> energy_vals;
double start_val = .1;
double end_val = 1000;
Expand Down
75 changes: 75 additions & 0 deletions larsoft/ISCalcNESTLAr.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
////////////////////////////////////////////////////////////////////////
// Class: ISCalcNESTLAr
// Plugin Type: Algorithm
// File: ISCalcNESTLAr.cxx
// Description:
// Aug. 30 by Mu Wei
// Edited by N. Carrara to use LArNEST (05/29/2023)
////////////////////////////////////////////////////////////////////////

#include "larsim/IonizationScintillation/ISCalcNESTLAr.h"
#include "larcore/CoreUtils/ServiceUtil.h"
#include "lardata/DetectorInfoServices/LArPropertiesService.h"
#include "lardataalg/DetectorInfo/DetectorPropertiesData.h"
#include "lardataobj/Simulation/SimEnergyDeposit.h"
#include "larevt/SpaceChargeServices/SpaceChargeService.h"

#include "CLHEP/Random/RandFlat.h"
#include "CLHEP/Random/RandGauss.h"
#include "CLHEP/Units/SystemOfUnits.h"

#include <algorithm>

namespace {
constexpr double LAr_Z{18};
constexpr double Density_LAr{1.393};

constexpr double scint_yield{1.0 / (19.5 * CLHEP::eV)};
constexpr double resolution_scale{0.107}; // Doke 1976
}

namespace larg4 {

//----------------------------------------------------------------------------
ISCalcNESTLAr::ISCalcNESTLAr(CLHEP::HepRandomEngine& Engine)
: fEngine(Engine), fSCE{lar::providerFrom<spacecharge::SpaceChargeService>()}
{
LArDetector* detector = new LArDetector();
mLArNEST = new NEST::LArNEST(detector);

std::cout << "ISCalcNESTLAr Initialize." << std::endl;
}

//----------------------------------------------------------------------------
ISCalcData ISCalcNESTLAr::CalcIonAndScint(detinfo::DetectorPropertiesData const& detProp,
sim::SimEnergyDeposit const& edep)
{

std::cout << "HERE IN NEST!" << std::endl;
return {0.0, 0.0, 0.0, 0.0};

// return {energyDeposit,
// static_cast<double>(NumElectrons),
// static_cast<double>(NumPhotons),
// GetScintYieldRatio(edep)};
}



//----------------------------------------------------------------------------
double ISCalcNESTLAr::EFieldAtStep(double efield, sim::SimEnergyDeposit const& edep)
{
geo::Point_t pos = edep.MidPoint();
double EField = efield;
geo::Vector_t eFieldOffsets;
if (fSCE->EnableSimEfieldSCE()) {
eFieldOffsets = fSCE->GetEfieldOffsets(pos);
EField =
std::sqrt((efield + efield * eFieldOffsets.X()) * (efield + efield * eFieldOffsets.X()) +
(efield * eFieldOffsets.Y() * efield * eFieldOffsets.Y()) +
(efield * eFieldOffsets.Z() * efield * eFieldOffsets.Z()));
}
return EField;
}

}
43 changes: 43 additions & 0 deletions larsoft/ISCalcNESTLAr.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
////////////////////////////////////////////////////////////////////////
// Class: ISCalcNESTLAr
// Plugin Type: Algorithm
// File: ISCalcNESTLAr.cxx
// Description:
// Aug. 30 by Mu Wei
// Edited by N. Carrara to use LArNEST (05/29/2023)
////////////////////////////////////////////////////////////////////////

#ifndef LARG4_ISCALCNESTLAr_H
#define LARG4_ISCALCNESTLAr_H

#include "larsim/IonizationScintillation/ISCalc.h"
#include "LArDetector.hh"
#include "LArNEST.hh"

namespace spacecharge {
class SpaceCharge;
}

namespace CLHEP {
class HepRandomEngine;
}

namespace larg4 {
class ISCalcNESTLAr : public ISCalc {
public:
explicit ISCalcNESTLAr(CLHEP::HepRandomEngine& fEngine);

double EFieldAtStep(double efield,
sim::SimEnergyDeposit const& edep)
override; //value of field with any corrections for this step
ISCalcData CalcIonAndScint(detinfo::DetectorPropertiesData const& detProp,
sim::SimEnergyDeposit const& edep) override;

private:
CLHEP::HepRandomEngine& fEngine; // random engine
const spacecharge::SpaceCharge* fSCE;

NEST::LArNEST* mLArNEST;
};
}
#endif // LARG4_ISCALCNESTLAr_H

0 comments on commit a88edfa

Please sign in to comment.