]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PHOS/AliPHOSRawStream.cxx
track matching macros from Alberto
[u/mrichter/AliRoot.git] / PHOS / AliPHOSRawStream.cxx
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
16 /* $Id$ */
17
18 ///////////////////////////////////////////////////////////////////////////////
19 ///
20 /// This class provides access to PHOS digits in raw data.
21 ///
22 /// It loops over all PHOS digits in the raw data given by the AliRawReader.
23 /// The Next method goes to the next digit. If there are no digits left
24 /// it returns kFALSE.
25 /// Several getters provide information about the current digit.
26 /// usage: 
27 /// root > AliRawReaderFile rawReader ; 
28 /// root > AliPHOSRawStream input(&rawReader) ; 
29 /// root > while (input.Next()) ..... 
30 ///////////////////////////////////////////////////////////////////////////////
31
32 #include <TString.h>
33 #include <TSystem.h>
34
35 #include "AliPHOSRawStream.h"
36 #include "AliRawReader.h"
37 #include "AliPHOSAltroMapping.h"
38
39 ClassImp(AliPHOSRawStream)
40
41
42 //_____________________________________________________________________________
43 AliPHOSRawStream::AliPHOSRawStream(AliRawReader* rawReader) :
44   AliAltroRawStream(rawReader),
45   fModule(-1),
46   fPrevModule(-1),
47   fRow(-1),
48   fPrevRow(-1),
49   fColumn(-1),
50   fPrevColumn(-1),
51   fGain(0)
52 {
53 // create an object to read PHOS raw digits
54
55   SelectRawData("PHOS");
56
57   TString path = gSystem->Getenv("ALICE_ROOT");
58   path += "/PHOS/mapping/RCU";
59   TString path2;
60   for(Int_t i = 0; i < 4; i++) {
61     path2 = path;
62     path2 += i;
63     path2 += ".data";
64     fMapping[i] = new AliPHOSAltroMapping(path2.Data());
65   }
66
67   SetNoAltroMapping(kFALSE);
68 }
69
70 //_____________________________________________________________________________
71 AliPHOSRawStream::AliPHOSRawStream(const AliPHOSRawStream& stream) :
72   AliAltroRawStream(stream),
73   fModule(-1),
74   fPrevModule(-1),
75   fRow(-1),
76   fPrevRow(-1),
77   fColumn(-1),
78   fPrevColumn(-1),
79   fGain(0)
80 {  
81   Fatal("AliPHOSRawStream", "copy constructor not implemented");
82 }
83
84 //_____________________________________________________________________________
85 AliPHOSRawStream& AliPHOSRawStream::operator = (const AliPHOSRawStream& 
86                                               /* stream */)
87 {
88   Fatal("operator =", "assignment operator not implemented");
89   return *this;
90 }
91
92 //_____________________________________________________________________________
93 AliPHOSRawStream::~AliPHOSRawStream()
94 {
95 // destructor
96
97   for(Int_t i = 0; i < 4; i++) delete fMapping[i];
98 }
99
100 //_____________________________________________________________________________
101 void AliPHOSRawStream::Reset()
102 {
103   // reset phos raw stream params
104   AliAltroRawStream::Reset();
105   fModule = fPrevModule = fRow = fPrevRow = fColumn = fPrevColumn = -1;
106   fGain = 0;
107 }
108
109 //_____________________________________________________________________________
110 Bool_t AliPHOSRawStream::Next()
111 {
112   // Read next PHOS signal
113   // Apply the PHOS altro mapping to get
114   // the module,row and column indeces
115   fPrevModule = fModule;
116   fPrevRow = fRow;
117   fPrevColumn = fColumn;
118   if (AliAltroRawStream::Next()) {
119     if (IsNewHWAddress())
120       ApplyAltroMapping();
121     return kTRUE;
122   }
123   else
124     return kFALSE;
125 }
126
127 //_____________________________________________________________________________
128 void AliPHOSRawStream::ApplyAltroMapping()
129 {
130   // Take the DDL index, load
131   // the corresponding altro mapping
132   // object and fill the sector,row and pad indeces
133   Int_t ddlNumber = GetDDLNumber();
134   fModule = ddlNumber / 4;
135
136   Int_t rcuIndex = ddlNumber % 4;
137
138   Short_t hwAddress = GetHWAddress();
139   fRow = fMapping[rcuIndex]->GetPadRow(hwAddress);
140   fColumn = fMapping[rcuIndex]->GetPad(hwAddress);
141   fGain = fMapping[rcuIndex]->GetSector(hwAddress);
142
143 }