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 digits
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;
121 for (Int_t indexDDL = 0; indexDDL < kDDL; indexDDL++)
128 else if (indexDDL >= 4)
133 precpvADC = new int **[iSMN];
134 for (Int_t i=0; i<iSMN; i++) precpvADC[i] = new int *[kRow];
135 for (Int_t i=0; i<iSMN;i++)
137 for (Int_t j=0; j<kRow; j++) precpvADC[i][j] = new int [kCol];
139 for (Int_t i = 0; i < iSMN; i++)
141 for (Int_t j = 0; j < kRow; j++)
143 for (Int_t k = 0; k < kCol; k++)
145 precpvADC[i][j][k] = 0;
151 AliPMDRawStream pmdinput(rawReader);
152 rawReader->Select("PMD", indexDDL, indexDDL);
154 pmdinput.DdlData(indexDDL,&pmdddlcont);
156 Int_t ientries = pmdddlcont.GetEntries();
157 for (Int_t ient = 0; ient < ientries; ient++)
159 AliPMDddldata *pmdddl = (AliPMDddldata*)pmdddlcont.UncheckedAt(ient);
161 Int_t det = pmdddl->GetDetector();
162 Int_t smn = pmdddl->GetSMN();
163 //Int_t mcm = pmdddl->GetMCM();
164 //Int_t chno = pmdddl->GetChannel();
165 Int_t row = pmdddl->GetRow();
166 Int_t col = pmdddl->GetColumn();
167 Int_t sig = pmdddl->GetSignal();
173 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
175 indexsmn = smn - indexDDL * 6;
177 else if (indexDDL == 4)
180 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
186 else if (smn >= 18 && smn < 24)
191 else if (indexDDL == 5)
194 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
196 if (smn >= 6 && smn < 12)
200 else if (smn >= 12 && smn < 18)
205 precpvADC[indexsmn][row][col] = sig;
210 // Add the sdigits here
213 for (Int_t indexsmn = 0; indexsmn < iSMN; indexsmn++)
217 ismn = indexsmn + indexDDL * 6;
220 else if (indexDDL == 4)
226 else if (indexsmn >= 6 && indexsmn < 12)
228 ismn = indexsmn + 12;
232 else if (indexDDL == 5)
238 else if (indexsmn >= 6 && indexsmn < 12)
245 for (Int_t irow = 0; irow < kRow; irow++)
247 for (Int_t icol = 0; icol < kCol; icol++)
251 Int_t sig1 = precpvADC[indexsmn][irow][icol];
253 // plug in a function to convert to adc to MeV
258 AddSDigit(trno,idet,ismn,irow,icol,edep);
268 pmdLoader->WriteSDigits("OVERWRITE");
271 // ------------------------------------------------------------------------- //
272 void AliPMDRawToSDigits::Raw2Digits(AliRunLoader *runLoader, AliRawReader *rawReader)
274 // Converts RAW data to digits
276 TObjArray pmdddlcont;
278 AliLoader *pmdLoader = runLoader->GetLoader("PMDLoader");
280 TTree* treeD = pmdLoader->TreeD();
283 pmdLoader->MakeTree("D");
284 treeD = pmdLoader->TreeD();
286 Int_t bufsize = 16000;
287 if (!fDigits) fDigits = new TClonesArray("AliPMDdigit", 1000);
288 treeD->Branch("PMDDigit", &fDigits, bufsize);
290 const Int_t kDDL = AliDAQ::NumberOfDdls("PMD");
291 const Int_t kRow = 48;
292 const Int_t kCol = 96;
298 for (Int_t indexDDL = 0; indexDDL < kDDL; indexDDL++)
305 else if (indexDDL >= 4)
310 precpvADC = new int **[iSMN];
311 for (Int_t i=0; i<iSMN; i++) precpvADC[i] = new int *[kRow];
312 for (Int_t i=0; i<iSMN;i++)
314 for (Int_t j=0; j<kRow; j++) precpvADC[i][j] = new int [kCol];
316 for (Int_t i = 0; i < iSMN; i++)
318 for (Int_t j = 0; j < kRow; j++)
320 for (Int_t k = 0; k < kCol; k++)
322 precpvADC[i][j][k] = 0;
328 AliPMDRawStream pmdinput(rawReader);
329 rawReader->Select("PMD", indexDDL, indexDDL);
331 //pmdinput.DdlData(&pmdddlcont);
332 pmdinput.DdlData(indexDDL,&pmdddlcont);
335 Int_t ientries = pmdddlcont.GetEntries();
336 for (Int_t ient = 0; ient < ientries; ient++)
338 AliPMDddldata *pmdddl = (AliPMDddldata*)pmdddlcont.UncheckedAt(ient);
340 Int_t det = pmdddl->GetDetector();
341 Int_t smn = pmdddl->GetSMN();
342 //Int_t mcm = pmdddl->GetMCM();
343 //Int_t chno = pmdddl->GetChannel();
344 Int_t row = pmdddl->GetRow();
345 Int_t col = pmdddl->GetColumn();
346 Int_t sig = pmdddl->GetSignal();
352 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
354 indexsmn = smn - indexDDL * 6;
356 else if (indexDDL == 4)
359 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
365 else if (smn >= 18 && smn < 24)
370 else if (indexDDL == 5)
373 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
375 if (smn >= 6 && smn < 12)
379 else if (smn >= 12 && smn < 18)
384 precpvADC[indexsmn][row][col] = sig;
389 // Add the digits here
392 for (Int_t indexsmn = 0; indexsmn < iSMN; indexsmn++)
396 ismn = indexsmn + indexDDL * 6;
399 else if (indexDDL == 4)
405 else if (indexsmn >= 6 && indexsmn < 12)
407 ismn = indexsmn + 12;
411 else if (indexDDL == 5)
417 else if (indexsmn >= 6 && indexsmn < 12)
424 for (Int_t irow = 0; irow < kRow; irow++)
426 for (Int_t icol = 0; icol < kCol; icol++)
429 Int_t sig1 = precpvADC[indexsmn][irow][icol];
431 // plug in a function to convert to adc to MeV
434 AddDigit(trno,idet,ismn,irow,icol,sig1);
444 pmdLoader->WriteDigits("OVERWRITE");
447 // ------------------------------------------------------------------------- //
449 void AliPMDRawToSDigits::AdcToMeV(Int_t adc, Float_t &edep)
451 // To be implemented, this is just for the test
453 const Float_t kConstant = 7.181;
454 // const Float_t kErConstant = 0.6899;
455 const Float_t kSlope = 35.93;
456 // const Float_t kErSlope = 0.306;
460 Float_t adc10bit = (Float_t) adc/4;
461 edep = (1000.0/kSlope)*(adc10bit - kConstant);
464 // ------------------------------------------------------------------------- //
466 void AliPMDRawToSDigits::AddSDigit(Int_t trnumber, Int_t det, Int_t smnumber,
467 Int_t irow, Int_t icol, Float_t adc)
471 if (!fSDigits) fSDigits = new TClonesArray("AliPMDsdigit", 1000);
472 TClonesArray &lsdigits = *fSDigits;
473 new(lsdigits[fNsdigit++]) AliPMDsdigit(trnumber,det,smnumber,irow,icol,adc);
476 // ------------------------------------------------------------------------- //
477 void AliPMDRawToSDigits::AddDigit(Int_t trnumber, Int_t det, Int_t smnumber,
478 Int_t irow, Int_t icol, Float_t adc)
482 if (!fDigits) fDigits = new TClonesArray("AliPMDdigit", 1000);
483 TClonesArray &ldigits = *fDigits;
484 new(ldigits[fNdigit++]) AliPMDdigit(trnumber,det,smnumber,irow,icol,adc);
487 // ------------------------------------------------------------------------- //
488 void AliPMDRawToSDigits::ResetSDigit()
492 if (fSDigits) fSDigits->Clear();
494 // ------------------------------------------------------------------------- //
495 void AliPMDRawToSDigits::ResetDigit()
499 if (fDigits) fDigits->Clear();