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