]>
Commit | Line | Data |
---|---|---|
8309c1ab | 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 | /////////////////////////////////////////////////////////////////////////////// | |
19 | // // | |
20 | // ZDC digitizer class // | |
21 | // // | |
22 | /////////////////////////////////////////////////////////////////////////////// | |
23 | ||
24 | #include <stdlib.h> | |
25 | ||
26 | // --- ROOT system | |
27 | #include <TTree.h> | |
28 | #include <TFile.h> | |
29 | #include <TNtuple.h> | |
30 | #include <TRandom.h> | |
31 | ||
32 | // --- AliRoot header files | |
33 | #include "AliLog.h" | |
34 | #include "AliRun.h" | |
35 | #include "AliHeader.h" | |
36 | #include "AliGenHijingEventHeader.h" | |
37 | #include "AliRunDigitizer.h" | |
38 | #include "AliRunLoader.h" | |
12434381 | 39 | #include "AliGRPObject.h" |
78d18275 | 40 | #include "AliCDBManager.h" |
48642b09 | 41 | #include "AliCDBEntry.h" |
8309c1ab | 42 | #include "AliZDCSDigit.h" |
43 | #include "AliZDCDigit.h" | |
44 | #include "AliZDCFragment.h" | |
a18a0543 | 45 | #include "AliZDCv3.h" |
8309c1ab | 46 | #include "AliZDCDigitizer.h" |
8a2624cc | 47 | |
48 | class AliCDBStorage; | |
6024ec85 | 49 | class AliZDCPedestals; |
8309c1ab | 50 | |
51 | ClassImp(AliZDCDigitizer) | |
52 | ||
53 | ||
54 | //____________________________________________________________________________ | |
a718c993 | 55 | AliZDCDigitizer::AliZDCDigitizer() : |
56 | fIsCalibration(0), | |
fd9afd60 | 57 | fIsSignalInADCGate(kFALSE), |
58 | fFracLostSignal(0.), | |
a718c993 | 59 | fPedData(0), |
2d9c70ab | 60 | fSpectators2Track(kFALSE), |
61 | fBeamEnergy(0.) | |
8309c1ab | 62 | { |
698e394d | 63 | // Default constructor |
8309c1ab | 64 | |
65 | } | |
66 | ||
67 | //____________________________________________________________________________ | |
68 | AliZDCDigitizer::AliZDCDigitizer(AliRunDigitizer* manager): | |
a718c993 | 69 | AliDigitizer(manager), |
70 | fIsCalibration(0), //By default the simulation doesn't create calib. data | |
fd9afd60 | 71 | fIsSignalInADCGate(kFALSE), |
72 | fFracLostSignal(0.), | |
a718c993 | 73 | fPedData(GetPedData()), |
2d9c70ab | 74 | fSpectators2Track(kFALSE), |
75 | fBeamEnergy(0.) | |
8309c1ab | 76 | { |
78d18275 | 77 | // Get calibration data |
d27e20dd | 78 | if(fIsCalibration!=0) printf("\n\t AliZDCDigitizer -> Creating calibration data (pedestals)\n"); |
edb4e893 | 79 | for(Int_t i=0; i<5; i++){ |
698e394d | 80 | for(Int_t j=0; j<5; j++) |
81 | fPMGain[i][j] = 0.; | |
82 | } | |
8309c1ab | 83 | } |
84 | ||
85 | //____________________________________________________________________________ | |
86 | AliZDCDigitizer::~AliZDCDigitizer() | |
87 | { | |
88 | // Destructor | |
a718c993 | 89 | // Not implemented |
8309c1ab | 90 | } |
91 | ||
92 | ||
cc2abffd | 93 | //____________________________________________________________________________ |
94 | AliZDCDigitizer::AliZDCDigitizer(const AliZDCDigitizer &digitizer): | |
a718c993 | 95 | AliDigitizer(), |
96 | fIsCalibration(digitizer.fIsCalibration), | |
fd9afd60 | 97 | fIsSignalInADCGate(digitizer.fIsSignalInADCGate), |
98 | fFracLostSignal(digitizer.fFracLostSignal), | |
a718c993 | 99 | fPedData(digitizer.fPedData), |
2d9c70ab | 100 | fSpectators2Track(digitizer.fSpectators2Track), |
101 | fBeamEnergy(digitizer.fBeamEnergy) | |
cc2abffd | 102 | { |
103 | // Copy constructor | |
104 | ||
edb4e893 | 105 | for(Int_t i=0; i<5; i++){ |
cc2abffd | 106 | for(Int_t j=0; j<5; j++){ |
107 | fPMGain[i][j] = digitizer.fPMGain[i][j]; | |
108 | } | |
109 | } | |
110 | for(Int_t i=0; i<2; i++) fADCRes[i] = digitizer.fADCRes[i]; | |
cc2abffd | 111 | |
12434381 | 112 | |
cc2abffd | 113 | } |
114 | ||
8309c1ab | 115 | //____________________________________________________________________________ |
116 | Bool_t AliZDCDigitizer::Init() | |
117 | { | |
48642b09 | 118 | // Initialize the digitizer |
12434381 | 119 | |
120 | AliCDBEntry* entry = AliCDBManager::Instance()->Get("GRP/GRP/Data"); | |
121 | AliGRPObject* grpData = 0x0; | |
122 | if(entry){ | |
123 | TMap* m = dynamic_cast<TMap*>(entry->GetObject()); // old GRP entry | |
124 | if(m){ | |
125 | //m->Print(); | |
126 | grpData = new AliGRPObject(); | |
127 | grpData->ReadValuesFromMap(m); | |
128 | } | |
129 | else{ | |
130 | grpData = dynamic_cast<AliGRPObject*>(entry->GetObject()); // new GRP entry | |
131 | } | |
132 | entry->SetOwner(0); | |
133 | AliCDBManager::Instance()->UnloadFromCache("GRP/GRP/Data"); | |
134 | } | |
135 | if(!grpData) AliError("No GRP entry found in OCDB!"); | |
136 | ||
137 | TString beamType = grpData->GetBeamType(); | |
138 | if(beamType==AliGRPObject::GetInvalidString()){ | |
139 | AliError("\t UNKNOWN beam type from GRP obj -> PMT gains not set in ZDC digitizer!!!\n"); | |
140 | } | |
141 | ||
2d9c70ab | 142 | fBeamEnergy = grpData->GetBeamEnergy(); |
143 | if(fBeamEnergy==AliGRPObject::GetInvalidFloat()){ | |
12434381 | 144 | AliWarning("GRP/GRP/Data entry: missing value for the beam energy ! Using 0."); |
145 | AliError("\t UNKNOWN beam type from GRP obj -> PMT gains not set in ZDC digitizer!!!\n"); | |
2d9c70ab | 146 | fBeamEnergy = 0.; |
12434381 | 147 | } |
b553507a | 148 | |
2d9c70ab | 149 | if((beamType.CompareTo("P-P")) == 0 || (beamType.CompareTo("p-p")) == 0){ |
12434381 | 150 | //PTM gains rescaled to beam energy for p-p |
2d9c70ab | 151 | if(fBeamEnergy != 0){ |
4df5e18f | 152 | for(Int_t j = 0; j < 5; j++){ |
153 | fPMGain[0][j] = 1.515831*(661.444/fBeamEnergy+0.000740671)*10000000; | |
154 | fPMGain[1][j] = 0.674234*(864.350/fBeamEnergy+0.00234375)*10000000; | |
155 | fPMGain[3][j] = 1.350938*(661.444/fBeamEnergy+0.000740671)*10000000; | |
156 | fPMGain[4][j] = 0.678597*(864.350/fBeamEnergy+0.00234375)*10000000; | |
157 | } | |
158 | fPMGain[2][1] = 0.869654*(1.32312-0.000101515*fBeamEnergy)*10000000; | |
159 | fPMGain[2][2] = 1.030883*(1.32312-0.000101515*fBeamEnergy)*10000000; | |
160 | AliInfo(Form(" PMT gains for p-p @ %1.0f+%1.0f GeV: ZN(%1.0f), ZP(%1.0f), ZEM(%1.0f)\n", | |
161 | fBeamEnergy, fBeamEnergy, fPMGain[0][0], fPMGain[1][0], fPMGain[2][1])); | |
12434381 | 162 | } |
163 | } | |
f91d1e35 | 164 | else if((beamType.CompareTo("A-A")) == 0){ |
2d9c70ab | 165 | // PTM gains for Pb-Pb @ 2.7+2.7 A TeV *************** |
166 | // rescaled for Pb-Pb @ 1.38+1.38 A TeV *************** | |
2413fd18 | 167 | // New correction coefficients for PMT gains needed |
168 | // to reproduce experimental spectra (from Grazia Jul 2010) | |
2d9c70ab | 169 | Float_t scalGainFactor = fBeamEnergy/2760.; |
12434381 | 170 | for(Int_t j = 0; j < 5; j++){ |
7cf15420 | 171 | fPMGain[0][j] = 50000./scalGainFactor; |
172 | fPMGain[1][j] = 100000./scalGainFactor; | |
edb4e893 | 173 | fPMGain[2][j] = 100000./scalGainFactor; |
7cf15420 | 174 | fPMGain[3][j] = 50000./scalGainFactor; |
edb4e893 | 175 | fPMGain[4][j] = 100000./scalGainFactor; |
12434381 | 176 | } |
2d9c70ab | 177 | AliInfo(Form(" PMT gains for Pb-Pb @ %1.0f+%1.0f A GeV: ZN(%1.0f), ZP(%1.0f), ZEM(%1.0f)\n", |
4df5e18f | 178 | fBeamEnergy, fBeamEnergy, fPMGain[0][0], fPMGain[1][0], fPMGain[2][1])); |
12434381 | 179 | } |
698e394d | 180 | |
181 | // ADC Caen V965 | |
7f73eb6b | 182 | fADCRes[0] = 0.0000008; // ADC Resolution high gain: 200 fC/adcCh |
183 | fADCRes[1] = 0.0000064; // ADC Resolution low gain: 25 fC/adcCh | |
8309c1ab | 184 | |
185 | return kTRUE; | |
186 | } | |
187 | ||
188 | //____________________________________________________________________________ | |
189 | void AliZDCDigitizer::Exec(Option_t* /*option*/) | |
190 | { | |
48642b09 | 191 | // Execute digitization |
8309c1ab | 192 | |
d79f8d50 | 193 | // ------------------------------------------------------------ |
f91d1e35 | 194 | // !!! 2nd ZDC set added |
195 | // *** 1st 3 arrays are digits from REAL (simulated) hits | |
196 | // *** last 2 are copied from simulated digits | |
fd9afd60 | 197 | // --- pm[0][...] = light in ZN side C [C, Q1, Q2, Q3, Q4] |
198 | // --- pm[1][...] = light in ZP side C [C, Q1, Q2, Q3, Q4] | |
48642b09 | 199 | // --- pm[2][...] = light in ZEM [x, 1, 2, x, x] |
fd9afd60 | 200 | // --- pm[3][...] = light in ZN side A [C, Q1, Q2, Q3, Q4] ->NEW! |
201 | // --- pm[4][...] = light in ZP side A [C, Q1, Q2, Q3, Q4] ->NEW! | |
d79f8d50 | 202 | // ------------------------------------------------------------ |
203 | Float_t pm[5][5]; | |
8574b308 | 204 | for(Int_t iSector1=0; iSector1<5; iSector1++) |
205 | for(Int_t iSector2=0; iSector2<5; iSector2++){ | |
8309c1ab | 206 | pm[iSector1][iSector2] = 0; |
207 | } | |
d79f8d50 | 208 | |
209 | // ------------------------------------------------------------ | |
210 | // ### Out of time ADC added (22 channels) | |
211 | // --- same codification as for signal PTMs (see above) | |
212 | // ------------------------------------------------------------ | |
213 | Float_t pmoot[5][5]; | |
8574b308 | 214 | for(Int_t iSector1=0; iSector1<5; iSector1++) |
215 | for(Int_t iSector2=0; iSector2<5; iSector2++){ | |
d79f8d50 | 216 | pmoot[iSector1][iSector2] = 0; |
217 | } | |
8309c1ab | 218 | |
219 | // impact parameter and number of spectators | |
220 | Float_t impPar = -1; | |
fd9afd60 | 221 | Int_t specNTarg = 0, specPTarg = 0; |
222 | Int_t specNProj = 0, specPProj = 0; | |
a18a0543 | 223 | Float_t signalTime0 = 0.; |
8309c1ab | 224 | |
225 | // loop over input streams | |
8574b308 | 226 | for(Int_t iInput = 0; iInput<fManager->GetNinputs(); iInput++){ |
8309c1ab | 227 | |
228 | // get run loader and ZDC loader | |
229 | AliRunLoader* runLoader = | |
230 | AliRunLoader::GetRunLoader(fManager->GetInputFolderName(iInput)); | |
231 | AliLoader* loader = runLoader->GetLoader("ZDCLoader"); | |
8574b308 | 232 | if(!loader) continue; |
8309c1ab | 233 | |
234 | // load sdigits | |
235 | loader->LoadSDigits(); | |
236 | TTree* treeS = loader->TreeS(); | |
8574b308 | 237 | if(!treeS) continue; |
8309c1ab | 238 | AliZDCSDigit sdigit; |
239 | AliZDCSDigit* psdigit = &sdigit; | |
240 | treeS->SetBranchAddress("ZDC", &psdigit); | |
241 | ||
242 | // loop over sdigits | |
8574b308 | 243 | for(Int_t iSDigit=0; iSDigit<treeS->GetEntries(); iSDigit++){ |
8309c1ab | 244 | treeS->GetEntry(iSDigit); |
7f73eb6b | 245 | // |
8574b308 | 246 | if(!psdigit) continue; |
247 | if((sdigit.GetSector(1) < 0) || (sdigit.GetSector(1) > 4)){ | |
8309c1ab | 248 | AliError(Form("\nsector[0] = %d, sector[1] = %d\n", |
249 | sdigit.GetSector(0), sdigit.GetSector(1))); | |
250 | continue; | |
251 | } | |
fd9afd60 | 252 | // Checking if signal is inside ADC gate |
253 | if(iSDigit==0) signalTime0 = sdigit.GetTrackTime(); | |
254 | else{ | |
255 | // Assuming a signal lenght of 20 ns, signal is in gate if | |
256 | // signal ENDS in signalTime0+50. -> sdigit.GetTrackTime()+20<=signalTime0+50. | |
257 | if(sdigit.GetTrackTime()<=signalTime0+30.) fIsSignalInADCGate = kTRUE; | |
258 | if(sdigit.GetTrackTime()>signalTime0+30.){ | |
259 | fIsSignalInADCGate = kFALSE; | |
260 | // Vedi quaderno per spiegazione approx. usata | |
261 | // nel calcolo della fraz. di segnale perso | |
262 | fFracLostSignal = (sdigit.GetTrackTime()-30)*(sdigit.GetTrackTime()-30)/280.; | |
263 | } | |
264 | } | |
698e394d | 265 | |
fd9afd60 | 266 | Float_t sdSignal = sdigit.GetLightPM(); |
267 | if(fIsSignalInADCGate == kFALSE){ | |
7e858b1d | 268 | AliDebug(2,Form("\t Signal time %f -> fraction %f of ZDC signal for det.(%d, %d) out of ADC gate\n", |
0fba8107 | 269 | sdigit.GetTrackTime(),fFracLostSignal,sdigit.GetSector(0),sdigit.GetSector(1))); |
fd9afd60 | 270 | sdSignal = (1-fFracLostSignal)*sdSignal; |
271 | } | |
272 | ||
48642b09 | 273 | pm[(sdigit.GetSector(0))-1][sdigit.GetSector(1)] += sdigit.GetLightPM(); |
698e394d | 274 | //Ch. debug |
275 | /*printf("\t Detector %d, Tower %d -> pm[%d][%d] = %.0f \n", | |
48642b09 | 276 | sdigit.GetSector(0), sdigit.GetSector(1),sdigit.GetSector(0)-1, |
698e394d | 277 | sdigit.GetSector(1), pm[sdigit.GetSector(0)-1][sdigit.GetSector(1)]); |
878fa0b3 | 278 | */ |
fd9afd60 | 279 | |
8309c1ab | 280 | } |
281 | ||
8309c1ab | 282 | loader->UnloadSDigits(); |
283 | ||
284 | // get the impact parameter and the number of spectators in case of hijing | |
8574b308 | 285 | if(!runLoader->GetAliRun()) runLoader->LoadgAlice(); |
d3b3a3b2 | 286 | AliHeader* header = runLoader->GetHeader(); |
8574b308 | 287 | if(!header) continue; |
8309c1ab | 288 | AliGenEventHeader* genHeader = header->GenEventHeader(); |
8574b308 | 289 | if(!genHeader) continue; |
290 | if(!genHeader->InheritsFrom(AliGenHijingEventHeader::Class())) continue; | |
a18a0543 | 291 | |
70ecaffe | 292 | if(fSpectators2Track==kTRUE){ |
a18a0543 | 293 | impPar = ((AliGenHijingEventHeader*) genHeader)->ImpactParameter(); |
294 | specNProj = ((AliGenHijingEventHeader*) genHeader)->ProjSpectatorsn(); | |
295 | specPProj = ((AliGenHijingEventHeader*) genHeader)->ProjSpectatorsp(); | |
296 | specNTarg = ((AliGenHijingEventHeader*) genHeader)->TargSpectatorsn(); | |
297 | specPTarg = ((AliGenHijingEventHeader*) genHeader)->TargSpectatorsp(); | |
298 | printf("\n\t AliZDCDigitizer: b = %1.2f fm\n" | |
299 | " \t PROJ.: #spectator n %d, #spectator p %d\n" | |
2413fd18 | 300 | " \t TARG.: #spectator n %d, #spectator p %d\n", |
a18a0543 | 301 | impPar, specNProj, specPProj, specNTarg, specPTarg); |
302 | } | |
303 | ||
8309c1ab | 304 | } |
305 | ||
fd9afd60 | 306 | // Applying fragmentation algorithm and adding spectator signal |
70ecaffe | 307 | if(fSpectators2Track==kTRUE && impPar) { |
fd9afd60 | 308 | Int_t freeSpecNProj, freeSpecPProj; |
309 | Fragmentation(impPar, specNProj, specPProj, freeSpecNProj, freeSpecPProj); | |
310 | Int_t freeSpecNTarg, freeSpecPTarg; | |
311 | Fragmentation(impPar, specNTarg, specPTarg, freeSpecNTarg, freeSpecPTarg); | |
312 | SpectatorSignal(1, freeSpecNProj, pm); | |
2413fd18 | 313 | printf("\t AliZDCDigitizer -> Adding signal for %d PROJ free spectator n",freeSpecNProj); |
fd9afd60 | 314 | SpectatorSignal(2, freeSpecPProj, pm); |
2413fd18 | 315 | printf(" and %d free spectator p\n",freeSpecPProj); |
fd9afd60 | 316 | SpectatorSignal(3, freeSpecNTarg, pm); |
2413fd18 | 317 | printf("\t AliZDCDigitizer -> Adding signal for %d TARG free spectator n",freeSpecNTarg); |
fd9afd60 | 318 | SpectatorSignal(4, freeSpecPTarg, pm); |
2413fd18 | 319 | printf(" and %d free spectator p\n\n",freeSpecPTarg); |
8309c1ab | 320 | } |
321 | ||
8a2624cc | 322 | |
8309c1ab | 323 | // get the output run loader and loader |
324 | AliRunLoader* runLoader = | |
325 | AliRunLoader::GetRunLoader(fManager->GetOutputFolderName()); | |
326 | AliLoader* loader = runLoader->GetLoader("ZDCLoader"); | |
8574b308 | 327 | if(!loader) { |
8309c1ab | 328 | AliError("no ZDC loader found"); |
329 | return; | |
330 | } | |
331 | ||
332 | // create the output tree | |
333 | const char* mode = "update"; | |
8574b308 | 334 | if(runLoader->GetEventNumber() == 0) mode = "recreate"; |
8309c1ab | 335 | loader->LoadDigits(mode); |
336 | loader->MakeTree("D"); | |
337 | TTree* treeD = loader->TreeD(); | |
338 | AliZDCDigit digit; | |
339 | AliZDCDigit* pdigit = &digit; | |
340 | const Int_t kBufferSize = 4000; | |
341 | treeD->Branch("ZDC", "AliZDCDigit", &pdigit, kBufferSize); | |
342 | ||
343 | // Create digits | |
80e87581 | 344 | Int_t sector[2]; |
345 | Int_t digi[2], digioot[2]; | |
346 | for(sector[0]=1; sector[0]<6; sector[0]++){ | |
abf60186 | 347 | for(sector[1]=0; sector[1]<5; sector[1]++){ |
348 | if((sector[0]==3) && ((sector[1]<1) || (sector[1]>2))) continue; | |
8574b308 | 349 | for(Int_t res=0; res<2; res++){ |
abf60186 | 350 | digi[res] = Phe2ADCch(sector[0], sector[1], pm[sector[0]-1][sector[1]], res) |
48642b09 | 351 | + Pedestal(sector[0], sector[1], res); |
7f73eb6b | 352 | } |
abf60186 | 353 | new(pdigit) AliZDCDigit(sector, digi); |
8309c1ab | 354 | treeD->Fill(); |
698e394d | 355 | |
356 | //Ch. debug | |
357 | //printf("\t DIGIT added -> det %d quad %d - digi[0,1] = [%d, %d]\n", | |
358 | // sector[0], sector[1], digi[0], digi[1]); // Chiara debugging! | |
359 | ||
8309c1ab | 360 | } |
83347831 | 361 | } // Loop over detector |
362 | // Adding in-time digits for 2 reference PTM signals (after signal ch.) | |
363 | // (for the moment the ref. signal is completely invented assuming a PMgain of 5*10^4!) | |
364 | Int_t sectorRef[2]; | |
365 | sectorRef[1] = 5; | |
9d38ced8 | 366 | Int_t sigRef[2]; |
80e87581 | 367 | // Reference signal are set to 100 (high gain chain) and 800 (low gain chain) |
9d38ced8 | 368 | if(fIsCalibration==0) {sigRef[0]=100; sigRef[1]=800;} |
80e87581 | 369 | else {sigRef[0]=0; sigRef[1]=0;} // calibration -> simulation of pedestal values |
9d38ced8 | 370 | // |
83347831 | 371 | for(Int_t iref=0; iref<2; iref++){ |
372 | sectorRef[0] = 3*iref+1; | |
373 | for(Int_t res=0; res<2; res++){ | |
374 | sigRef[res] += Pedestal(sectorRef[0], sectorRef[1], res); | |
375 | } | |
83347831 | 376 | new(pdigit) AliZDCDigit(sectorRef, sigRef); |
377 | treeD->Fill(); | |
698e394d | 378 | |
379 | //Ch. debug | |
380 | //printf("\t RefDigit added -> det = %d, quad = %d - digi[0,1] = [%d, %d]\n", | |
381 | // sectorRef[0], sectorRef[1], sigRef[0], sigRef[1]); // Chiara debugging! | |
abf60186 | 382 | } |
d79f8d50 | 383 | // |
384 | // --- Adding digits for out-of-time channels after signal digits | |
80e87581 | 385 | for(sector[0]=1; sector[0]<6; sector[0]++){ |
d79f8d50 | 386 | for(sector[1]=0; sector[1]<5; sector[1]++){ |
387 | if((sector[0]==3) && ((sector[1]<1) || (sector[1]>2))) continue; | |
8574b308 | 388 | for(Int_t res=0; res<2; res++){ |
d79f8d50 | 389 | digioot[res] = Pedestal(sector[0], sector[1], res); // out-of-time ADCs |
390 | } | |
d79f8d50 | 391 | new(pdigit) AliZDCDigit(sector, digioot); |
392 | treeD->Fill(); | |
698e394d | 393 | |
394 | //Ch. debug | |
395 | //printf("\t DIGIToot added -> det = %d, quad = %d - digi[0,1] = [%d, %d]\n", | |
396 | // sector[0], sector[1], digioot[0], digioot[1]); // Chiara debugging! | |
d79f8d50 | 397 | } |
398 | } | |
83347831 | 399 | // Adding out-of-time digits for 2 reference PTM signals (after out-of-time ch.) |
400 | Int_t sigRefoot[2]; | |
401 | for(Int_t iref=0; iref<2; iref++){ | |
402 | sectorRef[0] = 3*iref+1; | |
403 | for(Int_t res=0; res<2; res++){ | |
404 | sigRefoot[res] = Pedestal(sectorRef[0], sectorRef[1], res); | |
405 | } | |
83347831 | 406 | new(pdigit) AliZDCDigit(sectorRef, sigRefoot); |
407 | treeD->Fill(); | |
698e394d | 408 | //Ch. debug |
409 | //printf("\t RefDigitoot added -> det = %d, quad = %d - digi[0,1] = [%d, %d]\n", | |
410 | // sectorRef[0], sectorRef[1], sigRefoot[0], sigRefoot[1]); // Chiara debugging! | |
411 | ||
83347831 | 412 | } |
413 | //printf("\t AliZDCDigitizer -> TreeD has %d entries\n",(Int_t) treeD->GetEntries()); | |
414 | ||
8309c1ab | 415 | // write the output tree |
416 | loader->WriteDigits("OVERWRITE"); | |
417 | loader->UnloadDigits(); | |
418 | } | |
419 | ||
420 | ||
421 | //_____________________________________________________________________________ | |
422 | void AliZDCDigitizer::Fragmentation(Float_t impPar, Int_t specN, Int_t specP, | |
423 | Int_t &freeSpecN, Int_t &freeSpecP) const | |
424 | { | |
425 | // simulate fragmentation of spectators | |
426 | ||
8309c1ab | 427 | AliZDCFragment frag(impPar); |
8309c1ab | 428 | |
429 | // Fragments generation | |
92339a90 | 430 | frag.GenerateIMF(); |
431 | Int_t nAlpha = frag.GetNalpha(); | |
8309c1ab | 432 | |
433 | // Attach neutrons | |
98711e01 | 434 | frag.AttachNeutrons(); |
92339a90 | 435 | Int_t ztot = frag.GetZtot(); |
436 | Int_t ntot = frag.GetNtot(); | |
98711e01 | 437 | |
438 | // Removing fragments and alpha pcs | |
8309c1ab | 439 | freeSpecN = specN-ntot-2*nAlpha; |
440 | freeSpecP = specP-ztot-2*nAlpha; | |
98711e01 | 441 | |
3848c666 | 442 | // Removing deuterons |
a0607c1f | 443 | Int_t ndeu = (Int_t) (freeSpecN*frag.DeuteronNumber()); |
3848c666 | 444 | freeSpecN -= ndeu; |
98711e01 | 445 | freeSpecP -= ndeu; |
3848c666 | 446 | // |
8309c1ab | 447 | if(freeSpecN<0) freeSpecN=0; |
448 | if(freeSpecP<0) freeSpecP=0; | |
449 | AliDebug(2, Form("FreeSpn = %d, FreeSpp = %d", freeSpecN, freeSpecP)); | |
450 | } | |
451 | ||
452 | //_____________________________________________________________________________ | |
453 | void AliZDCDigitizer::SpectatorSignal(Int_t SpecType, Int_t numEvents, | |
fd9afd60 | 454 | Float_t pm[5][5]) const |
8309c1ab | 455 | { |
456 | // add signal of the spectators | |
fd9afd60 | 457 | |
2d9c70ab | 458 | TFile *specSignalFile = TFile::Open("$ALICE_ROOT/ZDC/SpectatorSignal.root"); |
459 | if(!specSignalFile || !specSignalFile->IsOpen()) { | |
460 | AliError((" Opening file $ALICE_ROOT/ZDC/SpectatorSignal.root failed\n")); | |
461 | return; | |
8309c1ab | 462 | } |
2d9c70ab | 463 | |
e7eabc21 | 464 | TNtuple* zdcSignal=0x0; |
2d9c70ab | 465 | |
466 | Float_t sqrtS = 2*fBeamEnergy; | |
467 | // | |
468 | if(TMath::Abs(sqrtS-5500) < 100.){ | |
469 | specSignalFile->cd("energy5500"); | |
470 | // | |
471 | if(SpecType == 1) { // --- Signal for projectile spectator neutrons | |
472 | specSignalFile->GetObject("energy5500/ZNCSignal;1",zdcSignal); | |
473 | if(!zdcSignal) AliError(" PROBLEM!!! Can't retrieve ZNCSignal from SpectatorSignal.root file"); | |
474 | } | |
475 | else if(SpecType == 2) { // --- Signal for projectile spectator protons | |
476 | specSignalFile->GetObject("energy5500/ZPCSignal;1",zdcSignal); | |
477 | if(!zdcSignal) AliError(" PROBLEM!!! Can't retrieve ZPCSignal from SpectatorSignal.root file"); | |
478 | } | |
479 | else if(SpecType == 3) { // --- Signal for target spectator neutrons | |
480 | specSignalFile->GetObject("energy5500/ZNASignal;1",zdcSignal); | |
481 | if(!zdcSignal) AliError(" PROBLEM!!! Can't retrieve ZNASignal from SpectatorSignal.root file"); | |
482 | } | |
483 | else if(SpecType == 4) { // --- Signal for target spectator protons | |
484 | specSignalFile->GetObject("energy5500/ZPASignal;1",zdcSignal); | |
485 | if(!zdcSignal) AliError(" PROBLEM!!! Can't retrieve ZPASignal from SpectatorSignal.root file"); | |
486 | } | |
fd9afd60 | 487 | } |
2d9c70ab | 488 | else if(TMath::Abs(sqrtS-2760) < 100.){ |
489 | specSignalFile->cd("energy2760"); | |
490 | // | |
491 | if(SpecType == 1) { // --- Signal for projectile spectator neutrons | |
492 | specSignalFile->GetObject("energy2760/ZNCSignal;1",zdcSignal); | |
493 | if(!zdcSignal) AliError(" PROBLEM!!! Can't retrieve ZNCSignal from SpectatorSignal.root file"); | |
494 | } | |
495 | else if(SpecType == 2) { // --- Signal for projectile spectator protons | |
496 | specSignalFile->GetObject("energy2760/ZPCSignal;1",zdcSignal); | |
497 | if(!zdcSignal) AliError(" PROBLEM!!! Can't retrieve ZPCSignal from SpectatorSignal.root file"); | |
498 | } | |
499 | else if(SpecType == 3) { // --- Signal for target spectator neutrons | |
500 | specSignalFile->GetObject("energy2760/ZNASignal;1",zdcSignal); | |
501 | if(!zdcSignal) AliError(" PROBLEM!!! Can't retrieve ZNASignal from SpectatorSignal.root file"); | |
502 | } | |
503 | else if(SpecType == 4) { // --- Signal for target spectator protons | |
504 | specSignalFile->GetObject("energy2760/ZPASignal;1",zdcSignal); | |
505 | if(!zdcSignal) AliError(" PROBLEM!!! Can't retrieve ZPASignal from SpectatorSignal.root file"); | |
506 | } | |
fd9afd60 | 507 | } |
508 | ||
8309c1ab | 509 | Int_t nentries = (Int_t) zdcSignal->GetEntries(); |
510 | ||
fd9afd60 | 511 | Float_t *entry; |
512 | Int_t pl, i, k, iev=0, rnd[125], volume[2]; | |
48642b09 | 513 | for(pl=0;pl<125;pl++) rnd[pl] = 0; |
8574b308 | 514 | if(numEvents > 125) { |
fea9b334 | 515 | AliDebug(2,Form("numEvents (%d) is larger than 125", numEvents)); |
8309c1ab | 516 | numEvents = 125; |
517 | } | |
518 | for(pl=0;pl<numEvents;pl++){ | |
519 | rnd[pl] = (Int_t) (9999*gRandom->Rndm()); | |
85a96223 | 520 | if(rnd[pl] >= 9999) rnd[pl] = 9998; |
8309c1ab | 521 | //printf(" rnd[%d] = %d\n",pl,rnd[pl]); |
522 | } | |
523 | // Sorting vector in ascending order with C function QSORT | |
524 | qsort((void*)rnd,numEvents,sizeof(Int_t),comp); | |
525 | do{ | |
526 | for(i=0; i<nentries; i++){ | |
527 | zdcSignal->GetEvent(i); | |
528 | entry = zdcSignal->GetArgs(); | |
529 | if(entry[0] == rnd[iev]){ | |
530 | for(k=0; k<2; k++) volume[k] = (Int_t) entry[k+1]; | |
48642b09 | 531 | // |
fd9afd60 | 532 | Float_t lightQ = entry[7]; |
533 | Float_t lightC = entry[8]; | |
534 | // | |
acf9550c | 535 | if(volume[0] != 3) { // ZN or ZP |
8309c1ab | 536 | pm[volume[0]-1][0] += lightC; |
537 | pm[volume[0]-1][volume[1]] += lightQ; | |
48642b09 | 538 | //printf("\n pm[%d][0] = %.0f, pm[%d][%d] = %.0f\n",(volume[0]-1),pm[volume[0]-1][0], |
539 | // (volume[0]-1),volume[1],pm[volume[0]-1][volume[1]]); | |
540 | } | |
541 | else { | |
8574b308 | 542 | if(volume[1] == 1) pm[2][1] += lightC; // ZEM 1 |
acf9550c | 543 | else pm[2][2] += lightQ; // ZEM 2 |
48642b09 | 544 | //printf("\n pm[2][1] = %.0f, pm[2][2] = %.0f\n",pm[2][1],pm[2][2]); |
545 | } | |
8309c1ab | 546 | } |
547 | else if(entry[0] > rnd[iev]){ | |
548 | iev++; | |
549 | continue; | |
550 | } | |
551 | } | |
552 | }while(iev<numEvents); | |
553 | ||
2d9c70ab | 554 | specSignalFile->Close(); |
555 | delete specSignalFile; | |
8309c1ab | 556 | } |
557 | ||
558 | ||
559 | //_____________________________________________________________________________ | |
560 | Int_t AliZDCDigitizer::Phe2ADCch(Int_t Det, Int_t Quad, Float_t Light, | |
561 | Int_t Res) const | |
562 | { | |
48642b09 | 563 | // Evaluation of the ADC channel corresponding to the light yield Light |
8a2624cc | 564 | Int_t vADCch = (Int_t) (Light * fPMGain[Det-1][Quad] * fADCRes[Res]); |
698e394d | 565 | // Ch. debug |
566 | //printf("\t Phe2ADCch -> det %d quad %d - PMGain[%d][%d] %1.0f phe %1.2f ADC %d\n", | |
567 | // Det,Quad,Det-1,Quad,fPMGain[Det-1][Quad],Light,vADCch); | |
7f73eb6b | 568 | |
8a2624cc | 569 | return vADCch; |
48642b09 | 570 | } |
8309c1ab | 571 | |
48642b09 | 572 | //_____________________________________________________________________________ |
573 | Int_t AliZDCDigitizer::Pedestal(Int_t Det, Int_t Quad, Int_t Res) const | |
574 | { | |
8a2624cc | 575 | // Returns a pedestal for detector det, PM quad, channel with res. |
576 | // | |
65b16e87 | 577 | Float_t pedValue; |
abf60186 | 578 | // Normal run |
579 | if(fIsCalibration == 0){ | |
c35ed519 | 580 | Int_t index=0, kNch=24; |
83347831 | 581 | if(Quad!=5){ |
c35ed519 | 582 | if(Det==1) index = Quad+kNch*Res; // ZNC |
583 | else if(Det==2) index = (Quad+5)+kNch*Res; // ZPC | |
584 | else if(Det==3) index = (Quad+9)+kNch*Res; // ZEM | |
585 | else if(Det==4) index = (Quad+12)+kNch*Res; // ZNA | |
586 | else if(Det==5) index = (Quad+17)+kNch*Res; // ZPA | |
83347831 | 587 | } |
c35ed519 | 588 | else index = (Det-1)/3+22+kNch*Res; // Reference PMs |
83347831 | 589 | // |
c35ed519 | 590 | Float_t meanPed = fPedData->GetMeanPed(index); |
591 | Float_t pedWidth = fPedData->GetMeanPedWidth(index); | |
65b16e87 | 592 | pedValue = gRandom->Gaus(meanPed,pedWidth); |
abf60186 | 593 | // |
58e12fee | 594 | /*printf("\t AliZDCDigitizer::Pedestal -> det %d quad %d res %d - Ped[%d] = %d\n", |
65b16e87 | 595 | Det, Quad, Res, index,(Int_t) pedValue); // Chiara debugging! |
abf60186 | 596 | */ |
597 | } | |
7f73eb6b | 598 | // To create calibration object |
83347831 | 599 | else{ |
65b16e87 | 600 | if(Res == 0) pedValue = gRandom->Gaus((35.+10.*gRandom->Rndm()),(0.5+0.2*gRandom->Rndm())); //High gain |
601 | else pedValue = gRandom->Gaus((250.+100.*gRandom->Rndm()),(3.5+2.*gRandom->Rndm())); //Low gain | |
83347831 | 602 | } |
dbc8d7fc | 603 | |
65b16e87 | 604 | return (Int_t) pedValue; |
8309c1ab | 605 | } |
606 | ||
607 | //_____________________________________________________________________________ | |
78d18275 | 608 | AliCDBStorage* AliZDCDigitizer::SetStorage(const char *uri) |
8309c1ab | 609 | { |
8309c1ab | 610 | |
78d18275 | 611 | Bool_t deleteManager = kFALSE; |
48642b09 | 612 | |
78d18275 | 613 | AliCDBManager *manager = AliCDBManager::Instance(); |
614 | AliCDBStorage *defstorage = manager->GetDefaultStorage(); | |
48642b09 | 615 | |
78d18275 | 616 | if(!defstorage || !(defstorage->Contains("ZDC"))){ |
617 | AliWarning("No default storage set or default storage doesn't contain ZDC!"); | |
618 | manager->SetDefaultStorage(uri); | |
619 | deleteManager = kTRUE; | |
620 | } | |
621 | ||
622 | AliCDBStorage *storage = manager->GetDefaultStorage(); | |
623 | ||
624 | if(deleteManager){ | |
625 | AliCDBManager::Instance()->UnsetDefaultStorage(); | |
626 | defstorage = 0; // the storage is killed by AliCDBManager::Instance()->Destroy() | |
627 | } | |
628 | ||
629 | return storage; | |
630 | } | |
48642b09 | 631 | |
78d18275 | 632 | //_____________________________________________________________________________ |
6024ec85 | 633 | AliZDCPedestals* AliZDCDigitizer::GetPedData() const |
634 | { | |
635 | ||
636 | // Getting pedestal calibration object for ZDC set | |
637 | ||
638 | AliCDBEntry *entry = AliCDBManager::Instance()->Get("ZDC/Calib/Pedestals"); | |
639 | if(!entry) AliFatal("No calibration data loaded!"); | |
640 | ||
641 | AliZDCPedestals *calibdata = dynamic_cast<AliZDCPedestals*> (entry->GetObject()); | |
642 | if(!calibdata) AliFatal("Wrong calibration object in calibration file!"); | |
643 | ||
644 | return calibdata; | |
645 | } | |
f91d1e35 | 646 |