]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/STEERBase/AliInputEventHandler.cxx
Merge branch 'master' into TPCdev
[u/mrichter/AliRoot.git] / STEER / STEERBase / AliInputEventHandler.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$ */
17
18 //-------------------------------------------------------------------------
19 //     Event handler for event input 
20 //     Author: Andreas Morsch, CERN
21 //-------------------------------------------------------------------------
22
23
24 #include "AliInputEventHandler.h"
25 #include "AliVEvent.h"
26 #include "AliVCuts.h"
27 #include "AliLog.h"
28
29
30 ClassImp(AliInputEventHandler)
31
32 //______________________________________________________________________________
33 AliInputEventHandler::AliInputEventHandler() :
34     AliVEventHandler(),
35     fTree(0),
36     fBranches(),
37     fBranchesOn(),
38     fInputFileName(),
39     fNewEvent(kTRUE),
40     fEventCuts(0),
41     fIsSelectedResult(0),
42     fMixingHandler(0),
43     fParentHandler(0),
44     fUserInfo(0)
45 {
46   // default constructor
47 }
48
49 //______________________________________________________________________________
50 AliInputEventHandler::~AliInputEventHandler() 
51 {
52 // destructor
53 }
54
55 //______________________________________________________________________________
56 AliInputEventHandler::AliInputEventHandler(const char* name, const char* title):
57     AliVEventHandler(name, title),
58     fTree(0),
59     fBranches(),
60     fBranchesOn(),
61     fInputFileName(),
62     fNewEvent(kTRUE),
63     fEventCuts(0),
64     fIsSelectedResult(0),
65     fMixingHandler(0),
66     fParentHandler(0),
67     fUserInfo(0)
68 {
69 // Named constructor.
70 }
71
72 //______________________________________________________________________________
73 void AliInputEventHandler::SwitchOffBranches() const {
74   //
75   // Switch of branches on user request
76     TObjArray * tokens = fBranches.Tokenize(" ");
77     Int_t ntok = tokens->GetEntries();
78     for (Int_t i = 0; i < ntok; i++)  {
79         TString str = ((TObjString*) tokens->At(i))->GetString();
80         if (str.Length() == 0)
81             continue;
82         fTree->SetBranchStatus(Form("%s%s%s","*", str.Data(), "*"), 0);
83         AliDebug(1,Form("Branch %s switched off", str.Data()));
84     }
85   delete tokens;
86 }
87
88 //______________________________________________________________________________
89 void AliInputEventHandler::SwitchOnBranches() const {
90   //
91   // Switch of branches on user request
92   TObjArray * tokens = fBranchesOn.Tokenize(" ");
93   Int_t ntok = tokens->GetEntries();
94
95   for (Int_t i = 0; i < ntok; i++)  {
96       TString str = ((TObjString*) tokens->At(i))->GetString();
97       if (str.Length() == 0)
98           continue;
99       fTree->SetBranchStatus(Form("%s%s%s","*", str.Data(), "*"), 1);
100       AliDebug(1,Form("Branch %s switched on", str.Data()));
101   }
102   delete tokens;
103 }
104
105 //______________________________________________________________________________
106 TObject *AliInputEventHandler::GetStatistics(Option_t *) const
107 {
108 // Returns the statistics object(s) (TH2F histogram) produced by the physics
109 // selection. Implementations both for ESD and AOD input handlers.
110   return NULL;
111 }
112    
113 Long64_t AliInputEventHandler::GetReadEntry() const 
114 {
115   // Get the current entry.
116   return fTree->GetReadEntry();
117 }
118
119 //______________________________________________________________________________
120 void AliInputEventHandler::SetInputFileName(const char* fname)
121 {
122 // Set the input file name to be analyzed. Done automatically by the manager, but
123 // in case this needs to be done at an earlier stage has to be done manually.
124    if (!strlen(fname)) return;
125    if (fInputFileName.Length()) {
126       Error("SetInputFileName", "Input file name already set to: %s\n", fInputFileName.Data());
127       return;
128    }
129    fInputFileName  = fname;
130 }