14 #include "libxml/parser.h" 15 #include "libxml/xmlmemory.h" 17 #include <TLorentzVector.h> 34 using namespace genie;
56 for(pdg_iter = pdg_list.begin(); pdg_iter != pdg_list.end(); ++pdg_iter) {
58 this->insert( map<int, double>::value_type(pdgc, 0.) );
73 for(iter = plist.begin(); iter != plist.end(); ++iter) {
74 int pdgc = iter->first;
75 double pl = iter->second;
76 this->insert( map<int, double>::value_type(pdgc, pl) );
89 if (this->
count(pdgc) == 1) { (*this)[pdgc] += pl; }
92 <<
"No material with PDG code = " << pdgc <<
" in path length list";
100 if (this->
count(pdgc) == 1) { (*this)[pdgc] = pl; }
103 <<
"No material with PDG code = " << pdgc <<
" in path length list";
111 if (this->
count(pdgc) == 1) {
112 double pl = (*this)[pdgc];
117 <<
"No material with PDG code = " << pdgc <<
" in path length list";
125 if ( this->
count(pdgc) == 1 ) {
127 return pl_iter->second;
130 <<
"No material with PDG code = " << pdgc <<
" in path length list";
139 for(pl_iter = this->
begin(); pl_iter != this->
end(); ++pl_iter) {
140 int pdgc = pl_iter->first;
151 for(pl_iter = this->
begin(); pl_iter != this->
end(); ++pl_iter) {
152 double pl = pl_iter->second;
162 for(pl_iter = plist.begin(); pl_iter != plist.end(); ++pl_iter) {
163 int pdgc = pl_iter->first;
164 double pl = pl_iter->second;
165 this->insert( map<int, double>::value_type(pdgc, pl) );
171 stream <<
"\n[-]" <<
endl;
176 size_t nc = this->
size();
178 for(pl_iter = this->
begin(); pl_iter != this->
end(); ++pl_iter) {
180 int pdgc = pl_iter->first;
181 double pl = pl_iter->second;
183 TParticlePDG *
p = pdglib->
Find(pdgc);
186 stream <<
" |---o ** ERR: no particle with PDG code: " << pdgc;
188 string name = p->GetName();
189 stream <<
" |---o code: " << pdgc <<
" [" <<
setfill(
' ')
190 <<
setw(5) << name <<
"] " <<
"-----> path-length = " << pl;
192 if( (--nc) > 0) stream <<
endl;
202 <<
"Loading PathLengthList from XML file: " <<
filename;
204 xmlDocPtr xml_doc = xmlParseFile(filename.c_str() );
208 <<
"XML file could not be parsed! [filename: " << filename <<
"]";
212 xmlNodePtr xmlCur = xmlDocGetRootElement(xml_doc);
216 <<
"XML doc. has null root element! [filename: " << filename <<
"]";
220 if( xmlStrcmp(xmlCur->name, (
const xmlChar *)
"path_length_list") ) {
222 <<
"XML doc. has invalid root element! [filename: " << filename <<
"]";
226 LOG(
"PathL",
pINFO) <<
"XML file was successfully parsed";
228 xmlCur = xmlCur->xmlChildrenNode;
231 while (xmlCur != NULL) {
234 if( (!xmlStrcmp(xmlCur->name, (
const xmlChar *)
"path_length")) ) {
236 xmlNodePtr xmlPlVal = xmlCur->xmlChildrenNode;
242 xmlNodeListGetString(xml_doc, xmlPlVal, 1));
244 LOG(
"PathL",
pDEBUG) <<
"pdgc = " << spdgc <<
" --> pl = " << spl;
246 int pdgc = atoi( spdgc.c_str() );
247 double pl = atof( spl.c_str() );
249 TParticlePDG *
p = pdglib->
Find(pdgc);
252 <<
"No particle with pdgc " << pdgc
253 <<
" found. Will not load its path length";
255 this->insert( map<int, double>::value_type(pdgc, pl) );
259 xmlCur = xmlCur->next;
271 <<
"Saving PathLengthList as XML in file: " <<
filename;
275 ofstream outxml(filename.c_str());
276 if(!outxml.is_open()) {
280 outxml <<
"<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
282 outxml <<
"<!-- generated by PathLengthList::SaveAsXml() -->";
283 outxml << endl <<
endl;
285 outxml <<
"<path_length_list>" << endl <<
endl;
289 for(pl_iter = this->
begin(); pl_iter != this->
end(); ++pl_iter) {
291 int pdgc = pl_iter->first;
292 double pl = pl_iter->second;
294 TParticlePDG *
p = pdglib->
Find(pdgc);
296 outxml <<
" <path_length pdgc=\"" << pdgc <<
"\"> " 297 <<
setfill(
' ') <<
setw(10) << pl <<
" </path_length>";
298 if ( p ) outxml <<
" <!-- [" <<
setfill(
' ')
299 <<
setw(5) << p->GetName() <<
"] -->";
302 outxml << endl <<
"</path_length_list>";
void ScalePathLength(int pdgc, double scale)
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
double PathLength(int pdgc) const
bool AreAllZero(void) const
THE MAIN GENIE PROJECT NAMESPACE
PathLengthList & operator=(const PathLengthList &list)
bool AreEqual(double x1, double x2)
string TrimSpaces(xmlChar *xmls)
void SetPathLength(int pdgc, double pl)
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
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.
void SaveAsXml(string filename) const
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
XmlParserStatus_t LoadFromXml(string filename)
Q_EXPORT QTSManip setw(int w)
string TrimSpaces(string input)
void Print(ostream &stream) const
static PDGLibrary * Instance(void)
Singleton class to load & serve a TDatabasePDG.
ostream & operator<<(ostream &stream, const AlgConfigPool &config_pool)
vector< vector< double > > clear
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
void AddPathLength(int pdgc, double pl)
TParticlePDG * Find(int pdgc, bool must_exist=true)
enum genie::EXmlParseStatus XmlParserStatus_t
string GetAttribute(xmlNodePtr xml_cur, string attr_name)
Q_EXPORT QTSManip setfill(int f)
void Copy(const PathLengthList &plist)
QTextStream & endl(QTextStream &s)