1 |
loizides |
1.1 |
// $Id: runSimpleExample.C,v 1.10 2009/03/23 14:56:32 loizides Exp $
|
2 |
|
|
|
3 |
|
|
#if !defined(__CINT__) || defined(__MAKECINT__)
|
4 |
|
|
#include <TROOT.h>
|
5 |
|
|
#include "MitAna/DataUtil/interface/Debug.h"
|
6 |
|
|
#include "MitAna/DataTree/interface/CaloMet.h"
|
7 |
|
|
#include "MitAna/TreeMod/interface/Analysis.h"
|
8 |
|
|
#include "MitAna/PhysicsMod/interface/SimpleExampleMod.h"
|
9 |
|
|
#endif
|
10 |
|
|
|
11 |
|
|
namespace mithep
|
12 |
|
|
{
|
13 |
|
|
class TestMod : public BaseMod
|
14 |
|
|
{
|
15 |
|
|
public:
|
16 |
|
|
TestMod() : fSumPt(0), fCount(0) {}
|
17 |
|
|
protected:
|
18 |
|
|
void Process() {
|
19 |
|
|
LoadBranch("GsfTracks");
|
20 |
|
|
for(UInt_t i=0;i<fCol->Entries();++i) {
|
21 |
|
|
fSumPt+=fCol->At(i)->Pt();
|
22 |
|
|
++fCount;
|
23 |
|
|
}
|
24 |
|
|
}
|
25 |
|
|
void SlaveBegin() {
|
26 |
|
|
ReqBranch("GsfTracks",fCol);
|
27 |
|
|
}
|
28 |
|
|
void SlaveTerminate() {
|
29 |
|
|
printf("Avg pt found: %f", fSumPt/fCount);
|
30 |
|
|
}
|
31 |
|
|
|
32 |
|
|
const TrackCol *fCol;
|
33 |
|
|
Double_t fSumPt;
|
34 |
|
|
Int_t fCount;
|
35 |
|
|
|
36 |
|
|
ClassDef(TestMod, 1)
|
37 |
|
|
};
|
38 |
|
|
}
|
39 |
|
|
|
40 |
|
|
//--------------------------------------------------------------------------------------------------
|
41 |
|
|
void runGsfTrackTest(const char *files = "mit-gen_000.root")
|
42 |
|
|
{
|
43 |
|
|
using namespace mithep;
|
44 |
|
|
gDebugMask = Debug::kAnalysis;
|
45 |
|
|
gDebugLevel = 1;
|
46 |
|
|
|
47 |
|
|
TestMod *tmod = new TestMod;
|
48 |
|
|
|
49 |
|
|
// set up analysis
|
50 |
|
|
Analysis *ana = new Analysis;
|
51 |
|
|
ana->SetSuperModule(tmod);
|
52 |
|
|
ana->AddFile(files);
|
53 |
|
|
ana->SetUseHLT(0);
|
54 |
|
|
if (gROOT->IsBatch())
|
55 |
|
|
ana->SetOutputName("mit-example-hist.root");
|
56 |
|
|
|
57 |
|
|
// run the analysis after successful initialisation
|
58 |
|
|
ana->Run(!gROOT->IsBatch());
|
59 |
|
|
}
|