ATLAS Offline Software
Loading...
Searching...
No Matches
Splitter.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
6
10
11#include "TString.h"
12
13#include <map>
14#include <iostream>
15using std::cout;
16using std::endl;
17
18using namespace LArSamples;
19
20
21bool Splitter::splitEvents(const TString& name, unsigned int max) const
22{
23 std::map<unsigned int, bool> events;
24
25 cout << "Scanning ntuple..." << endl;
26 for (unsigned int i = 0; i < m_interface->nChannels(); i++) {
27 const History* history = m_interface->cellHistory(i);
28 if (!history) continue;
29 for (unsigned int k = 0; k < history->nData(); k++)
30 events[history->data(k)->event()] = true;
31 }
32
33 cout << "Found " << events.size() << " events";
34 if (events.size() > max) {
35 cout << ", greater than specified maximum (" << max << "), aborting..." << endl;
36 return false;
37 }
38 cout << ", will now split the ntuple" << endl;
39
40 unsigned int i = 1;
41 for (std::map<unsigned int, bool>::const_iterator event = events.begin();
42 event != events.end(); ++event, ++i) {
43 cout << "Processing event " << event->first << " (" << i << " of " << events.size() << ")" << endl;
45 f.addEvent(event->first);
46 auto pInterface = m_interface->filter(f, DataTweaker(), Form("%s_%d.root", name.Data(), event->first));
47 //nothing is ever done with this (unfinished code?), so simply delete it.
48 delete (pInterface);
49 }
50
51 return true;
52}
53
#define max(a, b)
Definition cfImp.cxx:41
int event() const
Definition Data.cxx:28
const Data * data(unsigned int i) const
Definition History.cxx:91
unsigned int nData() const
Definition History.h:51
const Interface * m_interface
Definition Splitter.h:32
bool splitEvents(const TString &name, unsigned int max=20) const
Definition Splitter.cxx:21