Loading [MathJax]/extensions/tex2jax.js
 |
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 & |
scTree, |
|
|
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 |
◆ addSC()
◆ 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()
◆ currentContainerSC()
◆ 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 324 of file TreeAccessor.cxx.
328 if (filterList.
size() == 0) {
329 cout <<
"No filter categories specified, done! (?)" << endl;
330 return std::vector<TreeAccessor*>();
333 for (
unsigned int f = 0;
f < filterList.
size();
f++) {
334 cout <<
"Skimming to " << filterList.
fileName(
f) << endl;
335 if (!gSystem->AccessPathName(filterList.
fileName(
f))) {
336 cout <<
"File already exists, exiting." << endl;
337 return std::vector<TreeAccessor*>();
341 std::vector<TreeAccessor*> newAccessors;
342 for (
unsigned int f = 0;
f < filterList.
size();
f++)
344 std::map<std::pair<unsigned int, unsigned int>,
unsigned int> eventIndices;
345 std::vector< std::map<unsigned int, unsigned int> > eventsToKeep(filterList.
size());
346 std::vector< std::map<unsigned int, unsigned int> > runsToKeep(filterList.
size());
348 double nTot = 0, nPass = 0;
350 for (
unsigned int i = 0;
i <
accessor.nEvents();
i++) {
355 for (
unsigned int i = 0;
i <
accessor.nChannels();
i++) {
356 if (
i % 25000 == 0) {
357 cout <<
"Filtering " <<
i <<
"/" <<
accessor.nChannels()
358 <<
" (passing so far = " << nPass <<
", total seen = " << nTot <<
")" << endl;
363 const History* history =
nullptr;
364 for (
unsigned int f = 0;
f < filterList.
size();
f++) {
368 for (
unsigned int f = 0;
f < filterList.
size();
f++) {
377 for (
unsigned int k = 0;
k < history->
nData();
k++) {
380 std::map<std::pair<unsigned int, unsigned int>,
unsigned int>::const_iterator findIndex =
382 if (findIndex == eventIndices.end()) {
383 cout <<
"Inconsistent event numbering!!!" << endl;
385 return std::vector<TreeAccessor*>();
387 int oldEvtIndex = findIndex->second;
388 bool isNewEvt = (eventsToKeep[
f].find(oldEvtIndex) == eventsToKeep[
f].end());
389 unsigned int newEvtIndex = (isNewEvt ? eventsToKeep[
f].size() : eventsToKeep[
f][oldEvtIndex]);
390 if (isNewEvt) eventsToKeep[
f][oldEvtIndex] = newEvtIndex;
393 bool isNewRun = (runsToKeep[
f].find(oldRunIndex) == runsToKeep[
f].end());
394 unsigned int newRunIndex = (isNewRun ? runsToKeep[
f].size() : runsToKeep[
f][oldRunIndex]);
395 if (isNewRun) runsToKeep[
f][oldRunIndex] = newRunIndex;
399 cout <<
"Filtering failed on data " <<
k <<
" of cell " <<
i <<
", aborting" << endl;
401 for (
unsigned int f = 0;
f < filterList.
size();
f++)
delete newAccessors[
f];
402 return std::vector<TreeAccessor*>();
412 for (
unsigned int f = 0;
f < filterList.
size();
f++) {
413 cout <<
"Adding runs..." << endl;
414 std::vector<unsigned int> runsToKeep_ordered(runsToKeep[
f].
size());
415 for (
const auto& runIndex : runsToKeep[
f])
416 runsToKeep_ordered[runIndex.second] = runIndex.first;
418 for (
unsigned int runIndex : runsToKeep_ordered) {
420 newAccessors[
f]->addRun(newRun);
423 cout <<
"Adding events..." << endl;
424 std::vector<unsigned int> eventsToKeep_ordered(eventsToKeep[
f].
size());
428 for (
unsigned int eventIndex : eventsToKeep_ordered) {
429 std::map<unsigned int, unsigned int>::const_iterator
idx = runsToKeep[
f].find(
accessor.eventData(
eventIndex)->runIndex());
430 int newRunIndex = (
idx == runsToKeep[
f].end() ? 0 :
idx->second);
432 newAccessors[
f]->addEvent(newEvent);
436 cout <<
"Filtering done! final size = " << nPass << endl;
438 for (
unsigned int f = 0;
f < filterList.
size();
f++) {
439 cout <<
"Saving " << newAccessors[
f]->fileName() << endl;
440 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 |
◆ getSCEntry()
int LArSamples::PersistentAccessor::getSCEntry |
( |
unsigned int |
i | ) |
const |
|
inlineinherited |
◆ getSCHistory()
const History * TreeAccessor::getSCHistory |
( |
unsigned int |
i | ) |
const |
Definition at line 77 of file TreeAccessor.cxx.
82 std::vector<const EventData*> eventDatas;
87 eventDatas.push_back(newEvtData);
◆ getSCInfo()
◆ historyContainer()
◆ historyContainerSC()
◆ historySize()
unsigned int LArSamples::TreeAccessor::historySize |
( |
unsigned int |
i | ) |
const |
|
inlinevirtual |
◆ historySizeSC()
unsigned int LArSamples::TreeAccessor::historySizeSC |
( |
unsigned int |
i | ) |
const |
|
inlinevirtual |
◆ makeTemplate()
Definition at line 446 of file TreeAccessor.cxx.
450 std::vector<short> samples(5, 0);
451 std::vector<float> autoCorrs(4, 0);
454 newAccessor->
addRun(dummyRun);
461 for (
unsigned int i = 0;
i <
accessor.nChannels();
i++) {
463 cout <<
"Templating " <<
i <<
"/" <<
accessor.nChannels() << endl;
465 if (!history || !history->
cellInfo()) {
◆ merge() [1/4]
Definition at line 182 of file TreeAccessor.cxx.
188 std::vector<unsigned int> LBList;
189 std::ifstream
infile(LBFile.Data());
195 if(
list->GetEntries() == 0){
196 printf(
"No LB filtering specified, or bad format. Exiting.\n");
201 for(
int k = 0;
k <
list->GetEntries();
k++){
202 TObjString* tobs = (TObjString*)(
list->At(
k));
203 LBList.push_back((
unsigned int)(tobs->String()).Atoi());
206 printf(
"LB List: %d\n",(
int)LBList.size());
211 unsigned int size = 0;
214 int evtIndex = 0, runIndex = 0;
215 std::map<std::pair<int, int>,
int> evtMap;
216 std::map<int, int> runMap;
218 cout <<
"Merging runs" << endl;
221 cout <<
"Cannot merge: one of the inputs is null!" << endl;
225 for (
unsigned int i = 0;
i <
accessor->nRuns();
i++) {
227 if (runMap.find(
run) != runMap.end())
continue;
228 runMap[
run] = runIndex;
236 cout <<
"Merging events" << endl;
237 unsigned int nEventsTotal = 0, iEvt = 0;
239 nEventsTotal +=
accessor->nEvents();
241 for (
unsigned int i = 0;
i <
accessor->nEvents();
i++) {
243 if (iEvt % 100000 == 0) cout <<
"Merging event " << iEvt <<
"/" << nEventsTotal << endl;
248 for(
unsigned int ilb = 0 ;
ilb < LBList.size() ;
ilb++){
249 if(LBList.at(
ilb)==
accessor->eventData(
i)->lumiBlock()){
258 std::pair<int, int> evtId(
accessor->eventData(
i)->run(),
accessor->eventData(
i)->event());
259 if (evtMap.find(evtId) != evtMap.end())
continue;
260 evtMap[evtId] = evtIndex;
261 std::map<int, int>::const_iterator
idx = runMap.find(
accessor->eventData(
i)->run());
262 int newRunIndex = (
idx == runMap.end() ? -999 :
idx->second);
270 for (
unsigned int i = 0;
i < newAcc->
nChannels();
i++) {
271 if (
i % 10000 == 0) {
272 cout <<
"Merging channel " <<
i <<
"/" << newAcc->
nChannels() <<
" (current size = " <<
size <<
")" << endl;
278 if (!history || !history->
isValid())
continue;
283 for (
unsigned int j = 0; j < history->
nData(); j++) {
285 std::map<std::pair<int, int>,
int>::const_iterator newIndex
286 = evtMap.find(std::make_pair(history->
data(j)->
run(), history->
data(j)->
event()));
288 newDC->
setEventIndex(newIndex != evtMap.end() ? newIndex->second : -1);
293 cout <<
"Shape not filled for hash = " <<
i <<
", index = " << j <<
", gain = " <<
Data::gainStr(history->
data(j)->
gain()) << endl;
307 cout <<
"Merging done, final size = " <<
size << endl;
◆ merge() [2/4]
Definition at line 92 of file TreeAccessor.cxx.
95 cout <<
"Merging to " <<
fileName << endl;
97 unsigned int size = 0;
100 int evtIndex = 0, runIndex = 0;
101 std::map<std::pair<int, int>,
int> evtMap;
102 std::map<int, int> runMap;
104 cout <<
"Merging runs" << endl;
107 cout <<
"Cannot merge: one of the inputs is null!" << endl;
111 for (
unsigned int i = 0;
i <
accessor->nRuns();
i++) {
113 if (runMap.find(
run) != runMap.end())
continue;
114 runMap[
run] = runIndex;
122 cout <<
"Merging events" << endl;
123 unsigned int nEventsTotal = 0, iEvt = 0;
125 nEventsTotal +=
accessor->nEvents();
127 for (
unsigned int i = 0;
i <
accessor->nEvents();
i++) {
129 if (iEvt % 100000 == 0) cout <<
"Merging event " << iEvt <<
"/" << nEventsTotal << endl;
130 std::pair<int, int> evtId(
accessor->eventData(
i)->run(),
accessor->eventData(
i)->event());
131 if (evtMap.find(evtId) != evtMap.end())
continue;
132 evtMap[evtId] = evtIndex;
133 std::map<int, int>::const_iterator
idx = runMap.find(
accessor->eventData(
i)->run());
134 int newRunIndex = (
idx == runMap.end() ? -999 :
idx->second);
143 for (
unsigned int i = 0;
i < newAcc->
nChannels();
i++) {
144 if (
i % 10000 == 0) {
145 cout <<
"Merging channel " <<
i <<
"/" << newAcc->
nChannels() <<
" (current size = " <<
size <<
")" << endl;
151 if (!history || !history->
isValid())
continue;
156 for (
unsigned int j = 0; j < history->
nData(); j++) {
158 std::map<std::pair<int, int>,
int>::const_iterator newIndex
159 = evtMap.find(std::make_pair(history->
data(j)->
run(), history->
data(j)->
event()));
160 if (newIndex == evtMap.end()) cout <<
"Event not found for cell " <<
i <<
", data " << j <<
"." << endl;
161 newDC->
setEventIndex(newIndex != evtMap.end() ? newIndex->second : -1);
166 cout <<
"Shape not filled for hash = " <<
i <<
", index = " << j <<
", gain = " <<
Data::gainStr(history->
data(j)->
gain()) << endl;
176 cout <<
"Merging done, final size = " <<
size << endl;
◆ merge() [3/4]
Definition at line 209 of file PersistentAccessor.cxx.
213 unsigned int size = 0;
216 int evtIndex = 0, runIndex = 0;
217 std::map<std::pair<int, int>,
int> evtMap;
218 std::map<int, int> runMap;
219 std::map< std::pair<const PersistentAccessor*, int>,
int > evtAccMap;
221 cout <<
"Merging runs" << endl;
224 cout <<
"Cannot merge: one of the inputs is null!" << endl;
228 for (
unsigned int i = 0;
i <
accessor->nRuns();
i++) {
230 if (runMap.find(
run) != runMap.end())
continue;
231 runMap[
run] = runIndex;
239 cout <<
"Merging events" << endl;
240 unsigned int nEventsTotal = 0, iEvt = 0;
242 nEventsTotal +=
accessor->nEvents();
245 for (
unsigned int i = 0;
i <
accessor->nEvents();
i++) {
247 if (iEvt % 100000 == 0) cout <<
"Merging event " << iEvt <<
"/" << nEventsTotal << endl;
248 std::pair<int, int> evtId(
accessor->eventData(
i)->run(),
accessor->eventData(
i)->event());
249 std::pair<const PersistentAccessor*, int> evtAccId(
accessor,
i);
250 if (evtMap.find(evtId) != evtMap.end()) {
251 cout <<
"ERROR: Skipping duplicate entry for run " <<
accessor->eventData(
i)->run() <<
", event " <<
accessor->eventData(
i)->event() << endl;
254 evtAccMap[evtAccId] = evtIndex;
255 evtMap[evtId] = evtIndex;
256 std::map<int, int>::const_iterator
idx = runMap.find(
accessor->eventData(
i)->run());
257 int newRunIndex = (
idx == runMap.end() ? -999 :
idx->second);
267 cout <<
"Merging cells" << endl;
269 if (
i % 10000 == 0) {
276 if (!history || !history->
isValid())
continue;
283 std::map<std::pair<const PersistentAccessor*, int>,
int>::const_iterator newIndex
285 if (newIndex == evtAccMap.end()) cout <<
"Event not found for cell " <<
i <<
", data " << j <<
"." << endl;
286 newDC->
setEventIndex(newIndex != evtAccMap.end() ? newIndex->second : -1);
287 newHistory->
add(newDC);
297 newAcc->
add(newHistory);
302 cout <<
"Merging SC" << endl;
304 if (
i % 10000 == 0) {
311 if (!history || !history->
isValid())
continue;
318 std::map<std::pair<const PersistentAccessor*, int>,
int>::const_iterator newIndex
320 if (newIndex == evtAccMap.end()) cout <<
"Event not found for cell " <<
i <<
", data " << j <<
"." << endl;
321 newDC->
setEventIndex(newIndex != evtAccMap.end() ? newIndex->second : -1);
322 newHistory->
add(newDC);
332 newAcc->
addSC(newHistory);
336 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()
Definition at line 30 of file TreeAccessor.cxx.
33 if (!
file)
return nullptr;
34 if (!
file->IsOpen()) {
delete file;
return nullptr; }
37 TTree* scTree = (TTree*)
file->Get(
"SC");
38 if (!scTree)
return nullptr;
◆ 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 191 of file PersistentAccessor.cxx.
195 cout <<
"Writing " <<
m_runTree->GetEntries() <<
" run(s)..." << endl;
197 cout <<
"Writing " <<
m_eventTree->GetEntries() <<
" event(s)..." << endl;
199 cout <<
"Writing " <<
m_cellTree->GetEntries() <<
" cell(s)..." << endl;
201 cout <<
"Writing " <<
m_SCTree->GetEntries() <<
" SC(s)..." << endl;
204 cout <<
"Writing done!" << endl;
◆ SCTree()
const TTree& LArSamples::PersistentAccessor::SCTree |
( |
| ) |
const |
|
inlineinherited |
◆ writeToFile()
bool TreeAccessor::writeToFile |
( |
const TString & |
fileName | ) |
const |
|
virtual |
Implements LArSamples::Accessor.
Definition at line 482 of file TreeAccessor.cxx.
484 TFile* newFile =
new TFile(
fileName,
"RECREATE");
485 if (newFile && !newFile->IsOpen()) {
delete newFile; newFile =
nullptr; }
486 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_historyContSC
◆ 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 |
◆ m_SCTree
TTree * LArSamples::PersistentAccessor::m_SCTree |
|
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)
const TTree & SCTree() const
void add(HistoryContainer *cont)
HistoryContainer * m_historyContSC
const Data * data(unsigned int i) const
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 historySizeSC(unsigned int i) 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
const DataContainer * dissolve()
CaloGain::CaloGain gain() const
const HistoryContainer * historyContainerSC(unsigned int i) 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)
HistoryContainer * currentContainerSC() const
static const unsigned int nChannelsSC
void add(const DataContainer *data)
append data (takes ownership)
int getSCEntry(unsigned int i) const
void addSC(HistoryContainer *cont)
const TTree & eventTree() const
virtual void resetCache() const
TreeAccessor(TTree &cellTree, TTree &scTree, TTree &eventTree, TTree *runTree, TFile *file)
Constructor
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)
PersistentAccessor(TTree &cellTree, TTree &SCTree, TTree &eventTree, TTree *runTree, TFile *file)
Constructor
void setEventIndex(int index)
virtual unsigned int nChannels() const
unsigned int nDataContainers() const
thread_local event_number_t eventIndex