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() :
41 //__________________________________________
42 AliAnaScale::AliAnaScale(const char *name) :
43 AliAnalysisTask(name,""),
53 // Called only after the event loop
54 SetPostEventLoop(kTRUE);
57 DefineInput(0, TList::Class()) ;
60 DefineOutput(0, TList::Class()) ;
64 //_________________________________________________
65 void AliAnaScale::ConnectInputData(const Option_t*)
67 // Initialisation of branch container and histograms
69 if(fDebug > 1) printf("*** Initialization of %s \n", GetName()) ;
70 fInputList = dynamic_cast<TList*>(GetInputData(0)) ;
74 //_____________________________________
75 void AliAnaScale::CreateOutputObjects()
77 // Create the outputs containers
79 fOutputList = new TList() ;
80 fOutputList->SetName(GetName()) ;
82 fhCount =new TH1F("hCount","count files",1,0,1);
83 fOutputList->Add(fhCount);
85 fOutputList->SetOwner(kTRUE);
87 PostData(0, fOutputList);
91 //________________________________
92 void AliAnaScale::Exec(Option_t *)
96 if(fDebug > 0 ) printf(">>>>> Scaling factor %e, do Sumw2 %d <<<<< \n",fScale,fSumw2) ;
98 const Int_t buffersize = 255;
99 char name[buffersize] ;
101 TIter next(fInputList) ;
103 while ( (h = next()) )
107 if ( !strncmp(h->ClassName(),"TH",2) )
109 snprintf(name, buffersize, "%sScaled", h->GetName()) ;
111 TH1 * hout = dynamic_cast<TH1*> (h->Clone(name)) ;
115 if(fSumw2) hout->Sumw2();
116 hout->Scale(fScale) ;
117 fOutputList->Add(hout) ;
120 else fOutputList->Add(h) ;
125 //File scaled, needed for file merging on grid
128 PostData(0, fOutputList);
133 //______________________
134 void AliAnaScale::Init()
136 // Intialisation of parameters
138 if(fDebug > 0 )printf("No initialization in scale class \n") ;