ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/macros/examples/runGsfTracksTest.C
(Generate patch)

Comparing UserCode/MitAna/macros/examples/runGsfTracksTest.C (file contents):
Revision 1.1 by loizides, Tue Apr 7 11:06:03 2009 UTC vs.
Revision 1.2 by loizides, Tue Apr 7 13:00:58 2009 UTC

# Line 13 | Line 13 | namespace mithep
13    class TestMod : public BaseMod
14    {
15      public:
16 <      TestMod() : fSumPt(0), fCount(0) {}
16 >      TestMod(const char *n="GsfTracks") : fCol(0), fName(n), fSumPt(0), fCount(0) {}
17      protected:
18        void        Process() {
19 <        LoadBranch("GsfTracks");
20 <        for(UInt_t i=0;i<fCol->Entries();++i) {
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("GsfTracks",fCol);
26 >        ReqBranch(fName,fCol);
27        }
28        void        SlaveTerminate() {
29 <        printf("Avg pt found: %f", fSumPt/fCount);
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  
# Line 38 | Line 39 | namespace mithep
39   }
40  
41   //--------------------------------------------------------------------------------------------------
42 < void runGsfTrackTest(const char *files = "mit-gen_000.root")
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 *tmod = new TestMod;
48 >  TestMod *tmod1 = new TestMod("GsfTracks");
49 >  TestMod *tmod2 = new TestMod("Tracks");
50    
51    // set up analysis
52    Analysis *ana = new Analysis;
53 <  ana->SetSuperModule(tmod);
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    

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines