990119d6 |
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 | /* $Id$ */ |
17 | |
18 | //_________________________________________________________________________ |
990119d6 |
19 | //*-- Author : Dmitri Peressounko (SUBATECH & Kurchatov Institute) |
20 | ////////////////////////////////////////////////////////////////////////////// |
a4e98857 |
21 | // This TTask performs digitization of Summable digits (in the PHOS case it is just |
22 | // the sum of contributions from all primary particles into a given cell). |
990119d6 |
23 | // In addition it performs mixing of summable digits from different events. |
7b7c1533 |
24 | // The name of the TTask is also the title of the branch that will contain |
25 | // the created SDigits |
26 | // The title of the TTAsk is the name of the file that contains the hits from |
27 | // which the SDigits are created |
bca3b32a |
28 | // |
29 | // For each event two branches are created in TreeD: |
30 | // "PHOS" - list of digits |
31 | // "AliPHOSDigitizer" - AliPHOSDigitizer with all parameters used in digitization |
32 | // |
a4e98857 |
33 | // Note, that one can set a title for new digits branch, and repeat digitization with |
bca3b32a |
34 | // another set of parameters. |
35 | // |
a4e98857 |
36 | // Use case: |
990119d6 |
37 | // root[0] AliPHOSDigitizer * d = new AliPHOSDigitizer() ; |
38 | // root[1] d->ExecuteTask() |
39 | // Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated |
40 | // //Digitizes SDigitis in all events found in file galice.root |
bca3b32a |
41 | // |
8cb3533f |
42 | // root[2] AliPHOSDigitizer * d1 = new AliPHOSDigitizer("galice1.root") ; |
43 | // // Will read sdigits from galice1.root |
44 | // root[3] d1->MixWith("galice2.root") |
990119d6 |
45 | // Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated |
a4e98857 |
46 | // // Reads another set of sdigits from galice2.root |
8cb3533f |
47 | // root[3] d1->MixWith("galice3.root") |
a4e98857 |
48 | // // Reads another set of sdigits from galice3.root |
8cb3533f |
49 | // root[4] d->ExecuteTask("deb timing") |
50 | // // Reads SDigits from files galice1.root, galice2.root .... |
51 | // // mixes them and stores produced Digits in file galice1.root |
52 | // // deb - prints number of produced digits |
53 | // // deb all - prints list of produced digits |
54 | // // timing - prints time used for digitization |
990119d6 |
55 | // |
990119d6 |
56 | |
57 | // --- ROOT system --- |
8cb3533f |
58 | #include "TFile.h" |
990119d6 |
59 | #include "TTree.h" |
60 | #include "TSystem.h" |
8cb3533f |
61 | #include "TROOT.h" |
62 | #include "TFolder.h" |
63 | #include "TObjString.h" |
64 | #include "TBenchmark.h" |
ba54256b |
65 | |
990119d6 |
66 | // --- Standard library --- |
8cb3533f |
67 | #include <iomanip.h> |
990119d6 |
68 | |
69 | // --- AliRoot header files --- |
70 | |
8cb3533f |
71 | #include "AliRun.h" |
990119d6 |
72 | #include "AliPHOSDigit.h" |
dd5c4038 |
73 | #include "AliPHOS.h" |
7b7c1533 |
74 | #include "AliPHOSGetter.h" |
990119d6 |
75 | #include "AliPHOSDigitizer.h" |
76 | #include "AliPHOSSDigitizer.h" |
8cb3533f |
77 | #include "AliPHOSGeometry.h" |
990119d6 |
78 | |
79 | ClassImp(AliPHOSDigitizer) |
80 | |
81 | |
82 | //____________________________________________________________________________ |
7b7c1533 |
83 | AliPHOSDigitizer::AliPHOSDigitizer():TTask("","") |
990119d6 |
84 | { |
85 | // ctor |
86 | |
2bd5457f |
87 | fPinNoise = 0.01 ; |
88 | fEMCDigitThreshold = 0.01 ; |
89 | fCPVNoise = 0.01; |
90 | fCPVDigitThreshold = 0.09 ; |
91 | fPPSDNoise = 0.0000001; |
92 | fPPSDDigitThreshold = 0.0000002 ; |
2b60655b |
93 | fDigitsInRun = 0 ; |
8cb3533f |
94 | |
990119d6 |
95 | } |
96 | |
990119d6 |
97 | //____________________________________________________________________________ |
7b7c1533 |
98 | AliPHOSDigitizer::AliPHOSDigitizer(const char *headerFile,const char * name): |
99 | TTask(name, headerFile) |
990119d6 |
100 | { |
101 | // ctor |
7b7c1533 |
102 | |
2bd5457f |
103 | fPinNoise = 0.01 ; |
104 | fEMCDigitThreshold = 0.01 ; |
105 | fCPVNoise = 0.01; |
106 | fCPVDigitThreshold = 0.09 ; |
107 | fPPSDNoise = 0.0000001; |
990119d6 |
108 | fPPSDDigitThreshold = 0.0000002 ; |
2b60655b |
109 | fDigitsInRun = 0 ; |
2bd5457f |
110 | |
111 | Init() ; |
8cb3533f |
112 | |
990119d6 |
113 | } |
114 | |
115 | //____________________________________________________________________________ |
116 | AliPHOSDigitizer::~AliPHOSDigitizer() |
117 | { |
118 | // dtor |
8cb3533f |
119 | |
8cb3533f |
120 | |
990119d6 |
121 | } |
122 | |
123 | //____________________________________________________________________________ |
7b7c1533 |
124 | void AliPHOSDigitizer::Digitize(const Int_t event) |
a4e98857 |
125 | { |
126 | |
127 | // Makes the digitization of the collected summable digits. |
128 | // It first creates the array of all PHOS modules |
129 | // filled with noise (different for EMC, CPV and PPSD) and |
130 | // then adds contributions from SDigits. |
131 | // This design avoids scanning over the list of digits to add |
132 | // contribution to new SDigits only. |
990119d6 |
133 | |
7b7c1533 |
134 | if( strcmp(GetName(), "") == 0 ) |
8cb3533f |
135 | Init() ; |
990119d6 |
136 | |
7b7c1533 |
137 | AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; |
138 | TClonesArray * digits = gime->Digits() ; |
139 | |
140 | digits->Clear() ; |
990119d6 |
141 | |
7b7c1533 |
142 | const AliPHOSGeometry *geom = gime->PHOSGeometry() ; |
990119d6 |
143 | |
144 | //Making digits with noise, first EMC |
145 | Int_t nEMC = geom->GetNModules()*geom->GetNPhi()*geom->GetNZ(); |
146 | |
147 | Int_t nCPV ; |
148 | Int_t nPPSD ; |
149 | Int_t absID ; |
150 | TString name = geom->GetName() ; |
151 | |
152 | if ( name == "IHEP" || name == "MIXT" ) |
153 | nCPV =nEMC + geom->GetNumberOfCPVPadsZ()*geom->GetNumberOfCPVPadsPhi()* |
154 | geom->GetNCPVModules()*geom->GetNumberOfCPVLayers() ; |
155 | else |
156 | nCPV = nEMC; |
157 | |
158 | if ( name == "GPS2" || name == "MIXT" ) |
159 | nPPSD =nCPV+2*geom->GetNPPSDModules()*geom->GetNumberOfModulesPhi()*geom->GetNumberOfModulesZ()* |
160 | geom->GetNumberOfPadsPhi()*geom->GetNumberOfPadsZ() ; |
161 | else |
162 | nPPSD = nCPV; |
8cb3533f |
163 | |
164 | |
7b7c1533 |
165 | digits->Expand(nPPSD) ; |
8cb3533f |
166 | |
7b7c1533 |
167 | |
168 | // sdigitize random gaussian noise and add it to all cells (EMCA+CPV+PPSD) |
169 | // get first the sdigitizer from the tasks list (must have same name as the digitizer) |
170 | const AliPHOSSDigitizer * sDigitizer = gime->SDigitizer(GetName()); |
171 | if ( !sDigitizer) { |
172 | cerr << "ERROR: AliPHOSDigitizer::Digitize -> SDigitizer with name " << GetName() << " not found " << endl ; |
173 | abort() ; |
174 | } |
990119d6 |
175 | for(absID = 1; absID <= nEMC; absID++){ |
176 | Float_t noise = gRandom->Gaus(0., fPinNoise) ; |
7b7c1533 |
177 | new((*digits)[absID-1]) AliPHOSDigit( -1,absID,sDigitizer->Digitize(noise) ) ; |
990119d6 |
178 | } |
179 | |
180 | for(absID = nEMC+1; absID <= nCPV; absID++){ |
181 | Float_t noise = gRandom->Gaus(0., fCPVNoise) ; |
7b7c1533 |
182 | new((*digits)[absID-1]) AliPHOSDigit( -1,absID,sDigitizer->Digitize(noise) ) ; |
990119d6 |
183 | } |
184 | |
185 | for(absID = nCPV+1; absID <= nPPSD; absID++){ |
186 | Float_t noise = gRandom->Gaus(0., fPPSDNoise) ; |
7b7c1533 |
187 | new((*digits)[absID-1]) AliPHOSDigit( -1,absID,sDigitizer->Digitize(noise) ) ; |
990119d6 |
188 | } |
189 | |
7b7c1533 |
190 | // loop through the sdigits posted to the White Board and add them to the noise |
191 | TCollection * folderslist = ((TFolder*)gROOT->FindObjectAny("YSAlice/WhiteBoard/SDigits/PHOS"))->GetListOfFolders() ; |
192 | TIter next(folderslist) ; |
193 | TFolder * folder = 0 ; |
194 | TClonesArray * sdigits = 0 ; |
195 | TString eventS ; |
196 | eventS += event ; |
197 | while ( (folder = (TFolder*)next()) ) { |
03358e3b |
198 | if ( (strcmp(folder->GetTitle(), eventS.Data()) == 0) || (strcmp(folder->GetTitle(), "") == 0) ) { |
7b7c1533 |
199 | Int_t numberoffiles = 0 ; |
200 | if ( (sdigits = (TClonesArray*)folder->FindObject(GetName()) ) ) { |
03358e3b |
201 | cout << "INFO: AliPHOSDigitizer::Digitize -> Adding SDigits " << GetName() << " from " << folder->GetName() << endl ; |
7b7c1533 |
202 | numberoffiles++ ; |
203 | Int_t index ; |
204 | AliPHOSDigit * curSDigit ; |
205 | AliPHOSDigit * digit ; |
206 | for ( index = 0 ; index < sdigits->GetEntriesFast(); index++) { |
207 | curSDigit = (AliPHOSDigit*)sdigits->At(index) ; |
208 | curSDigit->ShiftPrimary(numberoffiles) ; |
209 | digit = (AliPHOSDigit*)digits->At(curSDigit->GetId() - 1 ) ; |
210 | *digit = *digit + *curSDigit ; |
211 | } |
212 | } |
213 | } |
990119d6 |
214 | } |
990119d6 |
215 | //remove digits below thresholds |
216 | for(absID = 0; absID < nEMC ; absID++) |
7b7c1533 |
217 | if(sDigitizer->Calibrate(((AliPHOSDigit*)digits->At(absID))->GetAmp()) < fEMCDigitThreshold) |
218 | digits->RemoveAt(absID) ; |
219 | |
990119d6 |
220 | for(absID = nEMC; absID < nCPV ; absID++) |
7b7c1533 |
221 | if(sDigitizer->Calibrate(((AliPHOSDigit*)digits->At(absID))->GetAmp()) < fCPVDigitThreshold) |
222 | digits->RemoveAt(absID) ; |
223 | |
990119d6 |
224 | for(absID = nCPV; absID < nPPSD ; absID++) |
7b7c1533 |
225 | if(sDigitizer->Calibrate(((AliPHOSDigit *)digits->At(absID))->GetAmp()) < fPPSDDigitThreshold) |
226 | digits->RemoveAt(absID) ; |
990119d6 |
227 | |
7b7c1533 |
228 | digits->Compress() ; |
990119d6 |
229 | |
7b7c1533 |
230 | Int_t ndigits = digits->GetEntriesFast() ; |
7b7c1533 |
231 | digits->Expand(ndigits) ; |
990119d6 |
232 | |
990119d6 |
233 | //Set indexes in list of digits |
234 | Int_t i ; |
235 | for (i = 0 ; i < ndigits ; i++) { |
7b7c1533 |
236 | AliPHOSDigit * digit = (AliPHOSDigit *) digits->At(i) ; |
990119d6 |
237 | digit->SetIndexInList(i) ; |
238 | } |
990119d6 |
239 | |
7b7c1533 |
240 | } |
990119d6 |
241 | |
7b7c1533 |
242 | //____________________________________________________________________________ |
243 | void AliPHOSDigitizer::Exec(Option_t *option) |
244 | { |
245 | // Managing method |
990119d6 |
246 | |
7b7c1533 |
247 | if( strcmp(GetName(), "") == 0 ) |
248 | Init() ; |
8cb3533f |
249 | |
7b7c1533 |
250 | if (strstr(option,"print")) { |
251 | Print(""); |
252 | return ; |
8cb3533f |
253 | } |
990119d6 |
254 | |
7b7c1533 |
255 | if(strstr(option,"tim")) |
256 | gBenchmark->Start("PHOSDigitizer"); |
8cb3533f |
257 | |
7b7c1533 |
258 | //Check, if this branch already exits |
259 | TObjArray * lob = (TObjArray*)gAlice->TreeD()->GetListOfBranches() ; |
260 | TIter next(lob) ; |
261 | TBranch * branch = 0 ; |
262 | Bool_t phosfound = kFALSE, digitizerfound = kFALSE ; |
8cb3533f |
263 | |
7b7c1533 |
264 | while ( (branch = (TBranch*)next()) && (!phosfound || !digitizerfound) ) { |
265 | if ( (strcmp(branch->GetName(), "PHOS")==0) && (strcmp(branch->GetTitle(), GetName())==0) ) |
266 | phosfound = kTRUE ; |
8cb3533f |
267 | |
7b7c1533 |
268 | else if ( (strcmp(branch->GetName(), "AliPHOSDigitizer")==0) && (strcmp(branch->GetTitle(), GetName())==0) ) |
269 | digitizerfound = kTRUE ; |
8cb3533f |
270 | } |
990119d6 |
271 | |
7b7c1533 |
272 | if ( phosfound || digitizerfound ) { |
273 | cerr << "WARNING: AliPHOSDigitizer::WriteDigits -> Digits and/or Digitizer branch with name " << GetName() |
274 | << " already exits" << endl ; |
275 | return ; |
276 | } |
eec3ac52 |
277 | |
7b7c1533 |
278 | Int_t nevents = (Int_t) gAlice->TreeE()->GetEntries() ; |
279 | Int_t ievent ; |
bca3b32a |
280 | |
7b7c1533 |
281 | for(ievent = 0; ievent < nevents; ievent++){ |
01a599c9 |
282 | gAlice->SetEvent(ievent) ; |
7b7c1533 |
283 | if(!ReadSDigits(ievent)) //read sdigits event(s) evaluated by Combinator() from file(s) |
01a599c9 |
284 | continue ; |
990119d6 |
285 | |
7b7c1533 |
286 | Digitize(ievent) ; //Add prepared SDigits to digits and add the noise |
ba54256b |
287 | |
7b7c1533 |
288 | WriteDigits(ievent) ; |
7b7c1533 |
289 | |
01a599c9 |
290 | if(strstr(option,"deb")) |
291 | PrintDigits(option); |
292 | } |
990119d6 |
293 | |
8cb3533f |
294 | if(strstr(option,"tim")){ |
295 | gBenchmark->Stop("PHOSDigitizer"); |
296 | cout << "AliPHOSDigitizer:" << endl ; |
ba54256b |
297 | cout << " took " << gBenchmark->GetCpuTime("PHOSDigitizer") << " seconds for Digitizing " |
298 | << gBenchmark->GetCpuTime("PHOSDigitizer")/nevents << " seconds per event " << endl ; |
8cb3533f |
299 | cout << endl ; |
300 | } |
990119d6 |
301 | |
302 | } |
303 | |
7b7c1533 |
304 | //____________________________________________________________________________ |
305 | void AliPHOSDigitizer::Init() |
a4e98857 |
306 | { |
7b7c1533 |
307 | // Makes all memory allocations |
308 | // Adds Digitizer task to the folder of PHOS tasks |
309 | //============================================================= YS |
310 | // The initialisation is now done by AliPHOSGetter |
8cb3533f |
311 | |
7b7c1533 |
312 | if( strcmp(GetTitle(), "") == 0 ) |
313 | SetTitle("galice.root") ; |
314 | |
315 | |
316 | // the SDigits name is stored by AliPHOSGetter as the name of the TClones Array |
317 | // //YSAlice/WhiteBoard/SDigits/PHOS/headerFile/branchname and has branchTitle as title. |
990119d6 |
318 | |
7b7c1533 |
319 | AliPHOSGetter * gime = AliPHOSGetter::GetInstance(GetTitle(), GetName()) ; |
320 | if ( gime == 0 ) { |
321 | cerr << "ERROR: AliPHOSDigitizer::Init -> Could not obtain the Getter object !" << endl ; |
322 | return ; |
323 | } |
324 | |
325 | // fIevent = new TArrayI(1) ; |
326 | // fIevent->AddAt(-1,0 ) ; |
327 | // fIeventMax = new TArrayI(1) ; |
990119d6 |
328 | |
7b7c1533 |
329 | // fIeventMax->AddAt((Int_t) gAlice->TreeE()->GetEntries(), 0 ); |
330 | |
331 | //add Task to //YSAlice/tasks/Digitizer/PHOS |
332 | TTask * aliceSD = (TTask*)gROOT->FindObjectAny("YSAlice/tasks/Digitizer") ; |
333 | TTask * phosSD = (TTask*)aliceSD->GetListOfTasks()->FindObject("PHOS") ; |
334 | phosSD->Add(this) ; |
335 | // create a folder on the white board //YSAlice/WhiteBoard/Digits/PHOS/headerFile/digitsTitle |
336 | gime->Post(GetTitle(), "D", GetName() ) ; |
990119d6 |
337 | |
338 | } |
7b7c1533 |
339 | |
990119d6 |
340 | //__________________________________________________________________ |
7b7c1533 |
341 | void AliPHOSDigitizer::MixWith(const char* headerFile) |
a4e98857 |
342 | { |
ba54256b |
343 | // Allows to produce digits by superimposing background and signal event. |
bca3b32a |
344 | // It is assumed, that headers file with SIGNAL events is opened in |
a4e98857 |
345 | // the constructor. |
346 | // Sets the BACKGROUND event, with which the SIGNAL event is to be mixed |
347 | // Thus we avoid writing (changing) huge and expensive |
bca3b32a |
348 | // backgound files: all output will be writen into SIGNAL, i.e. |
349 | // opened in constructor file. |
350 | // |
a4e98857 |
351 | // One can open as many files to mix with as one needs. |
7b7c1533 |
352 | // However only Sdigits with the same name (i.e. constructed with the same SDigitizer) |
353 | // can be mixed. |
bca3b32a |
354 | |
7b7c1533 |
355 | if( strcmp(GetName(), "") == 0 ) |
8cb3533f |
356 | Init() ; |
357 | |
7b7c1533 |
358 | const char* sDigitsTitle = GetName() ; |
359 | |
360 | // check if the specified SDigits do not already exist on the White Board: |
361 | // //YSAlice/WhiteBoard/SDigits/PHOS/headerFile/sDigitsTitle |
990119d6 |
362 | |
7b7c1533 |
363 | TString path = "YSAlice/WhiteBoard/SDigits/PHOS/" ; |
364 | path += headerFile ; |
365 | path += "/" ; |
366 | path += sDigitsTitle ; |
367 | if ( gROOT->FindObjectAny(path.Data()) ) { |
368 | cerr << "WARNING: AliPHOSDigitizer::MixWith -> Entry already exists, do not add" << endl ; |
369 | return; |
990119d6 |
370 | } |
7b7c1533 |
371 | // check if the requested file is already open or exist and if SDigits Branch exist |
372 | TFile * file = (TFile*)gROOT->FindObject(headerFile); |
373 | if ( !file ) { |
374 | file = new TFile(headerFile, "READ") ; |
375 | if (!file) { |
376 | cerr << "ERROR: AliPHOSDigitizer::MixWith -> File " << headerFile << " does not exist!" << endl ; |
377 | return ; |
378 | } |
379 | } |
03358e3b |
380 | |
381 | // Read the first event with SDigits from the file-to-mix and post it to SDigits folder |
382 | |
383 | Int_t ievent =0 ; |
384 | TString tsname("TreeS") ; |
385 | tsname += ievent ; |
386 | TTree * ts = (TTree*)file->Get(tsname.Data()) ; |
387 | if ( !ts ) { |
388 | cerr << "ERROR: AliPHOSDigitizer::MixWith -> TreeS0 " << " does not exist in " << headerFile << endl ; |
389 | return ; |
390 | } |
7b7c1533 |
391 | |
03358e3b |
392 | TObjArray * lob = (TObjArray*)ts->GetListOfBranches() ; |
393 | TIter next(lob) ; |
394 | TBranch * branch = 0 ; |
395 | TBranch * sdigitsbranch = 0 ; |
396 | TBranch * sdigitizerbranch = 0 ; |
397 | Bool_t phosfound = kFALSE, sdigitizerfound = kFALSE ; |
7b7c1533 |
398 | |
03358e3b |
399 | while ( (branch = (TBranch*)next()) && (!phosfound || !sdigitizerfound) ) { |
400 | if ( (strcmp(branch->GetName(), "PHOS")==0) && (strcmp(branch->GetTitle(), sDigitsTitle)==0) ) { |
401 | sdigitsbranch = branch ; |
402 | phosfound = kTRUE ; |
403 | } |
404 | else if ( (strcmp(branch->GetName(), "AliPHOSSDigitizer")==0) && (strcmp(branch->GetTitle(), sDigitsTitle)==0) ) { |
405 | sdigitizerbranch = branch ; |
406 | sdigitizerfound = kTRUE ; |
7b7c1533 |
407 | } |
03358e3b |
408 | } |
7b7c1533 |
409 | |
03358e3b |
410 | if ( !phosfound || !sdigitizerfound ) { |
411 | cerr << "WARNING: AliPHOSDigitizer::MixWith -> Cannot find SDigits and/or SDigitizer with name " << sDigitsTitle << endl ; |
412 | return ; |
413 | } |
7b7c1533 |
414 | |
03358e3b |
415 | // post the new SDigits to the White Board |
416 | AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; |
417 | gime->Post(headerFile, "S", sDigitsTitle) ; |
ba54256b |
418 | |
990119d6 |
419 | } |
7b7c1533 |
420 | |
990119d6 |
421 | //__________________________________________________________________ |
dd5c4038 |
422 | void AliPHOSDigitizer::Print(Option_t* option)const { |
423 | // Print Digitizer's parameters |
7b7c1533 |
424 | if( strcmp(GetName(), "") != 0 ){ |
8cb3533f |
425 | |
426 | cout << "------------------- "<< GetName() << " -------------" << endl ; |
427 | cout << "Digitizing sDigits from file(s): " <<endl ; |
7b7c1533 |
428 | |
429 | TCollection * folderslist = ((TFolder*)gROOT->FindObjectAny("YSAlice/WhiteBoard/SDigits/PHOS"))->GetListOfFolders() ; |
430 | TIter next(folderslist) ; |
431 | TFolder * folder = 0 ; |
432 | |
433 | while ( (folder = (TFolder*)next()) ) { |
434 | if ( folder->FindObject(GetName()) ) |
435 | cout << "Adding SDigits " << GetName() << " from " << folder->GetName() << endl ; |
8cb3533f |
436 | } |
437 | cout << endl ; |
7b7c1533 |
438 | cout << "Writing digits to " << GetTitle() << endl ; |
8cb3533f |
439 | |
440 | cout << endl ; |
441 | cout << "With following parameters: " << endl ; |
442 | cout << " Electronics noise in EMC (fPinNoise) = " << fPinNoise << endl ; |
443 | cout << " Threshold in EMC (fEMCDigitThreshold) = " << fEMCDigitThreshold << endl ; ; |
444 | cout << " Noise in CPV (fCPVNoise) = " << fCPVNoise << endl ; |
445 | cout << " Threshold in CPV (fCPVDigitThreshold) = " << fCPVDigitThreshold << endl ; |
446 | cout << " Noise in PPSD (fPPSDNoise) = " << fPPSDNoise << endl ; |
447 | cout << " Threshold in PPSD (fPPSDDigitThreshold) = " << fPPSDDigitThreshold << endl ; |
448 | cout << "---------------------------------------------------" << endl ; |
990119d6 |
449 | } |
8cb3533f |
450 | else |
451 | cout << "AliPHOSDigitizer not initialized " << endl ; |
452 | |
453 | } |
454 | //__________________________________________________________________ |
dd5c4038 |
455 | void AliPHOSDigitizer::PrintDigits(Option_t * option){ |
456 | // Print a table of digits |
a4e98857 |
457 | |
7b7c1533 |
458 | AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; |
459 | TClonesArray * digits = gime->Digits() ; |
460 | |
01a599c9 |
461 | cout << "AliPHOSDigitiser: event " << gAlice->GetEvNumber() << endl ; |
7b7c1533 |
462 | cout << " Number of entries in Digits list " << digits->GetEntriesFast() << endl ; |
990119d6 |
463 | cout << endl ; |
2b60655b |
464 | |
465 | fDigitsInRun += digits->GetEntriesFast() ; |
466 | |
8cb3533f |
467 | if(strstr(option,"all")){ |
468 | |
469 | //loop over digits |
470 | AliPHOSDigit * digit; |
471 | cout << "Digit Id " << " Amplitude " << " Index " << " Nprim " << " Primaries list " << endl; |
472 | Int_t index ; |
7b7c1533 |
473 | for (index = 0 ; index < digits->GetEntries() ; index++) { |
474 | digit = (AliPHOSDigit * ) digits->At(index) ; |
8cb3533f |
475 | cout << setw(8) << digit->GetId() << " " << setw(3) << digit->GetAmp() << " " |
476 | << setw(6) << digit->GetIndexInList() << " " |
477 | << setw(5) << digit->GetNprimary() <<" "; |
478 | |
479 | Int_t iprimary; |
480 | for (iprimary=0; iprimary<digit->GetNprimary(); iprimary++) |
481 | cout << setw(5) << digit->GetPrimary(iprimary+1) << " "; |
482 | cout << endl; |
483 | } |
484 | |
485 | } |
486 | } |
7b7c1533 |
487 | |
8cb3533f |
488 | //__________________________________________________________________ |
a4e98857 |
489 | void AliPHOSDigitizer::SetSDigitsBranch(const char* title) |
490 | { |
bca3b32a |
491 | // we set title (comment) of the SDigits branch in the first! header file |
7b7c1533 |
492 | if( strcmp(GetName(), "") == 0 ) |
493 | Init() ; |
990119d6 |
494 | |
7b7c1533 |
495 | AliPHOSGetter::GetInstance()->SDigits()->SetName(title) ; |
496 | |
8cb3533f |
497 | } |
7b7c1533 |
498 | |
8cb3533f |
499 | //__________________________________________________________________ |
7b7c1533 |
500 | Bool_t AliPHOSDigitizer::ReadSDigits(Int_t event) |
a4e98857 |
501 | { |
7b7c1533 |
502 | // Reads summable digits from the opened files for the particular set of events given by fIevent |
503 | |
504 | AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; |
8cb3533f |
505 | |
03358e3b |
506 | // loop over all opened files and read their SDigits to the White Board |
507 | TCollection * folderslist = ((TFolder*)gROOT->FindObjectAny("YSAlice/WhiteBoard/SDigits/PHOS"))->GetListOfFolders() ; |
508 | TIter next(folderslist) ; |
509 | TFolder * folder = 0 ; |
510 | TClonesArray * sdigits = 0 ; |
ba54256b |
511 | TFile * file; |
512 | TTree * treeS = 0; |
03358e3b |
513 | while ( (folder = (TFolder*)next()) ) { |
ba54256b |
514 | printf("Reading folder %s\n",folder->GetName()); |
515 | file = (TFile*)gROOT->GetFile(folder->GetName()); |
03358e3b |
516 | file->cd() ; |
01a599c9 |
517 | |
03358e3b |
518 | // Get SDigits Tree header from file |
519 | TString treeName("TreeS") ; |
520 | treeName += event ; |
ba54256b |
521 | treeS = (TTree*)gDirectory->Get(treeName.Data()); |
03358e3b |
522 | |
523 | if(treeS==0){ |
524 | cerr << "ERROR: AliPHOSDigitizer::ReadSDigits There is no SDigit Tree" << endl; |
525 | return kFALSE; |
526 | } |
ba54256b |
527 | |
03358e3b |
528 | //set address of the SDigits and SDigitizer |
529 | TBranch * sdigitsBranch = 0; |
530 | TBranch * sdigitizerBranch = 0; |
531 | TBranch * branch = 0 ; |
532 | TObjArray * lob = (TObjArray*)treeS->GetListOfBranches() ; |
533 | TIter next(lob) ; |
534 | Bool_t phosfound = kFALSE, sdigitizerfound = kFALSE ; |
535 | |
536 | while ( (branch = (TBranch*)next()) && (!phosfound || !sdigitizerfound) ) { |
537 | if ( (strcmp(branch->GetName(), "PHOS")==0) && (strcmp(branch->GetTitle(), GetName())==0) ) { |
538 | phosfound = kTRUE ; |
539 | sdigitsBranch = branch ; |
540 | } |
541 | |
542 | else if ( (strcmp(branch->GetName(), "AliPHOSSDigitizer")==0) && (strcmp(branch->GetTitle(), GetName())==0) ) { |
543 | sdigitizerfound = kTRUE ; |
544 | sdigitizerBranch = branch ; |
545 | } |
7b7c1533 |
546 | } |
03358e3b |
547 | if ( !phosfound || !sdigitizerfound ) { |
548 | cerr << "WARNING: AliPHOSDigitizer::ReadSDigits -> Digits and/or Digitizer branch with name " << GetName() |
549 | << " not found" << endl ; |
550 | return kFALSE ; |
551 | } |
7b7c1533 |
552 | |
03358e3b |
553 | if ( (sdigits = (TClonesArray*)folder->FindObject(GetName()) ) ) { |
554 | sdigitsBranch->SetAddress(&sdigits) ; |
555 | sdigits->Clear(); |
556 | |
557 | AliPHOSSDigitizer * sdigitizer = gime->SDigitizer() ; |
558 | sdigitizerBranch->SetAddress(&sdigitizer) ; |
559 | |
560 | sdigitsBranch->GetEntry(0) ; |
561 | sdigitizerBranch->GetEntry(0) ; |
562 | |
563 | fPedestal = sdigitizer->GetPedestalParameter() ; |
564 | fSlope = sdigitizer->GetCalibrationParameter() ; |
7b7c1533 |
565 | } |
ba54256b |
566 | if (treeS) { delete treeS; treeS = 0;} |
03358e3b |
567 | } |
7b7c1533 |
568 | |
03358e3b |
569 | // After SDigits have been read from all files, return to the first one |
570 | |
571 | next.Reset(); |
572 | folder = (TFolder*)next(); |
ba54256b |
573 | file = (TFile*)gROOT->GetFile(folder->GetName()); |
574 | file ->cd() ; |
01a599c9 |
575 | |
576 | return kTRUE ; |
7b7c1533 |
577 | |
578 | } |
579 | |
580 | //____________________________________________________________________________ |
581 | void AliPHOSDigitizer::Reset() |
582 | { |
583 | // sets current event number to the first simulated event |
584 | |
585 | if( strcmp(GetName(), "") == 0 ) |
586 | Init() ; |
587 | |
588 | // Int_t inputs ; |
589 | // for(inputs = 0; inputs < fNinputs ;inputs++) |
590 | // fIevent->AddAt(-1, inputs ) ; |
591 | |
592 | } |
593 | |
594 | //____________________________________________________________________________ |
595 | void AliPHOSDigitizer::WriteDigits(Int_t event) |
596 | { |
597 | |
598 | // Makes TreeD in the output file. |
599 | // Check if branch already exists: |
600 | // if yes, exit without writing: ROOT TTree does not support overwriting/updating of |
601 | // already existing branches. |
602 | // else creates branch with Digits, named "PHOS", title "...", |
603 | // and branch "AliPHOSDigitizer", with the same title to keep all the parameters |
604 | // and names of files, from which digits are made. |
605 | |
606 | AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; |
607 | TClonesArray * digits = gime->Digits() ; |
608 | |
ba54256b |
609 | TTree * treeD = 0; |
610 | TString treeName("TreeD") ; |
611 | treeName += event ; |
612 | treeD = (TTree*)gDirectory->Get(treeName.Data()); |
613 | |
614 | if(treeD==0) |
7b7c1533 |
615 | gAlice->MakeTree("D") ; |
616 | |
617 | // create new branches |
618 | // -- generate file name if necessary |
619 | char * file =0; |
620 | if(gSystem->Getenv("CONFIG_SPLIT_FILE")){ //generating file name |
621 | file = new char[strlen(gAlice->GetBaseFile())+20] ; |
622 | sprintf(file,"%s/PHOS.Digits.root",gAlice->GetBaseFile()) ; |
623 | } |
624 | |
625 | TDirectory *cwd = gDirectory; |
7b7c1533 |
626 | // -- create Digits branch |
627 | Int_t bufferSize = 32000 ; |
ba54256b |
628 | TBranch * digitsBranch = treeD->Branch("PHOS",&digits,bufferSize); |
7b7c1533 |
629 | digitsBranch->SetTitle(GetName()); |
630 | if (file) { |
631 | digitsBranch->SetFile(file); |
632 | TIter next( digitsBranch->GetListOfBranches()); |
633 | TBranch * sbr ; |
634 | while ((sbr=(TBranch*)next())) { |
635 | sbr->SetFile(file); |
636 | } |
637 | cwd->cd(); |
638 | } |
639 | |
640 | // -- Create Digitizer branch |
641 | Int_t splitlevel = 0 ; |
642 | AliPHOSDigitizer * d = gime->Digitizer(GetName()) ; |
ba54256b |
643 | TBranch * digitizerBranch = treeD->Branch("AliPHOSDigitizer", "AliPHOSDigitizer", &d,bufferSize,splitlevel); |
7b7c1533 |
644 | digitizerBranch->SetTitle(GetName()); |
645 | if (file) { |
646 | digitizerBranch->SetFile(file); |
647 | TIter next( digitizerBranch->GetListOfBranches()); |
648 | TBranch * sbr; |
649 | while ((sbr=(TBranch*)next())) { |
650 | sbr->SetFile(file); |
651 | } |
652 | cwd->cd(); |
653 | } |
654 | |
7b7c1533 |
655 | digitsBranch->Fill() ; |
656 | digitizerBranch->Fill() ; |
657 | |
ba54256b |
658 | treeD->Write(0,kOverwrite) ; |
659 | treeD->Delete(""); |
7b7c1533 |
660 | } |