1 #include <boost/regex.hpp> 4 #include "TEveTreeTools.h" 33 #include <boost/bind.hpp> 41 m_globalTag(
"gt_undef"),
48 delete (*i)->m_eventList;
56 TFile* newFile = TFile::Open(
m_name.c_str());
58 if (newFile ==
nullptr || newFile->IsZombie() || !newFile->Get(
"Events")) {
61 throw std::runtime_error(
"Invalid file. Ignored.");
69 typedef std::vector<edm::ProcessHistory> provList;
71 TTree* metaData =
dynamic_cast<TTree*
>(
m_file->Get(
"MetaData"));
72 TBranch*
b = metaData->GetBranch(
"ProcessHistory");
75 metaData->SetBranchAddress(
"ProcessHistory", &pPhv);
79 typedef std::map<edm::ParameterSetID, edm::ParameterSetBlob>
ParameterSetMap;
81 TTree* psetTree =
dynamic_cast<TTree*
>(newFile->Get(
"ParameterSets"));
82 typedef std::pair<edm::ParameterSetID, edm::ParameterSetBlob> IdToBlobs;
84 IdToBlobs* pIdToBlob = &idToBlob;
85 psetTree->SetBranchAddress(
"IdToParameterSetsBlobs", &pIdToBlob);
86 for (
long long i = 0;
i != psetTree->GetEntries(); ++
i) {
87 psetTree->GetEntry(
i);
88 psm_.insert(idToBlob);
92 for (
auto const&
item : psm_) {
99 int latestVersion = 0;
100 int currentVersionArr[] = {0, 0, 0};
101 for (
auto const& processHistory : phv_) {
102 for (
auto const& processConfiguration : processHistory) {
104 TString dcv = processConfiguration.releaseVersion();
106 int nvv = currentVersionArr[0] * 100 + currentVersionArr[1] * 10 + currentVersionArr[2];
107 if (nvv > latestVersion) {
109 dd = &processConfiguration;
115 if (checkGlobalTag) {
116 std::map<edm::ProcessConfigurationID, unsigned int> simpleIDs;
118 for (
auto const& ph : phv_) {
119 for (
auto const& pc : ph) {
120 unsigned int id = simpleIDs[pc.id()];
123 simpleIDs[pc.id()] =
id;
125 ParameterSetMap::const_iterator itFind = psm_.find(pc.parameterSetID());
126 if (itFind == psm_.end()) {
127 std::cout <<
"No ParameterSetID for " << pc.parameterSetID() << std::endl;
128 fwLog(
fwlog::kInfo) <<
"FWFileEntry::openFile no ParameterSetID for " << pc.parameterSetID() << std::endl;
131 std::vector<std::string> sourceStrings, moduleStrings;
132 std::vector<std::string>
sources = processConfig.getParameter<std::vector<std::string>>(
"@all_essources");
133 for (
auto& itM : sources) {
139 if (name !=
"GlobalTag")
142 for (
auto const&
item : pset.
tbl()) {
143 if (
item.first ==
"globaltag") {
163 b->SetAddress(
nullptr);
168 "incompatible data: Process version does not mactch major data formats version. File produced with %s. " 169 "Data formats version \"CMSSW_%d_%d_%d\".\n",
174 msg +=
"Use --no-version-check option if you still want to view the file.\n";
175 throw std::runtime_error(msg.Data());
178 TString
msg =
"No process history available\n";
179 msg +=
"Use --no-version-check option if you still want to view the file.\n";
180 throw std::runtime_error(msg.Data());
186 if (m_eventTree ==
nullptr) {
187 throw std::runtime_error(
"Cannot find TTree 'Events' in the data file");
192 printf(
"FWFileEntry::openFile enabling FWTTreeCache for file class '%s'.",
m_file->ClassName());
195 m_file->SetCacheRead(tc, m_eventTree);
197 tc->SetLearnEntries(20);
198 tc->SetLearnPrefill(TTreeCache::kAllBranches);
199 tc->StartLearningPhase();
211 throw std::runtime_error(
"fwlite::Event size == 0");
216 printf(
"Reading %lld bytes in %d transactions.\n",
m_file->GetBytesRead(),
m_file->GetReadCalls());
256 Long64_t
val = tree_entry;
270 Long64_t
val = tree_entry;
272 if (list[idx] == val)
283 if ((*it)->m_selector->m_enabled)
301 if ((*it)->m_selector->m_enabled && (*it)->m_needsUpdate) {
306 if ((*it)->m_selector->m_enabled) {
307 if ((*it)->hasSelectedEvents()) {
313 }
else if (!globalOR) {
336 std::vector<std::string> branch_names;
349 boost::regex re(
std::string(
"\\$") + (*i)->name());
351 if (boost::regex_search(interpretedSelection, re)) {
359 interpretedSelection = boost::regex_replace(interpretedSelection, re, fullBranchName +
".obj");
361 branch_names.push_back(fullBranchName);
370 std::size_t
found = interpretedSelection.find(
'$');
371 if (found != std::string::npos) {
372 fwLog(
fwlog::kError) <<
"FWFileEntry::RunFilter invalid expression " << interpretedSelection << std::endl;
382 auto interCache =
new TTreeCache(
m_eventTree, 10 * 1024 * 1024);
386 for (
auto&
b : branch_names)
387 interCache->AddBranch(
b.c_str(),
true);
388 interCache->StopLearningPhase();
394 std::map<TBranch*, void*> prevAddrs;
397 TObjArray* branches =
m_eventTree->GetListOfBranches();
398 std::unique_ptr<TIterator> pIt(branches->MakeIterator());
399 while (TObject* branchObj = pIt->Next()) {
400 TBranch*
b =
dynamic_cast<TBranch*
>(branchObj);
402 const char*
name = b->GetName();
403 unsigned int length = strlen(name);
404 if (length > 1 && name[length - 1] !=
'.') {
408 if (
nullptr != b->GetAddress()) {
409 if (prevAddrs.find(b) != prevAddrs.end()) {
412 prevAddrs.insert(std::make_pair(b, b->GetAddress()));
415 b->SetAddress(
nullptr);
426 fwLog(
fwlog::kInfo) <<
"FWFileEntry::runFilter Running filter " << interpretedSelection <<
"' " 427 <<
"for file '" <<
m_file->GetName() <<
"'.\n";
429 TEveSelectorToEventList stoelist(filter->
m_eventList, interpretedSelection.c_str());
438 <<
"] events selected" << std::endl;
442 for (
auto i : prevAddrs) {
444 i.first->SetAddress(
i.second);
459 boost::regex re_spaces(
"\\s+");
460 selection = boost::regex_replace(selection, re_spaces,
"");
461 if (selection.find(
"&&") != std::string::npos && selection.find(
"||") != std::string::npos) {
482 bool junction_mode =
true;
483 if (selection.find(
"||") != std::string::npos)
484 junction_mode =
false;
486 boost::regex re(
"\\&\\&|\\|\\|");
488 boost::sregex_token_iterator
i(selection.begin(), selection.end(), re, -1);
489 boost::sregex_token_iterator
j;
492 std::vector<std::pair<unsigned int, bool>>
filters;
497 if (filter[0] ==
'!') {
499 filter.erase(filter.begin());
502 if (index == triggerNames->
size()) {
506 filters.push_back(std::make_pair(index, flag));
523 std::vector<std::pair<unsigned int, bool>>::const_iterator
filter = filters.begin();
524 bool passed = hTriggerResults->
accept(filter->first) == filter->second;
525 while (++filter != filters.end()) {
527 passed &= hTriggerResults->
accept(filter->first) == filter->second;
529 passed |= hTriggerResults->
accept(filter->first) == filter->second;
549 assert(tc !=
nullptr &&
"FWFileEntry::treeCache can not access TTreeCache");
564 printf(
"FWFileEntry:NewEventItemCallIn FWEventItem %s, learning=%d\n",
getBranchName(it).c_str(), tc->IsLearning());
573 printf(
"FWFileEntry:RemovingEventItemCallIn FWEventItem %s, learning=%d\n",
std::vector< ProcessHistory > ProcessHistoryVector
T getParameter(std::string const &) const
fireworks::Context * getContext()
FWEventSelector * m_selector
Event const & toBegin() override
Go to the very first Event.
FWFileEntry(const std::string &name, bool checkVersion, bool checkGlobalTag)
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
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
bool insertMapped(value_type const &v, bool forceUpdate=false)
std::type_info const & typeInfo() const
std::list< Filter * > & filters()
static int GetDefaultCacheSize()
void openFile(bool, bool)
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)
std::map< ParameterSetID, ParameterSetBlob > ParameterSetMap
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
table const & tbl() const
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
static Registry * instance()
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