13 #include "art/Framework/Core/EDAnalyzer.h"
14 #include "art/Framework/Core/ModuleMacros.h"
15 #include "art/Framework/Principal/Event.h"
16 #include "fhiclcpp/ParameterSet.h"
17 #include "art/Framework/Principal/Run.h"
18 #include "art/Framework/Principal/SubRun.h"
19 #include "art/Framework/Principal/Handle.h"
20 #include "canvas/Persistency/Common/Ptr.h"
21 #include "canvas/Persistency/Common/PtrVector.h"
22 #include "art/Framework/Services/Registry/ServiceHandle.h"
23 #include "art_root_io/TFileService.h"
24 #include "art_root_io/TFileDirectory.h"
25 #include "canvas/Persistency/Common/FindOneP.h"
26 #include "canvas/Persistency/Common/FindManyP.h"
27 #include "canvas/Utilities/InputTag.h"
28 #include "messagefacility/MessageLogger/MessageLogger.h"
54 #include "nusimdata/SimulationBase/MCParticle.h"
55 #include "nusimdata/SimulationBase/MCTruth.h"
56 #include "nusimdata/SimulationBase/MCNeutrino.h"
58 #include "nug4/ParticleNavigation/ParticleList.h"
70 #include "TTimeStamp.h"
94 void analyze(art::Event
const &
e)
override;
160 photonLabel(p.
get<art::InputTag>(
"fottoni",
"largeant")),
161 chargeLabel(p.
get<art::InputTag>(
"carconi",
"largeant")),
162 typoLabel (p.
get<art::InputTag>(
"tiponi",
"generator"))
165 std::cout <<
" PMT coordinates constructor " << std::endl;
172 art::ServiceHandle<geo::Geometry> geom;
174 std::vector<sim::SimPhotons>
const& optical = *(evt.getValidHandle<std::vector<sim::SimPhotons>>(photonLabel));
175 std::vector<sim::SimChannel>
const& charge = *(evt.getValidHandle<std::vector<sim::SimChannel>>(chargeLabel));
180 event = evt.id().event();
184 auto type = evt.getMany< std::vector<simb::MCTruth> >();
186 for(
size_t mcl = 0; mcl <
type.size(); ++mcl)
188 art::Handle< std::vector<simb::MCTruth> > mclistHandle =
type[mcl];
190 for(
size_t m = 0;
m < mclistHandle->size(); ++
m)
192 art::Ptr<simb::MCTruth> mct(mclistHandle,
m);
200 event_type=mct->GetParticle(0).PdgCode();
201 vertex_x=mct->GetParticle(0).Vx();
202 vertex_y=mct->GetParticle(0).Vy();
203 vertex_z=mct->GetParticle(0).Vz();
205 if (event_type==12||event_type==-12||event_type==14||event_type==-14||event_type==16||event_type==-16)
208 Neutrino_Interaction=mct->GetNeutrino().InteractionType();
213 Neutrino_Interaction=-9999;
226 for (
int u=0; u<360; u++)
232 true_barycentre_x =0;
233 true_barycentre_y =0;
234 true_barycentre_z =0;
236 total_quenched_energy =0;
240 for (std::size_t chargechannel = 0; chargechannel<charge.size(); ++chargechannel)
242 auto const& channeltdcide = charge.at(chargechannel).TDCIDEMap();
244 for (std::size_t TDCnu = 0; TDCnu<channeltdcide.size(); ++TDCnu)
247 sim::TDCIDE const& tdcide = channeltdcide.at(TDCnu);
249 for (std::size_t IDEnu = 0; IDEnu<tdcide.second.size(); ++IDEnu)
251 sim::IDE const& ida = tdcide.second.at(IDEnu);
255 true_barycentre_x = true_barycentre_x + ida.
x*ida.
energy;
256 true_barycentre_y = true_barycentre_y + ida.
y*ida.
energy;
257 true_barycentre_z = true_barycentre_z + ida.
z*ida.
energy;
258 total_quenched_energy = total_quenched_energy + ida.
energy;
266 true_barycentre_x = true_barycentre_x/total_quenched_energy;
267 true_barycentre_y = true_barycentre_y/total_quenched_energy;
268 true_barycentre_z = true_barycentre_z/total_quenched_energy;
270 total_quenched_energy = total_quenched_energy/3;
278 total_coll_photons=0;
280 for (std::size_t channel = 0; channel < optical.size(); ++channel) {
284 noPMT[channel] = channel;
286 photons_collected[channel]= photon_vec.size();
287 std::cout <<
" channel " << channel <<
" photons collected " << photons_collected[channel] << std::endl;
292 QE_photons_collected[channel]= 0.06*photons_collected[channel];
294 if (photons_collected[channel]>0){
301 geom->OpDetGeoFromOpChannel(channel).GetCenter(xyz);
303 PMTx[channel] = xyz[0];
304 PMTy[channel] = xyz[1];
305 PMTz[channel] = xyz[2];
307 reco_barycentre_y = reco_barycentre_y + PMTy[channel]*photons_collected[channel];
308 reco_barycentre_z = reco_barycentre_z + PMTz[channel]*photons_collected[channel];
309 total_coll_photons= total_coll_photons + photons_collected[channel];
310 std::cout <<
" channel " << channel <<
" total photons " << total_coll_photons << std::endl;
311 firstphoton_time[channel] = 100000000;
313 if (photons_collected[channel]>0)
315 for (
size_t i = 0; i<photon_vec.size() && int(i)<
MaxPhotons; ++i)
317 photon_time[channel][i]= photon_vec.at(i).Time;
319 if (photon_time[channel][i]<firstphoton_time[channel])
321 firstphoton_time[channel]=photon_time[channel][i];
330 if (PMTx[channel]<0){Cryostat[channel]=0;}
331 if (PMTx[channel]>0){Cryostat[channel]=1;}
333 if (PMTx[channel]<-200){
TPC[channel]=0;}
334 if (PMTx[channel]>-200 && PMTx[channel]<0){
TPC[channel]=1;}
335 if (PMTx[channel]<200 && PMTx[channel]>0){
TPC[channel]=2;}
336 if (PMTx[channel]>200){
TPC[channel]=3;}
342 std::cout <<
" fotoni finale = " <<total_coll_photons <<std::endl;
344 reco_barycentre_y = reco_barycentre_y/total_coll_photons;
345 reco_barycentre_z = reco_barycentre_z/total_coll_photons;
348 PMT_error_y = reco_barycentre_y-true_barycentre_y;
349 PMT_error_z = reco_barycentre_z-true_barycentre_z;
350 PMT_total_error = sqrt((PMT_error_y*PMT_error_y)+(PMT_error_z*PMT_error_z));
353 std::cout <<
" after filling " << fTree << std::endl;
358 std::cout <<
" PMTcoordinates beginjob " << std::endl;
360 art::ServiceHandle<art::TFileService>
tfs;
361 fTree = tfs->make<TTree>(
"lighttree",
"tree for the light response");
363 fTree->Branch(
"event",&event,
"event/I");
364 fTree->Branch(
"event_type",&event_type,
"event_type/I");
365 fTree->Branch(
"is_Neutrino",&is_Neutrino,
"is_Neutrino/I");
366 fTree->Branch(
"Neutrino_Interaction",&Neutrino_Interaction,
"Neutrino_Interaction/I");
367 fTree->Branch(
"total_quenched_energy",&total_quenched_energy,
"total_quenched_energy");
374 fTree->Branch(
"turned_PMT",&turned_PMT,
"turned_PMT/I");
375 fTree->Branch(
"total_coll_photons",&total_coll_photons,
"total_coll_photons/F");
376 fTree->Branch(
"photons_colleted",&photons_collected,(
"photons_collected[" +
std::to_string(
nPMTs) +
"]/F").c_str());
377 fTree->Branch(
"QE_photons_colleted",&QE_photons_collected,(
"QE_photons_collected[" +
std::to_string(
nPMTs) +
"]/F").c_str());
378 fTree->Branch(
"firstphoton_time",&firstphoton_time,(
"firstphoton_time[" +
std::to_string(
nPMTs) +
"]/F").c_str());
379 fTree->Branch(
"photon_time",&photon_time,
"photon_time[360][10000]/F");
380 fTree->Branch(
"vertex_x",&vertex_x,
"vertex_x/D");
381 fTree->Branch(
"vertex_y",&vertex_y,
"vertex_y/D");
382 fTree->Branch(
"vertex_z",&vertex_z,
"vertex_z/D");
383 fTree->Branch(
"true_barycentre_x",&true_barycentre_x,
"true_barycentre_x/F");
384 fTree->Branch(
"true_barycentre_y",&true_barycentre_y,
"true_barycentre_y/F");
385 fTree->Branch(
"true_barycentre_z",&true_barycentre_z,
"true_barycentre_z/F");
386 fTree->Branch(
"reco_barycentre_y",&reco_barycentre_y,
"reco_barycentre_y/F");
387 fTree->Branch(
"reco_barycentre_z",&reco_barycentre_z,
"reco_barycentre_z/F");
388 fTree->Branch(
"PMT_error_y",&PMT_error_y,
"PMT_error_y/F");
389 fTree->Branch(
"PMT_error_z",&PMT_error_z,
"PMT_error_z/F");
390 fTree->Branch(
"PMT_total_error",&PMT_total_error,
"PMT_total_error/F");
float photon_time[nPMTs][MaxPhotons]
float total_quenched_energy
float z
z position of ionization [cm]
std::pair< unsigned short, std::vector< sim::IDE > > TDCIDE
List of energy deposits at the same time (on this channel)
Declaration of signal hit object.
art::InputTag chargeLabel
void analyze(art::Event const &e) override
float x
x position of ionization [cm]
tuple m
now if test mode generate materials, CRT shell, world, gdml header else just generate CRT shell for u...
Simulation objects for optical detectors.
Ionization at a point of the TPC sensitive volume.
float energy
energy deposited by ionization by this track ID and time [MeV]
Declaration of cluster object.
Definition of data types for geometry description.
Provides recob::Track data product.
float y
y position of ionization [cm]
Collection of photons which recorded on one channel.
PMTcoordinates & operator=(PMTcoordinates const &)=delete
art::InputTag photonLabel
PMTcoordinates(fhicl::ParameterSet const &p)
std::string to_string(WindowPattern const &pattern)
object containing MC truth information necessary for making RawDigits and doing back tracking ...
Declaration of basic channel signal object.
float photons_collected[nPMTs]
art::ServiceHandle< art::TFileService > tfs
Utility functions to extract information from recob::Track
Tools and modules for checking out the basics of the Monte Carlo.
float QE_photons_collected[nPMTs]
float firstphoton_time[nPMTs]
art framework interface to geometry description
BEGIN_PROLOG could also be cout