All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Attributes | List of all members
larg4::LArG4Ana Class Reference
Inheritance diagram for larg4::LArG4Ana:

Public Member Functions

 LArG4Ana (fhicl::ParameterSet const &pset)
 Standard constructor and destructor for an FMWK module. More...
 
void analyze (const art::Event &evt)
 
void beginJob ()
 

Private Attributes

std::string fG4ModuleLabel
 module label for the Geant More...
 
std::string fTruthModuleLabel
 module label for the Geant More...
 
TH1D * fPDGCodes
 
TH1D * fPi0Momentum
 
TH1D * fnEnergy
 
TH1D * fnDist
 
TH1D * fnumChannels
 The number of channels recieving charge per event. More...
 
TProfile * fnumIDEs
 Number of drift electrons per channel. More...
 
TH1D * fEventCharge
 Charge collected per event. More...
 
TH1D * fEventEnergy
 Energy collected per event. More...
 
TProfile * fChannelCharge
 Charge per channel. More...
 
TProfile * fChannelEnergy
 Energy per channel. More...
 
TTree * fTree
 
Int_t fTEvt
 
Int_t fTSub
 
Int_t fTRun
 
Int_t fTPdg
 
Int_t fTID
 
Int_t fTNdsOriginal
 
Int_t fTNds
 
Int_t fTNds4
 
Int_t * fTDID
 
Int_t * fTDPdg
 
Float_t * fTDWt
 
Char_t fTProcess [35]
 
Char_t fTVolume [35]
 
Char_t fTTVolume [35]
 
Char_t fTMaterial [35]
 
Char_t fTDProcess [200][35]
 
Int_t fTParentID
 
Int_t fTStatus
 
Float_t fTWeight
 
Float_t * fT4Origin
 
Float_t * fT4DOrigin
 
Float_t * fT4Termination
 
Float_t * fT4Momentum
 
Float_t * fT4DMomentum
 

Detailed Description

Definition at line 38 of file LArG4Ana_module.cc.

Constructor & Destructor Documentation

larg4::LArG4Ana::LArG4Ana ( fhicl::ParameterSet const &  pset)
explicit

Standard constructor and destructor for an FMWK module.

Definition at line 99 of file LArG4Ana_module.cc.

100  : EDAnalyzer(pset)
101  , fG4ModuleLabel{pset.get< std::string >("GeantModuleLabel")}
102  , fTruthModuleLabel{pset.get< std::string >("TruthModuleLabel")}
103  , fTNdsOriginal{pset.get< int >("Ndaughters" )}
105  {}
std::string fG4ModuleLabel
module label for the Geant
std::string fTruthModuleLabel
module label for the Geant

Member Function Documentation

void larg4::LArG4Ana::analyze ( const art::Event &  evt)

Definition at line 183 of file LArG4Ana_module.cc.

