]>
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> |
fe4da5cc | 35 | |
f901045b | 36 | // --- AliRoot header files |
88cb7938 | 37 | #include "AliDetector.h" |
fe4da5cc | 38 | #include "AliZDC.h" |
f901045b | 39 | #include "AliZDCHit.h" |
6de91202 | 40 | #include "AliZDCSDigit.h" |
41 | #include "AliZDCDigit.h" | |
42 | #include "AliZDCDigitizer.h" | |
43 | #include "AliZDCRawStream.h" | |
8af17dba | 44 | #include "AliZDCCalibData.h" |
88cb7938 | 45 | |
6de91202 | 46 | #include "AliRawDataHeader.h" |
88cb7938 | 47 | #include "AliLoader.h" |
48 | #include "AliRun.h" | |
5d12ce38 | 49 | #include "AliMC.h" |
99a553ce | 50 | #include "AliLog.h" |
362c9d61 | 51 | #include "AliDAQ.h" |
fe4da5cc | 52 | |
53 | ClassImp(AliZDC) | |
8af17dba | 54 | |
8a2624cc | 55 | AliZDC *gAliZDC; |
fe4da5cc | 56 | |
57 | //_____________________________________________________________________________ | |
cc2abffd | 58 | AliZDC::AliZDC() : |
59 | AliDetector(), | |
60 | fNoShower (0), | |
61 | fCalibData (0) | |
62 | ||
fe4da5cc | 63 | { |
64 | // | |
65 | // Default constructor for the Zero Degree Calorimeter base class | |
66 | // | |
2e6fc82a | 67 | |
cc2abffd | 68 | fIshunt = 1; |
69 | fNhits = 0; | |
70 | fHits = 0; | |
71 | fDigits = 0; | |
72 | fNdigits = 0; | |
d16dd065 | 73 | |
fe4da5cc | 74 | } |
75 | ||
76 | //_____________________________________________________________________________ | |
cc2abffd | 77 | AliZDC::AliZDC(const char *name, const char *title) : |
78 | AliDetector(name,title), | |
79 | fNoShower (0), | |
80 | fCalibData (0) | |
81 | ||
fe4da5cc | 82 | { |
83 | // | |
84 | // Standard constructor for the Zero Degree Calorimeter base class | |
85 | // | |
cc2abffd | 86 | |
87 | fIshunt = 1; | |
88 | fNhits = 0; | |
89 | fDigits = 0; | |
90 | fNdigits = 0; | |
91 | ||
92 | fHits = new TClonesArray("AliZDCHit",1000); | |
5d12ce38 | 93 | gAlice->GetMCApp()->AddHitList(fHits); |
8af17dba | 94 | |
95 | char sensname[5],senstitle[25]; | |
96 | sprintf(sensname,"ZDC"); | |
97 | sprintf(senstitle,"ZDC dummy"); | |
98 | SetName(sensname); SetTitle(senstitle); | |
f901045b | 99 | |
cc2abffd | 100 | gAliZDC = this; |
866ab5a2 | 101 | |
102 | } | |
cc2abffd | 103 | |
866ab5a2 | 104 | //____________________________________________________________________________ |
105 | AliZDC::~AliZDC() | |
106 | { | |
107 | // | |
108 | // ZDC destructor | |
109 | // | |
110 | ||
cc2abffd | 111 | fIshunt = 0; |
112 | gAliZDC = 0; | |
2e6fc82a | 113 | |
d16dd065 | 114 | delete fCalibData; |
115 | ||
fe4da5cc | 116 | } |
cc2abffd | 117 | |
118 | //_____________________________________________________________________________ | |
119 | AliZDC::AliZDC(const AliZDC& ZDC) : | |
120 | AliDetector("ZDC","ZDC") | |
121 | { | |
122 | // copy constructor | |
123 | fNoShower = ZDC.fNoShower; | |
124 | fCalibData = ZDC.fCalibData; | |
125 | fZDCCalibFName = ZDC.fZDCCalibFName; | |
126 | } | |
127 | ||
128 | //_____________________________________________________________________________ | |
129 | AliZDC& AliZDC::operator=(const AliZDC& ZDC) | |
130 | { | |
131 | // assignement operator | |
132 | if(this!=&ZDC){ | |
133 | fNoShower = ZDC.fNoShower; | |
134 | fCalibData = ZDC.fCalibData; | |
135 | fZDCCalibFName = ZDC.fZDCCalibFName; | |
136 | } return *this; | |
137 | } | |
138 | ||
fe4da5cc | 139 | //_____________________________________________________________________________ |
140 | void AliZDC::AddHit(Int_t track, Int_t *vol, Float_t *hits) | |
141 | { | |
142 | // | |
f901045b | 143 | // Add a ZDC hit to the hit list. |
144 | // -> We make use of 2 array of hits: | |
145 | // [1] fHits (the usual one) that contains hits for each PRIMARY | |
146 | // [2] fStHits that contains hits for each EVENT and is used to | |
147 | // obtain digits at the end of each event | |
fe4da5cc | 148 | // |
f901045b | 149 | |
68ca986e | 150 | static Float_t primKinEn, xImpact, yImpact, sFlag; |
151 | ||
43f34e8b | 152 | AliZDCHit *newquad, *curprimquad; |
f901045b | 153 | newquad = new AliZDCHit(fIshunt, track, vol, hits); |
65d4f2be | 154 | TClonesArray &lhits = *fHits; |
cefa66cb | 155 | |
156 | if(fNhits==0){ | |
157 | // First hit -> setting flag for primary or secondary particle | |
5d12ce38 | 158 | Int_t primary = gAlice->GetMCApp()->GetPrimary(track); |
cefa66cb | 159 | if(track != primary){ |
3ff116f2 | 160 | newquad->SetSFlag(1); // SECONDARY particle entering the ZDC |
cefa66cb | 161 | } |
162 | else if(track == primary){ | |
3ff116f2 | 163 | newquad->SetSFlag(0); // PRIMARY particle entering the ZDC |
cefa66cb | 164 | } |
3ff116f2 | 165 | sFlag = newquad->GetSFlag(); |
166 | primKinEn = newquad->GetPrimKinEn(); | |
167 | xImpact = newquad->GetXImpact(); | |
168 | yImpact = newquad->GetYImpact(); | |
cefa66cb | 169 | } |
170 | else{ | |
3ff116f2 | 171 | newquad->SetPrimKinEn(primKinEn); |
172 | newquad->SetXImpact(xImpact); | |
173 | newquad->SetYImpact(yImpact); | |
174 | newquad->SetSFlag(sFlag); | |
cefa66cb | 175 | } |
176 | ||
43f34e8b | 177 | Int_t j; |
f901045b | 178 | for(j=0; j<fNhits; j++){ |
2e6fc82a | 179 | // If hits are equal (same track, same volume), sum them. |
f901045b | 180 | curprimquad = (AliZDCHit*) lhits[j]; |
181 | if(*curprimquad == *newquad){ | |
182 | *curprimquad = *curprimquad+*newquad; | |
cc2abffd | 183 | // CH. debug |
184 | /*if(newquad->GetEnergy() != 0. || newquad->GetLightPMC() != 0. || | |
185 | newquad->GetLightPMQ() != 0.){ | |
186 | printf("\n\t --- Equal hits found\n"); | |
187 | curprimquad->Print(""); | |
188 | newquad->Print(""); | |
189 | printf("\t --- Det. %d, Quad. %d: X = %f, E = %f, LightPMC = %f, LightPMQ = %f\n", | |
190 | curprimquad->GetVolume(0),curprimquad->GetVolume(1),curprimquad->GetXImpact(), | |
191 | curprimquad->GetEnergy(), curprimquad->GetLightPMC(), curprimquad->GetLightPMQ()); | |
192 | }*/ | |
193 | // | |
f901045b | 194 | delete newquad; |
68ca986e | 195 | return; |
f901045b | 196 | } |
197 | } | |
f901045b | 198 | |
199 | //Otherwise create a new hit | |
cc2abffd | 200 | new(lhits[fNhits]) AliZDCHit(*newquad); |
f901045b | 201 | fNhits++; |
cc2abffd | 202 | // CH. debug |
203 | /*printf("\n\t New ZDC hit added! fNhits = %d\n", fNhits); | |
204 | printf("\t Det. %d, Quad.t %d: X = %f, E = %f, LightPMC = %f, LightPMQ = %f\n", | |
205 | newquad->GetVolume(0),newquad->GetVolume(1),newquad->GetXImpact(), | |
206 | newquad->GetEnergy(), newquad->GetLightPMC(), newquad->GetLightPMQ()); | |
207 | */ | |
866ab5a2 | 208 | delete newquad; |
cefa66cb | 209 | } |
210 | ||
fe4da5cc | 211 | //_____________________________________________________________________________ |
212 | void AliZDC::BuildGeometry() | |
213 | { | |
214 | // | |
215 | // Build the ROOT TNode geometry for event display | |
216 | // in the Zero Degree Calorimeter | |
217 | // This routine is dummy for the moment | |
218 | // | |
219 | ||
68ca986e | 220 | TNode *node, *top; |
221 | TBRIK *brik; | |
359cdddc | 222 | const int kColorZDC = kBlue; |
fe4da5cc | 223 | |
224 | // | |
68ca986e | 225 | top=gAlice->GetGeometry()->GetNode("alice"); |
fe4da5cc | 226 | |
227 | // ZDC | |
fe4da5cc | 228 | brik = new TBRIK("S_ZDC","ZDC box","void",300,300,5); |
68ca986e | 229 | top->cd(); |
230 | node = new TNode("ZDC","ZDC","S_ZDC",0,0,600,""); | |
231 | node->SetLineColor(kColorZDC); | |
232 | fNodes->Add(node); | |
fe4da5cc | 233 | } |
234 | ||
359cdddc | 235 | //____________________________________________________________________________ |
236 | Float_t AliZDC::ZMin(void) const | |
237 | { | |
238 | // Minimum dimension of the ZDC module in z | |
6de91202 | 239 | return -11600.; |
359cdddc | 240 | } |
241 | ||
242 | //____________________________________________________________________________ | |
243 | Float_t AliZDC::ZMax(void) const | |
244 | { | |
245 | // Maximum dimension of the ZDC module in z | |
6de91202 | 246 | return -11750.; |
359cdddc | 247 | } |
248 | ||
249 | ||
fe4da5cc | 250 | //_____________________________________________________________________________ |
5bc762ca | 251 | void AliZDC::MakeBranch(Option_t *opt) |
fe4da5cc | 252 | { |
253 | // | |
359cdddc | 254 | // Create Tree branches for the ZDC |
fe4da5cc | 255 | // |
359cdddc | 256 | |
257 | char branchname[10]; | |
258 | sprintf(branchname,"%s",GetName()); | |
88cb7938 | 259 | |
260 | const char *cH = strstr(opt,"H"); | |
261 | ||
262 | if (cH && fLoader->TreeH()) | |
263 | fHits = new TClonesArray("AliZDCHit",1000); | |
359cdddc | 264 | |
265 | AliDetector::MakeBranch(opt); | |
1450a7cd | 266 | } |
1450a7cd | 267 | |
b6d27557 | 268 | //_____________________________________________________________________________ |
269 | void AliZDC::Hits2SDigits() | |
270 | { | |
6de91202 | 271 | // Create summable digits from hits |
272 | ||
99a553ce | 273 | AliDebug(1,"\n Entering AliZDC::Hits2Digits() "); |
b6d27557 | 274 | |
85a5290f | 275 | fLoader->LoadHits("read"); |
276 | fLoader->LoadSDigits("recreate"); | |
6de91202 | 277 | AliRunLoader* runLoader = fLoader->GetRunLoader(); |
278 | AliZDCSDigit sdigit; | |
279 | AliZDCSDigit* psdigit = &sdigit; | |
85a5290f | 280 | |
6de91202 | 281 | // Event loop |
85a5290f | 282 | for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) { |
6de91202 | 283 | Float_t pmCZN = 0, pmCZP = 0, pmQZN[4], pmQZP[4], pmZEM1 = 0, pmZEM2 = 0; |
284 | for (Int_t i = 0; i < 4; i++) pmQZN[i] = pmQZP[i] = 0; | |
85a5290f | 285 | |
6de91202 | 286 | runLoader->GetEvent(iEvent); |
287 | TTree* treeH = fLoader->TreeH(); | |
359cdddc | 288 | Int_t ntracks = (Int_t) treeH->GetEntries(); |
6de91202 | 289 | ResetHits(); |
290 | ||
359cdddc | 291 | // Tracks loop |
6de91202 | 292 | Int_t sector[2]; |
293 | for (Int_t itrack = 0; itrack < ntracks; itrack++) { | |
294 | treeH->GetEntry(itrack); | |
295 | for (AliZDCHit* zdcHit = (AliZDCHit*)FirstHit(-1); zdcHit; | |
296 | zdcHit = (AliZDCHit*)NextHit()) { | |
b6d27557 | 297 | |
6de91202 | 298 | sector[0] = zdcHit->GetVolume(0); |
299 | sector[1] = zdcHit->GetVolume(1); | |
300 | if ((sector[1] < 1) || (sector[1] > 4)) { | |
301 | Error("Hits2SDigits", "sector[0] = %d, sector[1] = %d", | |
302 | sector[0], sector[1]); | |
303 | continue; | |
304 | } | |
305 | Float_t lightQ = zdcHit->GetLightPMQ(); | |
306 | Float_t lightC = zdcHit->GetLightPMC(); | |
307 | ||
308 | if (sector[0] == 1) { //ZN | |
309 | pmCZN += lightC; | |
310 | pmQZN[sector[1]-1] += lightQ; | |
311 | } else if (sector[0] == 2) { //ZP | |
312 | pmCZP += lightC; | |
313 | pmQZP[sector[1]-1] += lightQ; | |
314 | } else if (sector[0] == 3) { //ZEM | |
315 | if (sector[1] == 1) pmZEM1 += lightC; | |
316 | else pmZEM2 += lightQ; | |
317 | } | |
318 | }//Hits loop | |
359cdddc | 319 | } |
6de91202 | 320 | |
321 | // create the output tree | |
322 | fLoader->MakeTree("S"); | |
323 | TTree* treeS = fLoader->TreeS(); | |
324 | const Int_t kBufferSize = 4000; | |
325 | treeS->Branch(GetName(), "AliZDCSDigit", &psdigit, kBufferSize); | |
326 | ||
327 | // Create sdigits for ZN | |
328 | sector[0] = 1; // Detector = ZN | |
329 | sector[1] = 0; // Common PM ADC | |
330 | new(psdigit) AliZDCSDigit(sector, pmCZN); | |
331 | if (pmCZN > 0) treeS->Fill(); | |
332 | for (Int_t j = 0; j < 4; j++) { | |
333 | sector[1] = j+1; // Towers PM ADCs | |
334 | new(psdigit) AliZDCSDigit(sector, pmQZN[j]); | |
335 | if (pmQZN[j] > 0) treeS->Fill(); | |
b6d27557 | 336 | } |
359cdddc | 337 | |
6de91202 | 338 | // Create sdigits for ZP |
339 | sector[0] = 2; // Detector = ZP | |
340 | sector[1] = 0; // Common PM ADC | |
341 | new(psdigit) AliZDCSDigit(sector, pmCZP); | |
342 | if (pmCZP > 0) treeS->Fill(); | |
343 | for (Int_t j = 0; j < 4; j++) { | |
344 | sector[1] = j+1; // Towers PM ADCs | |
345 | new(psdigit) AliZDCSDigit(sector, pmQZP[j]); | |
346 | if (pmQZP[j] > 0) treeS->Fill(); | |
347 | } | |
348 | ||
349 | // Create sdigits for ZEM | |
350 | sector[0] = 3; | |
351 | sector[1] = 1; // Detector = ZEM1 | |
352 | new(psdigit) AliZDCSDigit(sector, pmZEM1); | |
353 | if (pmZEM1 > 0) treeS->Fill(); | |
354 | sector[1] = 2; // Detector = ZEM2 | |
355 | new(psdigit) AliZDCSDigit(sector, pmZEM2); | |
356 | if (pmZEM2 > 0) treeS->Fill(); | |
357 | ||
358 | // write the output tree | |
359 | fLoader->WriteSDigits("OVERWRITE"); | |
85a5290f | 360 | } |
361 | ||
362 | fLoader->UnloadHits(); | |
363 | fLoader->UnloadSDigits(); | |
359cdddc | 364 | } |
365 | ||
366 | //_____________________________________________________________________________ | |
6de91202 | 367 | AliDigitizer* AliZDC::CreateDigitizer(AliRunDigitizer* manager) const |
359cdddc | 368 | { |
6de91202 | 369 | // Create the digitizer for ZDC |
370 | ||
371 | return new AliZDCDigitizer(manager); | |
359cdddc | 372 | } |
373 | ||
374 | //_____________________________________________________________________________ | |
6de91202 | 375 | void AliZDC::Digits2Raw() |
359cdddc | 376 | { |
6de91202 | 377 | // Convert ZDC digits to raw data |
378 | ||
abf60186 | 379 | // Format: 22 interger values -> ZN1 (C+Q1-4), ZP1 (C+Q1-4), ZEM1, 2, ZN (C+Q1-4), ZP2 (C+Q1-4)) |
6de91202 | 380 | // For the CAEN module V965 we have an header, the Data Words and an End Of Block |
abf60186 | 381 | // 24 channels read on 1st ADC module, 20 channels read on 2nd ADC module |
382 | const int knADCData1=24, knADCData2=20; | |
7f73eb6b | 383 | UInt_t lADCHeader1; |
8a2624cc | 384 | UInt_t lADCData1[knADCData1]; |
7f73eb6b | 385 | // |
386 | UInt_t lADCHeader2; | |
8a2624cc | 387 | UInt_t lADCData2[knADCData2]; |
7f73eb6b | 388 | // |
232b622f | 389 | UInt_t lADCEndBlock; |
6de91202 | 390 | |
391 | // load the digits | |
392 | fLoader->LoadDigits("read"); | |
393 | AliZDCDigit digit; | |
394 | AliZDCDigit* pdigit = &digit; | |
395 | TTree* treeD = fLoader->TreeD(); | |
396 | if (!treeD) return; | |
397 | treeD->SetBranchAddress("ZDC", &pdigit); | |
abf60186 | 398 | //printf("\t AliZDC::Digits2raw -> TreeD has %d entries\n",(Int_t) treeD->GetEntries()); |
399 | //digit.Print(""); // Ch. debug | |
400 | ||
6de91202 | 401 | |
402 | // Fill data array | |
403 | // ADC header | |
232b622f | 404 | UInt_t lADCHeaderGEO = 0; |
405 | UInt_t lADCHeaderCRATE = 0; | |
8a2624cc | 406 | UInt_t lADCHeaderCNT1 = knADCData1; |
407 | UInt_t lADCHeaderCNT2 = knADCData2; | |
1450a7cd | 408 | |
7f73eb6b | 409 | lADCHeader1 = lADCHeaderGEO << 27 | 0x1 << 25 | lADCHeaderCRATE << 16 | |
410 | lADCHeaderCNT1 << 8 ; | |
abf60186 | 411 | // |
7f73eb6b | 412 | lADCHeader2 = lADCHeaderGEO << 27 | 0x1 << 25 | lADCHeaderCRATE << 16 | |
413 | lADCHeaderCNT2 << 8 ; | |
6de91202 | 414 | |
abf60186 | 415 | //printf("\t lADCHeader1 = %x, lADCHeader2 = %x\n",lADCHeader1, lADCHeader2); |
6de91202 | 416 | |
417 | // ADC data word | |
232b622f | 418 | UInt_t lADCDataGEO = lADCHeaderGEO; |
8a2624cc | 419 | UInt_t lADCDataValue1[knADCData1]; |
420 | UInt_t lADCDataValue2[knADCData2]; | |
421 | UInt_t lADCDataOvFlw1[knADCData1]; | |
422 | UInt_t lADCDataOvFlw2[knADCData2]; | |
423 | for(Int_t i = 0; i<knADCData1 ; i++){ | |
7f73eb6b | 424 | lADCDataValue1[i] = 0; |
425 | lADCDataOvFlw1[i] = 0; | |
426 | } | |
8a2624cc | 427 | for(Int_t i = 0; i<knADCData2 ; i++){ |
7f73eb6b | 428 | lADCDataValue2[i] = 0; |
429 | lADCDataOvFlw2[i] = 0; | |
6de91202 | 430 | } |
232b622f | 431 | UInt_t lADCDataChannel = 0; |
6de91202 | 432 | |
433 | // loop over digits | |
abf60186 | 434 | for (Int_t iDigit = 0; iDigit<treeD->GetEntries(); iDigit++) { |
6de91202 | 435 | treeD->GetEntry(iDigit); |
436 | if (!pdigit) continue; | |
abf60186 | 437 | |
6de91202 | 438 | //ADC data |
7f73eb6b | 439 | Int_t index1 = 0, index2 = 0; |
abf60186 | 440 | // ADC #1 (ZN1, ZP1, ZEM1,2) |
7f73eb6b | 441 | if(digit.GetSector(0)==1 || digit.GetSector(0)==2 || digit.GetSector(0)==3){ |
442 | if(digit.GetSector(0)==1 || digit.GetSector(0)==2){ | |
abf60186 | 443 | index1 = (digit.GetSector(0)-1) + digit.GetSector(1)*4; // ZN1 or ZP1 |
7f73eb6b | 444 | lADCDataChannel = (digit.GetSector(0)-1)*8 + digit.GetSector(1); |
445 | } | |
abf60186 | 446 | else if(digit.GetSector(0)==3){ // ZEM 1,2 |
447 | index1 = 20 + (digit.GetSector(1)-1); | |
448 | lADCDataChannel = 5 + (digit.GetSector(1)-1)*8; | |
7f73eb6b | 449 | } |
abf60186 | 450 | // |
451 | /*printf("\t AliZDC::Digits2raw -> det %d, quad %d, index = %d, ADCch = %d\n", | |
452 | digit.GetSector(0),digit.GetSector(1),index1,lADCDataChannel);// Ch. debug | |
453 | */ | |
454 | // | |
455 | lADCDataValue1[index1] = digit.GetADCValue(0); // High gain ADC ch. | |
456 | if(lADCDataValue1[index1] > 2047) lADCDataOvFlw1[index1] = 1; | |
457 | lADCDataValue1[index1+2] = digit.GetADCValue(1); // Low gain ADC ch. | |
458 | if(lADCDataValue1[index1+2] > 2047) lADCDataOvFlw1[index1+2] = 1; | |
7f73eb6b | 459 | |
abf60186 | 460 | lADCData1[index1] = lADCDataGEO << 27 | lADCDataChannel << 17 | |
7f73eb6b | 461 | lADCDataOvFlw1[index1] << 12 | (lADCDataValue1[index1] & 0xfff); |
462 | lADCData1[index1+2] = lADCDataGEO << 27 | lADCDataChannel << 17 | 0x1 << 16 | | |
463 | lADCDataOvFlw1[index1+2] << 12 | (lADCDataValue1[index1+2] & 0xfff); | |
6de91202 | 464 | } |
abf60186 | 465 | // ADC #2 (ZN2, ZP2) |
7f73eb6b | 466 | else if(digit.GetSector(0)==4 || digit.GetSector(0)==5){ |
abf60186 | 467 | index2 = (digit.GetSector(0)-4) + digit.GetSector(1)*4; // ZN2 or ZP2 |
7f73eb6b | 468 | lADCDataChannel = (digit.GetSector(0)-4)*8 + digit.GetSector(1); |
abf60186 | 469 | // |
470 | /*printf("\t AliZDC::Digits2raw -> det %d, quad %d, index = %d, ADCch = %d\n", | |
471 | digit.GetSector(0),digit.GetSector(1),index1,lADCDataChannel); // Ch. debug | |
472 | */ | |
473 | // | |
7f73eb6b | 474 | lADCDataValue2[index2] = digit.GetADCValue(0); |
475 | if (lADCDataValue2[index2] > 2047) lADCDataOvFlw2[index2] = 1; | |
476 | lADCDataValue2[index2+2] = digit.GetADCValue(1); | |
477 | if (lADCDataValue2[index2+2] > 2047) lADCDataOvFlw2[index2+2] = 1; | |
478 | // | |
479 | lADCData2[index2] = lADCDataGEO << 27 | lADCDataChannel << 17 | | |
480 | lADCDataOvFlw2[index2] << 12 | (lADCDataValue2[index2] & 0xfff); | |
481 | lADCData2[index2+2] = lADCDataGEO << 27 | lADCDataChannel << 17 | 0x1 << 16 | | |
482 | lADCDataOvFlw2[index2+2] << 12 | (lADCDataValue2[index2+2] & 0xfff); | |
483 | } | |
abf60186 | 484 | if((index1<0) || (index1>23)) { |
7f73eb6b | 485 | Error("Digits2Raw", "sector[0] = %d, sector[1] = %d", |
486 | digit.GetSector(0), digit.GetSector(1)); | |
487 | continue; | |
6de91202 | 488 | } |
abf60186 | 489 | if((index2<0) || (index2>19)) { |
6de91202 | 490 | Error("Digits2Raw", "sector[0] = %d, sector[1] = %d", |
491 | digit.GetSector(0), digit.GetSector(1)); | |
492 | continue; | |
1450a7cd | 493 | } |
1450a7cd | 494 | |
1450a7cd | 495 | |
1450a7cd | 496 | } |
abf60186 | 497 | //for(Int_t i=0;i<24;i++) printf("\t ADCData1[%d] = %x\n",i,lADCData1[i]); |
498 | //for(Int_t i=0;i<20;i++) printf("\t ADCData2[%d] = %x\n",i,lADCData2[i]); | |
7f73eb6b | 499 | |
6de91202 | 500 | // End of Block |
232b622f | 501 | UInt_t lADCEndBlockGEO = lADCHeaderGEO; |
502 | UInt_t lADCEndBlockEvCount = gAlice->GetEventNrInRun(); | |
1450a7cd | 503 | |
232b622f | 504 | lADCEndBlock = lADCEndBlockGEO << 27 | 0x1 << 26 | lADCEndBlockEvCount; |
1450a7cd | 505 | |
abf60186 | 506 | //printf("\t ADCEndBlock = %d\n",lADCEndBlock); |
6de91202 | 507 | |
508 | ||
509 | // open the output file | |
510 | char fileName[30]; | |
362c9d61 | 511 | strcpy(fileName,AliDAQ::DdlFileName("ZDC",0)); |
6de91202 | 512 | #ifndef __DECCXX |
513 | ofstream file(fileName, ios::binary); | |
514 | #else | |
515 | ofstream file(fileName); | |
516 | #endif | |
517 | ||
518 | // write the DDL data header | |
519 | AliRawDataHeader header; | |
7f73eb6b | 520 | header.fSize = sizeof(header) + sizeof(lADCHeader1) + sizeof(lADCData1) + |
521 | sizeof(lADCEndBlock)+ sizeof(lADCHeader2) + sizeof(lADCData2) + sizeof(lADCEndBlock); | |
abf60186 | 522 | /*printf("sizeof header = %d, ADCHeader1 = %d, ADCData1 = %d, ADCEndBlock = %d\n", |
523 | sizeof(header),sizeof(lADCHeader1),sizeof(lADCData1),sizeof(lADCEndBlock)); | |
524 | printf("sizeof header = %d, ADCHeader2 = %d, ADCData2 = %d, ADCEndBlock = %d\n", | |
525 | sizeof(header),sizeof(lADCHeader2),sizeof(lADCData2),sizeof(lADCEndBlock));*/ | |
6de91202 | 526 | header.SetAttribute(0); // valid data |
527 | file.write((char*)(&header), sizeof(header)); | |
528 | ||
529 | // write the raw data and close the file | |
7f73eb6b | 530 | file.write((char*) &lADCHeader1, sizeof (lADCHeader1)); |
531 | file.write((char*)(lADCData1), sizeof(lADCData1)); | |
532 | file.write((char*) &lADCEndBlock, sizeof(lADCEndBlock)); | |
533 | file.write((char*) &lADCHeader2, sizeof (lADCHeader2)); | |
534 | file.write((char*)(lADCData2), sizeof(lADCData2)); | |
232b622f | 535 | file.write((char*) &lADCEndBlock, sizeof(lADCEndBlock)); |
6de91202 | 536 | file.close(); |
537 | ||
538 | // unload the digits | |
539 | fLoader->UnloadDigits(); | |
359cdddc | 540 | } |
541 | ||
b81c9821 | 542 | //______________________________________________________________________ |
543 | void AliZDC::SetTreeAddress(){ | |
544 | // Set branch address for the Trees. | |
545 | // Inputs: | |
546 | // none. | |
547 | // Outputs: | |
548 | // none. | |
549 | // Return: | |
550 | // none. | |
551 | if (fLoader->TreeH() && (fHits == 0x0)) | |
552 | fHits = new TClonesArray("AliZDCHit",1000); | |
553 | ||
b81c9821 | 554 | AliDetector::SetTreeAddress(); |
555 | } | |
359cdddc | 556 | |
8af17dba | 557 | |
558 | //Calibration methods (by Alberto Colla) | |
559 | ||
560 | ||
561 | //________________________________________________________________ | |
562 | void AliZDC::CreateCalibData() | |
563 | { | |
564 | // | |
565 | //if (fCalibData) delete fCalibData; // delete previous version | |
566 | fCalibData = new AliZDCCalibData(GetName()); | |
567 | } | |
568 | //________________________________________________________________ | |
569 | void AliZDC::WriteCalibData(Int_t option) | |
570 | { | |
571 | // | |
572 | const int kCompressLevel = 9; | |
4d81e5e7 | 573 | char* fnam = GetZDCCalibFName(); |
8af17dba | 574 | if (!fnam || fnam[0]=='\0') { |
e689b8ea | 575 | fnam = gSystem->ExpandPathName("$(ALICE_ROOT)/data/AliZDCCalib.root"); |
8af17dba | 576 | Warning("WriteCalibData","No File Name is provided, using default %s",fnam); |
577 | } | |
578 | TFile* cdfile = TFile::Open(fnam,"UPDATE","",kCompressLevel); | |
579 | ||
580 | // Writes Calibration Data to current directory. | |
581 | // User MUST take care of corresponding file opening and ->cd()... !!! | |
582 | // By default, the object is overwritten. Use 0 option for opposite. | |
583 | if (option) option = TObject::kOverwrite; | |
584 | if (fCalibData) fCalibData->Write(0,option); | |
585 | else if (fCalibData) fCalibData->Write(0,option); | |
586 | ||
587 | cdfile->Close(); | |
588 | delete cdfile; | |
589 | } | |
590 | ||
591 | //________________________________________________________________ | |
592 | void AliZDC::LoadCalibData() | |
593 | { | |
594 | // | |
4d81e5e7 | 595 | char* fnam = GetZDCCalibFName(); |
8af17dba | 596 | if (!fnam || fnam[0]=='\0') return; |
597 | if (!gAlice->IsFileAccessible(fnam)) { | |
598 | Error("LoadCalibData","ZDC Calibration Data file is not accessible, %s",fnam); | |
599 | exit(1); | |
600 | } | |
601 | TFile* cdfile = TFile::Open(fnam); | |
602 | ||
603 | // Loads Calibration Data from current directory. | |
604 | // User MUST take care of corresponding file opening and ->cd()...!!! | |
605 | // | |
606 | if (fCalibData) delete fCalibData; // delete previous version | |
607 | TString dtname = "Calib_"; | |
608 | dtname += GetName(); | |
609 | fCalibData = (AliZDCCalibData*) gDirectory->Get(dtname.Data()); | |
610 | if (!fCalibData) { | |
611 | Error("LoadCalibData","No Calibration data found for %s",GetName()); | |
612 | exit(1); | |
613 | } | |
614 | ||
615 | cdfile->Close(); | |
616 | delete cdfile; | |
617 | } | |
618 | ||
619 | ||
620 | //Calibration methods (by Alberto Colla) |