1 |
dhidas |
1.1 |
/*
|
2 |
|
|
* NTupleEventReader.h
|
3 |
|
|
*
|
4 |
|
|
* Created on: Jun 25, 2010
|
5 |
|
|
* Author: lkreczko
|
6 |
|
|
*/
|
7 |
|
|
|
8 |
|
|
#ifndef NTUPLEEVENTREADER_H_
|
9 |
|
|
#define NTUPLEEVENTREADER_H_
|
10 |
|
|
#include <boost/scoped_ptr.hpp>
|
11 |
|
|
#include <boost/shared_ptr.hpp>
|
12 |
|
|
#include <boost/array.hpp>
|
13 |
|
|
#include "TChain.h"
|
14 |
|
|
#include "../Event.h"
|
15 |
|
|
#include "ElectronReader.h"
|
16 |
|
|
#include "JetReader.h"
|
17 |
|
|
#include "GenJetReader.h"
|
18 |
|
|
#include "MuonReader.h"
|
19 |
|
|
#include "VariableReader.h"
|
20 |
|
|
#include "VertexReader.h"
|
21 |
|
|
#include "METReader.h"
|
22 |
|
|
#include "TrackReader.h"
|
23 |
|
|
#include "GenParticleReader.h"
|
24 |
|
|
#include <string>
|
25 |
|
|
|
26 |
|
|
namespace BAT {
|
27 |
|
|
struct NoFileFoundException: public std::exception {
|
28 |
|
|
TString msg;
|
29 |
|
|
NoFileFoundException(TString message) :
|
30 |
|
|
msg(message) {
|
31 |
|
|
}
|
32 |
|
|
~NoFileFoundException() throw () {
|
33 |
|
|
}
|
34 |
|
|
|
35 |
|
|
const char* what() const throw () {
|
36 |
|
|
return msg;
|
37 |
|
|
}
|
38 |
|
|
};
|
39 |
|
|
|
40 |
|
|
class NTupleEventReader {
|
41 |
|
|
public:
|
42 |
|
|
static const char * EVENT_CHAIN;
|
43 |
|
|
|
44 |
|
|
static JetAlgorithm::value jetAlgorithm;
|
45 |
|
|
static ElectronAlgorithm::value electronAlgorithm;
|
46 |
|
|
static METAlgorithm::value metAlgorithm;
|
47 |
|
|
static MuonAlgorithm::value muonAlgorithm;
|
48 |
|
|
static bool loadTracks;
|
49 |
|
|
|
50 |
|
|
NTupleEventReader();
|
51 |
|
|
virtual ~NTupleEventReader();
|
52 |
|
|
const Event& getNextEvent();
|
53 |
|
|
bool hasNextEvent();
|
54 |
|
|
void addInputFile(const char* fileName);
|
55 |
|
|
// without check for unit tests -> faster to start, no difference in long analysis
|
56 |
|
|
void addInputFileWithoutCheck(const char* fileName);
|
57 |
|
|
void addInputFile(const char* fileName, DataType::value type);
|
58 |
|
|
void skipNumberOfEvents(unsigned long skipNextNEvents);
|
59 |
|
|
unsigned long getNumberOfProccessedEvents() const;
|
60 |
|
|
unsigned long getCurrentLocalEventNumber() const;
|
61 |
|
|
void setMaximumNumberOfEvents(unsigned long maxNumberOfEvents);
|
62 |
|
|
const boost::array<bool, DataType::NUMBER_OF_DATA_TYPES>& getSeenDatatypes();
|
63 |
|
|
const char* getCurrentFile() const;
|
64 |
|
|
Double_t test;
|
65 |
|
|
private:
|
66 |
|
|
unsigned long processedEvents;
|
67 |
|
|
unsigned long maximalNumberOfEvents;
|
68 |
|
|
unsigned long currentEventEntry;
|
69 |
|
|
unsigned long numberOfFiles;
|
70 |
|
|
boost::shared_ptr<TChain> input;
|
71 |
|
|
boost::shared_ptr<VariableReader<MultiIntPointer> > hltReader;
|
72 |
|
|
boost::scoped_ptr<VertexReader> vertexReader;
|
73 |
|
|
boost::scoped_ptr<TrackReader> trackReader;
|
74 |
|
|
boost::scoped_ptr<ElectronReader> electronReader;
|
75 |
|
|
boost::scoped_ptr<ElectronReader> loosePFelectronReader;
|
76 |
|
|
boost::scoped_ptr<GenParticleReader> genParticleReader;
|
77 |
|
|
boost::scoped_ptr<JetReader> jetReader;
|
78 |
|
|
boost::scoped_ptr<GenJetReader> genJetReader;
|
79 |
|
|
boost::scoped_ptr<MuonReader> muonReader;
|
80 |
|
|
boost::scoped_ptr<METReader> metReader;
|
81 |
|
|
|
82 |
|
|
boost::scoped_ptr<VariableReader<unsigned int> > runNumberReader;
|
83 |
|
|
boost::scoped_ptr<VariableReader<unsigned int> > eventNumberReader;
|
84 |
|
|
boost::scoped_ptr<VariableReader<unsigned int> > lumiBlockReader;
|
85 |
|
|
boost::scoped_ptr<VariableReader<unsigned int> > PileupInfoReader;
|
86 |
|
|
// boost::scoped_ptr<VariableReader<bool> > beamScrapingReader;
|
87 |
|
|
bool areReadersSet, areDatatypesKnown;
|
88 |
|
|
Event currentEvent;
|
89 |
|
|
boost::array<bool, DataType::NUMBER_OF_DATA_TYPES> seenDataTypes;
|
90 |
|
|
|
91 |
|
|
void selectNextNtupleEvent();
|
92 |
|
|
void initiateReadersIfNotSet();
|
93 |
|
|
DataType::value getDataType(const std::string filename);
|
94 |
|
|
void readDataTypes();
|
95 |
|
|
};
|
96 |
|
|
}
|
97 |
|
|
|
98 |
|
|
#endif /* NTUPLEEVENTREADER_H_ */
|