1 #include <boost/regex.hpp>
4 #include "TTreeCache.h"
15 #define private public
23 m_name(name), m_file(0), m_eventTree(0), m_event(0),
24 m_needUpdate(
true), m_globalEventList(0)
32 delete (*i)->m_eventList;
39 gErrorIgnoreLevel = 3000;
40 TFile *newFile = TFile::Open(
m_name.c_str());
41 if (newFile == 0 || newFile->IsZombie() || !newFile->Get(
"Events")) {
44 throw std::runtime_error(
"Invalid file. Ignored.");
46 gErrorIgnoreLevel = -1;
53 throw std::runtime_error(
"Cannot find TTree 'Events' in the data file");
59 typedef std::vector<edm::ProcessConfiguration> provList;
61 TTree *metaData =
dynamic_cast<TTree*
>(
m_file->Get(
"MetaData"));
62 TBranch *
b = metaData->GetBranch(
"ProcessConfiguration");
66 char rel[4] = { 0, 0, 0, 0 };
67 for (provList::iterator
i = x->begin();
i != x->end(); ++
i)
70 if (
i->releaseVersion().size() > 11)
72 rel[0] =
i->releaseVersion()[7];
73 rel[1] =
i->releaseVersion()[9];
74 rel[2] =
i->releaseVersion()[11];
75 int relInt = atoi(rel);
88 throw std::runtime_error(
"Incompatible data file. Process with version CMSSW_4_2_X or more required.\nUse --no-version-check option is want to still view the file.\n");
104 printf(
"Reading %lld bytes in %d transactions.\n",
152 Long64_t val = tree_entry;
167 Long64_t val = tree_entry;
169 if (list[idx] == val)
182 if ((*it)->m_selector->m_enabled)
202 if ((*it)->m_selector->m_enabled && (*it)->m_needsUpdate)
208 if ((*it)->m_selector->m_enabled)
210 if ((*it)->hasSelectedEvents())
259 boost::regex re(std::string(
"\\$") + (*i)->name());
265 interpretedSelection = boost::regex_replace(interpretedSelection, re,
266 fullBranchName +
".obj");
280 TObjArray* branches =
m_eventTree->GetListOfBranches();
281 std::vector<void*> previousBranchAddresses;
282 previousBranchAddresses.reserve(branches->GetEntriesFast());
284 std::auto_ptr<TIterator> pIt( branches->MakeIterator());
285 while(TObject* branchObj = pIt->Next()) {
286 TBranch*
b =
dynamic_cast<TBranch*
> (branchObj);
288 const char *
name = b->GetName();
289 unsigned int length = strlen(name);
290 if(length > 1 && name[length-1]!=
'.') {
292 previousBranchAddresses.push_back(0);
296 if(0!=b->GetAddress()) {
299 previousBranchAddresses.push_back(b->GetAddress());
301 previousBranchAddresses.push_back(0);
310 Int_t
result =
m_eventTree->Draw(
">>fworks_filter", interpretedSelection.c_str());
326 std::auto_ptr<TIterator> pIt( branches->MakeIterator());
327 std::vector<void*>::const_iterator itAddress = previousBranchAddresses.begin();
328 while(TObject* branchObj = pIt->Next()) {
329 TBranch*
b =
dynamic_cast<TBranch*
> (branchObj);
330 if(0!=b && 0!=*itAddress) {
331 b->SetAddress(*itAddress);
347 boost::regex re_spaces(
"\\s+");
348 selection = boost::regex_replace(selection,re_spaces,
"");
349 if (selection.find(
"&&") != std::string::npos &&
350 selection.find(
"||") != std::string::npos )
374 bool junction_mode =
true;
375 if (selection.find(
"||")!=std::string::npos)
376 junction_mode =
false;
378 boost::regex re(
"\\&\\&|\\|\\|");
380 boost::sregex_token_iterator
i(selection.begin(), selection.end(), re, -1);
381 boost::sregex_token_iterator
j;
384 std::vector<std::pair<unsigned int,bool> >
filters;
390 if (filter[0] ==
'!')
393 filter.erase(filter.begin());
396 if (index == triggerNames->
size())
401 filters.push_back(std::make_pair(index, flag));
419 std::vector<std::pair<unsigned int,bool> >::const_iterator
filter = filters.begin();
420 bool passed = hTriggerResults->
accept(filter->first) == filter->second;
421 while (++filter != filters.end())
424 passed &= hTriggerResults->
accept(filter->first) == filter->second;
426 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)
Strings::size_type size() const
const std::string & processName() const
virtual const std::string getBranchNameFor(const std::type_info &, const char *iModuleLabel, const char *iProductInstanceLabel, const char *iProcessName) const
Return the branch name in the TFile which contains the data.
bool isEventSelected(int event)
void getByLabel(const P &iP, const char *iModuleLabel, const char *iProductInstanceLabel=0, const char *iProcessLabel=0)
const std::string & productInstanceLabel() const
std::list< Filter * > m_filterEntries
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::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 filter
USE THIS FOR SKIMMED TRACKS process.p = cms.Path(process.hltLevel1GTSeed*process.skimming*process.offlineBeamSpot*process.TrackRefitter2) OTHERWISE USE THIS.
void runFilter(Filter *fe, const FWEventItemsManager *eiMng)
int nextSelectedEvent(int event)
const edm::EventBase * m_event
const Event & toBegin()
Go to the very first Event.
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