|
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 307 of file TreeAccessor.cxx.
311 if (filterList.
size() == 0) {
312 cout <<
"No filter categories specified, done! (?)" << endl;
313 return std::vector<TreeAccessor*>();
316 for (
unsigned int f = 0;
f < filterList.
size();
f++) {
317 cout <<
"Skimming to " << filterList.
fileName(
f) << endl;
318 if (!gSystem->AccessPathName(filterList.
fileName(
f))) {
319 cout <<
"File already exists, exiting." << endl;
320 return std::vector<TreeAccessor*>();
324 std::vector<TreeAccessor*> newAccessors;
325 for (
unsigned int f = 0;
f < filterList.
size();
f++)
327 std::map<std::pair<unsigned int, unsigned int>,
unsigned int> eventIndices;
328 std::vector< std::map<unsigned int, unsigned int> > eventsToKeep(filterList.
size());
329 std::vector< std::map<unsigned int, unsigned int> > runsToKeep(filterList.
size());
331 double nTot = 0, nPass = 0;
333 for (
unsigned int i = 0;
i <
accessor.nEvents();
i++) {
338 for (
unsigned int i = 0;
i <
accessor.nChannels();
i++) {
339 if (
i % 25000 == 0) {
340 cout <<
"Filtering " <<
i <<
"/" <<
accessor.nChannels()
341 <<
" (passing so far = " << nPass <<
", total seen = " << nTot <<
")" << endl;
346 const History* history =
nullptr;
347 for (
unsigned int f = 0;
f < filterList.
size();
f++) {
351 for (
unsigned int f = 0;
f < filterList.
size();
f++) {
360 for (
unsigned int k = 0;
k < history->
nData();
k++) {
363 std::map<std::pair<unsigned int, unsigned int>,
unsigned int>::const_iterator findIndex =
365 if (findIndex == eventIndices.end()) {
366 cout <<
"Inconsistent event numbering!!!" << endl;
368 return std::vector<TreeAccessor*>();
370 int oldEvtIndex = findIndex->second;
371 bool isNewEvt = (eventsToKeep[
f].find(oldEvtIndex) == eventsToKeep[
f].end());
372 unsigned int newEvtIndex = (isNewEvt ? eventsToKeep[
f].size() : eventsToKeep[
f][oldEvtIndex]);
373 if (isNewEvt) eventsToKeep[
f][oldEvtIndex] = newEvtIndex;
376 bool isNewRun = (runsToKeep[
f].find(oldRunIndex) == runsToKeep[
f].end());
377 unsigned int newRunIndex = (isNewRun ? runsToKeep[
f].size() : runsToKeep[
f][oldRunIndex]);
378 if (isNewRun) runsToKeep[
f][oldRunIndex] = newRunIndex;
382 cout <<
"Filtering failed on data " <<
k <<
" of cell " <<
i <<
", aborting" << endl;
384 for (
unsigned int f = 0;
f < filterList.
size();
f++)
delete newAccessors[
f];
385 return std::vector<TreeAccessor*>();
395 for (
unsigned int f = 0;
f < filterList.
size();
f++) {
396 cout <<
"Adding runs..." << endl;
397 std::vector<unsigned int> runsToKeep_ordered(runsToKeep[
f].
size());
398 for (
const auto& runIndex : runsToKeep[
f])
399 runsToKeep_ordered[runIndex.second] = runIndex.first;
401 for (
unsigned int runIndex : runsToKeep_ordered) {
403 newAccessors[
f]->addRun(newRun);
406 cout <<
"Adding events..." << endl;
407 std::vector<unsigned int> eventsToKeep_ordered(eventsToKeep[
f].
size());
411 for (
unsigned int eventIndex : eventsToKeep_ordered) {
412 std::map<unsigned int, unsigned int>::const_iterator
idx = runsToKeep[
f].find(
accessor.eventData(
eventIndex)->runIndex());
413 int newRunIndex = (
idx == runsToKeep[
f].end() ? 0 :
idx->second);
415 newAccessors[
f]->addEvent(newEvent);
419 cout <<
"Filtering done! final size = " << nPass << endl;
421 for (
unsigned int f = 0;
f < filterList.
size();
f++) {
422 cout <<
"Saving " << newAccessors[
f]->fileName() << endl;
423 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 429 of file TreeAccessor.cxx.
433 std::vector<short> samples(5, 0);
434 std::vector<float> autoCorrs(4, 0);
437 newAccessor->
addRun(dummyRun);
444 for (
unsigned int i = 0;
i <
accessor.nChannels();
i++) {
446 cout <<
"Templating " <<
i <<
"/" <<
accessor.nChannels() << endl;
448 if (!history || !history->
cellInfo()) {
◆ merge() [1/4]
Definition at line 165 of file TreeAccessor.cxx.
171 std::vector<unsigned int> LBList;
172 std::ifstream
infile(LBFile.Data());
178 if(
list->GetEntries() == 0){
179 printf(
"No LB filtering specified, or bad format. Exiting.\n");
184 for(
int k = 0;
k <
list->GetEntries();
k++){
185 TObjString* tobs = (TObjString*)(
list->At(
k));
186 LBList.push_back((
unsigned int)(tobs->String()).Atoi());
189 printf(
"LB List: %d\n",(
int)LBList.size());
194 unsigned int size = 0;
197 int evtIndex = 0, runIndex = 0;
198 std::map<std::pair<int, int>,
int> evtMap;
199 std::map<int, int> runMap;
201 cout <<
"Merging runs" << endl;
204 cout <<
"Cannot merge: one of the inputs is null!" << endl;
208 for (
unsigned int i = 0;
i <
accessor->nRuns();
i++) {
210 if (runMap.find(
run) != runMap.end())
continue;
211 runMap[
run] = runIndex;
219 cout <<
"Merging events" << endl;
220 unsigned int nEventsTotal = 0, iEvt = 0;
222 nEventsTotal +=
accessor->nEvents();
224 for (
unsigned int i = 0;
i <
accessor->nEvents();
i++) {
226 if (iEvt % 100000 == 0) cout <<
"Merging event " << iEvt <<
"/" << nEventsTotal << endl;
231 for(
unsigned int ilb = 0 ;
ilb < LBList.size() ;
ilb++){
232 if(LBList.at(
ilb)==
accessor->eventData(
i)->lumiBlock()){
241 std::pair<int, int> evtId(
accessor->eventData(
i)->run(),
accessor->eventData(
i)->event());
242 if (evtMap.find(evtId) != evtMap.end())
continue;
243 evtMap[evtId] = evtIndex;
244 std::map<int, int>::const_iterator
idx = runMap.find(
accessor->eventData(
i)->run());
245 int newRunIndex = (
idx == runMap.end() ? -999 :
idx->second);
253 for (
unsigned int i = 0;
i < newAcc->
nChannels();
i++) {
254 if (
i % 10000 == 0) {
255 cout <<
"Merging channel " <<
i <<
"/" << newAcc->
nChannels() <<
" (current size = " <<
size <<
")" << endl;
261 if (!history || !history->
isValid())
continue;
266 for (
unsigned int j = 0; j < history->
nData(); j++) {
268 std::map<std::pair<int, int>,
int>::const_iterator newIndex
269 = evtMap.find(std::make_pair(history->
data(j)->
run(), history->
data(j)->
event()));
271 newDC->
setEventIndex(newIndex != evtMap.end() ? newIndex->second : -1);
276 cout <<
"Shape not filled for hash = " <<
i <<
", index = " << j <<
", gain = " <<
Data::gainStr(history->
data(j)->
gain()) << endl;
290 cout <<
"Merging done, final size = " <<
size << endl;
◆ merge() [2/4]
Definition at line 75 of file TreeAccessor.cxx.
78 cout <<
"Merging to " <<
fileName << endl;
80 unsigned int size = 0;
83 int evtIndex = 0, runIndex = 0;
84 std::map<std::pair<int, int>,
int> evtMap;
85 std::map<int, int> runMap;
87 cout <<
"Merging runs" << endl;
90 cout <<
"Cannot merge: one of the inputs is null!" << endl;
94 for (
unsigned int i = 0;
i <
accessor->nRuns();
i++) {
96 if (runMap.find(
run) != runMap.end())
continue;
97 runMap[
run] = runIndex;
105 cout <<
"Merging events" << endl;
106 unsigned int nEventsTotal = 0, iEvt = 0;
108 nEventsTotal +=
accessor->nEvents();
110 for (
unsigned int i = 0;
i <
accessor->nEvents();
i++) {
112 if (iEvt % 100000 == 0) cout <<
"Merging event " << iEvt <<
"/" << nEventsTotal << endl;
113 std::pair<int, int> evtId(
accessor->eventData(
i)->run(),
accessor->eventData(
i)->event());
114 if (evtMap.find(evtId) != evtMap.end())
continue;
115 evtMap[evtId] = evtIndex;
116 std::map<int, int>::const_iterator
idx = runMap.find(
accessor->eventData(
i)->run());
117 int newRunIndex = (
idx == runMap.end() ? -999 :
idx->second);
126 for (
unsigned int i = 0;
i < newAcc->
nChannels();
i++) {
127 if (
i % 10000 == 0) {
128 cout <<
"Merging channel " <<
i <<
"/" << newAcc->
nChannels() <<
" (current size = " <<
size <<
")" << endl;
134 if (!history || !history->
isValid())
continue;
139 for (
unsigned int j = 0; j < history->
nData(); j++) {
141 std::map<std::pair<int, int>,
int>::const_iterator newIndex
142 = evtMap.find(std::make_pair(history->
data(j)->
run(), history->
data(j)->
event()));
143 if (newIndex == evtMap.end()) cout <<
"Event not found for cell " <<
i <<
", data " << j <<
"." << endl;
144 newDC->
setEventIndex(newIndex != evtMap.end() ? newIndex->second : -1);
149 cout <<
"Shape not filled for hash = " <<
i <<
", index = " << j <<
", gain = " <<
Data::gainStr(history->
data(j)->
gain()) << endl;
159 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 465 of file TreeAccessor.cxx.
467 TFile* newFile =
new TFile(
fileName,
"RECREATE");
468 if (newFile && !newFile->IsOpen()) {
delete newFile; newFile =
nullptr; }
469 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
TGraphErrors * GetEntries(TH2F *histo)
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)
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