]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TOF/AliTOFRawSector.cxx
Bug fixed into equipmentID-volume correspondence
[u/mrichter/AliRoot.git] / TOF / AliTOFRawSector.cxx
CommitLineData
68861244 1////////////////////////////////////////////////
2// Digitization class for set: TOF //
3// AliTOFRawSector class //
4// Member variables //
5// //
6// Member functions //
7// //
8//*-- Authors: Pierella, Seganti, Vicinanza //
9// (Bologna and Salerno University) //
10////////////////////////////////////////////////
11
12
13/**************************************************************************
14 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
15 * *
16 * Author: The ALICE Off-line Project. *
17 * Contributors are mentioned in the code where appropriate. *
18 * *
19 * Permission to use, copy, modify and distribute this software and its *
20 * documentation strictly for non-commercial purposes is hereby granted *
21 * without fee, provided that the above copyright notice appears in all *
22 * copies and that both the copyright notice and this permission notice *
23 * appear in the supporting documentation. The authors make no claims *
24 * about the suitability of this software for any purpose. It is *
25 * provided "as is" without express or implied warranty. *
26 **************************************************************************/
27
28#include "TClonesArray.h"
29
30#include "AliTOFRawSector.h"
31#include "AliTOFRoc.h"
32
33ClassImp(AliTOFRawSector)
34
35//______________________________________________________________________________
36AliTOFRawSector::AliTOFRawSector()
37{
38//
39// Constructor of AliTOFRawSector class
40// Each sector is in effect a
41// TClonesArray of 14 AliTOFRoc Objects
42//
2d8b0188 43 fRocData = 0;
68861244 44}
45
46//______________________________________________________________________________
47AliTOFRawSector::AliTOFRawSector(const AliTOFRawSector& tofrawsector)
5c016a7b 48:TObject()
49// : fHeader(tofrawsector.fHeader), fGlobalCheckSum(tofrawsector.fGlobalCheckSum)
68861244 50{
51// copy ctor for AliTOFRawSector class
52// (required also by RC10 Coding Convention)
53//
54// we make here a new istance of the TClonesArray containing Roc Data
55 fRocData = new TClonesArray("AliTOFRoc",14);
56
57// we make here a copy of Roc Data
58
59 for(Int_t nroc=1; nroc<=14; nroc++){
60// get the pointers to the current roc of new and to be copied TClonesArray
61 AliTOFRoc* currentrocnew = (AliTOFRoc*)fRocData->UncheckedAt(nroc);
62 AliTOFRoc* currentrocold = (AliTOFRoc*)tofrawsector.fRocData->UncheckedAt(nroc);
63
64// we create here 2 references: one for the new current roc and another for the old one
65 AliTOFRoc& newroc = *currentrocnew;
66 AliTOFRoc& oldroc = *currentrocold;
67
68 newroc = oldroc; // 'operator =' called for AliTOFRoc
69
70 } // end loop on Roc Data
71}
72
73//______________________________________________________________________________
74AliTOFRawSector& AliTOFRawSector::operator=(const AliTOFRawSector& tofrawsector)
75{
76// Assignment operator for AliTOFRawSector
77// (required also by RC10 Coding Conventions)
78//
79 if (this !=&tofrawsector) { // do nothing if assigned to self
80 fHeader=tofrawsector.fHeader;
81 fGlobalCheckSum=tofrawsector.fGlobalCheckSum;
82// loop on ROC data
83 for(Int_t nroc=1; nroc<=14; nroc++){
84// get the pointers to the current roc of new and to be copied TClonesArray
85 AliTOFRoc* currentrocnew = (AliTOFRoc*)fRocData->UncheckedAt(nroc);
86 AliTOFRoc* currentrocold = (AliTOFRoc*)tofrawsector.fRocData->UncheckedAt(nroc);
87// we create here 2 references: one for the new current roc and another for the old one
88 AliTOFRoc& newroc = *currentrocnew;
89 AliTOFRoc& oldroc = *currentrocold;
90 newroc = oldroc; // 'operator =' called for AliTOFRoc
91 } // end loop on Roc Data
92 } // close if
93 return *this;
94}
95
96//______________________________________________________________________________
97AliTOFRawSector::~AliTOFRawSector()
98{
99// destructor of the AliTOFRawSector object
100// Here we delete the 14 AliTOFRoc istances
101//
102 if (fRocData) {
103 fRocData->Delete() ;
104 delete fRocData;
105 fRocData = 0;
106 }
107}
108
109//______________________________________________________________________________
110void AliTOFRawSector::WriteSector()
111{
112//
113// Starting from the raw data objects writes a binary file
114// similar to real raw data.
115//
116
117 FILE *rawfile;
118 rawfile = fopen("rawdata.dat","w");
119
120// fprintf(rawfile,Header);
121
122 Int_t nRoc;
123
124// loop on all AliTOFRoc Headers to set them
125 for(nRoc=1; nRoc<=14; nRoc++){
126 AliTOFRoc* currentRoc = (AliTOFRoc*)fRocData->UncheckedAt(nRoc);
127 currentRoc->SetHeader();
128 // UInt_t RocHeader = currentRoc->fHeader;
129// fprintf(rawfile,RocHeader);
130 }
131
132 for(nRoc=1; nRoc<=14; nRoc++){
133 AliTOFRoc* currentRoc = (AliTOFRoc*)fRocData->UncheckedAt(nRoc);
134 Int_t rocItems = currentRoc->GetItems();
135
136 for(Int_t nItem=1; nItem<=rocItems;nItem++){
137 // UInt_t TimeRow = currentRoc->GetTimeRow(nItem);
138// fprintf(rawfile,TimeRow);
139 // UInt_t ChrgRow = currentRoc->GetTimeRow(nItem);
140// fprintf(rawfile,ChrgRow);
141 }
142 }
143
144 // UInt_t EndOfSector = GlobalCheckSum;
145// fprintf(rawfile,EndOfSector);
146}
147
148//______________________________________________________________________________
149void AliTOFRawSector::ReadSector()
150{
151//
152// Starting from raw data initialize and write the
153// Raw Data objects
154//(i.e. a TClonesArray of 18 AliTOFRawSector)
155//
156
157 FILE *rawfile;
158 rawfile = fopen("rawdata.dat","r");
159
160// fscanf(rawfile,Header);
161// fscanf(rawfile,Header);
162 Int_t nRoc;
163
164 for(nRoc=1; nRoc<=14; nRoc++){
165 AliTOFRoc* currentRoc = (AliTOFRoc*)fRocData->UncheckedAt(nRoc);
166 UInt_t rocHeader;
167 fscanf(rawfile,"%u",&rocHeader);
168 currentRoc->SetHeader(rocHeader);
169 }
170
171// UInt_t SCMWord;
172// fscanf(rawfile,"%u",SCMWord);
173
174 for(nRoc=1; nRoc<=14; nRoc++){
175 AliTOFRoc* currentRoc = (AliTOFRoc*)fRocData->UncheckedAt(nRoc);
176 // Int_t Size = currentRoc->SetSize();
177 Int_t nItems = currentRoc->GetItems();
178 for(Int_t nrow=0; nrow<=nItems; nrow++){
179 UInt_t charRow,timeRow;
180 fscanf(rawfile,"%u",&charRow);
181 currentRoc->SetTime(nrow, charRow);
182 fscanf(rawfile,"%u",&timeRow);
183 currentRoc->SetTime(nrow, timeRow);
184 }
185 Int_t finalWord;
186 fscanf(rawfile,"%d",&finalWord);
187 }
188// fscanf(rawfile,GlobalCheckSum);
189}
190
191
192