9 #include <boost/bind.hpp>
11 #include <xercesc/sax2/Attributes.hpp>
12 #include <xercesc/dom/DOM.hpp>
27 XERCES_CPP_NAMESPACE_USE
48 <<
"Could not open LHE file \""
49 << fileURL <<
"\" for reading"
84 const XMLCh *
const localname,
85 const XMLCh *
const qname,
89 const XMLCh *
const localname,
90 const XMLCh *
const qname);
92 void characters(
const XMLCh *
const data,
const unsigned int length);
93 void comment(
const XMLCh *
const data,
const unsigned int length);
110 for(
unsigned int i = 0;
i < attributes.getLength();
i++) {
111 const XMLCh *
name = attributes.getQName(
i);
112 const XMLCh *
value = attributes.getValue(
i);
114 dom->setAttribute(name, value);
121 const char *
end = len >= 0 ? (data + len) : 0;
122 while(*data && (!end || data < end)) {
123 std::size_t len = std::strcspn(data,
"\r\n");
124 if (end && data + len > end)
126 if (data[len] ==
'\r' && data[len + 1] ==
'\n')
130 header.
addLine(std::string(data, len));
136 const XMLCh *
const localname,
137 const XMLCh *
const qname,
143 if (name !=
"LesHouchesEvents")
145 <<
"LHE file has invalid header" << std::endl;
151 DOMElement *elem =
xmlHeader->createElement(qname);
158 <<
"LHE file has invalid format" << std::endl;
160 if (name ==
"header") {
162 impl = DOMImplementationRegistry::getDOMImplementation(
168 }
if (name ==
"init")
170 else if (name ==
"event")
175 <<
"LHE file has invalid format" << std::endl;
181 const XMLCh *
const localname,
182 const XMLCh *
const qname)
185 if (
mode == kHeader && xmlNodes.size() > 1) {
186 xmlNodes.resize(xmlNodes.size() - 1);
188 }
else if (
mode == kHeader) {
189 std::auto_ptr<DOMWriter> writer(
190 static_cast<DOMImplementationLS*>(
191 impl)->createDOMWriter());
194 for(DOMNode *
node = xmlNodes[0]->getFirstChild();
197 writer->writeToString(*
node));
203 switch(
node->getNodeType()) {
204 case DOMNode::ELEMENT_NODE:
205 elem =
static_cast<DOMElement*
>(
node);
208 p = std::strchr((
const char*)buffer,
210 q = std::strrchr(p,
'<');
212 case DOMNode::COMMENT_NODE:
215 q = buffer + strlen(buffer) - 3;
220 std::strspn(buffer,
" \t\r\n");
228 headers.push_back(header);
231 xmlHeader->release();
235 if (gotObject !=
kNone)
237 <<
"Unexpected pileup in"
238 " LHEReader::XMLHandler::endElement"
247 const unsigned int length)
249 if (
mode == kHeader) {
250 DOMText *
text = xmlHeader->createTextNode(data_);
251 xmlNodes.back()->appendChild(text);
266 <<
"LHE file has invalid format" << std::endl;
272 const unsigned int length)
274 if (
mode == kHeader) {
275 DOMComment *
comment = xmlHeader->createComment(data_);
276 xmlNodes.back()->appendChild(comment);
284 headers.push_back(header);
288 fileURLs(params.getUntrackedParameter< std::vector<std::string> >(
"fileNames")),
289 firstEvent(params.getUntrackedParameter<unsigned int>(
"skipEvents", 0)),
290 maxEvents(params.getUntrackedParameter<int>(
"limitEvents", -1)),
297 fileURLs(fileNames), firstEvent(firstEvent),
maxEvents(-1),
319 std::istringstream
data;
337 std::for_each(
handler->headers.begin(),
350 <<
"Got LHE event without"
351 " initialization." << std::endl;
359 return boost::shared_ptr<LHEEvent>();
363 return boost::shared_ptr<LHEEvent>(
368 return boost::shared_ptr<LHEEvent>();
LHEReader(const edm::ParameterSet ¶ms)
static void fillHeader(LHERunInfo::Header &header, const char *data, int len=-1)
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)
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
void characters(const XMLCh *const data, const unsigned int length)
std::auto_ptr< XMLDocument > curDoc
std::auto_ptr< StorageWrap > fileStream
virtual XMLDocument * createReader(XMLDocument::Handler &handler)=0
void comment(const XMLCh *const data, const unsigned int length)
std::auto_ptr< Source > curSource
FileSource(const std::string &fileURL)
XMLDocument * createReader(XMLDocument::Handler &handler)
boost::shared_ptr< LHEEvent > next()
static void attributesToDom(DOMElement *dom, const Attributes &attributes)