![Logo](../../ATLAS-Logo-Square-Blue-RGB.png) |
ATLAS Offline Software
|
#include <TreeAccessor.h>
|
static TreeAccessor * | open (const TString &fileName) |
|
static TreeAccessor * | merge (const std::vector< const Accessor * > &accessors, const TString &fileName="") |
|
static TreeAccessor * | merge (const std::vector< const Accessor * > &accessors, const TString &fileName, const TString &LBFile) |
|
static TreeAccessor * | filter (const Accessor &accessor, const FilterParams &filterParams, const TString &fileName, const DataTweaker &tweaker) |
|
static std::vector< TreeAccessor * > | filter (const Accessor &accessor, const FilterList &filterList, const DataTweaker &tweaker) |
|
static TreeAccessor * | makeTemplate (const Accessor &accessor, const TString &fileName) |
|
static PersistentAccessor * | merge (const std::vector< const PersistentAccessor * > &accessors, const TString &fileName) |
|
static PersistentAccessor * | merge (const std::vector< TString > &inputFiles, const TString &fileName) |
|
Definition at line 32 of file TreeAccessor.h.
◆ TreeAccessor() [1/2]
LArSamples::TreeAccessor::TreeAccessor |
( |
TTree & |
cellTree, |
|
|
TTree & |
eventTree, |
|
|
TTree * |
runTree, |
|
|
TFile * |
file |
|
) |
| |
|
inline |
◆ TreeAccessor() [2/2]
LArSamples::TreeAccessor::TreeAccessor |
( |
const TString & |
fileName | ) |
|
|
inline |
◆ ~TreeAccessor()
virtual LArSamples::TreeAccessor::~TreeAccessor |
( |
| ) |
|
|
inlinevirtual |
◆ add()
◆ addEvent()
void PersistentAccessor::addEvent |
( |
EventData * |
eventData | ) |
|
|
inherited |
◆ addRun()
void PersistentAccessor::addRun |
( |
RunData * |
runData | ) |
|
|
inherited |
◆ cachePos()
unsigned int LArSamples::AbsLArCells::cachePos |
( |
| ) |
const |
|
inlineinherited |
◆ cellCache()
◆ cellHistory()
const History * AbsLArCells::cellHistory |
( |
unsigned int |
i | ) |
const |
|
virtualinherited |
◆ cellInfo()
◆ cellInfoCache()
const CellInfo * AbsLArCells::cellInfoCache |
( |
unsigned int |
i | ) |
const |
|
inherited |
◆ cellTree()
const TTree& LArSamples::PersistentAccessor::cellTree |
( |
| ) |
const |
|
inlineinherited |
◆ currentContainer()
◆ eventData()
const EventData* LArSamples::TreeAccessor::eventData |
( |
unsigned int |
i | ) |
const |
|
inlinevirtual |
◆ eventTree()
const TTree& LArSamples::PersistentAccessor::eventTree |
( |
| ) |
const |
|
inlineinherited |
◆ file()
TFile* LArSamples::PersistentAccessor::file |
( |
| ) |
const |
|
inlineinherited |
◆ fileName()
TString PersistentAccessor::fileName |
( |
| ) |
const |
|
inherited |
◆ filter() [1/2]
Definition at line 303 of file TreeAccessor.cxx.
307 if (filterList.
size() == 0) {
308 cout <<
"No filter categories specified, done! (?)" << endl;
309 return std::vector<TreeAccessor*>();
312 for (
unsigned int f = 0;
f < filterList.
size();
f++) {
313 cout <<
"Skimming to " << filterList.
fileName(
f) << endl;
314 if (!gSystem->AccessPathName(filterList.
fileName(
f))) {
315 cout <<
"File already exists, exiting." << endl;
316 return std::vector<TreeAccessor*>();
320 std::vector<TreeAccessor*> newAccessors;
321 for (
unsigned int f = 0;
f < filterList.
size();
f++)
323 std::map<std::pair<unsigned int, unsigned int>,
unsigned int> eventIndices;
324 std::vector< std::map<unsigned int, unsigned int> > eventsToKeep(filterList.
size());
325 std::vector< std::map<unsigned int, unsigned int> > runsToKeep(filterList.
size());
327 double nTot = 0, nPass = 0;
329 for (
unsigned int i = 0;
i <
accessor.nEvents();
i++) {
334 for (
unsigned int i = 0;
i <
accessor.nChannels();
i++) {
335 if (
i % 25000 == 0) {
336 cout <<
"Filtering " <<
i <<
"/" <<
accessor.nChannels()
337 <<
" (passing so far = " << nPass <<
", total seen = " << nTot <<
")" << endl;
342 const History* history =
nullptr;
343 for (
unsigned int f = 0;
f < filterList.
size();
f++) {
347 for (
unsigned int f = 0;
f < filterList.
size();
f++) {
356 for (
unsigned int k = 0;
k < history->
nData();
k++) {
359 std::map<std::pair<unsigned int, unsigned int>,
unsigned int>::const_iterator findIndex =
361 if (findIndex == eventIndices.end()) {
362 cout <<
"Inconsistent event numbering!!!" << endl;
364 return std::vector<TreeAccessor*>();
366 int oldEvtIndex = findIndex->second;
367 bool isNewEvt = (eventsToKeep[
f].find(oldEvtIndex) == eventsToKeep[
f].end());
368 unsigned int newEvtIndex = (isNewEvt ? eventsToKeep[
f].size() : eventsToKeep[
f][oldEvtIndex]);
369 if (isNewEvt) eventsToKeep[
f][oldEvtIndex] = newEvtIndex;
372 bool isNewRun = (runsToKeep[
f].find(oldRunIndex) == runsToKeep[
f].end());
373 unsigned int newRunIndex = (isNewRun ? runsToKeep[
f].size() : runsToKeep[
f][oldRunIndex]);
374 if (isNewRun) runsToKeep[
f][oldRunIndex] = newRunIndex;
378 cout <<
"Filtering failed on data " <<
k <<
" of cell " <<
i <<
", aborting" << endl;
380 for (
unsigned int f = 0;
f < filterList.
size();
f++)
delete newAccessors[
f];
381 return std::vector<TreeAccessor*>();
391 for (
unsigned int f = 0;
f < filterList.
size();
f++) {
392 cout <<
"Adding runs..." << endl;
393 std::vector<unsigned int> runsToKeep_ordered(runsToKeep[
f].
size());
394 for (
const auto& runIndex : runsToKeep[
f])
395 runsToKeep_ordered[runIndex.second] = runIndex.first;
397 for (
unsigned int runIndex : runsToKeep_ordered) {
399 newAccessors[
f]->addRun(newRun);
402 cout <<
"Adding events..." << endl;
403 std::vector<unsigned int> eventsToKeep_ordered(eventsToKeep[
f].
size());
407 for (
unsigned int eventIndex : eventsToKeep_ordered) {
408 std::map<unsigned int, unsigned int>::const_iterator
idx = runsToKeep[
f].find(
accessor.eventData(
eventIndex)->runIndex());
409 int newRunIndex = (
idx == runsToKeep[
f].end() ? 0 :
idx->second);
411 newAccessors[
f]->addEvent(newEvent);
415 cout <<
"Filtering done! final size = " << nPass << endl;
417 for (
unsigned int f = 0;
f < filterList.
size();
f++) {
418 cout <<
"Saving " << newAccessors[
f]->fileName() << endl;
419 newAccessors[
f]->save();
◆ filter() [2/2]
◆ getCellEntry()
int LArSamples::PersistentAccessor::getCellEntry |
( |
unsigned int |
i | ) |
const |
|
inlineinherited |
◆ getCellHistory()
const History * TreeAccessor::getCellHistory |
( |
unsigned int |
i | ) |
const |
|
virtual |
◆ getCellInfo()
const CellInfo * TreeAccessor::getCellInfo |
( |
unsigned int |
i | ) |
const |
|
virtual |
◆ historyContainer()
◆ historySize()
unsigned int LArSamples::TreeAccessor::historySize |
( |
unsigned int |
i | ) |
const |
|
inlinevirtual |
◆ makeTemplate()
Definition at line 425 of file TreeAccessor.cxx.
429 std::vector<short>
samples(5, 0);
430 std::vector<float> autoCorrs(4, 0);
433 newAccessor->
addRun(dummyRun);
440 for (
unsigned int i = 0;
i <
accessor.nChannels();
i++) {
442 cout <<
"Templating " <<
i <<
"/" <<
accessor.nChannels() << endl;
444 if (!history || !history->
cellInfo()) {
◆ merge() [1/4]
Definition at line 162 of file TreeAccessor.cxx.
168 std::vector<unsigned int> LBList;
169 std::ifstream
infile(LBFile.Data());
175 if(
list->GetEntries() == 0){
176 printf(
"No LB filtering specified, or bad format. Exiting.\n");
181 for(
int k = 0;
k <
list->GetEntries();
k++){
182 TObjString* tobs = (TObjString*)(
list->At(
k));
183 LBList.push_back((
unsigned int)(tobs->String()).Atoi());
186 printf(
"LB List: %d\n",(
int)LBList.size());
191 unsigned int size = 0;
194 int evtIndex = 0, runIndex = 0;
195 std::map<std::pair<int, int>,
int> evtMap;
196 std::map<int, int> runMap;
198 cout <<
"Merging runs" << endl;
201 cout <<
"Cannot merge: one of the inputs is null!" << endl;
204 for (
unsigned int i = 0;
i <
accessor->nRuns();
i++) {
206 if (runMap.find(
run) != runMap.end())
continue;
207 runMap[
run] = runIndex;
215 cout <<
"Merging events" << endl;
216 unsigned int nEventsTotal = 0, iEvt = 0;
218 nEventsTotal +=
accessor->nEvents();
220 for (
unsigned int i = 0;
i <
accessor->nEvents();
i++) {
222 if (iEvt % 100000 == 0) cout <<
"Merging event " << iEvt <<
"/" << nEventsTotal << endl;
227 for(
unsigned int ilb = 0 ;
ilb < LBList.size() ;
ilb++){
228 if(LBList.at(
ilb)==
accessor->eventData(
i)->lumiBlock()){
237 std::pair<int, int> evtId(
accessor->eventData(
i)->run(),
accessor->eventData(
i)->event());
238 if (evtMap.find(evtId) != evtMap.end())
continue;
239 evtMap[evtId] = evtIndex;
240 std::map<int, int>::const_iterator
idx = runMap.find(
accessor->eventData(
i)->run());
241 int newRunIndex = (
idx == runMap.end() ? -999 :
idx->second);
249 for (
unsigned int i = 0;
i < newAcc->
nChannels();
i++) {
250 if (
i % 10000 == 0) {
251 cout <<
"Merging channel " <<
i <<
"/" << newAcc->
nChannels() <<
" (current size = " <<
size <<
")" << endl;
257 if (!history || !history->
isValid())
continue;
262 for (
unsigned int j = 0; j < history->
nData(); j++) {
264 std::map<std::pair<int, int>,
int>::const_iterator newIndex
265 = evtMap.find(std::make_pair(history->
data(j)->
run(), history->
data(j)->
event()));
267 newDC->
setEventIndex(newIndex != evtMap.end() ? newIndex->second : -1);
272 cout <<
"Shape not filled for hash = " <<
i <<
", index = " << j <<
", gain = " <<
Data::gainStr(history->
data(j)->
gain()) << endl;
286 cout <<
"Merging done, final size = " <<
size << endl;
◆ merge() [2/4]
Definition at line 73 of file TreeAccessor.cxx.
76 cout <<
"Merging to " <<
fileName << endl;
78 unsigned int size = 0;
81 int evtIndex = 0, runIndex = 0;
82 std::map<std::pair<int, int>,
int> evtMap;
83 std::map<int, int> runMap;
85 cout <<
"Merging runs" << endl;
88 cout <<
"Cannot merge: one of the inputs is null!" << endl;
91 for (
unsigned int i = 0;
i <
accessor->nRuns();
i++) {
93 if (runMap.find(
run) != runMap.end())
continue;
94 runMap[
run] = runIndex;
102 cout <<
"Merging events" << endl;
103 unsigned int nEventsTotal = 0, iEvt = 0;
105 nEventsTotal +=
accessor->nEvents();
107 for (
unsigned int i = 0;
i <
accessor->nEvents();
i++) {
109 if (iEvt % 100000 == 0) cout <<
"Merging event " << iEvt <<
"/" << nEventsTotal << endl;
110 std::pair<int, int> evtId(
accessor->eventData(
i)->run(),
accessor->eventData(
i)->event());
111 if (evtMap.find(evtId) != evtMap.end())
continue;
112 evtMap[evtId] = evtIndex;
113 std::map<int, int>::const_iterator
idx = runMap.find(
accessor->eventData(
i)->run());
114 int newRunIndex = (
idx == runMap.end() ? -999 :
idx->second);
123 for (
unsigned int i = 0;
i < newAcc->
nChannels();
i++) {
124 if (
i % 10000 == 0) {
125 cout <<
"Merging channel " <<
i <<
"/" << newAcc->
nChannels() <<
" (current size = " <<
size <<
")" << endl;
131 if (!history || !history->
isValid())
continue;
136 for (
unsigned int j = 0; j < history->
nData(); j++) {
138 std::map<std::pair<int, int>,
int>::const_iterator newIndex
139 = evtMap.find(std::make_pair(history->
data(j)->
run(), history->
data(j)->
event()));
140 if (newIndex == evtMap.end()) cout <<
"Event not found for cell " <<
i <<
", data " << j <<
"." << endl;
141 newDC->
setEventIndex(newIndex != evtMap.end() ? newIndex->second : -1);
146 cout <<
"Shape not filled for hash = " <<
i <<
", index = " << j <<
", gain = " <<
Data::gainStr(history->
data(j)->
gain()) << endl;
156 cout <<
"Merging done, final size = " <<
size << endl;
◆ merge() [3/4]
Definition at line 181 of file PersistentAccessor.cxx.
185 unsigned int size = 0;
188 int evtIndex = 0, runIndex = 0;
189 std::map<std::pair<int, int>,
int> evtMap;
190 std::map<int, int> runMap;
191 std::map< std::pair<const PersistentAccessor*, int>,
int > evtAccMap;
193 cout <<
"Merging runs" << endl;
196 cout <<
"Cannot merge: one of the inputs is null!" << endl;
200 for (
unsigned int i = 0;
i <
accessor->nRuns();
i++) {
202 if (runMap.find(
run) != runMap.end())
continue;
203 runMap[
run] = runIndex;
211 cout <<
"Merging events" << endl;
212 unsigned int nEventsTotal = 0, iEvt = 0;
214 nEventsTotal +=
accessor->nEvents();
217 for (
unsigned int i = 0;
i <
accessor->nEvents();
i++) {
219 if (iEvt % 100000 == 0) cout <<
"Merging event " << iEvt <<
"/" << nEventsTotal << endl;
220 std::pair<int, int> evtId(
accessor->eventData(
i)->run(),
accessor->eventData(
i)->event());
221 std::pair<const PersistentAccessor*, int> evtAccId(
accessor,
i);
222 if (evtMap.find(evtId) != evtMap.end()) {
223 cout <<
"ERROR: Skipping duplicate entry for run " <<
accessor->eventData(
i)->run() <<
", event " <<
accessor->eventData(
i)->event() << endl;
226 evtAccMap[evtAccId] = evtIndex;
227 evtMap[evtId] = evtIndex;
228 std::map<int, int>::const_iterator
idx = runMap.find(
accessor->eventData(
i)->run());
229 int newRunIndex = (
idx == runMap.end() ? -999 :
idx->second);
239 if (
i % 10000 == 0) {
246 if (!history || !history->
isValid())
continue;
253 std::map<std::pair<const PersistentAccessor*, int>,
int>::const_iterator newIndex
255 if (newIndex == evtAccMap.end()) cout <<
"Event not found for cell " <<
i <<
", data " << j <<
"." << endl;
256 newDC->
setEventIndex(newIndex != evtAccMap.end() ? newIndex->second : -1);
257 newHistory->
add(newDC);
261 cout <<
"Shape not filled for hash = " <<
i <<
", index = " << j <<
", gain = " << history->
dataContainer(j)->
gain() << endl;
267 newAcc->
add(newHistory);
271 cout <<
"Merging done, final size = " <<
size << endl;
◆ merge() [4/4]
◆ nChannels()
virtual unsigned int LArSamples::AbsLArCells::nChannels |
( |
| ) |
const |
|
inlinevirtualinherited |
◆ nEvents()
unsigned int LArSamples::TreeAccessor::nEvents |
( |
| ) |
const |
|
inlinevirtual |
◆ newCellHistory()
const History * AbsLArCells::newCellHistory |
( |
unsigned int |
i | ) |
const |
|
virtualinherited |
◆ nRuns()
unsigned int LArSamples::TreeAccessor::nRuns |
( |
| ) |
const |
|
inlinevirtual |
◆ open()
◆ pass()
◆ resetCache()
void AbsLArCells::resetCache |
( |
| ) |
const |
|
virtualinherited |
◆ resetCellInfoCache()
void AbsLArCells::resetCellInfoCache |
( |
| ) |
|
|
inherited |
◆ runData()
const RunData* LArSamples::TreeAccessor::runData |
( |
unsigned int |
i | ) |
const |
|
inlinevirtual |
◆ runTree()
const TTree& LArSamples::PersistentAccessor::runTree |
( |
| ) |
const |
|
inlineinherited |
◆ save()
bool PersistentAccessor::save |
( |
| ) |
const |
|
inherited |
Definition at line 165 of file PersistentAccessor.cxx.
169 cout <<
"Writing " <<
m_runTree->GetEntries() <<
" run(s)..." << endl;
171 cout <<
"Writing " <<
m_eventTree->GetEntries() <<
" event(s)..." << endl;
173 cout <<
"Writing " <<
m_cellTree->GetEntries() <<
" cell(s)..." << endl;
176 cout <<
"Writing done!" << endl;
◆ writeToFile()
bool TreeAccessor::writeToFile |
( |
const TString & |
fileName | ) |
const |
|
virtual |
Implements LArSamples::Accessor.
Definition at line 461 of file TreeAccessor.cxx.
463 TFile* newFile =
new TFile(
fileName,
"RECREATE");
464 if (newFile && !newFile->IsOpen()) {
delete newFile; newFile =
nullptr; }
465 if (!newFile)
return false;
◆ Interface
◆ m_cellCache
◆ m_cellInfoCache
std::vector<CellInfo*> LArSamples::AbsLArCells::m_cellInfoCache |
|
mutableprivateinherited |
◆ m_cellTree
TTree* LArSamples::PersistentAccessor::m_cellTree |
|
privateinherited |
◆ m_eventData
EventData* LArSamples::PersistentAccessor::m_eventData |
|
mutableprivateinherited |
◆ m_eventTree
TTree * LArSamples::PersistentAccessor::m_eventTree |
|
privateinherited |
◆ m_file
TFile* LArSamples::PersistentAccessor::m_file |
|
mutableprivateinherited |
◆ m_historyCont
◆ m_pos
unsigned int LArSamples::AbsLArCells::m_pos |
|
mutableprivateinherited |
◆ m_runCache
std::map<unsigned int, const RunData*> LArSamples::PersistentAccessor::m_runCache |
|
mutableprivateinherited |
◆ m_runData
RunData* LArSamples::PersistentAccessor::m_runData |
|
mutableprivateinherited |
◆ m_runTree
TTree * LArSamples::PersistentAccessor::m_runTree |
|
privateinherited |
The documentation for this class was generated from the following files:
JetConstituentVector::iterator iterator
bool passCell(const CellInfo &info) const
bool passEvent(const Data &data) const
const DataContainer & container() const
HistoryContainer * currentContainer() const
virtual const History * newCellHistory(unsigned int i) const
CaloGain::CaloGain gain() const
const CellInfo * cellInfo() const
virtual const History * cellHistory(unsigned int i) const
const RunData * runData(unsigned int i) const
A base class for accessing ntuple data.
const DataContainer * dataContainer(unsigned int i) const
std::vector< CellInfo * > m_cellInfoCache
const FilterParams & filterParams(unsigned int i) const
int run(int argc, char *argv[])
virtual const CellInfo * cellInfo(unsigned int i) const
const TTree & runTree() const
const EventData * eventData(unsigned int i) const
void addEvent(EventData *eventData)
void add(const FilterParams ¶ms, const TString &fileName)
void add(HistoryContainer *cont)
const Data * data(unsigned int i) const
PersistentAccessor(TTree &cellTree, TTree &eventTree, TTree *runTree, TFile *file)
Constructor
static const unsigned int nChannels
unsigned int nEvents() const
static TString gainStr(CaloGain::CaloGain gain)
virtual const CellInfo * getCellInfo(unsigned int i) const
const ShapeInfo * shape(CaloGain::CaloGain gain) const
unsigned int historySize(unsigned int i) const
InDet::SiSpacePointsSeedMakerEventData EventData
virtual const History * getCellHistory(unsigned int i) const =0
unsigned int nData() const
HistoryContainer * m_historyCont
const EventData * eventData(unsigned int i) const
static PersistentAccessor * open(const TString &fileName)
Data * tweak(const Data &data, int evtIndex=-1) const
int getCellEntry(unsigned int i) const
unsigned int nRuns() const
const TTree & cellTree() const
const CellInfo * cellInfoCache(unsigned int i) const
const TString & fileName(unsigned int i) const
const History * m_cellCache
TreeAccessor(TTree &cellTree, TTree &eventTree, TTree *runTree, TFile *file)
Constructor
const DataContainer * dissolve()
CaloGain::CaloGain gain() const
const AccessorWrapper< T > * accessor(xAOD::JetAttribute::AttributeID id)
Returns an attribute accessor corresponding to an AttributeID.
const CellInfo * cellInfo() const
static TreeAccessor * filter(const Accessor &accessor, const FilterParams &filterParams, const TString &fileName, const DataTweaker &tweaker)
void add(const DataContainer *data)
append data (takes ownership)
double GetEntries(TH1D *h, int ilow, int ihi)
const TTree & eventTree() const
virtual void resetCache() const
void addRun(RunData *runData)
void add(HistoryContainer *cont)
const HistoryContainer * historyContainer(unsigned int i) const
const EventData * eventData() const
unsigned int size() const
static PersistentAccessor * merge(const std::vector< const PersistentAccessor * > &accessors, const TString &fileName)
void setEventIndex(int index)
virtual unsigned int nChannels() const
unsigned int nDataContainers() const
thread_local event_number_t eventIndex