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

Public Member Functions

 CellTree (fhicl::ParameterSet const &pset)
 

Private Member Functions

void endJob ()
 
void beginRun (const art::Run &run)
 
void analyze (const art::Event &evt)
 
void initOutput ()
 
void printEvent ()
 
void print_vector (ostream &out, vector< double > &v, TString desc, bool end=false)
 
void processRaw (const art::Event &evt)
 
void processCalib (const art::Event &evt)
 
void processOpHit (const art::Event &evt)
 
void processOpFlash (const art::Event &evt)
 
void processSpacePoint (const art::Event &event, TString option, ostream &out=cout)
 
void processSpacePointTruthDepo (const art::Event &event, TString option, ostream &out=cout)
 
void processSimChannel (const art::Event &evt)
 
void processMC (const art::Event &evt)
 
void processMCTracks ()
 
void processTrigger (const art::Event &evt)
 
void reset ()
 
void InitProcessMap ()
 
bool IsPrimary (int i)
 
bool KeepMC (int i)
 
double KE (float *momentum)
 
TString PDGName (int pdg)
 
bool DumpMCJSON (int id, ostream &out)
 
void DumpMCJSON (ostream &out=cout)
 

Private Attributes

std::string fRawDigitLabel
 
std::string fCalibLabel
 
std::string fOpHitLabel
 
std::string fOpFlashLabel
 
std::string fTriggerLabel
 
std::string fSimEnergyDepositLabel
 
std::vector< std::string > fSpacePointLabels
 
std::string fSimChannelLabel
 
std::string fOutFileName
 
std::string mcOption
 
int nRawSamples
 
float opMultPEThresh
 
bool fSaveMCTrackPoints
 
bool fSaveSimChannel
 
bool fSaveRaw
 
bool fSaveCalib
 
bool fSaveOpHit
 
bool fSaveOpFlash
 
bool fSaveMC
 
bool fSaveTrigger
 
bool fSaveJSON
 
art::ServiceHandle
< geo::Geometry const > 
fGeometry
 
TFile * fOutFile
 
TTree * fEventTree
 
std::map< std::string, int > processMap
 
std::map< int, int > savedMCTrackIdMap
 
int entryNo
 
int fEvent
 
int fRun
 
int fSubRun
 
double fEventTime
 
unsigned int fTriggernumber
 
double fTriggertime
 
double fBeamgatetime
 
unsigned int fTriggerbits
 
int fCalib_nChannel
 
std::vector< int > fCalib_channelId
 
TClonesArray * fCalib_wf
 
int oh_nHits
 
vector< int > oh_channel
 
vector< double > oh_bgtime
 
vector< double > oh_trigtime
 
vector< double > oh_pe
 
int of_nFlash
 
vector< float > of_t
 
vector< float > of_peTotal
 
vector< int > of_multiplicity
 
TClonesArray * fPEperOpDet
 
int fRaw_nChannel
 
std::vector< int > fRaw_channelId
 
TClonesArray * fRaw_wf
 
int fSIMIDE_size
 
vector< int > fSIMIDE_channelIdY
 
vector< int > fSIMIDE_trackId
 
vector< unsigned short > fSIMIDE_tdc
 
vector< float > fSIMIDE_x
 
vector< float > fSIMIDE_y
 
vector< float > fSIMIDE_z
 
vector< float > fSIMIDE_numElectrons
 
int mc_Ntrack
 
int mc_id [MAX_TRACKS]
 
int mc_pdg [MAX_TRACKS]
 
int mc_process [MAX_TRACKS]
 
int mc_mother [MAX_TRACKS]
 
float mc_startXYZT [MAX_TRACKS][4]
 
float mc_endXYZT [MAX_TRACKS][4]
 
float mc_startMomentum [MAX_TRACKS][4]
 
float mc_endMomentum [MAX_TRACKS][4]
 
std::vector< std::vector< int > > mc_daughters
 
TObjArray * fMC_trackPosition
 
int mc_isnu
 
int mc_nGeniePrimaries
 
int mc_nu_pdg
 
int mc_nu_ccnc
 
int mc_nu_mode
 
int mc_nu_intType
 
int mc_nu_target
 
int mc_hitnuc
 
int mc_hitquark
 
double mc_nu_Q2
 
double mc_nu_W
 
double mc_nu_X
 
double mc_nu_Y
 
double mc_nu_Pt
 
double mc_nu_Theta
 
float mc_nu_pos [4]
 
float mc_nu_mom [4]
 
std::map< int, int > trackIndex
 
std::vector< std::vector< int > > trackParents
 
std::vector< std::vector< int > > trackChildren
 
std::vector< std::vector< int > > trackSiblings
 
TDatabasePDG * dbPDG
 

Detailed Description

Definition at line 55 of file CellTree_module.cc.

Constructor & Destructor Documentation

wc::CellTree::CellTree ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 211 of file CellTree_module.cc.

212  : EDAnalyzer(p)
213 {
214  dbPDG = new TDatabasePDG();
215  entryNo = 0;
216 
217  fRawDigitLabel = p.get<std::string>("RawDigitLabel");
218  fCalibLabel = p.get<std::string>("CalibLabel");
219  fOpHitLabel = p.get<std::string>("OpHitLabel");
220  fOpFlashLabel = p.get<std::string>("OpFlashLabel");
221  fTriggerLabel = p.get<std::string>("TriggerLabel");
222  fSimEnergyDepositLabel = p.get<std::string>("SimEnergyDepositLabel");
223  fSpacePointLabels= p.get<std::vector<std::string> >("SpacePointLabels");
224  fSimChannelLabel = p.get<std::string>("SimChannelLabel");
225  fOutFileName = p.get<std::string>("outFile");
226  mcOption = p.get<std::string>("mcOption");
227  fSaveMCTrackPoints = p.get<bool>("saveMCTrackPoints");
228  fSaveRaw = p.get<bool>("saveRaw");
229  fSaveCalib = p.get<bool>("saveCalib");
230  fSaveOpHit = p.get<bool>("saveOpHit");
231  fSaveOpFlash = p.get<bool>("saveOpFlash");
232  fSaveMC = p.get<bool>("saveMC");
233  fSaveSimChannel = p.get<bool>("saveSimChannel");
234  fSaveTrigger = p.get<bool>("saveTrigger");
235  fSaveJSON = p.get<bool>("saveJSON");
236  opMultPEThresh = p.get<float>("opMultPEThresh");
237  nRawSamples = p.get<int>("nRawSamples");
238 
239  InitProcessMap();
240  initOutput();
241 }
std::string fSimChannelLabel
pdgs p
Definition: selectors.fcl:22
std::string fOutFileName
std::string fRawDigitLabel
std::string fOpHitLabel
std::string fOpFlashLabel
TDatabasePDG * dbPDG
std::string fSimEnergyDepositLabel
std::string mcOption
std::string fCalibLabel
std::vector< std::string > fSpacePointLabels
std::string fTriggerLabel

Member Function Documentation

void wc::CellTree::analyze ( const art::Event &  evt)
private

Definition at line 372 of file CellTree_module.cc.

373 {
374  reset();
375  fEvent = event.id().event();
376  fRun = event.run();
377  fSubRun = event.subRun();
378  art::Timestamp ts = event.time();
379  TTimeStamp tts(ts.timeHigh(), ts.timeLow());
380  fEventTime = tts.AsDouble();
381 
382  if (fSaveRaw) processRaw(event);
383  if (fSaveCalib) processCalib(event);
384  if (fSaveOpHit) processOpHit(event);
385  if (fSaveOpFlash) processOpFlash(event);
387  if (fSaveMC) processMC(event);
388  if (fSaveTrigger) processTrigger(event);
389 
390  if (fSaveJSON) {
391  gSystem->MakeDirectory(TString::Format("bee/data/%i", entryNo).Data());
392  int nSp = fSpacePointLabels.size();
393  for (int i=0; i<nSp; i++) {
394  TString jsonfile;
395  jsonfile.Form("bee/data/%i/%i-%s.json", entryNo, entryNo, fSpacePointLabels[i].c_str());
396  std::ofstream out(jsonfile.Data());
397  if (fSpacePointLabels[i] == "truthDepo") {
399  }
400  else {
401  processSpacePoint(event, fSpacePointLabels[i], out);
402  }
403  out.close();
404  }
405 
406  if(fSaveMC) {
407  processMCTracks();
408  TString jsonfile;
409  jsonfile.Form("bee/data/%i/%i-mc.json", entryNo, entryNo);
410  std::ofstream out(jsonfile.Data());
411  DumpMCJSON(out);
412  out.close();
413  }
414  }
415 
416  // printEvent();
417  fEventTree->Fill();
418 
419  entryNo++;
420 }
void processMCTracks()
void processRaw(const art::Event &evt)
void processSpacePointTruthDepo(const art::Event &event, TString option, ostream &out=cout)
void processSimChannel(const art::Event &evt)
bool DumpMCJSON(int id, ostream &out)
void processOpFlash(const art::Event &evt)
void processOpHit(const art::Event &evt)
void processCalib(const art::Event &evt)
void processMC(const art::Event &evt)
std::vector< std::string > fSpacePointLabels
void processSpacePoint(const art::Event &event, TString option, ostream &out=cout)
void processTrigger(const art::Event &evt)
void wc::CellTree::beginRun ( const art::Run &  run)
private

