]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TOF/AliTOFRawSector.cxx
Minor changes to the Digitizer procedure
[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//
43 fRocData = new TClonesArray("AliTOFRoc",14);
44}
45
46//______________________________________________________________________________
47AliTOFRawSector::AliTOFRawSector(const AliTOFRawSector& tofrawsector)
48 : fHeader(tofrawsector.fHeader), fGlobalCheckSum(tofrawsector.fGlobalCheckSum)
49{
50// copy ctor for AliTOFRawSector class
51// (required also by RC10 Coding Convention)
52//
53// we make here a new istance of the TClonesArray containing Roc Data
54 fRocData = new TClonesArray("AliTOFRoc",14);
55
56// we make here a copy of Roc Data
57
58 for(Int_t nroc=1; nroc<=14; nroc++){
59// get the pointers to the current roc of new and to be copied TClonesArray
60 AliTOFRoc* currentrocnew = (AliTOFRoc*)fRocData->UncheckedAt(nroc);
61 AliTOFRoc* currentrocold = (AliTOFRoc*)tofrawsector.fRocData->UncheckedAt(nroc);
62
63// we create here 2 references: one for the new current roc and another for the old one
64 AliTOFRoc& newroc = *currentrocnew;
65 AliTOFRoc& oldroc = *currentrocold;
66
67 newroc = oldroc; // 'operator =' called for AliTOFRoc
68
69 } // end loop on Roc Data
70}
71
72//______________________________________________________________________________
73AliTOFRawSector& AliTOFRawSector::operator=(const AliTOFRawSector& tofrawsector)
74{
75// Assignment operator for AliTOFRawSector
76// (required also by RC10 Coding Conventions)
77//
78 if (this !=&tofrawsector) { // do nothing if assigned to self
79 fHeader=tofrawsector.fHeader;
80 fGlobalCheckSum=tofrawsector.fGlobalCheckSum;
81// loop on ROC data
82 for(Int_t nroc=1; nroc<=14; nroc++){
83// get the pointers to the current roc of new and to be copied TClonesArray
84 AliTOFRoc* currentrocnew = (AliTOFRoc*)fRocData->UncheckedAt(nroc);
85 AliTOFRoc* currentrocold = (AliTOFRoc*)tofrawsector.fRocData->UncheckedAt(nroc);
86// we create here 2 references: one for the new current roc and another for the old one
87 AliTOFRoc& newroc = *currentrocnew;
88 AliTOFRoc& oldroc = *currentrocold;
89 newroc = oldroc; // 'operator =' called for AliTOFRoc
90 } // end loop on Roc Data
91 } // close if
92 return *this;
93}
94
95//______________________________________________________________________________
96AliTOFRawSector::~AliTOFRawSector()
97{
98// destructor of the AliTOFRawSector object
99// Here we delete the 14 AliTOFRoc istances
100//
101 if (fRocData) {
102 fRocData->Delete() ;
103 delete fRocData;
104 fRocData = 0;
105 }
106}
107
108//______________________________________________________________________________
109void AliTOFRawSector::WriteSector()
110{
111//
112// Starting from the raw data objects writes a binary file
113// similar to real raw data.
114//
115
116 FILE *rawfile;
117 rawfile = fopen("rawdata.dat","w");
118
119// fprintf(rawfile,Header);
120
121 Int_t nRoc;
122
123// loop on all AliTOFRoc Headers to set them
124 for(nRoc=1; nRoc<=14; nRoc++){
125 AliTOFRoc* currentRoc = (AliTOFRoc*)fRocData->UncheckedAt(nRoc);
126 currentRoc->SetHeader();
127 // UInt_t RocHeader = currentRoc->fHeader;
128// fprintf(rawfile,RocHeader);
129 }
130
131 for(nRoc=1; nRoc<=14; nRoc++){
132 AliTOFRoc* currentRoc = (AliTOFRoc*)fRocData->UncheckedAt(nRoc);
133 Int_t rocItems = currentRoc->GetItems();
134
135 for(Int_t nItem=1; nItem<=rocItems;nItem++){
136 // UInt_t TimeRow = currentRoc->GetTimeRow(nItem);
137// fprintf(rawfile,TimeRow);
138 // UInt_t ChrgRow = currentRoc->GetTimeRow(nItem);
139// fprintf(rawfile,ChrgRow);
140 }
141 }
142
143 // UInt_t EndOfSector = GlobalCheckSum;
144// fprintf(rawfile,EndOfSector);
145}
146
147//______________________________________________________________________________
148void AliTOFRawSector::ReadSector()
149{
150//
151// Starting from raw data initialize and write the
152// Raw Data objects
153//(i.e. a TClonesArray of 18 AliTOFRawSector)
154//
155
156 FILE *rawfile;
157 rawfile = fopen("rawdata.dat","r");
158
159// fscanf(rawfile,Header);
160// fscanf(rawfile,Header);
161 Int_t nRoc;
162
163 for(nRoc=1; nRoc<=14; nRoc++){
164 AliTOFRoc* currentRoc = (AliTOFRoc*)fRocData->UncheckedAt(nRoc);
165 UInt_t rocHeader;
166 fscanf(rawfile,"%u",&rocHeader);
167 currentRoc->SetHeader(rocHeader);
168 }
169
170// UInt_t SCMWord;
171// fscanf(rawfile,"%u",SCMWord);
172
173 for(nRoc=1; nRoc<=14; nRoc++){
174 AliTOFRoc* currentRoc = (AliTOFRoc*)fRocData->UncheckedAt(nRoc);
175 // Int_t Size = currentRoc->SetSize();
176 Int_t nItems = currentRoc->GetItems();
177 for(Int_t nrow=0; nrow<=nItems; nrow++){
178 UInt_t charRow,timeRow;
179 fscanf(rawfile,"%u",&charRow);
180 currentRoc->SetTime(nrow, charRow);
181 fscanf(rawfile,"%u",&timeRow);
182 currentRoc->SetTime(nrow, timeRow);
183 }
184 Int_t finalWord;
185 fscanf(rawfile,"%d",&finalWord);
186 }
187// fscanf(rawfile,GlobalCheckSum);
188}
189
190
191