]>
Commit | Line | Data |
---|---|---|
4c039060 | 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 | ||
88cb7938 | 16 | /* $Id$ */ |
4c039060 | 17 | |
fe4da5cc | 18 | /////////////////////////////////////////////////////////////////////////////// |
19 | // // | |
359cdddc | 20 | // Zero Degree Calorimeter // |
21 | // This class contains the basic functions for the ZDCs; // | |
22 | // functions specific to one particular geometry are // | |
23 | // contained in the derived classes // | |
fe4da5cc | 24 | // // |
fe4da5cc | 25 | /////////////////////////////////////////////////////////////////////////////// |
26 | ||
f901045b | 27 | // --- ROOT system |
fe4da5cc | 28 | #include <TBRIK.h> |
7ca4655f | 29 | #include <TClonesArray.h> |
88cb7938 | 30 | #include <TGeometry.h> |
31 | #include <TNode.h> | |
32 | #include <TTree.h> | |
232b622f | 33 | #include <TFile.h> |
8af17dba | 34 | #include <TSystem.h> |
90001c80 | 35 | #include <TRandom.h> |
fe4da5cc | 36 | |
f901045b | 37 | // --- AliRoot header files |
88cb7938 | 38 | #include "AliDetector.h" |
f7ee745b | 39 | #include "AliRawDataHeaderSim.h" |
90001c80 | 40 | #include "AliRawReader.h" |
41 | #include "AliLoader.h" | |
42 | #include "AliRun.h" | |
43 | #include "AliMC.h" | |
44 | #include "AliLog.h" | |
45 | #include "AliDAQ.h" | |
fe4da5cc | 46 | #include "AliZDC.h" |
f901045b | 47 | #include "AliZDCHit.h" |
6de91202 | 48 | #include "AliZDCSDigit.h" |
49 | #include "AliZDCDigit.h" | |
50 | #include "AliZDCDigitizer.h" | |
51 | #include "AliZDCRawStream.h" | |
6024ec85 | 52 | #include "AliZDCPedestals.h" |
53 | #include "AliZDCCalib.h" | |
54 | #include "AliZDCRecParam.h" | |
08f92f14 | 55 | #include "AliFstream.h" |
88cb7938 | 56 | |
fe4da5cc | 57 | |
58 | ClassImp(AliZDC) | |
8af17dba | 59 | |
fe4da5cc | 60 | //_____________________________________________________________________________ |
cc2abffd | 61 | AliZDC::AliZDC() : |
62 | AliDetector(), | |
a718c993 | 63 | fNoShower(0), |
6024ec85 | 64 | fPedCalib(0), |
65 | fCalibData(0), | |
a718c993 | 66 | fRecParam(0), |
67 | fZDCCalibFName("") | |
fe4da5cc | 68 | { |
69 | // | |
70 | // Default constructor for the Zero Degree Calorimeter base class | |
71 | // | |
2e6fc82a | 72 | |
cc2abffd | 73 | fIshunt = 1; |
74 | fNhits = 0; | |
75 | fHits = 0; | |
76 | fDigits = 0; | |
77 | fNdigits = 0; | |
d16dd065 | 78 | |
fe4da5cc | 79 | } |
80 | ||
81 | //_____________________________________________________________________________ | |
cc2abffd | 82 | AliZDC::AliZDC(const char *name, const char *title) : |
83 | AliDetector(name,title), | |
84 | fNoShower (0), | |
6024ec85 | 85 | fPedCalib(0), |
86 | fCalibData(0), | |
a718c993 | 87 | fRecParam(0), |
88 | fZDCCalibFName("") | |
fe4da5cc | 89 | { |
90 | // | |
91 | // Standard constructor for the Zero Degree Calorimeter base class | |
92 | // | |
cc2abffd | 93 | |
94 | fIshunt = 1; | |
95 | fNhits = 0; | |
96 | fDigits = 0; | |
97 | fNdigits = 0; | |
98 | ||
99 | fHits = new TClonesArray("AliZDCHit",1000); | |
5d12ce38 | 100 | gAlice->GetMCApp()->AddHitList(fHits); |
8af17dba | 101 | |
102 | char sensname[5],senstitle[25]; | |
103 | sprintf(sensname,"ZDC"); | |
104 | sprintf(senstitle,"ZDC dummy"); | |
105 | SetName(sensname); SetTitle(senstitle); | |
f901045b | 106 | |
866ab5a2 | 107 | } |
cc2abffd | 108 | |
866ab5a2 | 109 | //____________________________________________________________________________ |
110 | AliZDC::~AliZDC() | |
111 | { | |
112 | // | |
113 | // ZDC destructor | |
114 | // | |
115 | ||
cc2abffd | 116 | fIshunt = 0; |
6024ec85 | 117 | delete fPedCalib; |
d16dd065 | 118 | delete fCalibData; |
6024ec85 | 119 | delete fRecParam; |
d16dd065 | 120 | |
fe4da5cc | 121 | } |
cc2abffd | 122 | |
123 | //_____________________________________________________________________________ | |
124 | AliZDC::AliZDC(const AliZDC& ZDC) : | |
a718c993 | 125 | AliDetector("ZDC","ZDC"), |
126 | fNoShower(ZDC.fNoShower), | |
127 | fPedCalib(ZDC.fPedCalib), | |
128 | fCalibData(ZDC.fCalibData), | |
129 | fRecParam(ZDC.fRecParam), | |
130 | fZDCCalibFName(ZDC.fZDCCalibFName) | |
cc2abffd | 131 | { |
132 | // copy constructor | |
cc2abffd | 133 | } |
134 | ||
135 | //_____________________________________________________________________________ | |
136 | AliZDC& AliZDC::operator=(const AliZDC& ZDC) | |
137 | { | |
138 | // assignement operator | |
139 | if(this!=&ZDC){ | |
140 | fNoShower = ZDC.fNoShower; | |
6024ec85 | 141 | fPedCalib = ZDC.fPedCalib; |
cc2abffd | 142 | fCalibData = ZDC.fCalibData; |
6024ec85 | 143 | fRecParam = ZDC.fRecParam; |
cc2abffd | 144 | fZDCCalibFName = ZDC.fZDCCalibFName; |
145 | } return *this; | |
146 | } | |
147 | ||
fe4da5cc | 148 | //_____________________________________________________________________________ |
149 | void AliZDC::AddHit(Int_t track, Int_t *vol, Float_t *hits) | |
150 | { | |
151 | // | |
f901045b | 152 | // Add a ZDC hit to the hit list. |
153 | // -> We make use of 2 array of hits: | |
154 | // [1] fHits (the usual one) that contains hits for each PRIMARY | |
155 | // [2] fStHits that contains hits for each EVENT and is used to | |
156 | // obtain digits at the end of each event | |
fe4da5cc | 157 | // |
f901045b | 158 | |
68ca986e | 159 | static Float_t primKinEn, xImpact, yImpact, sFlag; |
160 | ||
43f34e8b | 161 | AliZDCHit *newquad, *curprimquad; |
f901045b | 162 | newquad = new AliZDCHit(fIshunt, track, vol, hits); |
65d4f2be | 163 | TClonesArray &lhits = *fHits; |
cefa66cb | 164 | |
165 | if(fNhits==0){ | |
166 | // First hit -> setting flag for primary or secondary particle | |
5d12ce38 | 167 | Int_t primary = gAlice->GetMCApp()->GetPrimary(track); |
cefa66cb | 168 | if(track != primary){ |
3ff116f2 | 169 | newquad->SetSFlag(1); // SECONDARY particle entering the ZDC |
cefa66cb | 170 | } |
171 | else if(track == primary){ | |
3ff116f2 | 172 | newquad->SetSFlag(0); // PRIMARY particle entering the ZDC |
cefa66cb | 173 | } |
3ff116f2 | 174 | sFlag = newquad->GetSFlag(); |
175 | primKinEn = newquad->GetPrimKinEn(); | |
176 | xImpact = newquad->GetXImpact(); | |
177 | yImpact = newquad->GetYImpact(); | |
cefa66cb | 178 | } |
179 | else{ | |
3ff116f2 | 180 | newquad->SetPrimKinEn(primKinEn); |
181 | newquad->SetXImpact(xImpact); | |
182 | newquad->SetYImpact(yImpact); | |
183 | newquad->SetSFlag(sFlag); | |
cefa66cb | 184 | } |
185 | ||
43f34e8b | 186 | Int_t j; |
f901045b | 187 | for(j=0; j<fNhits; j++){ |
2e6fc82a | 188 | // If hits are equal (same track, same volume), sum them. |
f901045b | 189 | curprimquad = (AliZDCHit*) lhits[j]; |
190 | if(*curprimquad == *newquad){ | |
191 | *curprimquad = *curprimquad+*newquad; | |
cc2abffd | 192 | // CH. debug |
193 | /*if(newquad->GetEnergy() != 0. || newquad->GetLightPMC() != 0. || | |
194 | newquad->GetLightPMQ() != 0.){ | |
195 | printf("\n\t --- Equal hits found\n"); | |
196 | curprimquad->Print(""); | |
197 | newquad->Print(""); | |
198 | printf("\t --- Det. %d, Quad. %d: X = %f, E = %f, LightPMC = %f, LightPMQ = %f\n", | |
199 | curprimquad->GetVolume(0),curprimquad->GetVolume(1),curprimquad->GetXImpact(), | |
200 | curprimquad->GetEnergy(), curprimquad->GetLightPMC(), curprimquad->GetLightPMQ()); | |
201 | }*/ | |
202 | // | |
f901045b | 203 | delete newquad; |
68ca986e | 204 | return; |
f901045b | 205 | } |
206 | } | |
f901045b | 207 | |
208 | //Otherwise create a new hit | |
cc2abffd | 209 | new(lhits[fNhits]) AliZDCHit(*newquad); |
f901045b | 210 | fNhits++; |
cc2abffd | 211 | // CH. debug |
212 | /*printf("\n\t New ZDC hit added! fNhits = %d\n", fNhits); | |
213 | printf("\t Det. %d, Quad.t %d: X = %f, E = %f, LightPMC = %f, LightPMQ = %f\n", | |
214 | newquad->GetVolume(0),newquad->GetVolume(1),newquad->GetXImpact(), | |
215 | newquad->GetEnergy(), newquad->GetLightPMC(), newquad->GetLightPMQ()); | |
216 | */ | |
866ab5a2 | 217 | delete newquad; |
cefa66cb | 218 | } |
219 | ||
fe4da5cc | 220 | //_____________________________________________________________________________ |
221 | void AliZDC::BuildGeometry() | |
222 | { | |
223 | // | |
224 | // Build the ROOT TNode geometry for event display | |
225 | // in the Zero Degree Calorimeter | |
226 | // This routine is dummy for the moment | |
227 | // | |
228 | ||
68ca986e | 229 | TNode *node, *top; |
230 | TBRIK *brik; | |
359cdddc | 231 | const int kColorZDC = kBlue; |
fe4da5cc | 232 | |
233 | // | |
68ca986e | 234 | top=gAlice->GetGeometry()->GetNode("alice"); |
fe4da5cc | 235 | |
236 | // ZDC | |
6024ec85 | 237 | brik = new TBRIK("S_ZDC","ZDC box","void",300,300,5); |
238 | top->cd(); | |
239 | node = new TNode("ZDC","ZDC","S_ZDC",0,0,600,""); | |
240 | node->SetLineColor(kColorZDC); | |
241 | fNodes->Add(node); | |
fe4da5cc | 242 | } |
243 | ||
359cdddc | 244 | //____________________________________________________________________________ |
245 | Float_t AliZDC::ZMin(void) const | |
246 | { | |
247 | // Minimum dimension of the ZDC module in z | |
6de91202 | 248 | return -11600.; |
359cdddc | 249 | } |
250 | ||
251 | //____________________________________________________________________________ | |
252 | Float_t AliZDC::ZMax(void) const | |
253 | { | |
254 | // Maximum dimension of the ZDC module in z | |
6de91202 | 255 | return -11750.; |
359cdddc | 256 | } |
257 | ||
258 | ||
fe4da5cc | 259 | //_____________________________________________________________________________ |
5bc762ca | 260 | void AliZDC::MakeBranch(Option_t *opt) |
fe4da5cc | 261 | { |
262 | // | |
359cdddc | 263 | // Create Tree branches for the ZDC |
fe4da5cc | 264 | // |
359cdddc | 265 | |
266 | char branchname[10]; | |
267 | sprintf(branchname,"%s",GetName()); | |
88cb7938 | 268 | |
269 | const char *cH = strstr(opt,"H"); | |
270 | ||
90001c80 | 271 | if(cH && fLoader->TreeH()) |
88cb7938 | 272 | fHits = new TClonesArray("AliZDCHit",1000); |
359cdddc | 273 | |
274 | AliDetector::MakeBranch(opt); | |
1450a7cd | 275 | } |
1450a7cd | 276 | |
b6d27557 | 277 | //_____________________________________________________________________________ |
278 | void AliZDC::Hits2SDigits() | |
279 | { | |
6de91202 | 280 | // Create summable digits from hits |
281 | ||
80e87581 | 282 | AliDebug(1,"\n Entering AliZDC::Hits2SDigits() "); |
b6d27557 | 283 | |
85a5290f | 284 | fLoader->LoadHits("read"); |
285 | fLoader->LoadSDigits("recreate"); | |
6de91202 | 286 | AliRunLoader* runLoader = fLoader->GetRunLoader(); |
287 | AliZDCSDigit sdigit; | |
288 | AliZDCSDigit* psdigit = &sdigit; | |
85a5290f | 289 | |
6de91202 | 290 | // Event loop |
90001c80 | 291 | for(Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) { |
80e87581 | 292 | Float_t pmCZNC=0, pmCZPC=0, pmCZNA=0, pmCZPA=0, pmZEM1 = 0, pmZEM2 = 0; |
293 | Float_t pmQZNC[4], pmQZPC[4], pmQZNA[4], pmQZPA[4]; | |
294 | for(Int_t i = 0; i < 4; i++) pmQZNC[i] = pmQZPC[i] = pmQZNA[i] = pmQZPA[i] = 0; | |
85a5290f | 295 | |
6de91202 | 296 | runLoader->GetEvent(iEvent); |
297 | TTree* treeH = fLoader->TreeH(); | |
359cdddc | 298 | Int_t ntracks = (Int_t) treeH->GetEntries(); |
6de91202 | 299 | ResetHits(); |
300 | ||
359cdddc | 301 | // Tracks loop |
6de91202 | 302 | Int_t sector[2]; |
90001c80 | 303 | for(Int_t itrack = 0; itrack < ntracks; itrack++) { |
6de91202 | 304 | treeH->GetEntry(itrack); |
90001c80 | 305 | for(AliZDCHit* zdcHit = (AliZDCHit*)FirstHit(-1); zdcHit; |
6de91202 | 306 | zdcHit = (AliZDCHit*)NextHit()) { |
b6d27557 | 307 | |
6de91202 | 308 | sector[0] = zdcHit->GetVolume(0); |
309 | sector[1] = zdcHit->GetVolume(1); | |
80e87581 | 310 | if((sector[1] < 1) || (sector[1] > 5)) { |
6de91202 | 311 | Error("Hits2SDigits", "sector[0] = %d, sector[1] = %d", |
312 | sector[0], sector[1]); | |
313 | continue; | |
314 | } | |
315 | Float_t lightQ = zdcHit->GetLightPMQ(); | |
316 | Float_t lightC = zdcHit->GetLightPMC(); | |
317 | ||
80e87581 | 318 | if(sector[0] == 1) { //ZNC |
319 | pmCZNC += lightC; | |
320 | pmQZNC[sector[1]-1] += lightQ; | |
321 | } | |
322 | else if(sector[0] == 2) { //ZPC | |
323 | pmCZPC += lightC; | |
324 | pmQZPC[sector[1]-1] += lightQ; | |
325 | } | |
326 | else if(sector[0] == 3) { //ZEM | |
90001c80 | 327 | if(sector[1] == 1) pmZEM1 += lightC; |
80e87581 | 328 | else pmZEM2 += lightQ; |
6de91202 | 329 | } |
80e87581 | 330 | if(sector[0] == 4) { //ZNA |
331 | pmCZNA += lightC; | |
332 | pmQZNA[sector[1]-1] += lightQ; | |
333 | } | |
334 | else if(sector[0] == 5) { //ZPA | |
335 | pmCZPA += lightC; | |
336 | pmQZPA[sector[1]-1] += lightQ; | |
337 | } | |
6de91202 | 338 | }//Hits loop |
359cdddc | 339 | } |
6de91202 | 340 | |
341 | // create the output tree | |
342 | fLoader->MakeTree("S"); | |
343 | TTree* treeS = fLoader->TreeS(); | |
344 | const Int_t kBufferSize = 4000; | |
345 | treeS->Branch(GetName(), "AliZDCSDigit", &psdigit, kBufferSize); | |
346 | ||
80e87581 | 347 | // Create sdigits for ZNC |
348 | sector[0] = 1; // Detector = ZNC | |
6de91202 | 349 | sector[1] = 0; // Common PM ADC |
80e87581 | 350 | new(psdigit) AliZDCSDigit(sector, pmCZNC); |
351 | if(pmCZNC > 0) treeS->Fill(); | |
90001c80 | 352 | for(Int_t j = 0; j < 4; j++) { |
6de91202 | 353 | sector[1] = j+1; // Towers PM ADCs |
80e87581 | 354 | new(psdigit) AliZDCSDigit(sector, pmQZNC[j]); |
355 | if(pmQZNC[j] > 0) treeS->Fill(); | |
b6d27557 | 356 | } |
359cdddc | 357 | |
80e87581 | 358 | // Create sdigits for ZPC |
359 | sector[0] = 2; // Detector = ZPC | |
6de91202 | 360 | sector[1] = 0; // Common PM ADC |
80e87581 | 361 | new(psdigit) AliZDCSDigit(sector, pmCZPC); |
362 | if(pmCZPC > 0) treeS->Fill(); | |
90001c80 | 363 | for(Int_t j = 0; j < 4; j++) { |
6de91202 | 364 | sector[1] = j+1; // Towers PM ADCs |
80e87581 | 365 | new(psdigit) AliZDCSDigit(sector, pmQZPC[j]); |
366 | if(pmQZPC[j] > 0) treeS->Fill(); | |
6de91202 | 367 | } |
368 | ||
369 | // Create sdigits for ZEM | |
370 | sector[0] = 3; | |
371 | sector[1] = 1; // Detector = ZEM1 | |
372 | new(psdigit) AliZDCSDigit(sector, pmZEM1); | |
90001c80 | 373 | if(pmZEM1 > 0) treeS->Fill(); |
6de91202 | 374 | sector[1] = 2; // Detector = ZEM2 |
375 | new(psdigit) AliZDCSDigit(sector, pmZEM2); | |
90001c80 | 376 | if(pmZEM2 > 0) treeS->Fill(); |
6de91202 | 377 | |
80e87581 | 378 | // Create sdigits for ZNA |
379 | sector[0] = 4; // Detector = ZNA | |
380 | sector[1] = 0; // Common PM ADC | |
381 | new(psdigit) AliZDCSDigit(sector, pmCZNA); | |
382 | if(pmCZNA > 0) treeS->Fill(); | |
383 | for(Int_t j = 0; j < 4; j++) { | |
384 | sector[1] = j+1; // Towers PM ADCs | |
385 | new(psdigit) AliZDCSDigit(sector, pmQZNA[j]); | |
386 | if(pmQZNA[j] > 0) treeS->Fill(); | |
387 | } | |
388 | ||
389 | // Create sdigits for ZPA | |
390 | sector[0] = 5; // Detector = ZPA | |
391 | sector[1] = 0; // Common PM ADC | |
392 | new(psdigit) AliZDCSDigit(sector, pmCZPA); | |
393 | if(pmCZPA > 0) treeS->Fill(); | |
394 | for(Int_t j = 0; j < 4; j++) { | |
395 | sector[1] = j+1; // Towers PM ADCs | |
396 | new(psdigit) AliZDCSDigit(sector, pmQZPA[j]); | |
397 | if(pmQZPA[j] > 0) treeS->Fill(); | |
398 | } | |
399 | ||
6de91202 | 400 | // write the output tree |
401 | fLoader->WriteSDigits("OVERWRITE"); | |
85a5290f | 402 | } |
403 | ||
404 | fLoader->UnloadHits(); | |
405 | fLoader->UnloadSDigits(); | |
359cdddc | 406 | } |
407 | ||
408 | //_____________________________________________________________________________ | |
6de91202 | 409 | AliDigitizer* AliZDC::CreateDigitizer(AliRunDigitizer* manager) const |
359cdddc | 410 | { |
6de91202 | 411 | // Create the digitizer for ZDC |
412 | ||
413 | return new AliZDCDigitizer(manager); | |
359cdddc | 414 | } |
415 | ||
416 | //_____________________________________________________________________________ | |
6de91202 | 417 | void AliZDC::Digits2Raw() |
359cdddc | 418 | { |
6de91202 | 419 | // Convert ZDC digits to raw data |
420 | ||
83347831 | 421 | // Format: 24 int values -> ZN1(C+Q1-4), ZP1(C+Q1-4), ZEM1, ZEM2, ZN(C+Q1-4), ZP2(C+Q1-4), 2 Ref PMs |
422 | // + 24 int values for the corresponding out of time channels | |
d79f8d50 | 423 | // For the CAEN module V965 we have an Header, the Data Words and an End Of Block |
424 | // 12 channels x 2 gain chains read from 1st ADC module | |
83347831 | 425 | // 12 channels x 2 gain chains read from 2nd ADC module |
d79f8d50 | 426 | // 12 channels x 2 gain chains read from 3rd ADC module (o.o.t.) |
83347831 | 427 | // 12 channels x 2 gain chains read from 4rth ADC module (o.o.t.) |
d79f8d50 | 428 | // |
83347831 | 429 | const int knADCData1=24, knADCData2=24; // In principle the 2 numbers can be different! |
7f73eb6b | 430 | UInt_t lADCHeader1; |
7f73eb6b | 431 | UInt_t lADCHeader2; |
83347831 | 432 | UInt_t lADCData1[knADCData1]; |
8a2624cc | 433 | UInt_t lADCData2[knADCData2]; |
d79f8d50 | 434 | UInt_t lADCData3[knADCData1]; |
d79f8d50 | 435 | UInt_t lADCData4[knADCData2]; |
436 | // | |
232b622f | 437 | UInt_t lADCEndBlock; |
6de91202 | 438 | |
439 | // load the digits | |
440 | fLoader->LoadDigits("read"); | |
441 | AliZDCDigit digit; | |
442 | AliZDCDigit* pdigit = &digit; | |
443 | TTree* treeD = fLoader->TreeD(); | |
90001c80 | 444 | if(!treeD) return; |
6de91202 | 445 | treeD->SetBranchAddress("ZDC", &pdigit); |
83347831 | 446 | //printf("\t AliZDC::Digits2Raw -> TreeD has %d entries\n",(Int_t) treeD->GetEntries()); |
6de91202 | 447 | |
448 | // Fill data array | |
449 | // ADC header | |
232b622f | 450 | UInt_t lADCHeaderGEO = 0; |
451 | UInt_t lADCHeaderCRATE = 0; | |
8a2624cc | 452 | UInt_t lADCHeaderCNT1 = knADCData1; |
453 | UInt_t lADCHeaderCNT2 = knADCData2; | |
1450a7cd | 454 | |
7f73eb6b | 455 | lADCHeader1 = lADCHeaderGEO << 27 | 0x1 << 25 | lADCHeaderCRATE << 16 | |
456 | lADCHeaderCNT1 << 8 ; | |
7f73eb6b | 457 | lADCHeader2 = lADCHeaderGEO << 27 | 0x1 << 25 | lADCHeaderCRATE << 16 | |
458 | lADCHeaderCNT2 << 8 ; | |
6de91202 | 459 | |
460 | // ADC data word | |
232b622f | 461 | UInt_t lADCDataGEO = lADCHeaderGEO; |
83347831 | 462 | // |
8a2624cc | 463 | UInt_t lADCDataValue1[knADCData1]; |
464 | UInt_t lADCDataValue2[knADCData2]; | |
d79f8d50 | 465 | UInt_t lADCDataValue3[knADCData1]; |
466 | UInt_t lADCDataValue4[knADCData2]; | |
83347831 | 467 | // |
8a2624cc | 468 | UInt_t lADCDataOvFlw1[knADCData1]; |
469 | UInt_t lADCDataOvFlw2[knADCData2]; | |
d79f8d50 | 470 | UInt_t lADCDataOvFlw3[knADCData1]; |
471 | UInt_t lADCDataOvFlw4[knADCData2]; | |
83347831 | 472 | // |
d79f8d50 | 473 | for(Int_t i=0; i<knADCData1 ; i++){ |
7f73eb6b | 474 | lADCDataValue1[i] = 0; |
475 | lADCDataOvFlw1[i] = 0; | |
d79f8d50 | 476 | lADCDataValue3[i] = 0; |
477 | lADCDataOvFlw3[i] = 0; | |
7f73eb6b | 478 | } |
d79f8d50 | 479 | for(Int_t i=0; i<knADCData2 ; i++){ |
7f73eb6b | 480 | lADCDataValue2[i] = 0; |
481 | lADCDataOvFlw2[i] = 0; | |
d79f8d50 | 482 | lADCDataValue4[i] = 0; |
483 | lADCDataOvFlw4[i] = 0; | |
6de91202 | 484 | } |
83347831 | 485 | // |
232b622f | 486 | UInt_t lADCDataChannel = 0; |
6de91202 | 487 | |
488 | // loop over digits | |
d79f8d50 | 489 | for(Int_t iDigit=0; iDigit<treeD->GetEntries(); iDigit++){ |
6de91202 | 490 | treeD->GetEntry(iDigit); |
d79f8d50 | 491 | if(!pdigit) continue; |
a5d5ab4c | 492 | //digit.Print(""); |
abf60186 | 493 | |
d79f8d50 | 494 | // *** ADC data |
83347831 | 495 | Int_t index=0; |
496 | if(digit.GetSector(1)!=5){ // ZDC signal channels | |
497 | // *** ADC1 (ZN1, ZP1, ZEM1,2) or ADC3 (ZN1, ZP1, ZEM1,2 o.o.t.) | |
498 | if(digit.GetSector(0)==1 || digit.GetSector(0)==2 || digit.GetSector(0)==3){ | |
499 | if(digit.GetSector(0)==1 || digit.GetSector(0)==2){ | |
500 | index = (digit.GetSector(0)-1) + 4*digit.GetSector(1); // ZN1 or ZP1 | |
501 | lADCDataChannel = 8*(digit.GetSector(0)-1) + digit.GetSector(1); | |
502 | } | |
503 | else if(digit.GetSector(0)==3){ // ZEM 1,2 | |
504 | index = 20 + (digit.GetSector(1)-1); | |
505 | lADCDataChannel = 5 + 8*(digit.GetSector(1)-1); | |
506 | } | |
507 | // | |
508 | /*printf("\t AliZDC::Digits2Raw -> idig%d det %d quad %d index %d, ADCch %d ADCVal[%d, %d]\n", | |
509 | iDigit,digit.GetSector(0),digit.GetSector(1),index,lADCDataChannel, | |
510 | digit.GetADCValue(0),digit.GetADCValue(1));// Ch. debug | |
511 | */ | |
512 | // | |
513 | if(iDigit<knADCData1){ // *** In-time signals | |
514 | lADCDataValue1[index] = digit.GetADCValue(0); // High gain ADC ch. | |
515 | if(lADCDataValue1[index] > 2047) lADCDataOvFlw1[index] = 1; | |
516 | lADCDataValue1[index+2] = digit.GetADCValue(1); // Low gain ADC ch. | |
517 | if(lADCDataValue1[index+2] > 2047) lADCDataOvFlw1[index+2] = 1; | |
518 | ||
519 | lADCData1[index] = lADCDataGEO << 27 | 0x1 << 24 | lADCDataChannel << 17 | | |
520 | lADCDataOvFlw1[index] << 12 | (lADCDataValue1[index] & 0xfff); | |
521 | lADCData1[index+2] = lADCDataGEO << 27 | 0x1 << 24 | lADCDataChannel << 17 | 0x1 << 16 | | |
522 | lADCDataOvFlw1[index+2] << 12 | (lADCDataValue1[index+2] & 0xfff); | |
523 | } | |
524 | else{ // *** Out-of-time signals | |
525 | lADCDataValue3[index] = digit.GetADCValue(0); // High gain ADC ch. | |
526 | if(lADCDataValue3[index] > 2047) lADCDataOvFlw3[index] = 1; | |
527 | lADCDataValue3[index+2] = digit.GetADCValue(1); // Low gain ADC ch. | |
528 | if(lADCDataValue3[index+2] > 2047) lADCDataOvFlw3[index+2] = 1; | |
529 | ||
530 | lADCData3[index] = lADCDataGEO << 27 | lADCDataChannel << 17 | | |
531 | lADCDataOvFlw3[index] << 12 | (lADCDataValue3[index] & 0xfff); | |
532 | lADCData3[index+2] = lADCDataGEO << 27 | lADCDataChannel << 17 | 0x1 << 16 | | |
533 | lADCDataOvFlw3[index+2] << 12 | (lADCDataValue3[index+2] & 0xfff); | |
534 | } | |
7f73eb6b | 535 | } |
83347831 | 536 | // *** ADC2 (ZN2, ZP2) or ADC4 (ZN2, ZP2 o.o.t.) |
537 | else if(digit.GetSector(0)==4 || digit.GetSector(0)==5){ | |
538 | index = (digit.GetSector(0)-4) + 4*digit.GetSector(1); // ZN2 or ZP2 | |
539 | lADCDataChannel = 8*(digit.GetSector(0)-4) + digit.GetSector(1); | |
540 | // | |
541 | /*printf("\t AliZDC::Digits2Raw -> idig%d det %d quad %d index %d, ADCch %d ADCVal[%d, %d]\n", | |
542 | iDigit,digit.GetSector(0),digit.GetSector(1),index,lADCDataChannel, | |
543 | digit.GetADCValue(0),digit.GetADCValue(1));// Ch. debug | |
544 | */ | |
545 | // | |
546 | if(iDigit<knADCData2){ // *** In-time signals | |
547 | lADCDataValue2[index] = digit.GetADCValue(0); | |
548 | if(lADCDataValue2[index] > 2047) lADCDataOvFlw2[index] = 1; | |
549 | lADCDataValue2[index+2] = digit.GetADCValue(1); | |
550 | if(lADCDataValue2[index+2] > 2047) lADCDataOvFlw2[index+2] = 1; | |
551 | // | |
552 | lADCData2[index] = lADCDataGEO << 27 | lADCDataChannel << 17 | | |
553 | lADCDataOvFlw2[index] << 12 | (lADCDataValue2[index] & 0xfff); | |
554 | lADCData2[index+2] = lADCDataGEO << 27 | lADCDataChannel << 17 | 0x1 << 16 | | |
555 | lADCDataOvFlw2[index+2] << 12 | (lADCDataValue2[index+2] & 0xfff); | |
556 | } | |
557 | else{ // *** Out-of-time signals | |
558 | lADCDataValue4[index] = digit.GetADCValue(0); | |
559 | if(lADCDataValue4[index] > 2047) lADCDataOvFlw4[index] = 1; | |
560 | lADCDataValue4[index+2] = digit.GetADCValue(1); | |
561 | if(lADCDataValue4[index+2] > 2047) lADCDataOvFlw4[index+2] = 1; | |
562 | // | |
563 | lADCData4[index] = lADCDataGEO << 27 | lADCDataChannel << 17 | | |
564 | lADCDataOvFlw4[index] << 12 | (lADCDataValue4[index] & 0xfff); | |
565 | lADCData4[index+2] = lADCDataGEO << 27 | lADCDataChannel << 17 | 0x1 << 16 | | |
566 | lADCDataOvFlw4[index+2] << 12 | (lADCDataValue4[index+2] & 0xfff); | |
567 | } | |
d79f8d50 | 568 | } |
6de91202 | 569 | } |
83347831 | 570 | // *** ADC2 (Reference PTMs) or ADC4 (Reference PTMs o.o.t.) |
571 | else if(digit.GetSector(1)==5){ | |
c35ed519 | 572 | index = 20 + (digit.GetSector(0)-1)/3; |
573 | lADCDataChannel = 5 + 8*(digit.GetSector(0)-1)/3; | |
abf60186 | 574 | // |
83347831 | 575 | /*printf("\t AliZDC::Digits2Raw -> idig%d det %d quad %d index %d, ADCch %d ADCVal[%d, %d]\n", |
576 | iDigit,digit.GetSector(0),digit.GetSector(1),index,lADCDataChannel, | |
577 | digit.GetADCValue(0),digit.GetADCValue(1));// Ch. debug | |
c7426372 | 578 | */ |
7f73eb6b | 579 | // |
83347831 | 580 | if(iDigit<knADCData2){ // *** In-time signals |
581 | lADCDataValue2[index] = digit.GetADCValue(0); | |
582 | if(lADCDataValue2[index] > 2047) lADCDataOvFlw2[index] = 1; | |
583 | lADCDataValue2[index+2] = digit.GetADCValue(1); | |
584 | if(lADCDataValue2[index+2] > 2047) lADCDataOvFlw2[index+2] = 1; | |
d79f8d50 | 585 | // |
83347831 | 586 | lADCData2[index] = lADCDataGEO << 27 | lADCDataChannel << 17 | |
587 | lADCDataOvFlw2[index] << 12 | (lADCDataValue2[index] & 0xfff); | |
588 | lADCData2[index+2] = lADCDataGEO << 27 | lADCDataChannel << 17 | 0x1 << 16 | | |
589 | lADCDataOvFlw2[index+2] << 12 | (lADCDataValue2[index+2] & 0xfff); | |
590 | } | |
591 | else{ // *** Out-of-time signals | |
592 | lADCDataValue4[index] = digit.GetADCValue(0); | |
593 | if(lADCDataValue4[index] > 2047) lADCDataOvFlw4[index] = 1; | |
594 | lADCDataValue4[index+2] = digit.GetADCValue(1); | |
595 | if(lADCDataValue4[index+2] > 2047) lADCDataOvFlw4[index+2] = 1; | |
d79f8d50 | 596 | // |
83347831 | 597 | lADCData4[index] = lADCDataGEO << 27 | lADCDataChannel << 17 | |
598 | lADCDataOvFlw4[index] << 12 | (lADCDataValue4[index] & 0xfff); | |
599 | lADCData4[index+2] = lADCDataGEO << 27 | lADCDataChannel << 17 | 0x1 << 16 | | |
600 | lADCDataOvFlw4[index+2] << 12 | (lADCDataValue4[index+2] & 0xfff); | |
601 | } | |
602 | ||
6de91202 | 603 | } |
83347831 | 604 | if((index<0) || (index>23)) { |
6de91202 | 605 | Error("Digits2Raw", "sector[0] = %d, sector[1] = %d", |
606 | digit.GetSector(0), digit.GetSector(1)); | |
607 | continue; | |
1450a7cd | 608 | } |
1450a7cd | 609 | |
1450a7cd | 610 | |
1450a7cd | 611 | } |
83347831 | 612 | // |
613 | /* | |
58e12fee | 614 | for(Int_t i=0;i<knADCData1;i++) printf("\t ADCData1[%d] = %x\n",i,lADCData1[i]); |
615 | for(Int_t i=0;i<knADCData2;i++) printf("\t ADCData2[%d] = %x\n",i,lADCData2[i]); | |
616 | for(Int_t i=0;i<knADCData1;i++) printf("\t ADCData3[%d] = %x\n",i,lADCData3[i]); | |
617 | for(Int_t i=0;i<knADCData2;i++) printf("\t ADCData4[%d] = %x\n",i,lADCData4[i]); | |
c7426372 | 618 | */ |
7f73eb6b | 619 | |
6de91202 | 620 | // End of Block |
232b622f | 621 | UInt_t lADCEndBlockGEO = lADCHeaderGEO; |
622 | UInt_t lADCEndBlockEvCount = gAlice->GetEventNrInRun(); | |
83347831 | 623 | // |
232b622f | 624 | lADCEndBlock = lADCEndBlockGEO << 27 | 0x1 << 26 | lADCEndBlockEvCount; |
256c2b16 | 625 | //printf("\t AliZDC::Digits2Raw -> ADCEndBlock = %d\n",lADCEndBlock); |
6de91202 | 626 | |
627 | ||
628 | // open the output file | |
629 | char fileName[30]; | |
362c9d61 | 630 | strcpy(fileName,AliDAQ::DdlFileName("ZDC",0)); |
08f92f14 | 631 | |
632 | AliFstream* file = new AliFstream(fileName); | |
6de91202 | 633 | |
634 | // write the DDL data header | |
f7ee745b | 635 | AliRawDataHeaderSim header; |
d79f8d50 | 636 | header.fSize = sizeof(header) + |
637 | sizeof(lADCHeader1) + sizeof(lADCData1) + sizeof(lADCEndBlock) + | |
638 | sizeof(lADCHeader2) + sizeof(lADCData2) + sizeof(lADCEndBlock) + | |
83347831 | 639 | sizeof(lADCHeader1) + sizeof(lADCData3) + sizeof(lADCEndBlock) + |
640 | sizeof(lADCHeader2) + sizeof(lADCData4) + sizeof(lADCEndBlock); | |
641 | // | |
abf60186 | 642 | /*printf("sizeof header = %d, ADCHeader1 = %d, ADCData1 = %d, ADCEndBlock = %d\n", |
643 | sizeof(header),sizeof(lADCHeader1),sizeof(lADCData1),sizeof(lADCEndBlock)); | |
644 | printf("sizeof header = %d, ADCHeader2 = %d, ADCData2 = %d, ADCEndBlock = %d\n", | |
83347831 | 645 | sizeof(header),sizeof(lADCHeader2),sizeof(lADCData2),sizeof(lADCEndBlock)); |
646 | */ | |
647 | // | |
6de91202 | 648 | header.SetAttribute(0); // valid data |
08f92f14 | 649 | file->WriteBuffer((char*)(&header), sizeof(header)); |
6de91202 | 650 | |
651 | // write the raw data and close the file | |
08f92f14 | 652 | file->WriteBuffer((char*) &lADCHeader1, sizeof (lADCHeader1)); |
653 | file->WriteBuffer((char*)(lADCData1), sizeof(lADCData1)); | |
654 | file->WriteBuffer((char*) &lADCEndBlock, sizeof(lADCEndBlock)); | |
655 | file->WriteBuffer((char*) &lADCHeader2, sizeof (lADCHeader2)); | |
656 | file->WriteBuffer((char*)(lADCData2), sizeof(lADCData2)); | |
657 | file->WriteBuffer((char*) &lADCEndBlock, sizeof(lADCEndBlock)); | |
83347831 | 658 | file->WriteBuffer((char*) &lADCHeader1, sizeof (lADCHeader1)); |
08f92f14 | 659 | file->WriteBuffer((char*)(lADCData3), sizeof(lADCData3)); |
660 | file->WriteBuffer((char*) &lADCEndBlock, sizeof(lADCEndBlock)); | |
83347831 | 661 | file->WriteBuffer((char*) &lADCHeader2, sizeof (lADCHeader2)); |
08f92f14 | 662 | file->WriteBuffer((char*)(lADCData4), sizeof(lADCData4)); |
663 | file->WriteBuffer((char*) &lADCEndBlock, sizeof(lADCEndBlock)); | |
664 | delete file; | |
6de91202 | 665 | |
666 | // unload the digits | |
667 | fLoader->UnloadDigits(); | |
359cdddc | 668 | } |
669 | ||
90001c80 | 670 | //_____________________________________________________________________________ |
671 | Bool_t AliZDC::Raw2SDigits(AliRawReader* rawReader) | |
672 | { | |
673 | // Convert ZDC raw data to Sdigits | |
674 | ||
36f43fdf | 675 | AliLoader* loader = (gAlice->GetRunLoader())->GetLoader("ZDCLoader"); |
676 | if(!loader) { | |
677 | AliError("no ZDC loader found"); | |
678 | return kFALSE; | |
679 | } | |
680 | ||
681 | // // Event loop | |
682 | Int_t iEvent = 0; | |
90001c80 | 683 | while(rawReader->NextEvent()){ |
36f43fdf | 684 | (gAlice->GetRunLoader())->GetEvent(iEvent++); |
90001c80 | 685 | // Create the output digit tree |
36f43fdf | 686 | TTree* treeS = loader->TreeS(); |
687 | if(!treeS){ | |
688 | loader->MakeTree("S"); | |
689 | treeS = loader->TreeS(); | |
90001c80 | 690 | } |
691 | // | |
692 | AliZDCSDigit sdigit; | |
693 | AliZDCSDigit* psdigit = &sdigit; | |
694 | const Int_t kBufferSize = 4000; | |
695 | treeS->Branch("ZDC", "AliZDCSDigit", &psdigit, kBufferSize); | |
696 | // | |
697 | AliZDCRawStream rawStream(rawReader); | |
6310fd85 | 698 | Int_t sector[2], resADC, rawADC, corrADC, nPheVal; |
90001c80 | 699 | Int_t jcount = 0; |
700 | while(rawStream.Next()){ | |
701 | if(rawStream.IsADCDataWord()){ | |
83347831 | 702 | //For the moment only in-time SDigits are foreseen (1st 48 raw values) |
703 | if(jcount < 48){ | |
90001c80 | 704 | for(Int_t j=0; j<2; j++) sector[j] = rawStream.GetSector(j); |
6310fd85 | 705 | rawADC = rawStream.GetADCValue(); |
706 | resADC = rawStream.GetADCGain(); | |
36f43fdf | 707 | //printf("\t RAw2SDigits raw%d -> RawADC[%d, %d, %d] read\n", |
6310fd85 | 708 | // jcount, sector[0], sector[1], rawADC); |
90001c80 | 709 | // |
6310fd85 | 710 | corrADC = rawADC - Pedestal(sector[0], sector[1], resADC); |
711 | if(corrADC<0) corrADC=0; | |
712 | nPheVal = ADCch2Phe(sector[0], sector[1], corrADC, resADC); | |
36f43fdf | 713 | // |
714 | //printf("\t \t -> SDigit[%d, %d, %d] created\n", | |
715 | // sector[0], sector[1], nPheVal); | |
716 | // | |
90001c80 | 717 | new(psdigit) AliZDCSDigit(sector, (Float_t) nPheVal); |
718 | treeS->Fill(); | |
36f43fdf | 719 | jcount++; |
90001c80 | 720 | } |
90001c80 | 721 | }//IsADCDataWord |
722 | }//rawStream.Next | |
723 | // write the output tree | |
724 | fLoader->WriteSDigits("OVERWRITE"); | |
725 | fLoader->UnloadSDigits(); | |
726 | }//Event loop | |
727 | ||
728 | return kTRUE; | |
729 | } | |
730 | ||
731 | //_____________________________________________________________________________ | |
732 | Int_t AliZDC::Pedestal(Int_t Det, Int_t Quad, Int_t Res) const | |
733 | { | |
734 | // Returns a pedestal for detector det, PM quad, channel with res. | |
735 | // | |
36f43fdf | 736 | // Getting calibration object for ZDC set |
737 | AliCDBManager *man = AliCDBManager::Instance(); | |
84dda325 | 738 | AliCDBEntry *entry = man->Get("ZDC/Calib/Pedestals"); |
6024ec85 | 739 | AliZDCPedestals *calibPed = (AliZDCPedestals*) entry->GetObject(); |
36f43fdf | 740 | // |
6024ec85 | 741 | if(!calibPed){ |
36f43fdf | 742 | printf("\t No calibration object found for ZDC!"); |
743 | return -1; | |
744 | } | |
745 | // | |
c35ed519 | 746 | Int_t index=0, kNch=24; |
747 | if(Quad!=5){ | |
748 | if(Det==1) index = Quad+kNch*Res; // ZN1 | |
749 | else if(Det==2) index = Quad+5+kNch*Res; // ZP1 | |
750 | else if(Det==3) index = Quad+9+kNch*Res; // ZEM | |
751 | else if(Det==4) index = Quad+12+kNch*Res; // ZN2 | |
752 | else if(Det==5) index = Quad+17+kNch*Res; // ZP2 | |
753 | } | |
754 | else index = (Det-1)/3+22+kNch*Res; // Reference PMs | |
36f43fdf | 755 | // |
756 | // | |
c35ed519 | 757 | Float_t meanPed = calibPed->GetMeanPed(index); |
758 | Float_t pedWidth = calibPed->GetMeanPedWidth(index); | |
759 | Float_t pedValue = gRandom->Gaus(meanPed,pedWidth); | |
90001c80 | 760 | // |
6310fd85 | 761 | //printf("\t AliZDC::Pedestal - det(%d, %d) - Ped[%d] = %d\n",Det, Quad, index,(Int_t) pedValue); // Chiara debugging! |
36f43fdf | 762 | |
90001c80 | 763 | |
764 | ||
6310fd85 | 765 | return (Int_t) pedValue; |
90001c80 | 766 | } |
767 | ||
768 | ||
769 | //_____________________________________________________________________________ | |
36f43fdf | 770 | Int_t AliZDC::ADCch2Phe(Int_t Det, Int_t Quad, Int_t ADCVal, Int_t Res) const |
90001c80 | 771 | { |
772 | // Evaluation of the no. of phe produced | |
6310fd85 | 773 | Float_t pmGain[6][5]; |
774 | Float_t resADC[2]; | |
90001c80 | 775 | for(Int_t j = 0; j < 5; j++){ |
6310fd85 | 776 | pmGain[0][j] = 50000.; |
777 | pmGain[1][j] = 100000.; | |
778 | pmGain[2][j] = 100000.; | |
779 | pmGain[3][j] = 50000.; | |
780 | pmGain[4][j] = 100000.; | |
781 | pmGain[5][j] = 100000.; | |
90001c80 | 782 | } |
783 | // ADC Caen V965 | |
6310fd85 | 784 | resADC[0] = 0.0000008; // ADC Resolution high gain: 200 fC/adcCh |
785 | resADC[1] = 0.0000064; // ADC Resolution low gain: 25 fC/adcCh | |
90001c80 | 786 | // |
6310fd85 | 787 | Int_t nPhe = (Int_t) (ADCVal * pmGain[Det-1][Quad] * resADC[Res]); |
36f43fdf | 788 | // |
789 | //printf("\t AliZDC::ADCch2Phe -> det(%d, %d) - ADC %d phe %d\n",Det,Quad,ADCVal,nPhe); | |
90001c80 | 790 | |
791 | return nPhe; | |
792 | } | |
793 | ||
b81c9821 | 794 | //______________________________________________________________________ |
795 | void AliZDC::SetTreeAddress(){ | |
90001c80 | 796 | |
b81c9821 | 797 | // Set branch address for the Trees. |
90001c80 | 798 | if(fLoader->TreeH() && (fHits == 0x0)) |
b81c9821 | 799 | fHits = new TClonesArray("AliZDCHit",1000); |
800 | ||
b81c9821 | 801 | AliDetector::SetTreeAddress(); |
802 | } |