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