1 #include <boost/regex.hpp>
4 #include "TTreeCache.h"
5 #include "TEveTreeTools.h"
18 #define private public
28 m_name(name), m_file(0), m_eventTree(0), m_event(0),
29 m_needUpdate(
true), m_globalEventList(0)
37 delete (*i)->m_eventList;
44 gErrorIgnoreLevel = 3000;
45 TFile *newFile = TFile::Open(
m_name.c_str());
46 if (newFile == 0 || newFile->IsZombie() || !newFile->Get(
"Events")) {
49 throw std::runtime_error(
"Invalid file. Ignored.");
51 gErrorIgnoreLevel = -1;
57 typedef std::vector<edm::ProcessHistory> provList;
59 TTree *metaData =
dynamic_cast<TTree*
>(
m_file->Get(
"MetaData"));
60 TBranch *
b = metaData->GetBranch(
"ProcessHistory");
67 int currentVersionArr[] = {0, 0, 0};
68 for (
auto const& processHistory : *x)
75 int nvv = currentVersionArr[0]*100 + currentVersionArr[1]*10 + currentVersionArr[2];
76 if (nvv > latestVersion) {
91 TString
msg = Form(
"incompatible data: Process version does not mactch major data formats version. File produced with %s. Data formats version \"CMSSW_%d_%d_%d\".\n",
93 msg +=
"Use --no-version-check option if you still want to view the file.\n";
94 throw std::runtime_error(msg.Data());
98 TString
msg =
"No process history available\n";
99 msg +=
"Use --no-version-check option if you still want to view the file.\n";
100 throw std::runtime_error(msg.Data());
108 throw std::runtime_error(
"fwlite::Event size == 0");
115 throw std::runtime_error(
"Cannot find TTree 'Events' in the data file");
129 printf(
"Reading %lld bytes in %d transactions.\n",
179 Long64_t val = tree_entry;
194 Long64_t val = tree_entry;
196 if (list[idx] == val)
209 if ((*it)->m_selector->m_enabled)
229 if ((*it)->m_selector->m_enabled && (*it)->m_needsUpdate)
235 if ((*it)->m_selector->m_enabled)
237 if ((*it)->hasSelectedEvents())
287 boost::regex re(
std::string(
"\\$") + (*i)->name());
289 if (boost::regex_search(interpretedSelection, re))
298 interpretedSelection = boost::regex_replace(interpretedSelection, re,
299 fullBranchName +
".obj");
309 std::size_t
found = interpretedSelection.find(
'$');
310 if (found!=std::string::npos)
312 fwLog(
fwlog::kError) <<
"FWFileEntry::RunFilter invalid expression " << interpretedSelection << std::endl;
324 std::map<TBranch*, void*> prevAddrs;
327 TObjArray* branches =
m_eventTree->GetListOfBranches();
328 std::auto_ptr<TIterator> pIt( branches->MakeIterator());
329 while (TObject* branchObj = pIt->Next())
331 TBranch*
b =
dynamic_cast<TBranch*
> (branchObj);
334 const char *
name = b->GetName();
335 unsigned int length = strlen(name);
336 if (length > 1 && name[length-1] !=
'.')
341 if (0 != b->GetAddress())
343 if (prevAddrs.find(b) != prevAddrs.end())
347 prevAddrs.insert(std::make_pair(b, b->GetAddress()));
361 TEveSelectorToEventList stoelist(filter->
m_eventList, interpretedSelection.c_str());
371 for (
auto i : prevAddrs)
374 i.first->SetAddress(
i.second);
388 boost::regex re_spaces(
"\\s+");
389 selection = boost::regex_replace(selection,re_spaces,
"");
390 if (selection.find(
"&&") != std::string::npos &&
391 selection.find(
"||") != std::string::npos )
415 bool junction_mode =
true;
416 if (selection.find(
"||")!=std::string::npos)
417 junction_mode =
false;
419 boost::regex re(
"\\&\\&|\\|\\|");
421 boost::sregex_token_iterator
i(selection.begin(), selection.end(), re, -1);
422 boost::sregex_token_iterator
j;
425 std::vector<std::pair<unsigned int,bool> >
filters;
431 if (filter[0] ==
'!')
434 filter.erase(filter.begin());
437 if (index == triggerNames->
size())
442 filters.push_back(std::make_pair(index, flag));
460 std::vector<std::pair<unsigned int,bool> >::const_iterator
filter = filters.begin();
461 bool passed = hTriggerResults->
accept(filter->first) == filter->second;
462 while (++filter != filters.end())
465 passed &= hTriggerResults->
accept(filter->first) == filter->second;
467 passed |= hTriggerResults->
accept(filter->first) == filter->second;
FWEventSelector * m_selector
virtual void Enter(Long64_t entry)
virtual edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const
bool accept() const
Has at least one path accepted the event?
FWTEventList * m_eventList
void getPrimaryData() const
std::string m_triggerProcess
FWFileEntry(const std::string &name, bool checkVersion)
void getDecomposedVersion(const TString &s, int *out)
Strings::size_type size() const
const std::string & processName() const
virtual std::string const getBranchNameFor(std::type_info const &, char const *iModuleLabel, char const *iProductInstanceLabel, char const *iProcessName) const
Return the branch name in the TFile which contains the data.
Long64_t size() const
Returns number of events in the file.
bool isEventSelected(int event)
static TypeWithDict byName(std::string const &name)
std::string const & processName() const
void getByLabel(const P &iP, const char *iModuleLabel, const char *iProductInstanceLabel=0, const char *iProcessLabel=0)
Event const & toBegin()
Go to the very first Event.
const std::string & productInstanceLabel() const
std::list< Filter * > m_filterEntries
int * supportedDataFormatsVersion()
unsigned int triggerIndex(std::string const &name) const
virtual void Add(const TEventList *list)
const TClass * type() const
bool filterEventsWithCustomParser(Filter *filter)
bool to(Long64_t iIndex)
Go to the event at index iIndex.
std::type_info const & typeInfo() const
std::list< Filter * > & filters()
virtual bool atEnd() const
const_iterator begin() const
NOTE: iterator is allowed to return a null object for items that have been removed.
tuple idx
DEBUGGING if hasattr(process,"trackMonIterativeTracking2012"): print "trackMonIterativeTracking2012 D...
ReleaseVersion const & releaseVersion() const
std::string wrappedClassName(std::string const &iFullName)
void runFilter(Filter *fe, const FWEventItemsManager *eiMng)
int nextSelectedEvent(int event)
const edm::EventBase * m_event
bool acceptDataFormatsVersion(TString &n)
void updateFilters(const FWEventItemsManager *eiMng, bool isOR)
FWTEventList * m_globalEventList
int previousSelectedEvent(int event)
std::vector< FWEventItem * >::const_iterator const_iterator
const std::string & moduleLabel() const
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 list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run
const_iterator end() const