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