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 for (Int_t indexDDL = 0; indexDDL < kDDL; indexDDL++)
144 AliPMDRawStream pmdinput(rawReader);
145 rawReader->Select("PMD", indexDDL, indexDDL);
147 pmdinput.DdlData(indexDDL,&pmdddlcont);
149 Int_t ientries = pmdddlcont.GetEntries();
150 for (Int_t ient = 0; ient < ientries; ient++)
152 AliPMDddldata *pmdddl = (AliPMDddldata*)pmdddlcont.UncheckedAt(ient);
154 Int_t det = pmdddl->GetDetector();
155 Int_t smn = pmdddl->GetSMN();
156 //Int_t mcm = pmdddl->GetMCM();
157 //Int_t chno = pmdddl->GetChannel();
158 Int_t row = pmdddl->GetRow();
159 Int_t col = pmdddl->GetColumn();
160 Int_t sig = pmdddl->GetSignal();
165 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
169 else if (indexDDL == 4 || indexDDL == 5)
172 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
177 precpvADC[indexsmn][row][col] = sig;
184 // Add the sdigits here
186 for ( indexsmn = 0; indexsmn < kSMN; indexsmn++)
194 else if (indexsmn > 23)
197 ismn = indexsmn - 24;
199 for (Int_t irow = 0; irow < kRow; irow++)
201 for (Int_t icol = 0; icol < kCol; icol++)
205 Int_t sig1 = precpvADC[indexsmn][irow][icol];
207 // plug in a function to convert to adc to MeV
212 AddSDigit(trno,idet,ismn,irow,icol,edep);
221 pmdLoader->WriteSDigits("OVERWRITE");
223 // Delete all the pointers
225 for (Int_t i = 0; i < kSMN; i++)
227 for (Int_t j = 0; j < kRow; j++)
229 delete [] precpvADC[i][j];
232 for (Int_t j = 0; j < kSMN; j++)
234 delete [] precpvADC[j];
239 // ------------------------------------------------------------------------- //
240 void AliPMDRawToSDigits::Raw2Digits(AliRunLoader *runLoader, AliRawReader *rawReader)
242 // Converts RAW data to digits
244 TObjArray pmdddlcont;
246 AliLoader *pmdLoader = runLoader->GetLoader("PMDLoader");
248 TTree* treeD = pmdLoader->TreeD();
251 pmdLoader->MakeTree("D");
252 treeD = pmdLoader->TreeD();
254 Int_t bufsize = 16000;
255 if (!fDigits) fDigits = new TClonesArray("AliPMDdigit", 1000);
256 treeD->Branch("PMDDigit", &fDigits, bufsize);
258 const Int_t kDDL = AliDAQ::NumberOfDdls("PMD");
259 const Int_t kRow = 48;
260 const Int_t kCol = 96;
261 const Int_t kSMN = 48;
268 precpvADC = new int **[kSMN];
269 for (Int_t i=0; i<kSMN; i++) precpvADC[i] = new int *[kRow];
270 for (Int_t i=0; i<kSMN;i++)
272 for (Int_t j=0; j<kRow; j++) precpvADC[i][j] = new int [kCol];
274 for (Int_t i = 0; i < kSMN; i++)
276 for (Int_t j = 0; j < kRow; j++)
278 for (Int_t k = 0; k < kCol; k++)
280 precpvADC[i][j][k] = 0;
284 for (Int_t indexDDL = 0; indexDDL < kDDL; indexDDL++)
287 AliPMDRawStream pmdinput(rawReader);
288 rawReader->Select("PMD", indexDDL, indexDDL);
290 //pmdinput.DdlData(&pmdddlcont);
291 pmdinput.DdlData(indexDDL,&pmdddlcont);
294 Int_t ientries = pmdddlcont.GetEntries();
295 for (Int_t ient = 0; ient < ientries; ient++)
297 AliPMDddldata *pmdddl = (AliPMDddldata*)pmdddlcont.UncheckedAt(ient);
299 Int_t det = pmdddl->GetDetector();
300 Int_t smn = pmdddl->GetSMN();
301 //Int_t mcm = pmdddl->GetMCM();
302 //Int_t chno = pmdddl->GetChannel();
303 Int_t row = pmdddl->GetRow();
304 Int_t col = pmdddl->GetColumn();
305 Int_t sig = pmdddl->GetSignal();
311 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
315 else if (indexDDL == 4 || indexDDL == 5)
318 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
322 precpvADC[indexsmn][row][col] = sig;
328 // Add the digits here
329 for (indexsmn = 0; indexsmn < kSMN; indexsmn++)
336 else if (indexsmn > 23)
341 for (Int_t irow = 0; irow < kRow; irow++)
343 for (Int_t icol = 0; icol < kCol; icol++)
346 Int_t sig1 = precpvADC[indexsmn][irow][icol];
348 // plug in a function to convert to adc to MeV
351 AddDigit(trno,idet,ismn,irow,icol,sig1);
359 pmdLoader->WriteDigits("OVERWRITE");
361 // Delete all the pointers
363 for (Int_t i = 0; i < kSMN; i++)
365 for (Int_t j = 0; j < kRow; j++)
367 delete [] precpvADC[i][j];
370 for (Int_t j = 0; j < kSMN; j++)
372 delete [] precpvADC[j];
376 // ------------------------------------------------------------------------- //
378 void AliPMDRawToSDigits::AdcToMeV(Int_t adc, Float_t &edep)
380 // To be implemented, this is just for the test
382 const Float_t kConstant = 7.181;
383 // const Float_t kErConstant = 0.6899;
384 const Float_t kSlope = 35.93;
385 // const Float_t kErSlope = 0.306;
389 Float_t adc10bit = (Float_t) adc/4;
390 edep = (1000.0/kSlope)*(adc10bit - kConstant);
393 // ------------------------------------------------------------------------- //
395 void AliPMDRawToSDigits::AddSDigit(Int_t trnumber, Int_t det, Int_t smnumber,
396 Int_t irow, Int_t icol, Float_t adc)
400 if (!fSDigits) fSDigits = new TClonesArray("AliPMDsdigit", 1000);
401 TClonesArray &lsdigits = *fSDigits;
402 new(lsdigits[fNsdigit++]) AliPMDsdigit(trnumber,det,smnumber,irow,icol,adc);
405 // ------------------------------------------------------------------------- //
406 void AliPMDRawToSDigits::AddDigit(Int_t trnumber, Int_t det, Int_t smnumber,
407 Int_t irow, Int_t icol, Float_t adc)
411 if (!fDigits) fDigits = new TClonesArray("AliPMDdigit", 1000);
412 TClonesArray &ldigits = *fDigits;
413 new(ldigits[fNdigit++]) AliPMDdigit(trnumber,det,smnumber,irow,icol,adc);
416 // ------------------------------------------------------------------------- //
417 void AliPMDRawToSDigits::ResetSDigit()
421 if (fSDigits) fSDigits->Clear();
423 // ------------------------------------------------------------------------- //
424 void AliPMDRawToSDigits::ResetDigit()
428 if (fDigits) fDigits->Clear();