34 std::vector<std::unique_ptr<const TreeAccessor> > accessors;
35 for (
const TString& fileName :
files) {
38 cout <<
"Skipping invalid file " << fileName << endl;
41 accessors.push_back(std::move(
accessor));
44 if (accessors.empty())
return nullptr;
45 return std::make_unique<MultiTreeAccessor>(std::move(accessors));
51 std::ifstream f(fileList);
53 cout <<
"file " << fileList <<
" not accessible" << endl;
60 std::vector<std::unique_ptr<const TreeAccessor> > accessors;
62 while (f >> fileName) {
65 cout <<
"Skipping invalid file " << fileName << endl;
68 cout << std::setw(2) << ++i <<
" - " << fileName << endl;
69 accessors.push_back(std::move(
accessor));
72 if (accessors.empty())
return nullptr;
73 return std::make_unique<MultiTreeAccessor>(std::move(accessors));
83 std::vector<std::unique_ptr<const TreeAccessor> > accessors;
85 for (
int i = 0; i < chain.GetListOfFiles()->
GetEntries(); i++) {
86 std::string fileName = chain.GetListOfFiles()->At(i)->GetTitle();
89 cout <<
"Skipping invalid file " << fileName << endl;
92 cout << std::setw(2) << i+1 <<
" - " << fileName <<
" , nEvents = " <<
accessor->nEvents() <<
", nRuns = " <<
accessor->nRuns() << endl;
93 accessors.push_back(std::move(
accessor));
96 if (accessors.empty())
return nullptr;
97 return std::make_unique<MultiTreeAccessor>(std::move(accessors));
108 unsigned int nEventsSoFar = 0;
110 unsigned int n =
accessor->nEvents();
111 if (i < nEventsSoFar + n)
return accessor->eventData(i - nEventsSoFar);
120 unsigned int nRunsSoFar = 0;
123 if (i < nRunsSoFar + n)
return accessor->runData(i - nRunsSoFar);
151 unsigned int size = 0;
162 unsigned int size = 0;
174 std::vector<const Data*> allData;
175 std::vector<const EventData*> allEventData;
177 std::unique_ptr<const History> thisHistory (
accessor->getCellHistory(i));
178 if (!thisHistory)
continue;
180 cellInfo = std::make_unique<CellInfo>(*thisHistory->cellInfo());
182 const std::vector<const EventData*>& thisEventData = thisHistory->eventData();
183 std::map<const EventData*, const EventData*> eventMap;
184 for (
const EventData* event : thisEventData) {
185 if (eventMap.find(event) != eventMap.end())
continue;
187 eventMap[event] = newED;
188 allEventData.push_back(newED);
191 for (
unsigned int j = 0; j < thisHistory->nData(); j++) {
192 allData.push_back(
new Data(*thisHistory->data(j), eventMap[thisHistory->data(j)->eventData()],
nullptr, -1));
193 if (!
cellInfo->shape(thisHistory->data(j)->gain())) {
194 const ShapeInfo* thisShape = thisHistory->cellInfo()->shape(thisHistory->data(j)->gain());
195 cellInfo->setShape(thisHistory->data(j)->gain(), thisShape ?
new ShapeInfo(*thisShape) :
nullptr);
207 std::vector<const Data*> allData;
208 std::vector<const EventData*> allEventData;
211 std::unique_ptr<const History> thisHistory (
accessor->getSCHistory(i));
213 if (!thisHistory)
continue;
215 cellInfo = std::make_unique<CellInfo>(*thisHistory->cellInfo());
219 const std::vector<const EventData*>& thisEventData = thisHistory->eventData();
220 std::map<const EventData*, const EventData*> eventMap;
221 for (
const EventData* event : thisEventData) {
222 if (eventMap.find(event) != eventMap.end())
continue;
223 auto newED = std::make_unique<EventData>(*event);
224 eventMap[event] = newED.get();
225 allEventData.push_back(newED.release());
229 for (
unsigned int ii = 0; ii < thisHistory->nData(); ii++) {
231 allData.push_back(
new Data(*thisHistory->data(ii), eventMap[thisHistory->data(ii)->eventData()],
nullptr, -1));
233 if (!
cellInfo->shape(thisHistory->data(ii)->gain())) {
234 const ShapeInfo* thisShape = thisHistory->cellInfo()->shape(thisHistory->data(ii)->gain());
235 cellInfo->setShape(thisHistory->data(ii)->gain(), thisShape ?
new ShapeInfo(*thisShape) :
nullptr);
259 std::vector<const Accessor*> accessors;
260 for (
unsigned int i = 0; i <
m_accessors.size(); i++)
262 cout <<
"Merging data..." << endl;
264 return !!singleContainer;
270 std::vector< std::vector<std::unique_ptr<const TreeAccessor> > > filteredAccessors(filterList.
size());
272 for (
unsigned int i = 0; i <
nAccessors(); i++) {
274 cout <<
"Processing data " << i <<
" of " <<
nAccessors();
275 if (treeAcc) cout <<
" (fileName = " << treeAcc->
fileName() <<
")";
279 for (
unsigned int f = 0; f < filterList.
size(); f++) {
280 std::string pathname = (string)filterList.
fileName(f);
281 if( pathname.find(
"eos/atlas/") < pathname.length() ){
282 int nslashes = 0, slpos = 0;
283 for(
int k1 = 0; k1 < (int)pathname.length(); k1++ ){
284 if( nslashes > 2 )
break;
285 if( pathname[k1] !=
'/' )
continue;
289 pathname.resize( slpos );
291 TString thisFN = Form(
"%s_filter%d.root", pathname.c_str(), i );
295 if (filteredTreeAccs.size() != filterList.
size()) {
296 cout <<
"Filtering failed, exiting" << endl;
297 return std::vector<MultiTreeAccessor*>();
299 for (
unsigned int f = 0; f < filteredTreeAccs.size(); f++) filteredAccessors[f].push_back(std::move(filteredTreeAccs[f]));
302 std::vector<MultiTreeAccessor*>
result;
303 for (
unsigned int f = 0; f < filteredAccessors.size(); f++)
result.push_back(
new MultiTreeAccessor(std::move(filteredAccessors[f])));
TGraphErrors * GetEntries(TH2F *histo)
virtual void resetCache() const
virtual const CellInfo * cellInfo(unsigned int i) const
void add(const FilterParams ¶ms, const TString &fileName)
unsigned int size() const
const FilterParams & filterParams(unsigned int i) const
const TString & fileName(unsigned int i) const
const CellInfo * cellInfo() const
unsigned int nDataContainers() const
unsigned int nEvents() const
unsigned int historySize(unsigned int i) const
const History * getSCHistory(unsigned int i) const
MultiTreeAccessor(std::vector< std::unique_ptr< const TreeAccessor > > &&accessors)
Constructor.
const EventData * eventData(unsigned int i) const
unsigned int historySizeSC(unsigned int i) const
std::vector< MultiTreeAccessor * > filterComponents(const FilterList &filterList, const DataTweaker &tweaker) const
unsigned int nRuns() const
unsigned int nAccessors() const
const History * getCellHistory(unsigned int i) const
const TreeAccessor & accessor(unsigned int i) const
static std::unique_ptr< MultiTreeAccessor > open(const std::vector< TString > &files)
const RunData * runData(unsigned int i) const
const CellInfo * getCellInfo(unsigned int i) const
virtual ~MultiTreeAccessor()
bool writeToFile(const TString &fileName) const
static std::unique_ptr< MultiTreeAccessor > openList(const TString &fileList)
static std::unique_ptr< MultiTreeAccessor > openWild(const TString &wcName)
std::vector< std::unique_ptr< const TreeAccessor > > m_accessors
static std::unique_ptr< TreeAccessor > merge(const std::vector< const Accessor * > &accessors, const TString &fileName="")
static std::unique_ptr< TreeAccessor > open(const TString &fileName)
static std::unique_ptr< TreeAccessor > filter(const Accessor &accessor, const FilterParams &filterParams, const TString &fileName, const DataTweaker &tweaker)
std::vector< std::string > files
file names and file pointers