1 ////////////////////////////////////////////////
2 // Digitization class for set: TOF //
3 // AliTOFRawSector class //
8 //*-- Authors: Pierella, Seganti, Vicinanza //
9 // (Bologna and Salerno University) //
10 ////////////////////////////////////////////////
13 /**************************************************************************
14 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
16 * Author: The ALICE Off-line Project. *
17 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
28 #include "TClonesArray.h"
30 #include "AliTOFRawSector.h"
31 #include "AliTOFRoc.h"
33 ClassImp(AliTOFRawSector)
35 //______________________________________________________________________________
36 AliTOFRawSector::AliTOFRawSector()
39 // Constructor of AliTOFRawSector class
40 // Each sector is in effect a
41 // TClonesArray of 14 AliTOFRoc Objects
46 //______________________________________________________________________________
47 AliTOFRawSector::AliTOFRawSector(const AliTOFRawSector& tofrawsector)
48 : fHeader(tofrawsector.fHeader), fGlobalCheckSum(tofrawsector.fGlobalCheckSum)
50 // copy ctor for AliTOFRawSector class
51 // (required also by RC10 Coding Convention)
53 // we make here a new istance of the TClonesArray containing Roc Data
54 fRocData = new TClonesArray("AliTOFRoc",14);
56 // we make here a copy of Roc Data
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);
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;
67 newroc = oldroc; // 'operator =' called for AliTOFRoc
69 } // end loop on Roc Data
72 //______________________________________________________________________________
73 AliTOFRawSector& AliTOFRawSector::operator=(const AliTOFRawSector& tofrawsector)
75 // Assignment operator for AliTOFRawSector
76 // (required also by RC10 Coding Conventions)
78 if (this !=&tofrawsector) { // do nothing if assigned to self
79 fHeader=tofrawsector.fHeader;
80 fGlobalCheckSum=tofrawsector.fGlobalCheckSum;
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
95 //______________________________________________________________________________
96 AliTOFRawSector::~AliTOFRawSector()
98 // destructor of the AliTOFRawSector object
99 // Here we delete the 14 AliTOFRoc istances
108 //______________________________________________________________________________
109 void AliTOFRawSector::WriteSector()
112 // Starting from the raw data objects writes a binary file
113 // similar to real raw data.
117 rawfile = fopen("rawdata.dat","w");
119 // fprintf(rawfile,Header);
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);
131 for(nRoc=1; nRoc<=14; nRoc++){
132 AliTOFRoc* currentRoc = (AliTOFRoc*)fRocData->UncheckedAt(nRoc);
133 Int_t rocItems = currentRoc->GetItems();
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);
143 // UInt_t EndOfSector = GlobalCheckSum;
144 // fprintf(rawfile,EndOfSector);
147 //______________________________________________________________________________
148 void AliTOFRawSector::ReadSector()
151 // Starting from raw data initialize and write the
153 //(i.e. a TClonesArray of 18 AliTOFRawSector)
157 rawfile = fopen("rawdata.dat","r");
159 // fscanf(rawfile,Header);
160 // fscanf(rawfile,Header);
163 for(nRoc=1; nRoc<=14; nRoc++){
164 AliTOFRoc* currentRoc = (AliTOFRoc*)fRocData->UncheckedAt(nRoc);
166 fscanf(rawfile,"%u",&rocHeader);
167 currentRoc->SetHeader(rocHeader);
171 // fscanf(rawfile,"%u",SCMWord);
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);
185 fscanf(rawfile,"%d",&finalWord);
187 // fscanf(rawfile,GlobalCheckSum);