10 #include <boost/bind.hpp>
12 #include <xercesc/sax2/Attributes.hpp>
13 #include <xercesc/dom/DOM.hpp>
30 XERCES_CPP_NAMESPACE_USE
57 <<
"Could not open LHE file \""
58 << fileURL <<
"\" for reading"
79 <<
"Empty LHE file string name \""
82 std::stringstream * tmpis =
new std::stringstream(inputs);
115 const XMLCh *
const localname,
116 const XMLCh *
const qname,
120 const XMLCh *
const localname,
121 const XMLCh *
const qname);
123 void characters(
const XMLCh *
const data,
const unsigned int length);
124 void comment(
const XMLCh *
const data,
const unsigned int length);
141 for(
unsigned int i = 0;
i < attributes.getLength();
i++) {
142 const XMLCh *
name = attributes.getQName(
i);
143 const XMLCh *
value = attributes.getValue(
i);
145 dom->setAttribute(name, value);
152 const char *
end = len >= 0 ? (data + len) : 0;
153 while(*data && (!end || data < end)) {
154 std::size_t len = std::strcspn(data,
"\r\n");
155 if (end && data + len > end)
157 if (data[len] ==
'\r' && data[len + 1] ==
'\n')
167 const XMLCh *
const localname,
168 const XMLCh *
const qname,
174 if (name !=
"LesHouchesEvents")
176 <<
"LHE file has invalid header" << std::endl;
189 <<
"LHE file has invalid format" << std::endl;
191 if (name ==
"header") {
193 impl = DOMImplementationRegistry::getDOMImplementation(
199 }
if (name ==
"init")
201 else if (name ==
"event")
206 <<
"LHE file has invalid format" << std::endl;
212 const XMLCh *
const localname,
213 const XMLCh *
const qname)
216 if (
mode == kHeader && xmlNodes.size() > 1) {
217 xmlNodes.resize(xmlNodes.size() - 1);
219 }
else if (
mode == kHeader) {
220 std::auto_ptr<DOMWriter> writer(
221 static_cast<DOMImplementationLS*>(
222 impl)->createDOMWriter());
225 for(DOMNode *
node = xmlNodes[0]->getFirstChild();
228 writer->writeToString(*
node));
234 switch(
node->getNodeType()) {
235 case DOMNode::ELEMENT_NODE:
236 elem =
static_cast<DOMElement*
>(
node);
239 p = std::strchr((
const char*)buffer,
241 q = std::strrchr(p,
'<');
243 case DOMNode::COMMENT_NODE:
246 q = buffer + strlen(buffer) - 3;
251 std::strspn(buffer,
" \t\r\n");
259 headers.push_back(header);
262 xmlHeader->release();
266 if (gotObject !=
kNone)
268 <<
"Unexpected pileup in"
269 " LHEReader::XMLHandler::endElement"
278 const unsigned int length)
280 if (
mode == kHeader) {
281 DOMText *
text = xmlHeader->createTextNode(data_);
282 xmlNodes.back()->appendChild(text);
297 <<
"LHE file has invalid format" << std::endl;
303 const unsigned int length)
305 if (
mode == kHeader) {
306 DOMComment *
comment = xmlHeader->createComment(data_);
307 xmlNodes.back()->appendChild(comment);
315 headers.push_back(header);
319 fileURLs(params.getUntrackedParameter< std::vector<std::
string> >(
"fileNames")),
321 firstEvent(params.getUntrackedParameter<unsigned int>(
"skipEvents", 0)),
322 maxEvents(params.getUntrackedParameter<int>(
"limitEvents", -1)),
329 fileURLs(fileNames), strName(
""), firstEvent(firstEvent),
maxEvents(-1),
336 strName(inputs), firstEvent(firstEvent),
maxEvents(-1),
354 if ( newFileOpened !=
nullptr ) *newFileOpened =
true;
367 std::istringstream
data;
387 std::for_each(
handler->headers.begin(),
400 <<
"Got LHE event without"
401 " initialization." << std::endl;
409 return boost::shared_ptr<LHEEvent>();
413 return boost::shared_ptr<LHEEvent>(
418 return boost::shared_ptr<LHEEvent>();
LHEReader(const edm::ParameterSet ¶ms)
static void logFileAction(char const *msg, std::string const &fileName)
static void fillHeader(LHERunInfo::Header &header, const char *data, int len=-1)
StringSource(const std::string &inputs)
Storage * open(const std::string &url, int mode=IOFlags::OpenRead)
void startElement(const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname, const Attributes &attributes)
const std::vector< std::string > fileURLs
static bool isSpace(XMLCh ch)
std::vector< LHERunInfo::Header > headers
static StorageFactory * get(void)
boost::shared_ptr< LHERunInfo > curRunInfo
void addHeader(const Header &header)
std::auto_ptr< XMLHandler > handler
static bool isAllSpaces(const XMLCh *str, unsigned int length)
const std::string strName
unsigned int offset(bool)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
void endElement(const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname)
std::vector< DOMElement * > xmlNodes
boost::shared_ptr< LHEEvent > next(bool *newFileOpened=nullptr)
void characters(const XMLCh *const data, const unsigned int length)
std::auto_ptr< XMLDocument > curDoc
std::auto_ptr< StorageWrap > fileStream
char data[epos_bytes_allocation]
virtual XMLDocument * createReader(XMLDocument::Handler &handler)=0
void comment(const XMLCh *const data, const unsigned int length)
std::auto_ptr< Source > curSource
std::auto_ptr< std::istream > fileStream
FileSource(const std::string &fileURL)
XMLDocument * createReader(XMLDocument::Handler &handler)
static void attributesToDom(DOMElement *dom, const Attributes &attributes)
XMLDocument * createReader(XMLDocument::Handler &handler)