Public Member Functions | Friends | List of all members
genie::PathLengthList Class Reference

Object to be filled with the neutrino path-length, for all detector geometry materials, when starting from a position x and travelling along the direction of the neutrino 4-momentum. More...

#include "/cvmfs/nova.opensciencegrid.org/externals/genie/v3_00_06_p01/Linux64bit+2.6-2.12-e17-debug/GENIE-Generator/src/Framework/EventGen/PathLengthList.h"

Inheritance diagram for genie::PathLengthList:

Public Member Functions

 PathLengthList ()
 
 PathLengthList (const PDGCodeList &pdglist)
 
 PathLengthList (const PathLengthList &plist)
 
 PathLengthList (const map< int, double > &plist)
 
 ~PathLengthList ()
 
void AddPathLength (int pdgc, double pl)
 
void SetPathLength (int pdgc, double pl)
 
void SetAllToZero (void)
 
bool AreAllZero (void) const
 
void ScalePathLength (int pdgc, double scale)
 
double PathLength (int pdgc) const
 
XmlParserStatus_t LoadFromXml (string filename)
 
void SaveAsXml (string filename) const
 
void Copy (const PathLengthList &plist)
 
void Print (ostream &stream) const
 
PathLengthListoperator= (const PathLengthList &list)
 

Friends

ostream & operator<< (ostream &stream, const PathLengthList &list)
 

Detailed Description

Object to be filled with the neutrino path-length, for all detector geometry materials, when starting from a position x and travelling along the direction of the neutrino 4-momentum.

Author
Costas Andreopoulos <costas.andreopoulos stfc.ac.uk> University of Liverpool & STFC Rutherford Appleton Lab

May 24, 2005

Copyright (c) 2003-2019, The GENIE Collaboration For the full text of the license visit http://copyright.genie-mc.org or see $GENIE/LICENSE

Definition at line 43 of file PathLengthList.h.

Constructor & Destructor Documentation

PathLengthList::PathLengthList ( void  )

Definition at line 53 of file PathLengthList.cxx.

53  :
54 map<int, double>()
55 {
56 
57 }
PathLengthList::PathLengthList ( const PDGCodeList pdglist)

Definition at line 59 of file PathLengthList.cxx.

59  :
60 map<int, double>()
61 {
62  PDGCodeList::const_iterator pdg_iter;
63 
64  for(pdg_iter = pdg_list.begin(); pdg_iter != pdg_list.end(); ++pdg_iter) {
65  int pdgc = *pdg_iter;
66  this->insert( map<int, double>::value_type(pdgc, 0.) );
67  }
68 }
PathLengthList::PathLengthList ( const PathLengthList plist)

Definition at line 70 of file PathLengthList.cxx.

References Copy().

70  :
71 map<int, double>()
72 {
73  this->Copy(plist);
74 }
void Copy(const PathLengthList &plist)
PathLengthList::PathLengthList ( const map< int, double > &  plist)

Definition at line 76 of file PathLengthList.cxx.

References std_candles::pl.

76  :
77 map<int, double>()
78 {
79  map<int,double>::const_iterator iter;
80 
81  for(iter = plist.begin(); iter != plist.end(); ++iter) {
82  int pdgc = iter->first;
83  double pl = iter->second;
84  this->insert( map<int, double>::value_type(pdgc, pl) );
85  }
86 }
PathLengthList::~PathLengthList ( )

Definition at line 88 of file PathLengthList.cxx.

89 {
90 
91 }

Member Function Documentation

void PathLengthList::AddPathLength ( int  pdgc,
double  pl 
)

Definition at line 93 of file PathLengthList.cxx.

References confusionMatrixTree::count, LOG, std_candles::pl, and pWARN.

Referenced by genie::geometry::ROOTGeomAnalyzer::ComputePathLengths().

94 {
95 // Adds pl to the total path length for material with code = pdgc
96 
97  if (this->count(pdgc) == 1) { (*this)[pdgc] += pl; }
98  else {
99  LOG("PathL", pWARN)
100  << "No material with PDG code = " << pdgc << " in path length list";
101  }
102 }
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:97
#define pWARN
Definition: Messenger.h:61
bool PathLengthList::AreAllZero ( void  ) const

