1 #include <boost/regex.hpp>
4 #include "TTreeCache.h"
13 #define private public
21 m_name(name), m_file(0), m_eventTree(0), m_event(0),
22 m_needUpdate(
true), m_globalEventList(0)
30 delete (*i)->m_eventList;
37 gErrorIgnoreLevel = 3000;
38 TFile *newFile = TFile::Open(
m_name.c_str());
39 if (newFile == 0 || newFile->IsZombie() || !newFile->Get(
"Events")) {
42 throw std::runtime_error(
"Invalid file. Ignored.");
44 gErrorIgnoreLevel = -1;
51 throw std::runtime_error(
"Cannot find TTree 'Events' in the data file");
65 printf(
"Reading %lld bytes in %d transactions.\n",
113 Long64_t val = tree_entry;
128 Long64_t val = tree_entry;
130 if (list[idx] == val)
143 if ((*it)->m_selector->m_enabled)
163 if ((*it)->m_selector->m_enabled && (*it)->m_needsUpdate)
169 if ((*it)->m_selector->m_enabled)
171 if ((*it)->hasSelectedEvents())
220 boost::regex re(std::string(
"\\$") + (*i)->name());
226 interpretedSelection = boost::regex_replace(interpretedSelection, re,
227 fullBranchName +
".obj");
241 TObjArray* branches =
m_eventTree->GetListOfBranches();
242 std::vector<void*> previousBranchAddresses;
243 previousBranchAddresses.reserve(branches->GetEntriesFast());
245 std::auto_ptr<TIterator> pIt( branches->MakeIterator());
246 while(TObject* branchObj = pIt->Next()) {
247 TBranch*
b =
dynamic_cast<TBranch*
> (branchObj);
249 const char *
name = b->GetName();
250 unsigned int length = strlen(name);
251 if(length > 1 && name[length-1]!=
'.') {
253 previousBranchAddresses.push_back(0);
257 if(0!=b->GetAddress()) {
260 previousBranchAddresses.push_back(b->GetAddress());
262 previousBranchAddresses.push_back(0);
271 Int_t
result =
m_eventTree->Draw(
">>fworks_filter", interpretedSelection.c_str());
287 std::auto_ptr<TIterator> pIt( branches->MakeIterator());
288 std::vector<void*>::const_iterator itAddress = previousBranchAddresses.begin();
289 while(TObject* branchObj = pIt->Next()) {
290 TBranch*
b =
dynamic_cast<TBranch*
> (branchObj);
291 if(0!=b && 0!=*itAddress) {
292 b->SetAddress(*itAddress);
308 boost::regex re_spaces(
"\\s+");
309 selection = boost::regex_replace(selection,re_spaces,
"");
310 if (selection.find(
"&&") != std::string::npos &&
311 selection.find(
"||") != std::string::npos )
335 bool junction_mode =
true;
336 if (selection.find(
"||")!=std::string::npos)
337 junction_mode =
false;
339 boost::regex re(
"\\&\\&|\\|\\|");
341 boost::sregex_token_iterator
i(selection.begin(), selection.end(), re, -1);
342 boost::sregex_token_iterator
j;
345 std::vector<std::pair<unsigned int,bool> >
filters;
351 if (filter[0] ==
'!')
354 filter.erase(filter.begin());
357 if (index == triggerNames->
size())
362 filters.push_back(std::make_pair(index, flag));
380 std::vector<std::pair<unsigned int,bool> >::const_iterator
filter = filters.begin();
381 bool passed = hTriggerResults->
accept(filter->first) == filter->second;
382 while (++filter != filters.end())
385 passed &= hTriggerResults->
accept(filter->first) == filter->second;
387 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
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)
FWFileEntry(const std::string &name)
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