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