Definition at line 153 of file PathLengthList.cxx.

References genie::utils::math::AreEqual(), febshutoff_auto::end, and std_candles::pl.

Referenced by GetTargetMaterial().

154 {
155  bool allzero = true;
156 
157  PathLengthList::const_iterator pl_iter;
158 
159  for(pl_iter = this->begin(); pl_iter != this->end(); ++pl_iter) {
160  double pl = pl_iter->second;
161  allzero = allzero && (utils::math::AreEqual(pl,0.));
162  }
163  return allzero;
164 }
bool AreEqual(double x1, double x2)
Definition: MathUtils.cxx:243
void PathLengthList::Copy ( const PathLengthList plist)

Definition at line 166 of file PathLengthList.cxx.

References clear, and std_candles::pl.

Referenced by operator=(), and PathLengthList().

167 {
168  this->clear();
169  PathLengthList::const_iterator pl_iter;
170  for(pl_iter = plist.begin(); pl_iter != plist.end(); ++pl_iter) {
171  int pdgc = pl_iter->first;
172  double pl = pl_iter->second;
173  this->insert( map<int, double>::value_type(pdgc, pl) );
174  }
175 }
vector< vector< double > > clear
XmlParserStatus_t PathLengthList::LoadFromXml ( string  filename)

Definition at line 204 of file PathLengthList.cxx.

References clear, shutoffs::filename, genie::PDGLibrary::Find(), genie::utils::xml::GetAttribute(), genie::PDGLibrary::Instance(), genie::kXmlEmpty, genie::kXmlInvalidRoot, genie::kXmlNotParsed, genie::kXmlOK, LOG, pDEBUG, pERROR, pINFO, std_candles::pl, genie::utils::str::TrimSpaces(), and genie::utils::xml::TrimSpaces().

205 {
206  this->clear();
207  PDGLibrary * pdglib = PDGLibrary::Instance();
208 
209  LOG("PathL", pINFO)
210  << "Loading PathLengthList from XML file: " << filename;
211 
212  xmlDocPtr xml_doc = xmlParseFile(filename.c_str() );
213 
214  if(xml_doc==NULL) {
215  LOG("PathL", pERROR)
216  << "XML file could not be parsed! [filename: " << filename << "]";
217  return kXmlNotParsed;
218  }
219 
220  xmlNodePtr xmlCur = xmlDocGetRootElement(xml_doc);
221 
222  if(xmlCur==NULL) {
223  LOG("PathL", pERROR)
224  << "XML doc. has null root element! [filename: " << filename << "]";
225  return kXmlEmpty;
226  }
227 
228  if( xmlStrcmp(xmlCur->name, (const xmlChar *) "path_length_list") ) {
229  LOG("PathL", pERROR)
230  << "XML doc. has invalid root element! [filename: " << filename << "]";
231  return kXmlInvalidRoot;
232  }
233 
234  LOG("PathL", pINFO) << "XML file was successfully parsed";
235 
236  xmlCur = xmlCur->xmlChildrenNode; // <path_length>'s
237 
238  // loop over all xml tree nodes that are children of the root node
239  while (xmlCur != NULL) {
240 
241  // enter everytime you find a <path_length> tag
242  if( (!xmlStrcmp(xmlCur->name, (const xmlChar *) "path_length")) ) {
243 
244  xmlNodePtr xmlPlVal = xmlCur->xmlChildrenNode;
245 
246  string spdgc = utils::str::TrimSpaces(
247  utils::xml::GetAttribute(xmlCur, "pdgc"));
248 
249  string spl = utils::xml::TrimSpaces(
250  xmlNodeListGetString(xml_doc, xmlPlVal, 1));
251 
252  LOG("PathL", pDEBUG) << "pdgc = " << spdgc << " --> pl = " << spl;
253 
254  int pdgc = atoi( spdgc.c_str() );
255  double pl = atof( spl.c_str() );
256 
257  TParticlePDG * p = pdglib->Find(pdgc);
258  if(!p) {
259  LOG("PathL", pERROR)
260  << "No particle with pdgc " << pdgc
261  << " found. Will not load its path length";
262  } else
263  this->insert( map<int, double>::value_type(pdgc, pl) );
264 
265  xmlFree(xmlPlVal);
266  }
267  xmlCur = xmlCur->next;
268  } // [end of] loop over tags within root elements
269 
270  xmlFree(xmlCur);
271  return kXmlOK;
272 }
#define pERROR
Definition: Messenger.h:60
string TrimSpaces(xmlChar *xmls)
const char * p
Definition: xmltok.h:285
vector< vector< double > > clear
string filename
Definition: shutoffs.py:106
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:97
#define pINFO
Definition: Messenger.h:63
string TrimSpaces(string input)
Definition: StringUtils.cxx:24
static PDGLibrary * Instance(void)
Definition: PDGLibrary.cxx:43
Singleton class to load & serve a TDatabasePDG.
Definition: PDGLibrary.h:30
TParticlePDG * Find(int pdgc)
Definition: PDGLibrary.cxx:61
string GetAttribute(xmlNodePtr xml_cur, string attr_name)
#define pDEBUG
Definition: Messenger.h:64
PathLengthList & PathLengthList::operator= ( const PathLengthList list)

