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