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