184  {
185 
186  //get the list of particles from this event
187  art::ServiceHandle<cheat::ParticleInventoryService const> pi_serv;
188  const sim::ParticleList& plist = pi_serv->ParticleList();
189  art::ServiceHandle<geo::Geometry const> geom;
190 
191  // loop over all sim::SimChannels in the event and make sure there are no
192  // sim::IDEs with trackID values that are not in the sim::ParticleList
193  std::vector<const sim::SimChannel*> sccol;
194  evt.getView(fG4ModuleLabel, sccol);
195 
196  double totalCharge=0.0;
197  double totalEnergy=0.0;
198  fnumChannels->Fill(sccol.size());
199  for(size_t sc = 0; sc < sccol.size(); ++sc){
200  double numIDEs=0.0;
201  double scCharge=0.0;
202  double scEnergy=0.0;
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()
209  && idevec[iv].trackID != sim::NoParticleId)
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;
215  }
216  }
217  fnumIDEs->Fill(sc,numIDEs);
218  fChannelCharge->Fill(sc,scCharge);
219  fChannelEnergy->Fill(sc,scEnergy);
220  }
221  fEventCharge->Fill(totalCharge);
222  fEventEnergy->Fill(totalEnergy);
223 
224  // get the particles from the back tracker
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());
231  }
232 
233  // now look for pi0's that decay to 2 gammas
234  int pi0loc = -1;
235  int numpi0gamma = 0;
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 &&
239  pi0loc > 0 &&
240  pvec[i]->PdgCode() == 22){
241  mf::LogInfo("LArG4Ana") << pvec[i]->E() << " gamma energy ";
242  ++numpi0gamma;
243  }
244 
245  // n,Lambda,K0s,K0L,K0
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());
253  }
254 
255  fTPdg = pvec[i]->PdgCode();
256  fTID = pvec[i]->TrackId();
257  // 0 out strings, else there may be cruft in here from prev evt.
258  for (unsigned int s = 0; s < 35; ++s){
259  *(fTProcess+s) = 0;
260  *(fTProcess+s) = 0;
261  *(fTMaterial+s) = 0;
262  *(fTMaterial+s) = 0;
263  *(fTVolume+s) = 0;
264  *(fTVolume+s) = 0;
265  *(fTTVolume+s) = 0;
266  *(fTTVolume+s) = 0;
267  }
268 
269  for(unsigned int s = 0; s < pvec[i]->Process().length(); ++s) *(fTProcess+s) = pvec[i]->Process()[s];
270 
271  TVector3 dum = pvec[i]->Position().Vect();
272 
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];
275 
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];
278 
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];
281 
282  fTEvt = evt.id().event();
283  fTSub = evt.subRun();
284  fTRun = evt.run();
285  fTParentID = pvec[i]->Mother();
286  fTStatus = pvec[i]->StatusCode();
287  int daughter = 9999;
288  fTNds = TMath::Min(pvec[i]->NumberDaughters(),fTNdsOriginal);
289  for( int d = 0; d < fTNds; d++ ){
290  daughter = pvec[i]->Daughter(d);
291  fTDID[d] = daughter;
292  // zero it out.
293  for (unsigned int s = 0; s < 35; ++s) *(fTDProcess[d]+s) = 0;
294 
295  for(unsigned int jj = i; jj < pvec.size(); ++jj){ // Don't look below i.
296 
297  if (fTDID[d] == pvec[jj]->TrackId()){
298  fTDPdg[d] = pvec[jj]->PdgCode(); // get the pointer,
299  fTDWt[d] = pvec[jj]->Weight();
300 
301  for (unsigned int s = 0; s < pvec[jj]->Process().length(); ++s)
302  *(fTDProcess[d]+s) = pvec[jj]->Process()[s];
303 
304  for (unsigned int kk = 0; kk < 4; ++kk){
305  fT4DOrigin[d*4+kk] = pvec[jj]->Position()[kk];
306  fT4DMomentum[d*4+kk] = pvec[jj]->Momentum()[kk];
307  }
308  break;
309  }
310  }
311  }//end loop over d
312 
313  for (unsigned int ii = 0; ii < 4; ++ii){
314  fT4Termination[ii] = 1e9;
315  fT4Origin[ii] = pvec[i]->Position()[ii];
316  if (ii!=3) fT4Termination[ii] = pvec[i]->EndPosition()[ii];
317  if (ii==4) fT4Termination[ii] = pvec[i]->Momentum()[ii]; // yes, odd
318  fT4Momentum[ii] = pvec[i]->Momentum()[ii];
319  }
320 
321  fTWeight = pvec[i]->Weight();
322  fTree->Fill();
323 
324  } // end loop on particles in list
325  if(numpi0gamma == 2 && pi0loc > 0){
326  mf::LogInfo("LArG4Ana") << pvec[pi0loc]->E();
327  fPi0Momentum->Fill(pvec[pi0loc]->E());
328  }
329 
330  return;
331  }
TProfile * fChannelCharge
Charge per channel.
unsigned int event
Definition: DataStructs.h:634
std::string fG4ModuleLabel
module label for the Geant
unsigned int run
Definition: DataStructs.h:635
TH1D * fnumChannels
The number of channels recieving charge per event.
Float_t * fT4Termination
Char_t fTTVolume[35]
Char_t fTMaterial[35]
process_name E
TH1D * fEventEnergy
Energy collected per event.
Char_t fTVolume[35]
TProfile * fChannelEnergy
Energy per channel.
Char_t fTDProcess[200][35]
Float_t * fT4DMomentum
static const int NoParticleId
Definition: sim.h:21
Char_t fTProcess[35]
TH1D * fEventCharge
Charge collected per event.
then echo File list $list not found else cat $list while read file do echo $file sed s
Definition: file_to_url.sh:60
unsigned int subRun
Definition: DataStructs.h:636
TCEvent evt
Definition: DataStructs.cxx:8
Float_t * fT4DOrigin
TProfile * fnumIDEs
Number of drift electrons per channel.
Float_t * fT4Momentum
void larg4::LArG4Ana::beginJob ( )

Definition at line 108 of file LArG4Ana_module.cc.

