AliPhysics  b555aef (b555aef)
AliAnaScale.cxx
Go to the documentation of this file.
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 // Root system
17 #include <TH1.h>
18 #include <TH1F.h>
19 
20 // Analysis system
21 #include "AliAnaScale.h"
22 
24 ClassImp(AliAnaScale) ;
26 
27 //__________________________
29 //__________________________
31  fDebug(0),
32  fScale(1.0),
33  fInputList(0x0),
34  fOutputList(0x0),
35  fSumw2(0),
36  fhCount()
37 {
38 }
39 
40 //__________________________________________
42 //__________________________________________
43 AliAnaScale::AliAnaScale(const char *name) :
44  AliAnalysisTask(name,""),
45  fDebug(0),
46  fScale(1.0),
47  fInputList(0x0),
48  fOutputList(0x0),
49  fSumw2(0),
50  fhCount(0)
51 {
52  // Called only after the event loop
53  SetPostEventLoop(kTRUE);
54 
55  // Input slot #0
56  DefineInput(0, TList::Class()) ;
57 
58  // Output slot
59  DefineOutput(0, TList::Class()) ;
60 }
61 
62 //_________________________________________________
64 //_________________________________________________
66 {
67  if(fDebug > 1) printf("*** Initialization of %s \n", GetName()) ;
68 
69  fInputList = dynamic_cast<TList*>(GetInputData(0)) ;
70 }
71 
72 //_____________________________________
74 //_____________________________________
76 {
77  fOutputList = new TList() ;
78  fOutputList->SetName(GetName()) ;
79 
80  fhCount =new TH1F("hCount","count files",1,0,1);
81  fOutputList->Add(fhCount);
82 
83  fOutputList->SetOwner(kTRUE);
84 
85  PostData(0, fOutputList);
86 }
87 
88 //________________________________
90 //________________________________
92 {
93  if(fDebug > 0 ) printf(">>>>> Scaling factor %e, do Sumw2 %d <<<<< \n",fScale,fSumw2) ;
94 
95  const Int_t buffersize = 255;
96  char name[buffersize] ;
97 
98  TIter next(fInputList) ;
99  TObject * h ;
100  while ( (h = next()) )
101  {
102  if(h)
103  {
104  if ( !strncmp(h->ClassName(),"TH",2) )
105  {
106  snprintf(name, buffersize, "%sScaled", h->GetName()) ;
107 
108  TH1 * hout = dynamic_cast<TH1*> (h->Clone(name)) ;
109 
110  if(hout)
111  {
112  if(fSumw2) hout->Sumw2();
113  hout->Scale(fScale) ;
114  fOutputList->Add(hout) ;
115  }// casting not null
116  }
117  else fOutputList->Add(h) ;
118  }
119  }
120  // number of files
121 
122  //File scaled, needed for file merging on grid
123  fhCount->Fill(0);
124 
125  PostData(0, fOutputList);
126 }
127 
128 //______________________
130 //______________________
132 {
133  if(fDebug > 0 )printf("No initialization in scale class \n") ;
134 }
135 
virtual void ConnectInputData(Option_t *="")
Initialisation of branch container with histograms.
Definition: AliAnaScale.cxx:65
TList * fInputList
! Input data list.
Definition: AliAnaScale.h:60
virtual void Init()
Intialization of parameters.
Scale input histograms.
Definition: AliAnaScale.h:19
virtual void Exec(Option_t *opt="")
Do the histogram scaling.
Definition: AliAnaScale.cxx:91
Bool_t fSumw2
Compute sum of squares of weights for bin content error calculation.
Definition: AliAnaScale.h:64
int Int_t
Definition: External.C:63
AliAnaScale()
Default constructor.
Definition: AliAnaScale.cxx:30
Float_t fScale
Scaling factor.
Definition: AliAnaScale.h:56
Int_t fDebug
Debug flag.
Definition: AliAnaScale.h:54
virtual void CreateOutputObjects()
Create the outputs containers.
Definition: AliAnaScale.cxx:75
TH1F * fhCount
! Counter histogram for file merging.
Definition: AliAnaScale.h:66
const char Option_t
Definition: External.C:48
TList * fOutputList
! Output data list.
Definition: AliAnaScale.h:62
Definition: External.C:196