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

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