1 #include <boost/regex.hpp> 4 #include "TEveTreeTools.h" 28 #include <boost/bind.hpp> 42 delete (*i)->m_eventList;
50 TFile* newFile = TFile::Open(
m_name.c_str());
52 if (newFile ==
nullptr || newFile->IsZombie() || !newFile->Get(
"Events")) {
55 throw std::runtime_error(
"Invalid file. Ignored.");
64 typedef std::vector<edm::ProcessHistory> provList;
66 TTree* metaData =
dynamic_cast<TTree*
>(
m_file->Get(
"MetaData"));
67 TBranch*
b = metaData->GetBranch(
"ProcessHistory");
68 provList*
x =
nullptr;
73 int latestVersion = 0;
74 int currentVersionArr[] = {0, 0, 0};
75 for (
auto const& processHistory : *x) {
76 for (
auto const& processConfiguration : processHistory) {
78 TString dcv = processConfiguration.releaseVersion();
80 int nvv = currentVersionArr[0] * 100 + currentVersionArr[1] * 10 + currentVersionArr[2];
81 if (nvv > latestVersion) {
83 dd = &processConfiguration;
92 b->SetAddress(
nullptr);
97 "incompatible data: Process version does not mactch major data formats version. File produced with %s. " 98 "Data formats version \"CMSSW_%d_%d_%d\".\n",
103 msg +=
"Use --no-version-check option if you still want to view the file.\n";
104 throw std::runtime_error(msg.Data());
107 TString
msg =
"No process history available\n";
108 msg +=
"Use --no-version-check option if you still want to view the file.\n";
109 throw std::runtime_error(msg.Data());
115 if (m_eventTree ==
nullptr) {
116 throw std::runtime_error(
"Cannot find TTree 'Events' in the data file");
121 printf(
"FWFileEntry::openFile enabling FWTTreeCache for file class '%s'.",
m_file->ClassName());
124 m_file->SetCacheRead(tc, m_eventTree);
126 tc->SetLearnEntries(20);
127 tc->SetLearnPrefill(TTreeCache::kAllBranches);
128 tc->StartLearningPhase();
140 throw std::runtime_error(
"fwlite::Event size == 0");
145 printf(
"Reading %lld bytes in %d transactions.\n",
m_file->GetBytesRead(),
m_file->GetReadCalls());
185 Long64_t
val = tree_entry;
199 Long64_t
val = tree_entry;
201 if (list[idx] == val)
212 if ((*it)->m_selector->m_enabled)
230 if ((*it)->m_selector->m_enabled && (*it)->m_needsUpdate) {
235 if ((*it)->m_selector->m_enabled) {
236 if ((*it)->hasSelectedEvents()) {
242 }
else if (!globalOR) {
265 std::vector<std::string> branch_names;
278 boost::regex re(
std::string(
"\\$") + (*i)->name());
280 if (boost::regex_search(interpretedSelection, re)) {
288 interpretedSelection = boost::regex_replace(interpretedSelection, re, fullBranchName +
".obj");
290 branch_names.push_back(fullBranchName);
299 std::size_t
found = interpretedSelection.find(
'$');
300 if (found != std::string::npos) {
301 fwLog(
fwlog::kError) <<
"FWFileEntry::RunFilter invalid expression " << interpretedSelection << std::endl;
311 auto interCache =
new TTreeCache(
m_eventTree, 10 * 1024 * 1024);
315 for (
auto&
b : branch_names)
316 interCache->AddBranch(
b.c_str(),
true);
317 interCache->StopLearningPhase();
323 std::map<TBranch*, void*> prevAddrs;
326 TObjArray* branches =
m_eventTree->GetListOfBranches();
327 std::unique_ptr<TIterator> pIt(branches->MakeIterator());
328 while (TObject* branchObj = pIt->Next()) {
329 TBranch*
b =
dynamic_cast<TBranch*
>(branchObj);
331 const char*
name = b->GetName();
332 unsigned int length = strlen(name);
333 if (length > 1 && name[length - 1] !=
'.') {
337 if (
nullptr != b->GetAddress()) {
338 if (prevAddrs.find(b) != prevAddrs.end()) {
341 prevAddrs.insert(std::make_pair(b, b->GetAddress()));
344 b->SetAddress(
nullptr);
355 fwLog(
fwlog::kInfo) <<
"FWFileEntry::runFilter Running filter " << interpretedSelection <<
"' " 356 <<
"for file '" <<
m_file->GetName() <<
"'.\n";
358 TEveSelectorToEventList stoelist(filter->
m_eventList, interpretedSelection.c_str());
367 <<
"] events selected" << std::endl;
371 for (
auto i : prevAddrs) {
373 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 && selection.find(
"||") != std::string::npos) {
411 bool junction_mode =
true;
412 if (selection.find(
"||") != std::string::npos)
413 junction_mode =
false;
415 boost::regex re(
"\\&\\&|\\|\\|");
417 boost::sregex_token_iterator
i(selection.begin(), selection.end(), re, -1);
418 boost::sregex_token_iterator
j;
421 std::vector<std::pair<unsigned int, bool> >
filters;
426 if (filter[0] ==
'!') {
428 filter.erase(filter.begin());
431 if (index == triggerNames->
size()) {
435 filters.push_back(std::make_pair(index, flag));
452 std::vector<std::pair<unsigned int, bool> >::const_iterator
filter = filters.begin();
453 bool passed = hTriggerResults->
accept(filter->first) == filter->second;
454 while (++filter != filters.end()) {
456 passed &= hTriggerResults->
accept(filter->first) == filter->second;
458 passed |= hTriggerResults->
accept(filter->first) == filter->second;
478 assert(tc !=
nullptr &&
"FWFileEntry::treeCache can not access TTreeCache");
493 printf(
"FWFileEntry:NewEventItemCallIn FWEventItem %s, learning=%d\n",
getBranchName(it).c_str(), tc->IsLearning());
502 printf(
"FWFileEntry:RemovingEventItemCallIn FWEventItem %s, learning=%d\n",
fireworks::Context * getContext()
FWEventSelector * m_selector
Event const & toBegin() override
Go to the very first Event.
const FWEventItemsManager * eventItemsManager() const
void setEvent(const edm::EventBase *iEvent)
void RemovingEventItemCallIn(const FWEventItem *it)
bool accept() const
Has at least one path accepted the event?
std::string getBranchName(const FWEventItem *it) const
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
std::string const getBranchNameFor(std::type_info const &, char const *iModuleLabel, char const *iProductInstanceLabel, char const *iProcessName) const override
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)
bool atEnd() const override
const std::string & productInstanceLabel() const
std::list< Filter * > m_filterEntries
int * supportedDataFormatsVersion()
unsigned int triggerIndex(std::string const &name) const
const TClass * type() const
static bool IsPrefetching()
sigc::signal< void, FWEventItem * > newItem_
bool filterEventsWithCustomParser(Filter *filter)
bool to(Long64_t iIndex)
Go to the event at index iIndex.
edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const override
std::type_info const & typeInfo() const
std::list< Filter * > & filters()
static int GetDefaultCacheSize()
const_iterator begin() const
NOTE: iterator is allowed to return a null object for items that have been removed.
static FWGUIManager * getGUIManager()
ReleaseVersion const & releaseVersion() const
std::string wrappedClassName(std::string const &iFullName)
void runFilter(Filter *fe, const FWEventItemsManager *eiMng)
int nextSelectedEvent(int event)
bool acceptDataFormatsVersion(TString &n)
void updateFilters(const FWEventItemsManager *eiMng, bool isOR)
FWTTreeCache * fwTreeCache()
void Enter(Long64_t entry) override
FWTEventList * m_globalEventList
int previousSelectedEvent(int event)
void Add(const TEventList *list) override
std::vector< FWEventItem * >::const_iterator const_iterator
void NewEventItemCallIn(const FWEventItem *it)
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