10 #include "art/Framework/Core/EDAnalyzer.h"
11 #include "art/Framework/Core/ModuleMacros.h"
12 #include "art/Framework/Principal/Event.h"
13 #include "art/Framework/Principal/Handle.h"
14 #include "art/Framework/Principal/Run.h"
15 #include "art/Framework/Principal/SubRun.h"
16 #include "art/Utilities/make_tool.h"
18 #include "canvas/Utilities/InputTag.h"
19 #include "fhiclcpp/ParameterSet.h"
20 #include "messagefacility/MessageLogger/MessageLogger.h"
22 #include "art_root_io/TFileService.h"
52 void analyze(art::Event
const&
e)
override;
102 fPDSMapPtr{art::make_tool<opdet::PDMapAlg>(pset.get<fhicl::ParameterSet>(
"PDSMapTool"))}
105 fVerbosity = pset.get<
int>(
"Verbosity");
109 fInputModule = pset.get<std::vector<std::string>>(
"InputModule");
113 fInputModule.push_back(pset.get<std::string>(
"InputModule"));
120 art::ServiceHandle<art::TFileService>
tfs;
123 fAllPhotonsTree = tfs->make<TTree>(
"AllPhotons",
"AllPhotons");
124 fAllPhotonsTree->Branch(
"EventID", &fEventID,
"EventID/I");
125 fAllPhotonsTree->Branch(
"Wavelength", &fWavelength,
"Wavelength/F");
126 fAllPhotonsTree->Branch(
"OpChannel", &fOpChannel,
"OpChannel/I");
127 fAllPhotonsTree->Branch(
"Time", &fTime,
"Time/F");
130 fTheOpDetTree = tfs->make<TTree>(
"PhotonsPerOpDet",
"PhotonsPerOpDet");
131 fTheOpDetTree->Branch(
"EventID", &fEventID,
"EventID/I");
132 fTheOpDetTree->Branch(
"OpChannel", &fOpChannel,
"OpChannel/I");
133 fTheOpDetTree->Branch(
"OpDetX", &fOpDetX,
"OpDetX/F");
134 fTheOpDetTree->Branch(
"OpDetY", &fOpDetY,
"OpDetY/F");
135 fTheOpDetTree->Branch(
"OpDetZ", &fOpDetZ,
"OpDetZ/F");
136 fTheOpDetTree->Branch(
"isPMT", &fisPMT);
137 fTheOpDetTree->Branch(
"CountAll", &fCountOpDetAll,
"CountAll/I");
138 fTheOpDetTree->Branch(
"CountDirect", &fCountOpDetDirect,
"CountDirect/I");
139 fTheOpDetTree->Branch(
"CountReflected", &fCountOpDetReflected,
"CountReflected/I");
142 fTheEventTree = tfs->make<TTree>(
"PhotonsPerEvent",
"PhotonsPerEvent");
143 fTheEventTree->Branch(
"EventID", &fEventID,
"EventID/I");
144 fTheEventTree->Branch(
"CountAll", &fCountEventAll,
"CountAll/I");
145 fTheEventTree->Branch(
"CountDirect", &fCountEventDirect,
"CountDirect/I");
146 fTheEventTree->Branch(
"CountReflected", &fCountEventReflected,
"CountReflected/I");
154 art::ServiceHandle<geo::Geometry> geo;
157 fEventID = evt.id().event();
162 auto photon_handles = evt.getMany<std::vector<sim::SimPhotonsLite>>();
163 if (photon_handles.size() == 0)
164 throw art::Exception(art::errors::ProductNotFound)<<
"sim SimPhotons retrieved and you requested them.";
170 fCountEventReflected=0;
174 fCountOpDetReflected=0;
177 fNOpDetAll.clear(); fNOpDetAll.resize(geo->NOpChannels(), 0);
178 fNOpDetDirect.clear(); fNOpDetDirect.resize(geo->NOpChannels(), 0);
179 fNOpDetReflected.clear(); fNOpDetReflected.resize(geo->NOpChannels(), 0);
182 for(
auto const& mod : fInputModule){
185 for (
auto const& ph_handle: photon_handles) {
187 if (!ph_handle.isValid())
continue;
188 if (ph_handle.provenance()->moduleLabel() != mod)
continue;
190 bool Reflected = (ph_handle.provenance()->productInstanceName() ==
"Reflected");
192 if(fVerbosity > 0)
std::cout<<
"Found OpDet hit collection of size "<< (*ph_handle).size()<<std::endl;
194 if((*ph_handle).size()>0)
197 for (
auto const&
photon : (*ph_handle) )
200 fOpChannel=
photon.OpChannel;
201 std::map<int, int> PhotonsMap =
photon.DetectedPhotons;
204 std::string pd_type=fPDSMapPtr->pdType(fOpChannel);
205 if (Reflected && pd_type==
"xarapuca_vuv")
continue;
206 if(!Reflected && (pd_type==
"xarapuca_vis" || pd_type==
"pmt_uncoated"))
continue;
208 for(
auto it = PhotonsMap.begin(); it!= PhotonsMap.end(); it++)
212 if (Reflected) fWavelength = kVisibleWavelength;
213 else fWavelength= kVUVWavelength;
218 for(
int i = 0; i < it->second ; i++)
222 fAllPhotonsTree->Fill();
225 fNOpDetAll[fOpChannel]++;
229 fNOpDetDirect[fOpChannel]++;
232 else if (Reflected) {
233 fNOpDetReflected[fOpChannel]++;
244 for (
unsigned int OpDet = 0; OpDet < geo->NOpChannels(); OpDet++) {
248 geo::Point_t OpDetCenter = geo->OpDetGeoFromOpDet(OpDet).GetCenter();
249 fOpDetX = OpDetCenter.X();
250 fOpDetY = OpDetCenter.Y();
251 fOpDetZ = OpDetCenter.Z();
252 fisPMT = geo->OpDetGeoFromOpDet(OpDet).isSphere();
253 fCountOpDetAll = fNOpDetAll[OpDet];
254 fCountOpDetDirect = fNOpDetDirect[OpDet];
255 fCountOpDetReflected = fNOpDetReflected[OpDet];
256 fTheOpDetTree->Fill();
259 fCountEventAll+=fCountOpDetAll;
260 fCountEventDirect+=fCountOpDetDirect;
261 fCountEventReflected+=fCountOpDetReflected;
263 if(fVerbosity >2)
std::cout<<
"OpDetResponseInterface PerOpDet : Event "<<fEventID<<
" OpDet " << fOpChannel <<
" All " << fCountOpDetAll <<
" Dir " <<fCountOpDetDirect <<
", Refl " << fCountOpDetReflected<<std::endl;
267 fTheEventTree->Fill();
269 if(fVerbosity >1)
std::cout<<
"OpDetResponseInterface PerEvent : Event "<<fEventID<<
" All " << fCountEventAll <<
" Dir " <<fCountEventDirect <<
", Refl " << fCountEventReflected <<std::endl;
process_name can override from command line with o or output photon
void analyze(art::Event const &e) override
OpDetAnalyzer(fhicl::ParameterSet const &p)
std::unique_ptr< opdet::PDMapAlg > fPDSMapPtr
std::vector< int > fNOpDetAll
std::vector< int > fNOpDetReflected
static constexpr double kVUVWavelength
Value used when a typical ultraviolet light wavelength is needed.
static constexpr double kVisibleWavelength
Value used when a typical visible light wavelength is needed.
Simulation objects for optical detectors.
std::vector< int > fNOpDetDirect
This is the interface class for a tool to handle PD mapping in SBN detectors, used for flash matching...
OpDetAnalyzer & operator=(OpDetAnalyzer const &)=delete
std::vector< std::string > fArapucaMapLabel
std::vector< std::string > fPMTMapLabel
art::ServiceHandle< art::TFileService > tfs
BEGIN_PROLOG OpDetAnalyzer
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
Tools and modules for checking out the basics of the Monte Carlo.
std::vector< std::string > fInputModule
art framework interface to geometry description
BEGIN_PROLOG could also be cout