109  {
110  art::ServiceHandle<art::TFileService const> tfs;
111  art::ServiceHandle<geo::Geometry const> geo;
112 
113  fPDGCodes = tfs->make<TH1D>("pdgcodes", ";PDG Code;", 5000, -2500, 2500);
114  fPi0Momentum = tfs->make<TH1D>("pi0mom", ";#pi^{0} Momentum (GeV);", 1000, 0., 1000.);
115 
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.);
119 
120 
121  // Some histograms relating to drift electrons, active detector
122  // channels and charge/energy on channels
123  fnumChannels = tfs->make<TH1D>("fnumChannels",
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(),
129  0, 1e4);
130  fEventCharge = tfs->make<TH1D>("fEventCharge",
131  "Charge in event;Total charge per event;# events",
132  100, 0, 2.5e8);
133  fEventEnergy = tfs->make<TH1D>("fEventEnergy",
134  "Energy in event;Total energy per event;# events",
135  100, 0, 1e4);
136  fChannelCharge = tfs->make<TProfile>("fChannelCharge",
137  "Charge on channel;Channel;Total charge per channel",
138  geo->Nchannels()+1,0,geo->Nchannels(),
139  0,1e5);
140  fChannelEnergy = tfs->make<TProfile>("fChannelEnergy",
141  "Energy on channel;Channel;Total energy per channel",
142  geo->Nchannels()+1,0,geo->Nchannels(),
143  0, 1e3);
144 
145 
146  fT4Origin = new Float_t[4];
147  fT4DOrigin = new Float_t[fTNds*4];
148  fT4Termination = new Float_t[4];
149  fT4Momentum = new Float_t[4];
150  fT4DMomentum = new Float_t[fTNds*4];
151  fTDID = new Int_t[fTNds];
152  fTDPdg = new Int_t[fTNds];
153  fTDWt = new Float_t[fTNds];
154  fTNds4 = fTNds*4; // TTree/Branch requirement to store this.
155 
156  fTree->Branch("MCEvt", &fTEvt, "MCEvt/I");
157  fTree->Branch("MCSub", &fTSub, "MCSub/I");
158  fTree->Branch("MCRun", &fTRun, "MCRun/I");
159  fTree->Branch("MCWt", &fTWeight, "MCWt/F");
160  fTree->Branch("MCPdg", &fTPdg, "MCPdg/I");
161  fTree->Branch("MCID", &fTID, "MCID/I");
162  fTree->Branch("MCParentID", &fTParentID, "MCParentID/I");
163  fTree->Branch("MCNumDs", &fTNds, "MCNumDs/I");
164  fTree->Branch("MCNumDs4", &fTNds4, "MCNumDs4/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");
168  fTree->Branch("MCProcess", fTProcess, "MCProcess/C");
169  fTree->Branch("MCVolume", fTVolume, "MCVolume/C");
170  fTree->Branch("MCTVolume", fTTVolume, "MCTVolume/C");
171  fTree->Branch("MCMaterial", fTMaterial, "MCMaterial/C");
172  fTree->Branch("MCDProcess", fTDProcess, "MCDProcess[MCNumDs]/C");
173  fTree->Branch("MCStatus", &fTStatus, "MCStatus/I");
174  fTree->Branch("MCOrigin", fT4Origin, "MCOrigin[4]/F");
175  fTree->Branch("MCDOrigin", fT4DOrigin, "MCDOrigin[MCNumDs4]/F");
176  fTree->Branch("MCTermination", fT4Termination, "MCTermination[4]/F");
177  fTree->Branch("MCMomentum", fT4Momentum, "MCMomentum[4]/F");
178  fTree->Branch("MCDMomentum", fT4DMomentum, "MCDMomentum[MCNumDs4]/F");
179 
180  }
TProfile * fChannelCharge
Charge per channel.
TH1D * fnumChannels
The number of channels recieving charge per event.
Float_t * fT4Termination
Char_t fTTVolume[35]
Char_t fTMaterial[35]
TH1D * fEventEnergy
Energy collected per event.
Char_t fTVolume[35]
TProfile * fChannelEnergy
Energy per channel.
Char_t fTDProcess[200][35]
Float_t * fT4DMomentum
Char_t fTProcess[35]
TH1D * fEventCharge
Charge collected per event.
art::ServiceHandle< art::TFileService > tfs
Float_t * fT4DOrigin
TProfile * fnumIDEs
Number of drift electrons per channel.
Float_t * fT4Momentum

Member Data Documentation

TProfile* larg4::LArG4Ana::fChannelCharge
private

Charge per channel.

Definition at line 61 of file LArG4Ana_module.cc.

TProfile* larg4::LArG4Ana::fChannelEnergy
private

Energy per channel.

Definition at line 62 of file LArG4Ana_module.cc.

