1 /***************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 //-----------------------------------------------------//
18 // Date : October 09 2006 //
19 // converts raw to sdigit and digit //
21 //-----------------------------------------------------//
23 #include <Riostream.h>
25 #include <TObjArray.h>
26 #include <TClonesArray.h>
30 #include "AliRunLoader.h"
31 #include "AliLoader.h"
32 #include "AliRawReader.h"
34 #include "AliPMDsdigit.h"
35 #include "AliPMDdigit.h"
36 #include "AliPMDRawToSDigits.h"
37 #include "AliPMDRawStream.h"
38 #include "AliPMDddldata.h"
41 ClassImp(AliPMDRawToSDigits)
43 AliPMDRawToSDigits::AliPMDRawToSDigits():
44 fSDigits(new TClonesArray("AliPMDsdigit", 1000)),
45 fDigits(new TClonesArray("AliPMDdigit", 1000)),
54 // ------------------------------------------------------------------------- //
55 AliPMDRawToSDigits::AliPMDRawToSDigits(const AliPMDRawToSDigits & /*pmdr2sd*/):
56 TObject(/* pmdr2sd */),
63 AliFatal("Copy constructor not implemented");
65 // ------------------------------------------------------------------------- //
68 AliPMDRawToSDigits &AliPMDRawToSDigits::operator=(const AliPMDRawToSDigits &/* pmdr2sd */)
70 // assignment operator
71 AliFatal("Assignment operator not implemented");
75 // ------------------------------------------------------------------------- //
77 AliPMDRawToSDigits::~AliPMDRawToSDigits()
94 // ------------------------------------------------------------------------- //
96 void AliPMDRawToSDigits::Raw2SDigits(AliRunLoader *runLoader, AliRawReader *rawReader)
98 // Converts RAW data to sdigits
100 TObjArray pmdddlcont;
101 AliLoader *pmdLoader = runLoader->GetLoader("PMDLoader");
103 TTree* treeS = pmdLoader->TreeS();
106 pmdLoader->MakeTree("S");
107 treeS = pmdLoader->TreeS();
109 Int_t bufsize = 16000;
110 if (!fSDigits) fSDigits = new TClonesArray("AliPMDsdigit", 1000);
111 treeS->Branch("PMDSDigit", &fSDigits, bufsize);
113 // const Int_t kDDL = AliDAQ::NumberOfDdls("PMD");
114 const Int_t kRow = 48;
115 const Int_t kCol = 96;
116 const Int_t kSMN = 48;
123 precpvADC = new int **[kSMN];
124 for (Int_t i=0; i<kSMN; i++) precpvADC[i] = new int *[kRow];
125 for (Int_t i=0; i<kSMN;i++)
127 for (Int_t j=0; j<kRow; j++) precpvADC[i][j] = new int [kCol];
129 for (Int_t i = 0; i < kSMN; i++)
131 for (Int_t j = 0; j < kRow; j++)
133 for (Int_t k = 0; k < kCol; k++)
135 precpvADC[i][j][k] = 0;
140 AliPMDRawStream pmdinput(rawReader);
142 while ((indexDDL = pmdinput.DdlData(&pmdddlcont)) >=0)
144 Int_t ientries = pmdddlcont.GetEntries();
145 for (Int_t ient = 0; ient < ientries; ient++)
147 AliPMDddldata *pmdddl = (AliPMDddldata*)pmdddlcont.UncheckedAt(ient);
149 Int_t det = pmdddl->GetDetector();
150 Int_t smn = pmdddl->GetSMN();
151 //Int_t mcm = pmdddl->GetMCM();
152 //Int_t chno = pmdddl->GetChannel();
153 Int_t row = pmdddl->GetRow();
154 Int_t col = pmdddl->GetColumn();
155 Int_t sig = pmdddl->GetSignal();
160 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
164 else if (indexDDL == 4 || indexDDL == 5)
167 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
172 precpvADC[indexsmn][row][col] = sig;
179 // Add the sdigits here
181 for ( indexsmn = 0; indexsmn < kSMN; indexsmn++)
189 else if (indexsmn > 23)
192 ismn = indexsmn - 24;
194 for (Int_t irow = 0; irow < kRow; irow++)
196 for (Int_t icol = 0; icol < kCol; icol++)
200 Int_t sig1 = precpvADC[indexsmn][irow][icol];
202 // plug in a function to convert to adc to MeV
207 AddSDigit(trno,idet,ismn,irow,icol,edep);
216 pmdLoader->WriteSDigits("OVERWRITE");
218 // Delete all the pointers
220 for (Int_t i = 0; i < kSMN; i++)
222 for (Int_t j = 0; j < kRow; j++)
224 delete [] precpvADC[i][j];
227 for (Int_t j = 0; j < kSMN; j++)
229 delete [] precpvADC[j];
234 // ------------------------------------------------------------------------- //
235 void AliPMDRawToSDigits::Raw2Digits(AliRunLoader *runLoader, AliRawReader *rawReader)
237 // Converts RAW data to digits
239 TObjArray pmdddlcont;
241 AliLoader *pmdLoader = runLoader->GetLoader("PMDLoader");
243 TTree* treeD = pmdLoader->TreeD();
246 pmdLoader->MakeTree("D");
247 treeD = pmdLoader->TreeD();
249 Int_t bufsize = 16000;
250 if (!fDigits) fDigits = new TClonesArray("AliPMDdigit", 1000);
251 treeD->Branch("PMDDigit", &fDigits, bufsize);
253 // const Int_t kDDL = AliDAQ::NumberOfDdls("PMD");
254 const Int_t kRow = 48;
255 const Int_t kCol = 96;
256 const Int_t kSMN = 48;
263 precpvADC = new int **[kSMN];
264 for (Int_t i=0; i<kSMN; i++) precpvADC[i] = new int *[kRow];
265 for (Int_t i=0; i<kSMN;i++)
267 for (Int_t j=0; j<kRow; j++) precpvADC[i][j] = new int [kCol];
269 for (Int_t i = 0; i < kSMN; i++)
271 for (Int_t j = 0; j < kRow; j++)
273 for (Int_t k = 0; k < kCol; k++)
275 precpvADC[i][j][k] = 0;
280 AliPMDRawStream pmdinput(rawReader);
282 while ((indexDDL = pmdinput.DdlData(&pmdddlcont)) >=0)
284 Int_t ientries = pmdddlcont.GetEntries();
285 for (Int_t ient = 0; ient < ientries; ient++)
287 AliPMDddldata *pmdddl = (AliPMDddldata*)pmdddlcont.UncheckedAt(ient);
289 Int_t det = pmdddl->GetDetector();
290 Int_t smn = pmdddl->GetSMN();
291 //Int_t mcm = pmdddl->GetMCM();
292 //Int_t chno = pmdddl->GetChannel();
293 Int_t row = pmdddl->GetRow();
294 Int_t col = pmdddl->GetColumn();
295 Int_t sig = pmdddl->GetSignal();
301 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
305 else if (indexDDL == 4 || indexDDL == 5)
308 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
312 precpvADC[indexsmn][row][col] = sig;
318 // Add the digits here
319 for (indexsmn = 0; indexsmn < kSMN; indexsmn++)
326 else if (indexsmn > 23)
331 for (Int_t irow = 0; irow < kRow; irow++)
333 for (Int_t icol = 0; icol < kCol; icol++)
336 Int_t sig1 = precpvADC[indexsmn][irow][icol];
338 // plug in a function to convert to adc to MeV
341 AddDigit(trno,idet,ismn,irow,icol,sig1);
349 pmdLoader->WriteDigits("OVERWRITE");
351 // Delete all the pointers
353 for (Int_t i = 0; i < kSMN; i++)
355 for (Int_t j = 0; j < kRow; j++)
357 delete [] precpvADC[i][j];
360 for (Int_t j = 0; j < kSMN; j++)
362 delete [] precpvADC[j];
366 // ------------------------------------------------------------------------- //
368 void AliPMDRawToSDigits::AdcToMeV(Int_t adc, Float_t &edep)
370 // To be implemented, this is just for the test
372 const Float_t kConstant = 7.181;
373 // const Float_t kErConstant = 0.6899;
374 const Float_t kSlope = 35.93;
375 // const Float_t kErSlope = 0.306;
379 Float_t adc10bit = (Float_t) adc/4;
380 edep = (1000.0/kSlope)*(adc10bit - kConstant);
383 // ------------------------------------------------------------------------- //
385 void AliPMDRawToSDigits::AddSDigit(Int_t trnumber, Int_t det, Int_t smnumber,
386 Int_t irow, Int_t icol, Float_t adc)
390 if (!fSDigits) fSDigits = new TClonesArray("AliPMDsdigit", 1000);
391 TClonesArray &lsdigits = *fSDigits;
392 new(lsdigits[fNsdigit++]) AliPMDsdigit(trnumber,det,smnumber,irow,icol,adc);
395 // ------------------------------------------------------------------------- //
396 void AliPMDRawToSDigits::AddDigit(Int_t trnumber, Int_t det, Int_t smnumber,
397 Int_t irow, Int_t icol, Float_t adc)
401 if (!fDigits) fDigits = new TClonesArray("AliPMDdigit", 1000);
402 TClonesArray &ldigits = *fDigits;
403 new(ldigits[fNdigit++]) AliPMDdigit(trnumber,det,smnumber,irow,icol,adc);
406 // ------------------------------------------------------------------------- //
407 void AliPMDRawToSDigits::ResetSDigit()
411 if (fSDigits) fSDigits->Clear();
413 // ------------------------------------------------------------------------- //
414 void AliPMDRawToSDigits::ResetDigit()
418 if (fDigits) fDigits->Clear();