Definition at line 366 of file CellTree_module.cc.

367 {
368  mf::LogInfo("CellTree") << "begin run";
369 }
bool wc::CellTree::DumpMCJSON ( int  id,
ostream &  out 
)
private

Definition at line 999 of file CellTree_module.cc.

1000 {
1001  int i = trackIndex[id];
1002  if (!KeepMC(i)) return false;
1003 
1004  int e = KE(mc_startMomentum[i])*1000;
1005 
1006  int nDaughter = mc_daughters.at(i).size();
1007  vector<int> saved_daughters;
1008  for (int j=0; j<nDaughter; j++) {
1009  int daughter_id = mc_daughters.at(i).at(j);
1010  // int e_daughter = KE(mc_startMomentum[ trackIndex[daughter_id] ])*1000;
1011  // if (e_daughter >= thresh_KE) {
1012  if ( KeepMC(trackIndex[daughter_id]) ) {
1013  saved_daughters.push_back(daughter_id);
1014  }
1015  }
1016 
1017  vector<double> vx, vy, vz;
1018  if (fSaveMCTrackPoints) {
1019  // fMC_trackPosition->Print();
1020  TClonesArray *traj = (TClonesArray*)(*fMC_trackPosition)[i];
1021  int nPoints = traj->GetEntries();
1022  // cout << "traj points: " << nPoints << endl;
1023  for(int j=0; j<nPoints; j++) {
1024  TLorentzVector* pos = (TLorentzVector*)(*traj)[j];
1025  vx.push_back(pos->X());
1026  vy.push_back(pos->Y());
1027  vz.push_back(pos->Z());
1028  }
1029  }
1030 
1031  out << fixed << setprecision(1);
1032  out << "{";
1033 
1034  out << "\"id\":" << id << ",";
1035  out << "\"text\":" << "\"" << PDGName(mc_pdg[i]) << " " << e << " MeV\",";
1036  out << "\"data\":{";
1037  print_vector(out, vx, "traj_x");
1038  print_vector(out, vy, "traj_y");
1039  print_vector(out, vz, "traj_z");
1040  out << "\"start\":[" << mc_startXYZT[i][0] << ", " << mc_startXYZT[i][1] << ", " << mc_startXYZT[i][2] << "],";
1041  out << "\"end\":[" << mc_endXYZT[i][0] << ", " << mc_endXYZT[i][1] << ", " << mc_endXYZT[i][2] << "]";
1042  out << "},";
1043  out << "\"children\":[";
1044  int nSavedDaughter = saved_daughters.size();
1045  if (nSavedDaughter == 0) {
1046  out << "],";
1047  out << "\"icon\":" << "\"jstree-file\"";
1048  out << "}";
1049  return true;
1050  }
1051  else {
1052  for (int j=0; j<nSavedDaughter; j++) {
1053  DumpMCJSON(saved_daughters.at(j), out);
1054  if (j!=nSavedDaughter-1) {
1055  out << ",";
1056  }
1057  }
1058  out << "]";
1059  out << "}";
1060  return true;
1061  }
1062 }
float mc_startMomentum[MAX_TRACKS][4]
std::map< int, int > trackIndex
float mc_endXYZT[MAX_TRACKS][4]
TString PDGName(int pdg)
int mc_pdg[MAX_TRACKS]
bool DumpMCJSON(int id, ostream &out)
void print_vector(ostream &out, vector< double > &v, TString desc, bool end=false)
bool KeepMC(int i)
TObjArray * fMC_trackPosition
std::vector< std::vector< int > > mc_daughters
double KE(float *momentum)
do i e
float mc_startXYZT[MAX_TRACKS][4]
void wc::CellTree::DumpMCJSON ( ostream &  out = cout)
private

Definition at line 1065 of file CellTree_module.cc.