TH1D* larg4::LArG4Ana::fEventCharge
private

Charge collected per event.

Definition at line 59 of file LArG4Ana_module.cc.

TH1D* larg4::LArG4Ana::fEventEnergy
private

Energy collected per event.

Definition at line 60 of file LArG4Ana_module.cc.

std::string larg4::LArG4Ana::fG4ModuleLabel
private

module label for the Geant

Definition at line 49 of file LArG4Ana_module.cc.

TH1D* larg4::LArG4Ana::fnDist
private

Definition at line 56 of file LArG4Ana_module.cc.

TH1D* larg4::LArG4Ana::fnEnergy
private

Definition at line 55 of file LArG4Ana_module.cc.

TH1D* larg4::LArG4Ana::fnumChannels
private

The number of channels recieving charge per event.

Definition at line 57 of file LArG4Ana_module.cc.

TProfile* larg4::LArG4Ana::fnumIDEs
private

Number of drift electrons per channel.

Definition at line 58 of file LArG4Ana_module.cc.

TH1D* larg4::LArG4Ana::fPDGCodes
private

Definition at line 53 of file LArG4Ana_module.cc.

TH1D* larg4::LArG4Ana::fPi0Momentum
private

Definition at line 54 of file LArG4Ana_module.cc.

Float_t* larg4::LArG4Ana::fT4DMomentum
private

Definition at line 90 of file LArG4Ana_module.cc.

Float_t* larg4::LArG4Ana::fT4DOrigin
private

Definition at line 87 of file LArG4Ana_module.cc.

Float_t* larg4::LArG4Ana::fT4Momentum
private

Definition at line 89 of file LArG4Ana_module.cc.

Float_t* larg4::LArG4Ana::fT4Origin
private

Definition at line 86 of file LArG4Ana_module.cc.

Float_t* larg4::LArG4Ana::fT4Termination
private

Definition at line 88 of file LArG4Ana_module.cc.

Int_t* larg4::LArG4Ana::fTDID
private

Definition at line 75 of file LArG4Ana_module.cc.

Int_t* larg4::LArG4Ana::fTDPdg
private

Definition at line 76 of file LArG4Ana_module.cc.

Char_t larg4::LArG4Ana::fTDProcess[200][35]
private

Definition at line 82 of file LArG4Ana_module.cc.

Float_t* larg4::LArG4Ana::fTDWt
private

Definition at line 77 of file LArG4Ana_module.cc.

Int_t larg4::LArG4Ana::fTEvt
private

Definition at line 67 of file LArG4Ana_module.cc.

Int_t larg4::LArG4Ana::fTID
private

Definition at line 71 of file LArG4Ana_module.cc.

Char_t larg4::LArG4Ana::fTMaterial[35]
private

Definition at line 81 of file LArG4Ana_module.cc.

Int_t larg4::LArG4Ana::fTNds
private

Definition at line 73 of file LArG4Ana_module.cc.

Int_t larg4::LArG4Ana::fTNds4
private

Definition at line 74 of file LArG4Ana_module.cc.

Int_t larg4::LArG4Ana::fTNdsOriginal
private

Definition at line 72 of file LArG4Ana_module.cc.

Int_t larg4::LArG4Ana::fTParentID
private

Definition at line 83 of file LArG4Ana_module.cc.

Int_t larg4::LArG4Ana::fTPdg
private

Definition at line 70 of file LArG4Ana_module.cc.

Char_t larg4::LArG4Ana::fTProcess[35]
private

Definition at line 78 of file LArG4Ana_module.cc.

TTree* larg4::LArG4Ana::fTree
private

Definition at line 66 of file LArG4Ana_module.cc.

Int_t larg4::LArG4Ana::fTRun
private

Definition at line 69 of file LArG4Ana_module.cc.

std::string larg4::LArG4Ana::fTruthModuleLabel
private

module label for the Geant

Definition at line 50 of file LArG4Ana_module.cc.

Int_t larg4::LArG4Ana::fTStatus
private

Definition at line 84 of file LArG4Ana_module.cc.

Int_t larg4::LArG4Ana::fTSub
private

Definition at line 68 of file LArG4Ana_module.cc.

Char_t larg4::LArG4Ana::fTTVolume[35]
private

Definition at line 80 of file LArG4Ana_module.cc.

Char_t larg4::LArG4Ana::fTVolume[35]
private

Definition at line 79 of file LArG4Ana_module.cc.

Float_t larg4::LArG4Ana::fTWeight
private

Definition at line 85 of file LArG4Ana_module.cc.


The documentation for this class was generated from the following file: