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)
49 // : fHeader(tofrawsector.fHeader), fGlobalCheckSum(tofrawsector.fGlobalCheckSum)
51 // copy ctor for AliTOFRawSector class
52 // (required also by RC10 Coding Convention)
54 // we make here a new istance of the TClonesArray containing Roc Data
55 fRocData = new TClonesArray("AliTOFRoc",14);
57 // we make here a copy of Roc Data
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);
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;
68 newroc = oldroc; // 'operator =' called for AliTOFRoc
70 } // end loop on Roc Data
73 //______________________________________________________________________________
74 AliTOFRawSector& AliTOFRawSector::operator=(const AliTOFRawSector& tofrawsector)
76 // Assignment operator for AliTOFRawSector
77 // (required also by RC10 Coding Conventions)
79 if (this !=&tofrawsector) { // do nothing if assigned to self
80 fHeader=tofrawsector.fHeader;
81 fGlobalCheckSum=tofrawsector.fGlobalCheckSum;
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
96 //______________________________________________________________________________
97 AliTOFRawSector::~AliTOFRawSector()
99 // destructor of the AliTOFRawSector object
100 // Here we delete the 14 AliTOFRoc istances
109 //______________________________________________________________________________
110 void AliTOFRawSector::WriteSector()
113 // Starting from the raw data objects writes a binary file
114 // similar to real raw data.
118 rawfile = fopen("rawdata.dat","w");
120 // fprintf(rawfile,Header);
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);
132 for(nRoc=1; nRoc<=14; nRoc++){
133 AliTOFRoc* currentRoc = (AliTOFRoc*)fRocData->UncheckedAt(nRoc);
134 Int_t rocItems = currentRoc->GetItems();
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);
144 // UInt_t EndOfSector = GlobalCheckSum;
145 // fprintf(rawfile,EndOfSector);
148 //______________________________________________________________________________
149 void AliTOFRawSector::ReadSector()
152 // Starting from raw data initialize and write the
154 //(i.e. a TClonesArray of 18 AliTOFRawSector)
158 rawfile = fopen("rawdata.dat","r");
160 // fscanf(rawfile,Header);
161 // fscanf(rawfile,Header);
164 for(nRoc=1; nRoc<=14; nRoc++){
165 AliTOFRoc* currentRoc = (AliTOFRoc*)fRocData->UncheckedAt(nRoc);
167 fscanf(rawfile,"%u",&rocHeader);
168 currentRoc->SetHeader(rocHeader);
172 // fscanf(rawfile,"%u",SCMWord);
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);
186 fscanf(rawfile,"%d",&finalWord);
188 // fscanf(rawfile,GlobalCheckSum);