ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/macros/examples/runGsfTracksTest.C
Revision: 1.2
Committed: Tue Apr 7 13:00:58 2009 UTC (16 years, 1 month ago) by loizides
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_009c, Mit_009b, Mit_009a, Mit_009
Changes since 1.1: +15 -9 lines
Log Message:
Test case updated

File Contents

# Content
1 // $Id: runGsfTracksTest.C,v 1.1 2009/04/07 11:06:03 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(const char *n="GsfTracks") : fCol(0), fName(n), fSumPt(0), fCount(0) {}
17 protected:
18 void Process() {
19 LoadBranch(fName);
20 for(UInt_t i=0;i<fCol->GetEntries();++i) {
21 fSumPt+=fCol->At(i)->Pt();
22 ++fCount;
23 }
24 }
25 void SlaveBegin() {
26 ReqBranch(fName,fCol);
27 }
28 void SlaveTerminate() {
29 printf("TestMod: %s -> Avg pt found: %f (%f/%d)\n", fName.Data(), fSumPt/fCount, fSumPt, fCount);
30 }
31
32 const TrackCol *fCol;
33 TString fName;
34 Double_t fSumPt;
35 Int_t fCount;
36
37 ClassDef(TestMod, 1)
38 };
39 }
40
41 //--------------------------------------------------------------------------------------------------
42 void runGsfTrackTest(const char *files, UInt_t nev=0)
43 {
44 using namespace mithep;
45 gDebugMask = Debug::kAnalysis;
46 gDebugLevel = 1;
47
48 TestMod *tmod1 = new TestMod("GsfTracks");
49 TestMod *tmod2 = new TestMod("Tracks");
50
51 // set up analysis
52 Analysis *ana = new Analysis;
53 ana->AddSuperModule(tmod1);
54 ana->AddSuperModule(tmod2);
55 ana->AddFile(files);
56 ana->SetUseHLT(0);
57 if (nev)
58 ana->SetProcessNEvents(nev);
59
60 if (gROOT->IsBatch())
61 ana->SetOutputName("mit-example-hist.root");
62
63 // run the analysis after successful initialisation
64 ana->Run(!gROOT->IsBatch());
65 }