Definition at line 317 of file PathLengthList.cxx.

References Copy().

318 {
319  this->Copy(list);
320  return (*this);
321 }
void Copy(const PathLengthList &plist)
double PathLengthList::PathLength ( int  pdgc) const

Definition at line 129 of file PathLengthList.cxx.

References confusionMatrixTree::count, LOG, and pWARN.

Referenced by GetTargetMaterial(), genie::geometry::ROOTGeomAnalyzer::MaxPathLengthsBoxMethod(), and genie::geometry::ROOTGeomAnalyzer::MaxPathLengthsFluxMethod().

130 {
131 // Gets the total path length for material with code = pdgc to be pl
132 
133  if ( this->count(pdgc) == 1 ) {
134  map<int, double>::const_iterator pl_iter = this->find(pdgc);
135  return pl_iter->second;
136  } else {
137  LOG("PathL", pWARN)
138  << "No material with PDG code = " << pdgc << " in path length list";
139  }
140  return 0;
141 }
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:97
#define pWARN
Definition: Messenger.h:61
void PathLengthList::Print ( ostream &  stream) const

Definition at line 177 of file PathLengthList.cxx.

References febshutoff_auto::end, allTimeWatchdog::endl, genie::PDGLibrary::Find(), genie::PDGLibrary::Instance(), nc, std_candles::pl, and gen_flatrecord::size.

Referenced by genie::operator<<().

178 {
179  stream << "\n[-]" << endl;
180 
181  PDGLibrary * pdglib = PDGLibrary::Instance();
182 
183  PathLengthList::const_iterator pl_iter;
184  size_t nc = this->size();
185 
186  for(pl_iter = this->begin(); pl_iter != this->end(); ++pl_iter) {
187 
188  int pdgc = pl_iter->first;
189  double pl = pl_iter->second; // path length
190 
191  TParticlePDG * p = pdglib->Find(pdgc);
192 
193  if(!p) {
194  stream << " |---o ** ERR: no particle with PDG code: " << pdgc;
195  } else {
196  string name = p->GetName();
197  stream << " |---o code: " << pdgc << " [" << setfill(' ')
198  << setw(5) << name << "] " << "-----> path-length = " << pl;
199  }
200  if( (--nc) > 0) stream << endl;
201  }
202 }
const XML_Char * name
Definition: expat.h:151
const char * p
Definition: xmltok.h:285
static PDGLibrary * Instance(void)
Definition: PDGLibrary.cxx:43
Singleton class to load & serve a TDatabasePDG.
Definition: PDGLibrary.h:30
TParticlePDG * Find(int pdgc)
Definition: PDGLibrary.cxx:61
enum BeamMode nc
void PathLengthList::SaveAsXml ( string  filename) const

Save path length list to XML file

Definition at line 274 of file PathLengthList.cxx.

References febshutoff_auto::end, allTimeWatchdog::endl, shutoffs::filename, genie::PDGLibrary::Find(), genie::PDGLibrary::Instance(), LOG, pERROR, pINFO, and std_candles::pl.

Referenced by main().

