]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG4/PartCorrBase/AliAnaScale.cxx
hooks for PMD flow analysis
[u/mrichter/AliRoot.git] / PWG4 / PartCorrBase / 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 //Root system
25 #include <TH1.h>
26 #include <TH1F.h>
27 //#include "Riostream.h"
28
29 //Analysis system
30 #include "AliAnaScale.h" 
31
32 //______________________________________________________________________________
33 AliAnaScale::AliAnaScale() : 
34   fDebug(0),
35   fScale(1.0),
36   fInputList(0x0), 
37   fOutputList(0x0),
38   fSumw2(0),
39   fhCount() 
40 {
41   //Default constructor
42 }
43 //______________________________________________________________________________
44 AliAnaScale::AliAnaScale(const char *name) : 
45   AliAnalysisTask(name,""),  
46   fDebug(0),
47   fScale(1.0), 
48   fInputList(0x0), 
49   fOutputList(0x0), 
50   fSumw2(0),
51   fhCount(0) 
52 {
53   // Constructor.
54   // Called only after the event loop
55   SetPostEventLoop(kTRUE);
56   // Input slot #0 
57   DefineInput(0,  TList::Class()) ; 
58   // Output slot 
59   DefineOutput(0,  TList::Class()) ; 
60 }
61
62 //______________________________________________________________________________
63 AliAnaScale::~AliAnaScale()
64 {
65   // dtor
66   
67 }
68
69
70 //______________________________________________________________________________
71 void AliAnaScale::ConnectInputData(const Option_t*)
72 {
73   // Initialisation of branch container and histograms 
74     
75   if(fDebug > 1) printf("*** Initialization of %s \n", GetName()) ; 
76   fInputList     = dynamic_cast<TList*>(GetInputData(0)) ;  
77 }
78 //________________________________________________________________________
79 void AliAnaScale::CreateOutputObjects()
80 {  
81   // Create the outputs containers
82
83   fOutputList = new TList() ; 
84   fOutputList->SetName(GetName()) ; 
85
86   fhCount =new TH1F("hCount","count files",1,0,1);  
87   fOutputList->Add(fhCount);
88
89 }
90
91 //______________________________________________________________________________
92 void AliAnaScale::Exec(Option_t *) 
93 {
94   // Do the Scaling
95
96   if(fDebug > 0 ) printf(">>>>> Scaling factor %e, do Sumw2 %d <<<<< \n",fScale,fSumw2) ;
97   
98   const Int_t buffersize = 255;
99   char name[buffersize] ; 
100
101   TIter next(fInputList) ;      
102   TObject * h ; 
103   while ( (h = next()) ) { 
104     if(h){
105       if ( !strncmp(h->ClassName(),"TH",2) ) {
106       snprintf(name, buffersize, "%sScaled", h->GetName()) ; 
107       TH1 * hout = dynamic_cast<TH1*> (h->Clone(name)) ; 
108       if(hout){
109         if(fSumw2) hout->Sumw2();
110         hout->Scale(fScale) ;  
111         fOutputList->Add(hout) ;
112         }// casting not null
113       } 
114       else  fOutputList->Add(h) ; 
115     }
116   }
117   // number of files
118
119   //File scaled, needed for file merging on grid
120   fhCount->Fill(0);
121  
122   PostData(0, fOutputList);
123 }
124
125
126 //______________________________________________________________________________
127 void AliAnaScale::Init()
128 {
129   // Intialisation of parameters
130   if(fDebug > 0 )printf("No initialization in scale class \n") ;
131
132 }
133
134 //______________________________________________________________________________
135 //void AliAnaScale::Terminate(Option_t *)
136 //{
137 //  // Processing when the event loop is ended
138 //  
139 //
140 //}