]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG4/AliAnaScale.cxx
bug fix
[u/mrichter/AliRoot.git] / PWG4 / AliAnaScale.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, 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 // A basic analysis task to analyse photon detected by PHOS
20 //
21 //*-- Yves Schutz 
22 //////////////////////////////////////////////////////////////////////////////
23
24 #include <TFile.h> 
25 #include <TH1.h>
26 #include <TH1F.h>
27 #include <TH1I.h>
28 #include <TCanvas.h> 
29
30 #include "AliAnaScale.h" 
31 #include "AliAnalysisManager.h"
32 #include "AliLog.h"
33 #include "Riostream.h"
34
35 //______________________________________________________________________________
36 AliAnaScale::AliAnaScale() : 
37   fDebug(0),
38   fScale(1.0),
39   fInputList(0x0), 
40   fOutputList(0x0) 
41 {
42   //Default constructor
43 }
44 //______________________________________________________________________________
45 AliAnaScale::AliAnaScale(const char *name) : 
46   AliAnalysisTask(name,""),  
47   fDebug(0),
48   fScale(1.0), 
49   fInputList(0x0), 
50   fOutputList(0x0) 
51 {
52   // Constructor.
53   // Called only after the event loop
54   SetPostEventLoop(kTRUE);
55   // Input slot #0 
56   DefineInput(0,  TList::Class()) ; 
57   // Output slot 
58   DefineOutput(0,  TList::Class()) ; 
59 }
60
61 //______________________________________________________________________________
62 AliAnaScale::~AliAnaScale()
63 {
64   // dtor
65   
66 }
67
68
69 //______________________________________________________________________________
70 void AliAnaScale::ConnectInputData(const Option_t*)
71 {
72   // Initialisation of branch container and histograms 
73     
74   AliInfo(Form("*** Initialization of %s", GetName())) ; 
75   fInputList     = dynamic_cast<TList*>(GetInputData(0)) ;  
76 }
77 //________________________________________________________________________
78 void AliAnaScale::CreateOutputObjects()
79 {  
80   // Create the outputs containers
81   // Is created in Exec(), because the input must be available
82
83 }
84
85 //______________________________________________________________________________
86 void AliAnaScale::Exec(Option_t *) 
87 {
88   // Do the Scaling
89     
90   fOutputList = new TList() ; 
91   fOutputList->SetName(GetName()) ; 
92   TIter next(fInputList) ;      
93   TObject * h ; 
94   while ( (h = next()) ) { 
95     if(h){
96       if ( strcmp(h->ClassName(),"TNtuple") ) {
97       char name[20] ; 
98       sprintf(name, "%sScaled", h->GetName()) ; 
99       TH1 * hout = dynamic_cast<TH1*> (h->Clone(name)) ; 
100       hout->Scale(fScale) ;  
101       fOutputList->Add(hout) ; 
102       } 
103       else  fOutputList->Add(h) ; 
104     }
105   }
106   cout<<"end"<<endl;
107   PostData(0, fOutputList);
108 }
109
110
111 //______________________________________________________________________________
112 void AliAnaScale::Init()
113 {
114   // Intialisation of parameters
115   AliInfo("Doing initialisation") ;
116   // nothing to be done
117 }
118
119 //______________________________________________________________________________
120 void AliAnaScale::Terminate(Option_t *)
121 {
122   // Processing when the event loop is ended
123   
124
125 }