37 #include "art_root_io/TFileService.h" 53 #include "nug4/ParticleNavigation/ParticleList.h" 57 #include "RtypesCore.h" 60 #include "TLorentzVector.h" 157 int channel,
int nDirectPhotons,
int nReflectedPhotons,
158 double reflectedT0 = 0.0
181 fInputModule = pset.
get<std::vector<std::string>>(
"InputModule",{
"largeant"});
199 <<
"Building a library with reflected light time is not supported when using SimPhotonsLite.\n";
213 double OpDetCenter[3];
215 std::cout<<ch<<
" "<<OpDetCenter[0]<<
" "<<OpDetCenter[1]<<
" "<<OpDetCenter[2]<<
std::endl;
218 double CryoBounds[6];
221 std::cout<<
"Xmin: "<<CryoBounds[0]<<
" Xmax: "<<CryoBounds[1]<<
" Ymin: "<<CryoBounds[2]
222 <<
" Ymax: "<<CryoBounds[3]<<
" Zmin: "<<CryoBounds[4]<<
" Zmax: "<<CryoBounds[5]<<
std::endl;
230 <<
"ParticleInventoryService service is not configured!" 231 " Please add it in the job configuration." 232 " In the meanwhile, some checks to particles will be skipped." 269 fTheEventTree = tfs->make<TTree>(
"OpDetEvents",
"OpDetEvents");
321 std::vector<simb::MCParticle>
const* mcpartVec =
nullptr;
324 std::vector<double> totalEnergy_track;
329 mcpartVec = evt.
getHandle<std::vector<simb::MCParticle>>(
"largeant").product();
331 size_t maxNtracks = 1000U;
336 for(
size_t itrack=0; itrack!=maxNtracks; itrack++) {
340 totalEnergy_track.resize(maxNtracks, 0.);
347 std::vector<const sim::SimChannel*> sccol;
351 double totalCharge=0.0;
352 double totalEnergy=0.0;
354 for(
size_t sc = 0; sc < sccol.size(); ++sc){
358 const auto & tdcidemap = sccol[sc]->TDCIDEMap();
360 for(
auto mapitr = tdcidemap.begin(); mapitr != tdcidemap.end(); mapitr++){
361 const std::vector<sim::IDE> idevec = (*mapitr).second;
362 numIDEs += idevec.size();
364 for(
size_t iv = 0; iv < idevec.size(); ++iv){
366 if(plist->find( idevec[iv].trackID ) == plist->end()
369 mf::LogWarning(
"LArG4Ana") << idevec[iv].trackID <<
" is not in particle list";
372 if(idevec[iv].trackID < 0)
continue;
373 totalCharge +=idevec[iv].numElectrons;
374 scCharge += idevec[iv].numElectrons;
375 totalEnergy +=idevec[iv].energy;
376 scEnergy += idevec[iv].energy;
378 totalEnergy_track[idevec[iv].trackID] += idevec[iv].energy/3.;
396 auto photon_handles = evt.
getMany<std::vector<sim::SimPhotons>>();
397 if (photon_handles.size() == 0)
404 for (
auto const& ph_handle: photon_handles) {
406 if (!ph_handle.isValid())
continue;
407 if (ph_handle.provenance()->moduleLabel() != mod)
continue;
409 bool Reflected = (ph_handle.provenance()->productInstanceName() ==
"Reflected");
411 if((*ph_handle).size()>0)
415 const int maxNtracks = 1000;
416 for(
size_t itrack=0; itrack!=maxNtracks; itrack++) {
417 for(
size_t pmt_i=0; pmt_i!=geo->
NOpChannels(); pmt_i++) {
427 if(
fVerbosity > 0) std::cout<<
"Found OpDet hit collection of size "<< (*ph_handle).size()<<
std::endl;
429 if((*ph_handle).size()>0)
432 for(
auto const& itOpDet: (*ph_handle) )
562 std::cout<<
"Filling the analysis tree"<<
std::endl;
565 std::vector<double> this_xyz;
570 if(pPart.Process() ==
"primary")
581 fpdg = pPart.PdgCode();
588 for(
size_t i_s=1; i_s < pPart.NumberTrajectoryPoints(); i_s++){
591 this_xyz[0] = pPart.Position(i_s).X();
592 this_xyz[1] = pPart.Position(i_s).Y();
593 this_xyz[2] = pPart.Position(i_s).Z();
595 fstepTimes.push_back(pPart.Position(i_s).T());
610 auto photon_handles = evt.
getMany<std::vector<sim::SimPhotonsLite>>();
611 if (photon_handles.size() == 0)
620 for (
auto const& ph_handle: photon_handles) {
622 if (!ph_handle.isValid())
continue;
623 if (ph_handle.provenance()->moduleLabel() != mod)
continue;
625 bool Reflected = (ph_handle.provenance()->productInstanceName() ==
"Reflected");
631 if(
fVerbosity > 0) std::cout<<
"Found OpDet hit collection of size "<< (*ph_handle).size()<<
std::endl;
634 if((*ph_handle).size()>0)
637 for (
auto const& photon : (*ph_handle) )
641 std::map<int, int> PhotonsMap = photon.DetectedPhotons;
648 for(
auto it = PhotonsMap.begin(); it!= PhotonsMap.end(); it++)
662 for(
int i = 0; i < it->second ; i++)
675 else if (Reflected) {
724 int channel,
int nDirectPhotons,
int nReflectedPhotons,
742 pvs.
SetLibraryEntry(VoxID, channel,
double(nReflectedPhotons)/NProd,
true);
Store parameters for running LArG4.
Int_t fCountOpDetDetected
std::vector< std::vector< double > > fstepPositions
TVector3 initialPhotonPosition
OpDetGeo const & OpDetGeoFromOpDet(unsigned int OpDet) const
Returns the geo::OpDetGeo object for the given detector number.
void RetrieveLightProd(int &VoxID, double &N) const
Encapsulate the construction of a single cyostat.
TTree * fLightAnalysisTree
Handle< PROD > getHandle(SelectorBase const &) const
void storeVisibility(int channel, int nDirectPhotons, int nReflectedPhotons, double reflectedT0=0.0) const
bool fMakeLightAnalysisTree
std::vector< double > fPosition0
All information of a photon entering the sensitive optical detector volume.
phot::PhotonVisibilityService const * fPVS
void GetCenter(double *xyz, double localz=0.0) const
std::vector< std::vector< double > > fSignalsvuv
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
virtual bool detected(int OpChannel, const sim::OnePhoton &Phot, int &newOpChannel) const
EDAnalyzer(fhicl::ParameterSet const &pset)
static constexpr double kVUVWavelength
Value used when a typical ultraviolet light wavelength is needed.
unsigned int NOpChannels() const
Number of electronics channels for all the optical detectors.
TVector3 finalPhotonPosition
void CryostatBoundaries(double *boundaries, geo::CryostatID const &cid) const
Returns the boundaries of the specified cryostat.
art framework interface to geometry description
std::vector< double > fstepTimes
std::vector< std::string > fInputModule
bool StoreReflected() const
Simulation objects for optical detectors.
bool isVisible(double wavelength) const
Returns if we label as "visibile" a photon with specified wavelength [nm].
#define DEFINE_ART_MODULE(klass)
void analyze(art::Event const &)
bool fMakeDetectedPhotonsTree
static const int NoParticleId
static constexpr double kVisibleWavelength
Value used when a typical visible light wavelength is needed.
TTree * fThePhotonTreeDetected
std::vector< Handle< PROD > > getMany(SelectorBase const &selector=MatchAllSelector{}) const
void SetLibraryReflT0Entry(int VoxID, int OpChannel, float value)
T get(std::string const &key) const
TTree * fThePhotonTreeAll
CryostatGeo const & Cryostat(geo::CryostatID const &cryoid) const
Returns the specified cryostat.
Int_t fCountEventDetected
Class def header for mctrack data container.
bool fMakeOpDetEventsTree
virtual bool detectedLite(int OpChannel, int &newOpChannel) const
const sim::ParticleList & ParticleList() const
Encapsulate the geometry of an optical detector.
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Collection of photons which recorded on one channel.
void SetLibraryEntry(int VoxID, OpDetID_t libOpChannel, float N, bool wantReflected=false)
unsigned int NOpDet() const
Number of optical detectors in this TPC.
std::vector< std::vector< std::vector< double > > > fSignals_vis
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
IDNumber_t< Level::Event > EventNumber_t
bool const fUseLitePhotons
EventNumber_t event() const
static constexpr double kVisibleThreshold
Threshold used to resolve between visible and ultraviolet light.
std::vector< std::vector< double > > fSignalsvis
Int_t fCountOpDetReflDetected
std::size_t getView(std::string const &moduleLabel, std::string const &productInstanceName, std::string const &processName, std::vector< ELEMENT const * > &result) const
Tools and modules for checking out the basics of the Monte Carlo.
virtual float wavelength(double energy) const
LArSoft geometry interface.
std::vector< std::vector< std::vector< double > > > fSignals_vuv
QTextStream & endl(QTextStream &s)
Event finding and building.
cheat::ParticleInventoryService const * pi_serv