275 {
276 //! Save path length list to XML file
277 
278  LOG("PathL", pINFO)
279  << "Saving PathLengthList as XML in file: " << filename;
280 
281  PDGLibrary * pdglib = PDGLibrary::Instance();
282 
283  ofstream outxml(filename.c_str());
284  if(!outxml.is_open()) {
285  LOG("PathL", pERROR) << "Couldn't create file = " << filename;
286  return;
287  }
288  outxml << "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
289  outxml << endl << endl;
290  outxml << "<!-- generated by PathLengthList::SaveAsXml() -->";
291  outxml << endl << endl;
292 
293  outxml << "<path_length_list>" << endl << endl;
294 
295  PathLengthList::const_iterator pl_iter;
296 
297  for(pl_iter = this->begin(); pl_iter != this->end(); ++pl_iter) {
298 
299  int pdgc = pl_iter->first;
300  double pl = pl_iter->second; // path length
301 
302  TParticlePDG * p = pdglib->Find(pdgc);
303 
304  outxml << " <path_length pdgc=\"" << pdgc << "\"> "
305  << setfill(' ') << setw(10) << pl << " </path_length>";
306  if ( p ) outxml << " <!-- [" << setfill(' ')
307  << setw(5) << p->GetName() << "] -->";
308  outxml << endl;
309  }
310  outxml << endl << "</path_length_list>";
311  outxml << endl;
312 
313  outxml.close();
314 
315 }
#define pERROR
Definition: Messenger.h:60
const char * p
Definition: xmltok.h:285
string filename
Definition: shutoffs.py:106
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:97
#define pINFO
Definition: Messenger.h:63
static PDGLibrary * Instance(void)
Definition: PDGLibrary.cxx:43
Singleton class to load & serve a TDatabasePDG.
Definition: PDGLibrary.h:30
TParticlePDG * Find(int pdgc)
Definition: PDGLibrary.cxx:61
void PathLengthList::ScalePathLength ( int  pdgc,
double  scale 
)

Definition at line 115 of file PathLengthList.cxx.

References confusionMatrixTree::count, LOG, std_candles::pl, pWARN, and scale.

Referenced by genie::geometry::ROOTGeomAnalyzer::Local2SI().

116 {
117 // Scales pl for material with code = pdgc with the input scale factor
118 
119  if (this->count(pdgc) == 1) {
120  double pl = (*this)[pdgc];
121  pl *= scale;
122  (*this)[pdgc] = pl;
123  } else {
124  LOG("PathL", pWARN)
125  << "No material with PDG code = " << pdgc << " in path length list";
126  }
127 }
Double_t scale
Definition: plot.C:25
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:97
#define pWARN
Definition: Messenger.h:61
void PathLengthList::SetAllToZero ( void  )

Definition at line 143 of file PathLengthList.cxx.

References febshutoff_auto::end.

Referenced by genie::geometry::ROOTGeomAnalyzer::ComputeMaxPathLengths(), and genie::geometry::ROOTGeomAnalyzer::ComputePathLengths().

144 {
145  PathLengthList::const_iterator pl_iter;
146 
147  for(pl_iter = this->begin(); pl_iter != this->end(); ++pl_iter) {
148  int pdgc = pl_iter->first;
149  (*this)[pdgc] = 0.;
150  }
151 }
void PathLengthList::SetPathLength ( int  pdgc,
double  pl 
)

Definition at line 104 of file PathLengthList.cxx.

References confusionMatrixTree::count, LOG, std_candles::pl, and pWARN.

Referenced by genie::geometry::ROOTGeomAnalyzer::MaxPathLengthsBoxMethod(), and genie::geometry::ROOTGeomAnalyzer::MaxPathLengthsFluxMethod().

105 {
106 // Sets the total path length for material with code = pdgc to be pl
107 
108  if (this->count(pdgc) == 1) { (*this)[pdgc] = pl; }
109  else {
110  LOG("PathL", pWARN)
111  << "No material with PDG code = " << pdgc << " in path length list";
112  }
113 }
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:97
#define pWARN
Definition: Messenger.h:61

Friends And Related Function Documentation

ostream& operator<< ( ostream &  stream,
const PathLengthList list 
)
friend

Definition at line 46 of file PathLengthList.cxx.

47  {
48  list.Print(stream);
49  return stream;
50  }
void Print(ostream &stream) const

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