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