]>
Commit | Line | Data |
---|---|---|
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 | |
22eb09de | 29 | //__________________________ |
1c5acb87 | 30 | AliAnaScale::AliAnaScale() : |
31 | fDebug(0), | |
32 | fScale(1.0), | |
33 | fInputList(0x0), | |
34 | fOutputList(0x0), | |
35 | fSumw2(0), | |
36 | fhCount() | |
37 | { | |
38 | //Default constructor | |
39 | } | |
22eb09de | 40 | |
41 | //__________________________________________ | |
1c5acb87 | 42 | AliAnaScale::AliAnaScale(const char *name) : |
43 | AliAnalysisTask(name,""), | |
44 | fDebug(0), | |
45 | fScale(1.0), | |
46 | fInputList(0x0), | |
47 | fOutputList(0x0), | |
48 | fSumw2(0), | |
49 | fhCount(0) | |
50 | { | |
22eb09de | 51 | // Constructor |
52 | ||
1c5acb87 | 53 | // Called only after the event loop |
54 | SetPostEventLoop(kTRUE); | |
22eb09de | 55 | |
1c5acb87 | 56 | // Input slot #0 |
57 | DefineInput(0, TList::Class()) ; | |
22eb09de | 58 | |
1c5acb87 | 59 | // Output slot |
22eb09de | 60 | DefineOutput(0, TList::Class()) ; |
1c5acb87 | 61 | |
62 | } | |
63 | ||
22eb09de | 64 | //_________________________________________________ |
1c5acb87 | 65 | void AliAnaScale::ConnectInputData(const Option_t*) |
66 | { | |
67 | // Initialisation of branch container and histograms | |
68 | ||
69 | if(fDebug > 1) printf("*** Initialization of %s \n", GetName()) ; | |
22eb09de | 70 | fInputList = dynamic_cast<TList*>(GetInputData(0)) ; |
71 | ||
1c5acb87 | 72 | } |
22eb09de | 73 | |
74 | //_____________________________________ | |
1c5acb87 | 75 | void AliAnaScale::CreateOutputObjects() |
76 | { | |
77 | // Create the outputs containers | |
78 | ||
79 | fOutputList = new TList() ; | |
80 | fOutputList->SetName(GetName()) ; | |
81 | ||
82 | fhCount =new TH1F("hCount","count files",1,0,1); | |
83 | fOutputList->Add(fhCount); | |
84 | ||
22eb09de | 85 | fOutputList->SetOwner(kTRUE); |
86 | ||
87 | PostData(0, fOutputList); | |
88 | ||
1c5acb87 | 89 | } |
90 | ||
22eb09de | 91 | //________________________________ |
1c5acb87 | 92 | void AliAnaScale::Exec(Option_t *) |
93 | { | |
94 | // Do the Scaling | |
22eb09de | 95 | |
1c5acb87 | 96 | if(fDebug > 0 ) printf(">>>>> Scaling factor %e, do Sumw2 %d <<<<< \n",fScale,fSumw2) ; |
f8006433 | 97 | |
98 | const Int_t buffersize = 255; | |
99 | char name[buffersize] ; | |
22eb09de | 100 | |
1c5acb87 | 101 | TIter next(fInputList) ; |
102 | TObject * h ; | |
22eb09de | 103 | while ( (h = next()) ) |
104 | { | |
105 | if(h) | |
106 | { | |
107 | if ( !strncmp(h->ClassName(),"TH",2) ) | |
108 | { | |
109 | snprintf(name, buffersize, "%sScaled", h->GetName()) ; | |
110 | ||
111 | TH1 * hout = dynamic_cast<TH1*> (h->Clone(name)) ; | |
112 | ||
113 | if(hout) | |
114 | { | |
115 | if(fSumw2) hout->Sumw2(); | |
116 | hout->Scale(fScale) ; | |
117 | fOutputList->Add(hout) ; | |
f8006433 | 118 | }// casting not null |
1c5acb87 | 119 | } |
120 | else fOutputList->Add(h) ; | |
121 | } | |
122 | } | |
123 | // number of files | |
22eb09de | 124 | |
1c5acb87 | 125 | //File scaled, needed for file merging on grid |
126 | fhCount->Fill(0); | |
22eb09de | 127 | |
1c5acb87 | 128 | PostData(0, fOutputList); |
22eb09de | 129 | |
1c5acb87 | 130 | } |
131 | ||
132 | ||
22eb09de | 133 | //______________________ |
1c5acb87 | 134 | void AliAnaScale::Init() |
135 | { | |
136 | // Intialisation of parameters | |
22eb09de | 137 | |
1c5acb87 | 138 | if(fDebug > 0 )printf("No initialization in scale class \n") ; |
139 | ||
140 | } | |
141 |