9 #include "art/Framework/Core/ModuleMacros.h"
10 #include "art/Framework/Core/EDAnalyzer.h"
13 #include "art/Framework/Principal/Event.h"
14 #include "fhiclcpp/ParameterSet.h"
15 #include "art/Framework/Services/Registry/ServiceHandle.h"
16 #include "art_root_io/TFileService.h"
17 #include "messagefacility/MessageLogger/MessageLogger.h"
21 #include "nug4/ParticleNavigation/ParticleList.h"
29 #include "TLorentzVector.h"
42 explicit LArG4Ana(fhicl::ParameterSet
const& pset);
101 , fG4ModuleLabel{pset.get< std::string >(
"GeantModuleLabel")}
110 art::ServiceHandle<art::TFileService const>
tfs;
111 art::ServiceHandle<geo::Geometry const> geo;
113 fPDGCodes = tfs->make<TH1D>(
"pdgcodes",
";PDG Code;", 5000, -2500, 2500);
114 fPi0Momentum = tfs->make<TH1D>(
"pi0mom",
";#pi^{0} Momentum (GeV);", 1000, 0., 1000.);
116 fTree = tfs->make<TTree>(
"MCTTree",
"MCTTree");
117 fnEnergy = tfs->make<TH1D>(
"nEnergy",
";n,#Lambda^{0},K^{0} Momentum (GeV);", 100, 0., 10.);
118 fnDist = tfs->make<TH1D>(
"nDistance",
";n,#Lambda^{0},K^{0} Distance (m);", 200, -30000.0, +30000.);
124 "Active channels;Active channels;# events",
125 256, 0, geo->Nchannels());
126 fnumIDEs = tfs->make<TProfile>(
"fnumIDEs",
127 "Drift Electrons per channel;Channel;Drift electrons",
128 geo->Nchannels()+1, 0, geo->Nchannels(),
131 "Charge in event;Total charge per event;# events",
134 "Energy in event;Total energy per event;# events",
137 "Charge on channel;Channel;Total charge per channel",
138 geo->Nchannels()+1,0,geo->Nchannels(),
141 "Energy on channel;Channel;Total energy per channel",
142 geo->Nchannels()+1,0,geo->Nchannels(),
163 fTree->Branch(
"MCNumDs", &
fTNds,
"MCNumDs/I");
165 fTree->Branch(
"MCDID",
fTDID,
"MCDID[MCNumDs]/I");
166 fTree->Branch(
"MCDPdg",
fTDPdg,
"MCDPdg[MCNumDs]/I");
167 fTree->Branch(
"MCDWt",
fTDWt,
"MCDWt[MCNumDs]/I");
174 fTree->Branch(
"MCOrigin", fT4Origin,
"MCOrigin[4]/F");
187 art::ServiceHandle<cheat::ParticleInventoryService const> pi_serv;
188 const sim::ParticleList& plist = pi_serv->ParticleList();
189 art::ServiceHandle<geo::Geometry const> geom;
193 std::vector<const sim::SimChannel*> sccol;
196 double totalCharge=0.0;
197 double totalEnergy=0.0;
199 for(
size_t sc = 0; sc < sccol.size(); ++sc){
203 const auto & tdcidemap = sccol[sc]->TDCIDEMap();
204 for(
auto mapitr = tdcidemap.begin(); mapitr != tdcidemap.end(); mapitr++){
205 const std::vector<sim::IDE> idevec = (*mapitr).second;
206 numIDEs += idevec.size();
207 for(
size_t iv = 0; iv < idevec.size(); ++iv){
208 if(plist.find( idevec[iv].trackID ) == plist.end()
210 mf::LogWarning(
"LArG4Ana") << idevec[iv].trackID <<
" is not in particle list";
211 totalCharge +=idevec[iv].numElectrons;
212 scCharge += idevec[iv].numElectrons;
213 totalEnergy +=idevec[iv].energy;
214 scEnergy += idevec[iv].energy;
225 const sim::ParticleList& Particles = pi_serv->ParticleList();
226 std::vector<const simb::MCParticle*> pvec;
227 pvec.reserve(Particles.size());
228 for (
const auto& PartPair: Particles) {
229 pvec.push_back(PartPair.second);
230 fPDGCodes->Fill(PartPair.second->PdgCode());
236 for(
unsigned int i = 0; i < pvec.size(); ++i){
237 if(pvec[i]->PdgCode() == 111) pi0loc = i;
238 if(pvec[i]->Mother() == pi0loc+1 &&
240 pvec[i]->PdgCode() == 22){
241 mf::LogInfo(
"LArG4Ana") << pvec[i]->E() <<
" gamma energy ";
246 if (pvec[i]->PdgCode() == 2112 ||
247 pvec[i]->PdgCode() == 3122 ||
248 pvec[i]->PdgCode() == 130 ||
249 pvec[i]->PdgCode() == 310 ||
250 pvec[i]->PdgCode() == 311 ) {
251 fnEnergy->Fill(pvec[i]->
E(),pvec[i]->Weight());
252 fnDist->Fill(pvec[i]->Vx(),pvec[i]->Weight());
255 fTPdg = pvec[i]->PdgCode();
256 fTID = pvec[i]->TrackId();
258 for (
unsigned int s = 0;
s < 35; ++
s){
269 for(
unsigned int s = 0;
s < pvec[i]->Process().length(); ++
s) *(
fTProcess+
s) = pvec[i]->Process()[
s];
271 TVector3 dum = pvec[i]->Position().Vect();
273 for (
unsigned int s = 0;
s < geom->MaterialName(pvec[i]->Position().Vect()).length(); ++
s)
274 *(
fTMaterial+
s) = geom->MaterialName(pvec[i]->Position().Vect())[
s];
276 for (
unsigned int s = 0;
s < geom->VolumeName(pvec[i]->Position().Vect()).length(); ++
s)
277 *(
fTVolume+
s) = geom->VolumeName(pvec[i]->Position().Vect())[
s];
279 for (
unsigned int s = 0;
s < geom->VolumeName(pvec[i]->EndPosition().Vect()).length(); ++
s)
280 *(
fTTVolume+
s) = geom->VolumeName(pvec[i]->EndPosition().Vect())[
s];
282 fTEvt = evt.id().event();
283 fTSub = evt.subRun();
289 for(
int d = 0; d <
fTNds; d++ ){
290 daughter = pvec[i]->Daughter(d);
295 for(
unsigned int jj = i; jj < pvec.size(); ++jj){
297 if (
fTDID[d] == pvec[jj]->TrackId()){
298 fTDPdg[d] = pvec[jj]->PdgCode();
299 fTDWt[d] = pvec[jj]->Weight();
301 for (
unsigned int s = 0;
s < pvec[jj]->Process().length(); ++
s)
304 for (
unsigned int kk = 0; kk < 4; ++kk){
305 fT4DOrigin[d*4+kk] = pvec[jj]->Position()[kk];
313 for (
unsigned int ii = 0; ii < 4; ++ii){
325 if(numpi0gamma == 2 && pi0loc > 0){
326 mf::LogInfo(
"LArG4Ana") << pvec[pi0loc]->E();
TProfile * fChannelCharge
Charge per channel.
void analyze(const art::Event &evt)
std::string fG4ModuleLabel
module label for the Geant
TH1D * fnumChannels
The number of channels recieving charge per event.
TH1D * fEventEnergy
Energy collected per event.
TProfile * fChannelEnergy
Energy per channel.
Char_t fTDProcess[200][35]
static const int NoParticleId
TH1D * fEventCharge
Charge collected per event.
LArG4Ana(fhicl::ParameterSet const &pset)
Standard constructor and destructor for an FMWK module.
then echo File list $list not found else cat $list while read file do echo $file sed s
std::string fTruthModuleLabel
module label for the Geant
object containing MC truth information necessary for making RawDigits and doing back tracking ...
art::ServiceHandle< art::TFileService > tfs
Tools and modules for checking out the basics of the Monte Carlo.
art framework interface to geometry description
TProfile * fnumIDEs
Number of drift electrons per channel.