1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 //_________________________________________________________________________
17 // A basic analysis task to scale histograms to a given cross section
20 //////////////////////////////////////////////////////////////////////////////
27 #include "AliAnaScale.h"
29 //______________________________________________________________________________
30 AliAnaScale::AliAnaScale() :
40 //______________________________________________________________________________
41 AliAnaScale::AliAnaScale(const char *name) :
42 AliAnalysisTask(name,""),
51 // Called only after the event loop
52 SetPostEventLoop(kTRUE);
54 DefineInput(0, TList::Class()) ;
56 DefineOutput(0, TList::Class()) ;
59 //______________________________________________________________________________
60 AliAnaScale::~AliAnaScale()
67 //______________________________________________________________________________
68 void AliAnaScale::ConnectInputData(const Option_t*)
70 // Initialisation of branch container and histograms
72 if(fDebug > 1) printf("*** Initialization of %s \n", GetName()) ;
73 fInputList = dynamic_cast<TList*>(GetInputData(0)) ;
75 //________________________________________________________________________
76 void AliAnaScale::CreateOutputObjects()
78 // Create the outputs containers
80 fOutputList = new TList() ;
81 fOutputList->SetName(GetName()) ;
83 fhCount =new TH1F("hCount","count files",1,0,1);
84 fOutputList->Add(fhCount);
88 //______________________________________________________________________________
89 void AliAnaScale::Exec(Option_t *)
93 if(fDebug > 0 ) printf(">>>>> Scaling factor %e, do Sumw2 %d <<<<< \n",fScale,fSumw2) ;
95 const Int_t buffersize = 255;
96 char name[buffersize] ;
98 TIter next(fInputList) ;
100 while ( (h = next()) ) {
102 if ( !strncmp(h->ClassName(),"TH",2) ) {
103 snprintf(name, buffersize, "%sScaled", h->GetName()) ;
104 TH1 * hout = dynamic_cast<TH1*> (h->Clone(name)) ;
106 if(fSumw2) hout->Sumw2();
107 hout->Scale(fScale) ;
108 fOutputList->Add(hout) ;
111 else fOutputList->Add(h) ;
116 //File scaled, needed for file merging on grid
119 PostData(0, fOutputList);
123 //______________________________________________________________________________
124 void AliAnaScale::Init()
126 // Intialisation of parameters
127 if(fDebug > 0 )printf("No initialization in scale class \n") ;