1066 {
1067  out << "[";
1068  vector<int> primaries;
1069  for (int i=0; i<mc_Ntrack; i++) {
1070  if (IsPrimary(i)) {
1071  // int e = KE(mc_startMomentum[i])*1000;
1072  // if (e<thresh_KE) continue;
1073  if (KeepMC(i)) {
1074  primaries.push_back(i);
1075  }
1076  }
1077  }
1078  int size = primaries.size();
1079  // cout << size << endl;
1080  for (int i=0; i<size; i++) {
1081  if (DumpMCJSON(mc_id[primaries[i]], out) && i!=size-1) {
1082  out << ", ";
1083  }
1084  }
1085 
1086  out << "]";
1087 }
int mc_id[MAX_TRACKS]
std::size_t size(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:561
bool DumpMCJSON(int id, ostream &out)
bool KeepMC(int i)
bool IsPrimary(int i)
void wc::CellTree::endJob ( )
private

Definition at line 346 of file CellTree_module.cc.

347 {
348  // Write fEventTree to file
349  TDirectory* tmpDir = gDirectory;
350  fOutFile->cd("/Event");
351 
352  fEventTree->Write();
353 
354  gDirectory = tmpDir;
355 
356  fOutFile->Close();
357 
358  if (fSaveJSON) {
359  gSystem->ChangeDirectory("bee");
360  system("zip -r bee_upload data");
361  gSystem->ChangeDirectory("..");
362  }
363 }
void wc::CellTree::initOutput ( )
private

Definition at line 244 of file CellTree_module.cc.

245 {
246  TDirectory* tmpDir = gDirectory;
247 
248  fOutFile = new TFile(fOutFileName.c_str(), "recreate");
249 
250  // 3.1: add mc_trackPosition
251  TNamed version("version", "4.0");
252  version.Write();
253 
254  // init Event TTree
255  TDirectory* subDir = fOutFile->mkdir("Event");
256  subDir->cd();
257  fEventTree = new TTree("Sim", "Event Tree from Simulation");
258  fEventTree->Branch("eventNo", &fEvent);
259  fEventTree->Branch("runNo", &fRun);
260  fEventTree->Branch("subRunNo", &fSubRun);
261  fEventTree->Branch("eventTime", &fEventTime); // timestamp
262 
263  fEventTree->Branch("triggerNo", &fTriggernumber); // timestamp
264  fEventTree->Branch("triggerTime", &fTriggertime); // timestamp
265  fEventTree->Branch("beamgateTime", &fBeamgatetime); // timestamp
266  fEventTree->Branch("triggerBits", &fTriggerbits); // timestamp
267 
268  fEventTree->Branch("raw_nChannel", &fRaw_nChannel); // number of hit channels above threshold
269  fEventTree->Branch("raw_channelId" , &fRaw_channelId); // hit channel id; size == raw_nChannel
270  fRaw_wf = new TClonesArray("TH1F");
271  fEventTree->Branch("raw_wf", &fRaw_wf, 256000, 0); // raw waveform adc of each channel
272 
273 
274  fEventTree->Branch("calib_nChannel", &fCalib_nChannel); // number of hit channels above threshold
275  fEventTree->Branch("calib_channelId" , &fCalib_channelId); // hit channel id; size == calib_Nhit
276  fCalib_wf = new TClonesArray("TH1F");
277  fEventTree->Branch("calib_wf", &fCalib_wf, 256000, 0); // calib waveform adc of each channel
278  // fCalib_wf->BypassStreamer();
279  // fEventTree->Branch("calib_wfTDC", &fCalib_wfTDC); // calib waveform tdc of each channel
280 
281  fEventTree->Branch("oh_nHits", &oh_nHits); // number of op hits
282  fEventTree->Branch("oh_channel", &oh_channel); //opchannel id; size == no ophits
283  fEventTree->Branch("oh_bgtime", &oh_bgtime); // optical pulse peak time w.r.t. start of beam gate
284  fEventTree->Branch("oh_trigtime", &oh_trigtime); // optical pulse peak time w.r.t. trigger
285  fEventTree->Branch("oh_pe", &oh_pe); // pulse PE
286 
287  fEventTree->Branch("of_nFlash", &of_nFlash);
288  fEventTree->Branch("of_t", &of_t); // time in us w.r.t. the trigger for each flash
289  fEventTree->Branch("of_peTotal", &of_peTotal); // total PE (sum of all PMTs) for each flash
290  fEventTree->Branch("of_multiplicity", &of_multiplicity); // total number of PMTs above threshold for each flash
291  fPEperOpDet = new TClonesArray("TH1F");
292  fEventTree->Branch("pe_opdet", &fPEperOpDet, 256000, 0);
293 
294  fEventTree->Branch("simide_size", &fSIMIDE_size); // size of stored sim:IDE
295  fEventTree->Branch("simide_channelIdY", &fSIMIDE_channelIdY);
296  fEventTree->Branch("simide_trackId", &fSIMIDE_trackId);
297  fEventTree->Branch("simide_tdc", &fSIMIDE_tdc);
298  fEventTree->Branch("simide_x", &fSIMIDE_x);
299  fEventTree->Branch("simide_y", &fSIMIDE_y);
300  fEventTree->Branch("simide_z", &fSIMIDE_z);
301  fEventTree->Branch("simide_numElectrons", &fSIMIDE_numElectrons);
302 
303  fEventTree->Branch("mc_Ntrack", &mc_Ntrack); // number of tracks in MC
304  fEventTree->Branch("mc_id", &mc_id, "mc_id[mc_Ntrack]/I"); // track id; size == mc_Ntrack
305  fEventTree->Branch("mc_pdg", &mc_pdg, "mc_pdg[mc_Ntrack]/I"); // track particle pdg; size == mc_Ntrack
306  fEventTree->Branch("mc_process", &mc_process, "mc_process[mc_Ntrack]/I"); // track generation process code; size == mc_Ntrack
307  fEventTree->Branch("mc_mother", &mc_mother, "mc_mother[mc_Ntrack]/I"); // mother id of this track; size == mc_Ntrack
308  fEventTree->Branch("mc_daughters", &mc_daughters); // daughters id of this track; vector
309  fEventTree->Branch("mc_startXYZT", &mc_startXYZT, "mc_startXYZT[mc_Ntrack][4]/F"); // start position of this track; size == mc_Ntrack
310  fEventTree->Branch("mc_endXYZT", &mc_endXYZT, "mc_endXYZT[mc_Ntrack][4]/F"); // start position of this track; size == mc_Ntrack
311  fEventTree->Branch("mc_startMomentum", &mc_startMomentum, "mc_startMomentum[mc_Ntrack][4]/F"); // start momentum of this track; size == mc_Ntrack
312  fEventTree->Branch("mc_endMomentum", &mc_endMomentum, "mc_endMomentum[mc_Ntrack][4]/F"); // start momentum of this track; size == mc_Ntrack
313  fMC_trackPosition = new TObjArray();
314  fMC_trackPosition->SetOwner(kTRUE);
315  fEventTree->Branch("mc_trackPosition", &fMC_trackPosition);
316 
317  fEventTree->Branch("mc_isnu", &mc_isnu);
318  fEventTree->Branch("mc_nGeniePrimaries", &mc_nGeniePrimaries);
319  fEventTree->Branch("mc_nu_pdg", &mc_nu_pdg);
320  fEventTree->Branch("mc_nu_ccnc", &mc_nu_ccnc);
321  fEventTree->Branch("mc_nu_mode", &mc_nu_mode);
322  fEventTree->Branch("mc_nu_intType", &mc_nu_intType);
323  fEventTree->Branch("mc_nu_target", &mc_nu_target);
324  fEventTree->Branch("mc_hitnuc", &mc_hitnuc);
325  fEventTree->Branch("mc_hitquark", &mc_hitquark);
326  fEventTree->Branch("mc_nu_Q2", &mc_nu_Q2);
327  fEventTree->Branch("mc_nu_W", &mc_nu_W);
328  fEventTree->Branch("mc_nu_X", &mc_nu_X);
329  fEventTree->Branch("mc_nu_Y", &mc_nu_Y);
330  fEventTree->Branch("mc_nu_Pt", &mc_nu_Pt);
331  fEventTree->Branch("mc_nu_Theta", &mc_nu_Theta);
332  fEventTree->Branch("mc_nu_pos", &mc_nu_pos, "mc_nu_pos[4]/F");
333  fEventTree->Branch("mc_nu_mom", &mc_nu_mom, "mc_nu_mom[4]/F");
334 
335  gDirectory = tmpDir;
336  if (fSaveJSON) {
337  system("rm -rf bee");
338  gSystem->MakeDirectory("bee");
339  // gSystem->ChangeDirectory("bee");
340  gSystem->MakeDirectory("bee/data");
341  }
342 
343 }
float mc_startMomentum[MAX_TRACKS][4]
vector< double > oh_pe
vector< int > fSIMIDE_channelIdY
vector< int > fSIMIDE_trackId
float mc_endXYZT[MAX_TRACKS][4]
int mc_id[MAX_TRACKS]
int mc_pdg[MAX_TRACKS]
vector< int > of_multiplicity
vector< float > fSIMIDE_y
std::string fOutFileName
vector< float > fSIMIDE_x
int mc_mother[MAX_TRACKS]
vector< unsigned short > fSIMIDE_tdc
float mc_endMomentum[MAX_TRACKS][4]
vector< int > oh_channel
int mc_process[MAX_TRACKS]
vector< double > oh_bgtime
vector< double > oh_trigtime
TClonesArray * fCalib_wf
TObjArray * fMC_trackPosition
std::vector< int > fRaw_channelId
vector< float > fSIMIDE_z
unsigned int fTriggerbits
std::vector< std::vector< int > > mc_daughters
TClonesArray * fRaw_wf
unsigned int fTriggernumber
std::vector< int > fCalib_channelId
float mc_nu_mom[4]
TClonesArray * fPEperOpDet
vector< float > fSIMIDE_numElectrons
float mc_startXYZT[MAX_TRACKS][4]
vector< float > of_peTotal
float mc_nu_pos[4]
vector< float > of_t
void wc::CellTree::InitProcessMap ( )
private

Definition at line 1171 of file CellTree_module.cc.

1172 {
1173  processMap["unknown"] = 0;
1174  processMap["primary"] = 1;
1175  processMap["compt"] = 2;
1176  processMap["phot"] = 3;
1177  processMap["annihil"] = 4;
1178  processMap["eIoni"] = 5;
1179  processMap["eBrem"] = 6;
1180  processMap["conv"] = 7;
1181  processMap["muIoni"] = 8;
1182  processMap["muMinusCaptureAtRest"] = 9;
1183  processMap["neutronInelastic"] = 10;
1184  processMap["nCapture"] = 11;
1185  processMap["hadElastic"] = 12;
1186  processMap["Decay"] = 13;
1187  processMap["CoulombScat"] = 14;
1188  processMap["muPairProd"] = 15;
1189  processMap["muBrems"] = 16;
1190  processMap["muPairProd"] = 17;
1191  processMap["PhotonInelastic"] = 18;
1192  processMap["hIoni"] = 19;
1193  processMap["protonInelastic"] = 20;
1194  processMap["pi+Inelastic"] = 21;
1195  processMap["CHIPSNuclearCaptureAtRest"] = 22;
1196  processMap["pi-Inelastic"] = 23;
1197 }
std::map< std::string, int > processMap
bool wc::CellTree::IsPrimary ( int  i)
inlineprivate

Definition at line 84 of file CellTree_module.cc.

84 { return mc_mother[i] == 0 ; }
int mc_mother[MAX_TRACKS]
double wc::CellTree::KE ( float *  momentum)
private

Definition at line 1090 of file CellTree_module.cc.

1091 {
1092  TLorentzVector particle(momentum);
1093  return particle.E()-particle.M();
1094 }
bool wc::CellTree::KeepMC ( int  i)
private

Definition at line 1097 of file CellTree_module.cc.

1098 {
1099  double e = KE(mc_startMomentum[i])*1000;
1100  double thresh_KE_em = 5.; // MeV
1101  double thresh_KE_np = 50; // MeV
1102  // cout << "pdg: " << mc_pdg[i] << ", KE: " << e << " MeV, process: " << mc_process[i] << endl;
1103  if (mc_process[i] == 8 // muIoni
1104  || mc_process[i] == 6 // eBrem
1105  || mc_process[i] == 5 // eIoni
1106  ) {
1107  return false; // skip those ionization and radiation electrons as there are too many to show.
1108  }
1109 
1110  if (mc_pdg[i]==22 || mc_pdg[i]==11 || mc_pdg[i]==-11) {
1111  if (e>=thresh_KE_em) return true;
1112  else return false;
1113  }
1114  else if (mc_pdg[i]==2112 || mc_pdg[i]==2212 || mc_pdg[i]>1e9) {
1115  if (e>=thresh_KE_np) return true;
1116  else return false;
1117  }
1118  return true;
1119 }
float mc_startMomentum[MAX_TRACKS][4]
int mc_pdg[MAX_TRACKS]
int mc_process[MAX_TRACKS]
double KE(float *momentum)
do i e
TString wc::CellTree::PDGName ( int  pdg)
private

Definition at line 1122 of file CellTree_module.cc.

1123 {
1124  TParticlePDG *p = dbPDG->GetParticle(pdg);
1125  if (p == 0) {
1126  if (pdg>1e9) {
1127  int z = (pdg - 1e9) / 10000;
1128  int a = (pdg - 1e9 - z*1e4) / 10;
1129  TString name;
1130  if (z == 18) name = "Ar";
1131 
1132  else if (z == 17) name = "Cl";
1133  else if (z == 19) name = "Ca";
1134  else if (z == 16) name = "S";
1135  else if (z == 15) name = "P";
1136  else if (z == 14) name = "Si";
1137  else if (z == 1) name = "H";
1138  else if (z == 2) name = "He";
1139 
1140  else return Form("%i", pdg);
1141  return Form("%s-%i", name.Data(), a);
1142  }
1143  return Form("%i", pdg);
1144  }
1145  else {
1146  return p->GetName();
1147  }
1148 }
process_name opflash particleana ie ie ie z
var pdg
Definition: selectors.fcl:14
pdgs p
Definition: selectors.fcl:22
process_name gaushit a
TDatabasePDG * dbPDG
then echo fcl name
void wc::CellTree::print_vector ( ostream &  out,
vector< double > &  v,
TString  desc,
bool  end = false 
)
private

Definition at line 907 of file CellTree_module.cc.

908 {
909  int N = v.size();
910 
911  out << '"' << desc << '"' << ":[";
912  for (int i=0; i<N; i++) {
913  out << v[i];
914  if (i!=N-1) {
915  out << ",";
916  }
917  }
918  out << "]";
919  if (!end) out << ",";
920  out << endl;
921 }
auto end(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:585
process_name largeant stream1 can override from command line with o or output physics producers generator N
void wc::CellTree::printEvent ( )
private

Definition at line 1151 of file CellTree_module.cc.

1152 {
1153  cout << " Run/SubRun/Event: " << fRun << "/" << fSubRun << "/" << fEvent << endl;
1154  cout << " Ntracks:" << mc_Ntrack << endl;
1155 
1156  for (int i=0; i<mc_Ntrack; i++) {
1157  cout << "\n id: " << mc_id[i];
1158  cout << "\n pdg: " << mc_pdg[i];
1159  cout << "\n mother: " << mc_mother[i];
1160  cout << "\n Ndaughters: " << mc_daughters.at(i).size();
1161  cout << "\n start XYZT: (" << mc_startXYZT[i][0] << ", " << mc_startXYZT[i][1] << ", " << mc_startXYZT[i][2] << ", " << mc_startXYZT[i][3] << ")";
1162  cout << "\n end XYZT: (" << mc_endXYZT[i][0] << ", " << mc_endXYZT[i][1] << ", " << mc_endXYZT[i][2] << ", " << mc_endXYZT[i][3] << ")";
1163  cout << "\n start momentum: (" << mc_startMomentum[i][0] << ", " << mc_startMomentum[i][1] << ", " << mc_startMomentum[i][2] << ", " << mc_startMomentum[i][3] << ")";
1164  cout << "\n end momentum: (" << mc_endMomentum[i][0] << ", " << mc_endMomentum[i][1] << ", " << mc_endMomentum[i][2] << ", " << mc_endMomentum[i][3] << ")";
1165 
1166  cout << endl;
1167  }
1168 }
float mc_startMomentum[MAX_TRACKS][4]
float mc_endXYZT[MAX_TRACKS][4]
int mc_id[MAX_TRACKS]
int mc_pdg[MAX_TRACKS]
int mc_mother[MAX_TRACKS]
float mc_endMomentum[MAX_TRACKS][4]
std::vector< std::vector< int > > mc_daughters
float mc_startXYZT[MAX_TRACKS][4]
BEGIN_PROLOG could also be cout
void wc::CellTree::processCalib ( const art::Event &  evt)
private

Definition at line 528 of file CellTree_module.cc.

529 {
530 
531  art::Handle< std::vector<recob::Wire> > wires_handle;
532  if (! event.getByLabel(fCalibLabel, wires_handle)) {
533  cout << "WARNING: no label " << fCalibLabel << endl;
534  return;
535  }
536  std::vector< art::Ptr<recob::Wire> > wires;
537  art::fill_ptr_vector(wires, wires_handle);
538 
539  // wires size should == Nchannels == 1992; (no hit channel has a flat 0-waveform)
540  // cout << "\n wires size: " << wires.size() << endl;
541  fCalib_nChannel = wires.size();
542 
543  int i=0;
544  for (auto const& wire: wires) {
545  std::vector<float> calibwf = wire->Signal();
546  int chanId = wire->Channel();
547  fCalib_channelId.push_back(chanId);
548  TH1F *h = new((*fCalib_wf)[i]) TH1F("", "", nRawSamples, 0, nRawSamples);
549  for (int j=1; j<=nRawSamples; j++) {
550  h->SetBinContent(j, calibwf[j]);
551  }
552  // fCalib_wf.push_back(calibwf);
553  // cout << chanId << ", " << nSamples << endl;
554  i++;
555  }
556 
557 }
while getopts h
std::vector< int > fCalib_channelId
std::string fCalibLabel
BEGIN_PROLOG could also be cout
void wc::CellTree::processMC ( const art::Event &  evt)
private

Definition at line 655 of file CellTree_module.cc.

656 {
657  art::Handle< std::vector<simb::MCParticle> > particleHandle;
658  if (! event.getByLabel("largeant", particleHandle)) return;
659  std::vector< art::Ptr<simb::MCParticle> > particles;
660  art::fill_ptr_vector(particles, particleHandle);
661 
662  art::Handle< std::vector<sim::SimChannel> > simChannelHandle;
663  event.getByLabel("largeant", simChannelHandle);
664 
665  // art::ServiceHandle<cheat::BackTracker const> bt;
666  art::FindOneP<simb::MCTruth> fo(particleHandle, event, "largeant");
667 
668  int i=0; // track index in saved MCParticles;
669  int i_all=0; // track index in all MCParticles;
670  for (auto const& particle: particles ) {
671  art::Ptr<simb::MCTruth> mctruth = fo.at(i_all);
672  i_all++;
673 
674  if (mcOption == "nuOnly") {
675  if ( !(mctruth->Origin() == 1 && particle->Mother() == 0) ) {
676  continue;
677  }
678  }
679 
680  // if (mctruth->Origin() == 1 || mc_mother[i] == 0) {
681  // cout << "process: " << particle->Process()
682  // << ", id: " << mc_id[i]
683  // << ", pdg: " << mc_pdg[i]
684  // << ", mother: " << mc_mother[i]
685  // << ", nDaughter: " << (particle->NumberDaughters())
686  // << ", truth: " << mctruth->Origin()
687  // << endl;
688  // }
689  // const art::Ptr<simb::MCTruth> mctruth = bt_serv->TrackIDToMCTruth(mc_id[i]);
690 
691  mc_process[i] = processMap[particle->Process()];
692  if (mc_process[i] == 0) cout << "unknown process: " << particle->Process() << endl;
693  mc_id[i] = particle->TrackId();
694  mc_pdg[i] = particle->PdgCode();
695  mc_mother[i] = particle->Mother();
696  savedMCTrackIdMap[mc_id[i]] = mc_pdg[i];
697 
698  int Ndaughters = particle->NumberDaughters();
699  vector<int> daughters;
700  for (int i=0; i<Ndaughters; i++) {
701  daughters.push_back(particle->Daughter(i));
702  }
703  mc_daughters.push_back(daughters);
704  size_t numberTrajectoryPoints = particle->NumberTrajectoryPoints();
705  int last = numberTrajectoryPoints - 1;
706  const TLorentzVector& positionStart = particle->Position(0);
707  const TLorentzVector& positionEnd = particle->Position(last);
708  const TLorentzVector& momentumStart = particle->Momentum(0);
709  const TLorentzVector& momentumEnd = particle->Momentum(last);
710  positionStart.GetXYZT(mc_startXYZT[i]);
711  positionEnd.GetXYZT(mc_endXYZT[i]);
712  momentumStart.GetXYZT(mc_startMomentum[i]);
713  momentumEnd.GetXYZT(mc_endMomentum[i]);
714 
715  if (fSaveMCTrackPoints) {
716  TClonesArray *Lposition = new TClonesArray("TLorentzVector", numberTrajectoryPoints);
717  // Read the position and momentum along this particle track
718  for(unsigned int j=0; j<numberTrajectoryPoints; j++) {
719  new ((*Lposition)[j]) TLorentzVector(particle->Position(j));
720  }
721  fMC_trackPosition->Add(Lposition);
722  }
723 
724  i++;
725  if (i==MAX_TRACKS) {
726  cout << "WARNING:: # tracks exceeded MAX_TRACKS " << MAX_TRACKS << endl;
727  break;
728  }
729  } // particle loop done
730  mc_Ntrack = i;
731  // cout << "MC_Ntracks:" << mc_Ntrack << endl;
732 
733  // Generator Info
734  art::Handle< std::vector<simb::MCTruth> > mctruthListHandle;
735  event.getByLabel("generator",mctruthListHandle);
736  std::vector<art::Ptr<simb::MCTruth> > mclist;
737  art::fill_ptr_vector(mclist, mctruthListHandle);
738  art::Ptr<simb::MCTruth> mctruth;
739 
740  if (mclist.size()>0) {
741  mctruth = mclist.at(0);
742  if (mctruth->NeutrinoSet()) {
743  simb::MCNeutrino nu = mctruth->GetNeutrino();
744  mc_isnu = 1;
745  mc_nGeniePrimaries = mctruth->NParticles();
746  mc_nu_pdg = nu.Nu().PdgCode();
747  mc_nu_ccnc = nu.CCNC();
748  mc_nu_mode = nu.Mode();
749  mc_nu_intType = nu.InteractionType();
750  mc_nu_target = nu.Target();
751  mc_hitnuc = nu.HitNuc();
752  mc_hitquark = nu.HitQuark();
753  mc_nu_Q2 = nu.QSqr();
754  mc_nu_W = nu.W();
755  mc_nu_X = nu.X();
756  mc_nu_Y = nu.Y();
757  mc_nu_Pt = nu.Pt();
758  mc_nu_Theta = nu.Theta();
759 
760  const TLorentzVector& position = nu.Nu().Position(0);
761  const TLorentzVector& momentum = nu.Nu().Momentum(0);
762  position.GetXYZT(mc_nu_pos);
763  momentum.GetXYZT(mc_nu_mom);
764  // cout << "nu: " << mc_nu_pdg << ", nPrim: " << mc_nGeniePrimaries
765  // << ", ccnc: " << mc_nu_ccnc << endl;
766  // for (int i=0; i<mc_nGeniePrimaries; i++) {
767  // simb::MCParticle particle = mctruth->GetParticle(i);
768  // cout << "id: " << particle.TrackId()
769  // << ", pdg: " << particle.PdgCode()
770  // << endl;
771  // }
772  }
773  }
774 
775 }
float mc_startMomentum[MAX_TRACKS][4]
float mc_endXYZT[MAX_TRACKS][4]
int mc_id[MAX_TRACKS]
int mc_pdg[MAX_TRACKS]
int mc_mother[MAX_TRACKS]
std::map< int, int > savedMCTrackIdMap
float mc_endMomentum[MAX_TRACKS][4]
int mc_process[MAX_TRACKS]
TObjArray * fMC_trackPosition
#define MAX_TRACKS
std::vector< std::vector< int > > mc_daughters
std::string mcOption
float mc_nu_mom[4]
std::map< std::string, int > processMap
float mc_startXYZT[MAX_TRACKS][4]
BEGIN_PROLOG SN nu
float mc_nu_pos[4]
BEGIN_PROLOG could also be cout
void wc::CellTree::processMCTracks ( )
private

Definition at line 924 of file CellTree_module.cc.

925 {
926  // map track id to track index in the array
927  for (int i=0; i<mc_Ntrack; i++) {
928  trackIndex[mc_id[i]] = i;
929  }
930 
931  // in trackParents, trackChildren, trackSiblings vectors, store track index (not track id)
932  for (int i=0; i<mc_Ntrack; i++) {
933  // currently, parent size == 1;
934  // for primary particle, parent id = 0;
935  vector<int> parents;
936  if ( !IsPrimary(i) ) {
937  parents.push_back(trackIndex[mc_mother[i]]);
938  }
939  trackParents.push_back(parents); // primary track will have 0 parents
940 
941  vector<int> children;
942  int nChildren = mc_daughters.at(i).size();
943  for (int j=0; j<nChildren; j++) {
944  children.push_back(trackIndex[mc_daughters.at(i).at(j)]);
945  }
946  trackChildren.push_back(children);
947 
948  }
949 
950  // siblings
951  for (int i=0; i<mc_Ntrack; i++) {
952  vector<int> siblings;
953  if ( IsPrimary(i) ) {
954  for (int j=0; j<mc_Ntrack; j++) {
955  if( IsPrimary(j) ) {
956  siblings.push_back(j);
957  }
958  }
959  }
960  else {
961  // siblings are simply children of the mother
962  int mother = trackIndex[mc_mother[i]];
963  int nSiblings = trackChildren.at(mother).size();
964  for (int j=0; j<nSiblings; j++) {
965  siblings.push_back(trackChildren.at(mother).at(j));
966  }
967  }
968  trackSiblings.push_back(siblings);
969  }
970 
971 }
std::vector< std::vector< int > > trackChildren
std::map< int, int > trackIndex
int mc_id[MAX_TRACKS]
std::vector< std::vector< int > > trackSiblings
int mc_mother[MAX_TRACKS]
std::vector< std::vector< int > > mc_daughters
bool IsPrimary(int i)
std::vector< std::vector< int > > trackParents
void wc::CellTree::processOpFlash ( const art::Event &  evt)
private

Definition at line 581 of file CellTree_module.cc.

582  {
583  art::Handle<std::vector<recob::OpFlash> > flash_handle;
584  if(! event.getByLabel(fOpFlashLabel, flash_handle)){
585  cout << "WARNING: no label " << fOpFlashLabel << endl;
586  return;
587  }
588  std::vector<art::Ptr<recob::OpFlash> > flashes;
589  art::fill_ptr_vector(flashes, flash_handle);
590  of_nFlash = (int)flashes.size();
591 
592  int a=0;
593  int nOpDet = fGeometry->NOpDets();
594 
595  for(auto const& flash: flashes){
596  of_t.push_back(flash->Time());
597  of_peTotal.push_back(flash->TotalPE());
598  TH1F *h = new ((*fPEperOpDet)[a]) TH1F("","",nOpDet,0,nOpDet);
599 
600  int mult = 0;
601  for(int i=0; i<nOpDet; ++i){
602  if(flash->PE(i) >= opMultPEThresh){
603  mult++;
604  }
605  h->SetBinContent(i, flash->PE(i));
606  }
607  of_multiplicity.push_back(mult);
608  a++;
609  }
610  }
vector< int > of_multiplicity
art::ServiceHandle< geo::Geometry const > fGeometry
process_name gaushit a
while getopts h
std::string fOpFlashLabel
vector< float > of_peTotal
BEGIN_PROLOG could also be cout
vector< float > of_t
void wc::CellTree::processOpHit ( const art::Event &  evt)
private

Definition at line 560 of file CellTree_module.cc.

561 {
562  art::Handle<std::vector<recob::OpHit> > ophit_handle;
563  if(! event.getByLabel(fOpHitLabel, ophit_handle)){
564  cout << "WARNING: no label " << fOpHitLabel << endl;
565  return;
566  }
567  std::vector<art::Ptr<recob::OpHit> > ophits;
568  art::fill_ptr_vector(ophits, ophit_handle);
569  oh_nHits = (int)ophits.size();
570 
571  for(auto const& oh : ophits){
572  oh_channel.push_back(oh->OpChannel());
573  oh_bgtime.push_back(oh->PeakTime());
574  oh_trigtime.push_back(oh->PeakTimeAbs());
575  oh_pe.push_back(oh->PE());
576  }
577 
578 }
vector< double > oh_pe
vector< int > oh_channel
std::string fOpHitLabel
vector< double > oh_bgtime
vector< double > oh_trigtime
BEGIN_PROLOG could also be cout
void wc::CellTree::processRaw ( const art::Event &  evt)
private

Definition at line 494 of file CellTree_module.cc.

495 {
496  art::Handle< std::vector<raw::RawDigit> > rawdigit;
497  if (! event.getByLabel(fRawDigitLabel, rawdigit)) {
498  cout << "WARNING: no label " << fRawDigitLabel << endl;
499  return;
500  }
501  std::vector< art::Ptr<raw::RawDigit> > wires;
502  art::fill_ptr_vector(wires, rawdigit);
503 
504  fRaw_nChannel = wires.size();
505 
506  int i=0;
507  for (auto const& wire: wires) {
508  int chanId = wire->Channel();
509  fRaw_channelId.push_back(chanId);
510 
511  int nSamples = wire->Samples();
512  std::vector<short> uncompressed(nSamples);
513  raw::Uncompress(wire->ADCs(), uncompressed, wire->Compression());
514 
515  TH1F *h = new((*fRaw_wf)[i]) TH1F("", "", nRawSamples, 0, nRawSamples);
516  for (int j=1; j<=nSamples; j++) {
517  h->SetBinContent(j, uncompressed[j-1]);
518  }
519  i++;
520  if (i==1) {
521  cout << nSamples << " samples expanding to " << nRawSamples << endl;
522  }
523  }
524 
525 }
std::string fRawDigitLabel
while getopts h
std::vector< int > fRaw_channelId
void Uncompress(const std::vector< short > &adc, std::vector< short > &uncompressed, raw::Compress_t compress)
Uncompresses a raw data buffer.
Definition: raw.cxx:776
BEGIN_PROLOG could also be cout
void wc::CellTree::processSimChannel ( const art::Event &  evt)
private

Definition at line 613 of file CellTree_module.cc.

614 {
615  art::Handle< std::vector<sim::SimChannel> > simChannelHandle;
616  // event.getByLabel("largeant", simChannelHandle);
617  if (! event.getByLabel(fSimChannelLabel, simChannelHandle)) {
618  cout << "WARNING: no label " << fSimChannelLabel << endl;
619  return;
620  }
621 
622  // cout << "total simChannel: " << (*simChannelHandle).size() << endl;
623  fSIMIDE_size = 0;
624  for ( auto const& channel : (*simChannelHandle) ) {
625  auto channelNumber = channel.Channel();
626  // cout << channelNumber << endl;
627  // if (! (fGeometry->SignalType( channelNumber ) == geo::kCollection) ) {
628  // continue;
629  // }
630  auto const& timeSlices = channel.TDCIDEMap();
631  for ( auto const& timeSlice : timeSlices ) {
632  auto const& energyDeposits = timeSlice.second;
633  for ( auto const& energyDeposit : energyDeposits ) {
634  fSIMIDE_size++;
635  fSIMIDE_channelIdY.push_back(channelNumber);
636  fSIMIDE_tdc.push_back(timeSlice.first);
637  fSIMIDE_trackId.push_back(energyDeposit.trackID);
638  fSIMIDE_x.push_back(energyDeposit.x);
639  fSIMIDE_y.push_back(energyDeposit.y);
640  fSIMIDE_z.push_back(energyDeposit.z);
641  fSIMIDE_numElectrons.push_back(energyDeposit.numElectrons);
642  // cout << channelNumber << ": " << energyDeposit.trackID << ": " << timeSlice.first << ": "
643  // << energyDeposit.x << ", " << energyDeposit.y << ", " << energyDeposit.z << ", "
644  // << energyDeposit.numElectrons << endl;
645  }
646  }
647 
648  }
649  cout << "total IDEs: " << fSIMIDE_size << endl;
650 
651 
652 }
vector< int > fSIMIDE_channelIdY
vector< int > fSIMIDE_trackId
std::string fSimChannelLabel
vector< float > fSIMIDE_y
vector< float > fSIMIDE_x
vector< unsigned short > fSIMIDE_tdc
vector< float > fSIMIDE_z
vector< float > fSIMIDE_numElectrons
BEGIN_PROLOG could also be cout
void wc::CellTree::processSpacePoint ( const art::Event &  event,
TString  option,
ostream &  out = cout 
)
private

Definition at line 779 of file CellTree_module.cc.

780 {
781 
782  art::Handle< std::vector<recob::SpacePoint> > sp_handle;
783  art::Handle< std::vector<recob::PointCharge> > pc_handle;
784  bool sp_exists = event.getByLabel(option.Data(), sp_handle);
785  bool pc_exists = event.getByLabel(option.Data(), pc_handle);
786  if (! sp_exists) {
787  cout << "WARNING: no label " << option << endl;
788  return;
789  }
790  std::vector< art::Ptr<recob::SpacePoint> > sps;
791  std::vector< art::Ptr<recob::PointCharge> > pcs;
792  art::fill_ptr_vector(sps, sp_handle);
793  if (pc_exists) {
794  art::fill_ptr_vector(pcs, pc_handle);
795  if (sps.size() != pcs.size()) {
796  cout << "WARNING: SpacePoint and PointCharge length mismatch" << endl;
797  return;
798  }
799  }
800  double x=0, y=0, z=0, q=0, nq=1;
801  vector<double> vx, vy, vz, vq, vnq;
802 
803  for (uint i=0; i < sps.size(); i++ ) {
804  // cout << sp->XYZ()[0] << ", " << sp->XYZ()[1] << ", " << sp->XYZ()[2] << endl;
805  x = sps[i]->XYZ()[0];
806  y = sps[i]->XYZ()[1];
807  z = sps[i]->XYZ()[2];
808  if (pc_exists && pcs[i]->hasCharge()) {
809  q = pcs[i]->charge();
810  } else {
811  q = 0;
812  }
813  vx.push_back(x);
814  vy.push_back(y);
815  vz.push_back(z);
816  vq.push_back(q);
817  vnq.push_back(nq);
818  }
819 
820  out << fixed << setprecision(1);
821  out << "{" << endl;
822 
823  out << '"' << "runNo" << '"' << ":" << '"' << fRun << '"' << "," << endl;
824  out << '"' << "subRunNo" << '"' << ":" << '"' << fSubRun << '"' << "," << endl;
825  out << '"' << "eventNo" << '"' << ":" << '"' << fEvent << '"' << "," << endl;
826 
827  TString geomName(fGeometry->DetectorName().c_str());
828  if (geomName.Contains("35t")) { geomName = "dune35t"; }
829  else if (geomName.Contains("protodune")) { geomName = "protodune"; }
830  else if (geomName.Contains("workspace")) { geomName = "dune10kt_workspace"; }
831  else if (geomName.Contains("icarus")) { geomName = "icarus"; }
832  else { geomName = "uboone"; } // use uboone as default
833  out << '"' << "geom" << '"' << ":" << '"' << geomName << '"' << "," << endl;
834 
835 
836  print_vector(out, vx, "x");
837  print_vector(out, vy, "y");
838  print_vector(out, vz, "z");
839 
840  out << fixed << setprecision(0);
841  print_vector(out, vq, "q");
842  print_vector(out, vnq, "nq");
843 
844  out << '"' << "type" << '"' << ":" << '"' << option << '"' << endl;
845  out << "}" << endl;
846 }
process_name opflash particleana ie ie ie z
process_name opflash particleana ie x
art::ServiceHandle< geo::Geometry const > fGeometry
void print_vector(ostream &out, vector< double > &v, TString desc, bool end=false)
process_name opflash particleana ie ie y
echo Invalid option
Definition: TrainMVA.sh:17
BEGIN_PROLOG could also be cout
void wc::CellTree::processSpacePointTruthDepo ( const art::Event &  event,
TString  option,
ostream &  out = cout 
)
private

Definition at line 849 of file CellTree_module.cc.

850 {
851 
852  art::Handle< std::vector<sim::SimEnergyDeposit> > sed_handle;
853  if (!event.getByLabel(fSimEnergyDepositLabel, sed_handle)) {
854  cout << "WARNING: no label " << fSimEnergyDepositLabel << " for SimEnergyDeposit" << endl;
855  return;
856  }
857  std::vector< art::Ptr<sim::SimEnergyDeposit> > sed;
858  art::fill_ptr_vector(sed, sed_handle);
859  int size = sed.size();
860  double x=0, y=0, z=0, q=0, nq=1;
861  vector<double> vx, vy, vz, vq, vnq;
862 
863  for (int i=0; i < size; i++ ) {
864  // cout << sp->XYZ()[0] << ", " << sp->XYZ()[1] << ", " << sp->XYZ()[2] << endl;
865  x = sed[i]->MidPointX();
866  y = sed[i]->MidPointY();
867  z = sed[i]->MidPointZ();
868  q = sed[i]->NumElectrons();
869  if (q<0) q = sed[i]->Energy()*25000; // approx. #electrons
870  // cout << q << ", " << sed[i]->Energy()*25000 << endl;
871  if (q<1000) continue; // skip small dots to reduce size
872  vx.push_back(x);
873  vy.push_back(y);
874  vz.push_back(z);
875  vq.push_back(q);
876  vnq.push_back(nq);
877  }
878 
879  out << fixed << setprecision(1);
880  out << "{" << endl;
881 
882  out << '"' << "runNo" << '"' << ":" << '"' << fRun << '"' << "," << endl;
883  out << '"' << "subRunNo" << '"' << ":" << '"' << fSubRun << '"' << "," << endl;
884  out << '"' << "eventNo" << '"' << ":" << '"' << fEvent << '"' << "," << endl;
885 
886  TString geomName(fGeometry->DetectorName().c_str());
887  if (geomName.Contains("35t")) { geomName = "dune35t"; }
888  else if (geomName.Contains("protodune")) { geomName = "protodune"; }
889  else if (geomName.Contains("workspace")) { geomName = "dune10kt_workspace"; }
890  else if (geomName.Contains("icarus")) { geomName = "icarus"; }
891  else { geomName = "uboone"; } // use uboone as default
892  out << '"' << "geom" << '"' << ":" << '"' << geomName << '"' << "," << endl;
893 
894  print_vector(out, vx, "x");
895  print_vector(out, vy, "y");
896  print_vector(out, vz, "z");
897 
898  out << fixed << setprecision(0);
899  print_vector(out, vq, "q");
900  print_vector(out, vnq, "nq");
901 
902  out << '"' << "type" << '"' << ":" << '"' << option << '"' << endl;
903  out << "}" << endl;
904 }
process_name opflash particleana ie ie ie z
process_name opflash particleana ie x
std::size_t size(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:561
art::ServiceHandle< geo::Geometry const > fGeometry
void print_vector(ostream &out, vector< double > &v, TString desc, bool end=false)
process_name opflash particleana ie ie y
std::string fSimEnergyDepositLabel
echo Invalid option
Definition: TrainMVA.sh:17
BEGIN_PROLOG could also be cout
void wc::CellTree::processTrigger ( const art::Event &  evt)
private

Definition at line 974 of file CellTree_module.cc.

975 {
976  art::Handle< std::vector<raw::Trigger>> triggerListHandle;
977  std::vector<art::Ptr<raw::Trigger>> triggerlist;
978  if (event.getByLabel(fTriggerLabel, triggerListHandle)) {
979  art::fill_ptr_vector(triggerlist, triggerListHandle);
980  }
981  else {
982  cout << "WARNING: no trigger label " << fTriggerLabel << endl;
983  }
984  if (triggerlist.size()){
985  fTriggernumber = triggerlist[0]->TriggerNumber();
986  fTriggertime = triggerlist[0]->TriggerTime();
987  fBeamgatetime = triggerlist[0]->BeamGateTime();
988  fTriggerbits = triggerlist[0]->TriggerBits();
989  }
990  else {
991  fTriggernumber = 0;
992  fTriggertime = 0;
993  fBeamgatetime = 0;
994  fTriggerbits = 0;
995  }
996 }
unsigned int fTriggerbits
unsigned int fTriggernumber
std::string fTriggerLabel
BEGIN_PROLOG could also be cout
void wc::CellTree::reset ( )
private

Definition at line 423 of file CellTree_module.cc.

424 {
425 
426  fRaw_channelId.clear();
427  // fRaw_wf->Clear();
428  fRaw_wf->Delete();
429 
430  fCalib_channelId.clear();
431  fCalib_wf->Clear();
432 
433  oh_channel.clear();
434  oh_bgtime.clear();
435  oh_trigtime.clear();
436  oh_pe.clear();
437 
438  of_t.clear();
439  of_peTotal.clear();
440  of_multiplicity.clear();
441  fPEperOpDet->Delete();
442 
443  fSIMIDE_channelIdY.clear();
444  fSIMIDE_trackId.clear();
445  fSIMIDE_tdc.clear();
446  fSIMIDE_x.clear();
447  fSIMIDE_y.clear();
448  fSIMIDE_z.clear();
449  fSIMIDE_numElectrons.clear();
450 
451  mc_Ntrack = 0;
452  for (int i=0; i<MAX_TRACKS; i++) {
453  mc_id[i] = 0;
454  mc_pdg[i] = 0;
455  mc_mother[i] = 0;
456  for (int j=0; j<4; j++) {
457  mc_startXYZT[i][j] = 0;
458  mc_endXYZT[i][j] = 0;
459  mc_startMomentum[i][j] = 0;
460  mc_endMomentum[i][j] = 0;
461  }
462  }
463  mc_daughters.clear();
464  savedMCTrackIdMap.clear();
465  fMC_trackPosition->Clear();
466 
467  mc_isnu = 0;
468  mc_nGeniePrimaries = -1;
469  mc_nu_pdg = -1;
470  mc_nu_ccnc = -1;
471  mc_nu_mode = -1;
472  mc_nu_intType = -1;
473  mc_nu_target = -1;
474  mc_hitnuc = -1;
475  mc_hitquark = -1;
476  mc_nu_Q2 = -1;
477  mc_nu_W = -1;
478  mc_nu_X = -1;
479  mc_nu_Y = -1;
480  mc_nu_Pt = -1;
481  mc_nu_Theta = -1;
482  for (int i=0; i<4; i++) {
483  mc_nu_pos[i] = 0;
484  mc_nu_mom[i] = 0;
485  }
486 
487  trackIndex.clear();
488  trackParents.clear();
489  trackChildren.clear();
490  trackSiblings.clear();
491 }
float mc_startMomentum[MAX_TRACKS][4]
std::vector< std::vector< int > > trackChildren
vector< double > oh_pe
vector< int > fSIMIDE_channelIdY
std::map< int, int > trackIndex
vector< int > fSIMIDE_trackId
float mc_endXYZT[MAX_TRACKS][4]
int mc_id[MAX_TRACKS]
int mc_pdg[MAX_TRACKS]
std::vector< std::vector< int > > trackSiblings
vector< int > of_multiplicity
vector< float > fSIMIDE_y
vector< float > fSIMIDE_x
int mc_mother[MAX_TRACKS]
vector< unsigned short > fSIMIDE_tdc
std::map< int, int > savedMCTrackIdMap
float mc_endMomentum[MAX_TRACKS][4]
vector< int > oh_channel
vector< double > oh_bgtime
vector< double > oh_trigtime
TClonesArray * fCalib_wf
TObjArray * fMC_trackPosition
std::vector< int > fRaw_channelId
vector< float > fSIMIDE_z
#define MAX_TRACKS
std::vector< std::vector< int > > mc_daughters
TClonesArray * fRaw_wf
std::vector< int > fCalib_channelId
float mc_nu_mom[4]
TClonesArray * fPEperOpDet
vector< float > fSIMIDE_numElectrons
float mc_startXYZT[MAX_TRACKS][4]
vector< float > of_peTotal
float mc_nu_pos[4]
vector< float > of_t
std::vector< std::vector< int > > trackParents

Member Data Documentation

TDatabasePDG* wc::CellTree::dbPDG
private

Definition at line 205 of file CellTree_module.cc.

int wc::CellTree::entryNo
private

Definition at line 124 of file CellTree_module.cc.

double wc::CellTree::fBeamgatetime
private

Definition at line 134 of file CellTree_module.cc.

std::vector<int> wc::CellTree::fCalib_channelId
private

Definition at line 140 of file CellTree_module.cc.

int wc::CellTree::fCalib_nChannel
private

Definition at line 137 of file CellTree_module.cc.

TClonesArray* wc::CellTree::fCalib_wf
private

Definition at line 142 of file CellTree_module.cc.

std::string wc::CellTree::fCalibLabel
private

Definition at line 94 of file CellTree_module.cc.

int wc::CellTree::fEvent
private

Definition at line 127 of file CellTree_module.cc.

double wc::CellTree::fEventTime
private

Definition at line 130 of file CellTree_module.cc.

TTree* wc::CellTree::fEventTree
private

Definition at line 120 of file CellTree_module.cc.

art::ServiceHandle<geo::Geometry const> wc::CellTree::fGeometry
private

Definition at line 114 of file CellTree_module.cc.

TObjArray* wc::CellTree::fMC_trackPosition
private

Definition at line 180 of file CellTree_module.cc.

std::string wc::CellTree::fOpFlashLabel
private

Definition at line 96 of file CellTree_module.cc.

std::string wc::CellTree::fOpHitLabel
private

Definition at line 95 of file CellTree_module.cc.

TFile* wc::CellTree::fOutFile
private

Definition at line 119 of file CellTree_module.cc.

std::string wc::CellTree::fOutFileName
private

Definition at line 101 of file CellTree_module.cc.

TClonesArray* wc::CellTree::fPEperOpDet
private

Definition at line 155 of file CellTree_module.cc.

std::vector<int> wc::CellTree::fRaw_channelId
private

Definition at line 158 of file CellTree_module.cc.

int wc::CellTree::fRaw_nChannel
private

Definition at line 157 of file CellTree_module.cc.

TClonesArray* wc::CellTree::fRaw_wf
private

Definition at line 159 of file CellTree_module.cc.

std::string wc::CellTree::fRawDigitLabel
private

Definition at line 93 of file CellTree_module.cc.

int wc::CellTree::fRun
private

Definition at line 128 of file CellTree_module.cc.

bool wc::CellTree::fSaveCalib
private

Definition at line 108 of file CellTree_module.cc.

bool wc::CellTree::fSaveJSON
private

Definition at line 113 of file CellTree_module.cc.

bool wc::CellTree::fSaveMC
private

Definition at line 111 of file CellTree_module.cc.

bool wc::CellTree::fSaveMCTrackPoints
private

Definition at line 105 of file CellTree_module.cc.

bool wc::CellTree::fSaveOpFlash
private

Definition at line 110 of file CellTree_module.cc.

bool wc::CellTree::fSaveOpHit
private

Definition at line 109 of file CellTree_module.cc.

bool wc::CellTree::fSaveRaw
private

Definition at line 107 of file CellTree_module.cc.

bool wc::CellTree::fSaveSimChannel
private

Definition at line 106 of file CellTree_module.cc.

bool wc::CellTree::fSaveTrigger
private

Definition at line 112 of file CellTree_module.cc.

std::string wc::CellTree::fSimChannelLabel
private

Definition at line 100 of file CellTree_module.cc.

std::string wc::CellTree::fSimEnergyDepositLabel
private

Definition at line 98 of file CellTree_module.cc.

vector<int> wc::CellTree::fSIMIDE_channelIdY
private

Definition at line 162 of file CellTree_module.cc.

vector<float> wc::CellTree::fSIMIDE_numElectrons
private

Definition at line 168 of file CellTree_module.cc.

int wc::CellTree::fSIMIDE_size
private

Definition at line 161 of file CellTree_module.cc.

vector<unsigned short> wc::CellTree::fSIMIDE_tdc
private

Definition at line 164 of file CellTree_module.cc.

vector<int> wc::CellTree::fSIMIDE_trackId
private

Definition at line 163 of file CellTree_module.cc.

vector<float> wc::CellTree::fSIMIDE_x
private

Definition at line 165 of file CellTree_module.cc.

vector<float> wc::CellTree::fSIMIDE_y
private

Definition at line 166 of file CellTree_module.cc.

vector<float> wc::CellTree::fSIMIDE_z
private

Definition at line 167 of file CellTree_module.cc.

std::vector<std::string> wc::CellTree::fSpacePointLabels
private

Definition at line 99 of file CellTree_module.cc.

int wc::CellTree::fSubRun
private

Definition at line 129 of file CellTree_module.cc.

unsigned int wc::CellTree::fTriggerbits
private

Definition at line 135 of file CellTree_module.cc.

std::string wc::CellTree::fTriggerLabel
private

Definition at line 97 of file CellTree_module.cc.

unsigned int wc::CellTree::fTriggernumber
private

Definition at line 132 of file CellTree_module.cc.

double wc::CellTree::fTriggertime
private

Definition at line 133 of file CellTree_module.cc.

std::vector<std::vector<int> > wc::CellTree::mc_daughters
private

Definition at line 179 of file CellTree_module.cc.

float wc::CellTree::mc_endMomentum[MAX_TRACKS][4]
private

Definition at line 178 of file CellTree_module.cc.

float wc::CellTree::mc_endXYZT[MAX_TRACKS][4]
private

Definition at line 176 of file CellTree_module.cc.

int wc::CellTree::mc_hitnuc
private

Definition at line 189 of file CellTree_module.cc.

int wc::CellTree::mc_hitquark
private

Definition at line 190 of file CellTree_module.cc.

int wc::CellTree::mc_id[MAX_TRACKS]
private

Definition at line 171 of file CellTree_module.cc.

int wc::CellTree::mc_isnu
private

Definition at line 182 of file CellTree_module.cc.

int wc::CellTree::mc_mother[MAX_TRACKS]
private

Definition at line 174 of file CellTree_module.cc.

int wc::CellTree::mc_nGeniePrimaries
private

Definition at line 183 of file CellTree_module.cc.

int wc::CellTree::mc_Ntrack
private

Definition at line 170 of file CellTree_module.cc.

int wc::CellTree::mc_nu_ccnc
private

Definition at line 185 of file CellTree_module.cc.

int wc::CellTree::mc_nu_intType
private

Definition at line 187 of file CellTree_module.cc.

int wc::CellTree::mc_nu_mode
private

Definition at line 186 of file CellTree_module.cc.

float wc::CellTree::mc_nu_mom[4]
private

Definition at line 198 of file CellTree_module.cc.

int wc::CellTree::mc_nu_pdg
private

Definition at line 184 of file CellTree_module.cc.

float wc::CellTree::mc_nu_pos[4]
private

Definition at line 197 of file CellTree_module.cc.

double wc::CellTree::mc_nu_Pt
private

Definition at line 195 of file CellTree_module.cc.

double wc::CellTree::mc_nu_Q2
private

Definition at line 191 of file CellTree_module.cc.

int wc::CellTree::mc_nu_target
private

Definition at line 188 of file CellTree_module.cc.

double wc::CellTree::mc_nu_Theta
private

Definition at line 196 of file CellTree_module.cc.

double wc::CellTree::mc_nu_W
private

Definition at line 192 of file CellTree_module.cc.

double wc::CellTree::mc_nu_X
private

Definition at line 193 of file CellTree_module.cc.

double wc::CellTree::mc_nu_Y
private

Definition at line 194 of file CellTree_module.cc.

int wc::CellTree::mc_pdg[MAX_TRACKS]
private

Definition at line 172 of file CellTree_module.cc.

int wc::CellTree::mc_process[MAX_TRACKS]
private

Definition at line 173 of file CellTree_module.cc.

float wc::CellTree::mc_startMomentum[MAX_TRACKS][4]
private

Definition at line 177 of file CellTree_module.cc.

float wc::CellTree::mc_startXYZT[MAX_TRACKS][4]
private

Definition at line 175 of file CellTree_module.cc.

std::string wc::CellTree::mcOption
private

Definition at line 102 of file CellTree_module.cc.

int wc::CellTree::nRawSamples
private

Definition at line 103 of file CellTree_module.cc.

vector<int> wc::CellTree::of_multiplicity
private

Definition at line 154 of file CellTree_module.cc.

int wc::CellTree::of_nFlash
private

Definition at line 151 of file CellTree_module.cc.

vector<float> wc::CellTree::of_peTotal
private

Definition at line 153 of file CellTree_module.cc.

vector<float> wc::CellTree::of_t
private

Definition at line 152 of file CellTree_module.cc.

vector<double> wc::CellTree::oh_bgtime
private

Definition at line 147 of file CellTree_module.cc.

vector<int> wc::CellTree::oh_channel
private

Definition at line 146 of file CellTree_module.cc.

int wc::CellTree::oh_nHits
private

Definition at line 145 of file CellTree_module.cc.

vector<double> wc::CellTree::oh_pe
private

Definition at line 149 of file CellTree_module.cc.

vector<double> wc::CellTree::oh_trigtime
private

Definition at line 148 of file CellTree_module.cc.

float wc::CellTree::opMultPEThresh
private

Definition at line 104 of file CellTree_module.cc.

std::map<std::string, int> wc::CellTree::processMap
private

Definition at line 121 of file CellTree_module.cc.

std::map<int, int> wc::CellTree::savedMCTrackIdMap
private

Definition at line 122 of file CellTree_module.cc.

std::vector<std::vector<int> > wc::CellTree::trackChildren
private

Definition at line 203 of file CellTree_module.cc.

std::map<int, int> wc::CellTree::trackIndex
private

Definition at line 201 of file CellTree_module.cc.

std::vector<std::vector<int> > wc::CellTree::trackParents
private

Definition at line 202 of file CellTree_module.cc.

std::vector<std::vector<int> > wc::CellTree::trackSiblings
private

Definition at line 204 of file CellTree_module.cc.


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