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