/*
$Id$
*/
-
#include <stddef.h>
#include <iomanip>
#include <Riostream.h>
#include <fstream>
-#include <AliRunLoader.h>
-#include <AliLoader.h>
-#include <AliITS.h>
#include "AliITSspdTestBeam.h"
// Return:
// A default constructed AliITSspdTestBeam class
+ fRH = 0;
+ fRT = 0;
fNBrst = 0;
fBrstSize = 0;
fBrst = 0;
fNEvents = 0;
fBuffSize = 0;
fBuff = 0;
- fVersion = 0;
fITS = 0;
fNfiles = 0;
fMaxFiles = 0;
// Return:
// A default constructed AliITSspdTestBeam class
+ fRH = 0;
+ fRT = 0;
fNBrst = 0;
fBrstSize = 0;
fBrst = 0;
fNEvents = 0;
fBuffSize = 0;
fBuff = 0;
- fVersion = 0;
fITS = 0;
fNfiles = 0;
fMaxFiles = 0;
// none.
// Return:
// nothing.
+ Int_t i,np;
- DeletefBrst();
- DeletefNData();
- DeletefData();
- DeletefHData();
- DeletefTData();
- DeletefFiles();
- DeletefBrstSize();
- DeletefBuff();
- DeletefITS();
- DeletefNeventsStart();
- DeletefNeventsEnd();
-}
-//----------------------------------------------------------------------
-void AliITSspdTestBeam::DeletefBrst(){
- // Properly deletes fBrst object.
- // Inputs:
- // none.
- // Outputs:
- // none.
- // Return:
- // none.
- Int_t i;
-
- if(fBrst){
- for(i=0;i<fNBrst;i++) if(fBrst[i]){
- delete[] fBrst[i];
- fBrst[i] = 0;
- } // end for i/if
- delete[] fBrst;
- fBrst = 0;
- } // end if
-}
-//----------------------------------------------------------------------
-void AliITSspdTestBeam::DeletefNData(){
- // Properly deletes fNData object.
- // Inputs:
- // none.
- // Outputs:
- // none.
- // Return:
- // none.
- Int_t i,np=GetNumberOfPilots();
-
- if(fNData){
- for(i=0;i<np;i++) if(fNData[i]){
- delete[] fNData[i];
- fNData[i] = 0;
- } // end for i
- delete[] fNData;
- fNData = 0;
- } // end if
-}
-//----------------------------------------------------------------------
-void AliITSspdTestBeam::DeletefData(){
- // Properly deletes fData object.
- // Inputs:
- // none.
- // Outputs:
- // none.
- // Return:
- // none.
- Int_t i,j,np=GetNumberOfPilots();
-
- if(fData){
- for(i=0;i<np;i++) if(fData[i]){
- for(j=0;j<fNEvents;j++){
- delete[] fData[i][j];
- fData[i][j] = 0;
- } // end for j
- delete[] fData[i];
- fData[i] = 0;
- } // end for i
- delete[] fData;
- fData = 0;
+ np = GetNumberOfPilots();
+ fRH = 0; // Just a Pointer into fBuff.
+ fRT = 0; // Just a Pointer into fBuff.
+ if(fBrst){delete[] fBrst; fBrst = 0;}
+ if(fNData)for(i=0;i<np;i++){
+ if(fNData[i]) delete[] fNData[i];
} // end if
-}
-//----------------------------------------------------------------------
-void AliITSspdTestBeam::DeletefHData(){
- // Properly deletes fHData object.
- // Inputs:
- // none.
- // Outputs:
- // none.
- // Return:
- // none.
- Int_t i,j,np=GetNumberOfPilots();
-
- if(fHData){
- for(i=0;i<np;i++) if(fHData[i]){
- for(j=0;j<fNEvents;j++){
- delete[] fHData[i][j];
- fHData[i][j] = 0;
- } // end for j
- delete[] fHData[i];
- fHData[i] = 0;
- } // end for i
- delete[] fHData;
- fHData = 0;
+ if(fNData) {delete[] fNData; fNData = 0;}
+ if(fData)for(i=0;i<np;i++){
+ if(fData[i]) delete[] fData[i];
} // end if
-}
-//----------------------------------------------------------------------
-void AliITSspdTestBeam::DeletefTData(){
- // Properly deletes fTData object.
- // Inputs:
- // none.
- // Outputs:
- // none.
- // Return:
- // none.
- Int_t i,j,np=GetNumberOfPilots();
-
- if(fTData){
- for(i=0;i<np;i++) if(fTData[i]){
- for(j=0;j<fNEvents;j++){
- delete[] fTData[i][j];
- fTData[i][j] = 0;
- } // end for j
- delete[] fTData[i];
- fTData[i] = 0;
- } // end for i
- delete[] fTData;
- fTData = 0;
+ if(fData) delete[] fData;
+ fData = 0;
+ if(fHData)for(i=0;i<np;i++){
+ if(fHData[i]) delete[] fHData[i];
} // end if
-}
-//----------------------------------------------------------------------
-void AliITSspdTestBeam::DeletefFiles(){
- // Properly deletes fBrst object.
- // Inputs:
- // none.
- // Outputs:
- // none.
- // Return:
- // none.
- Int_t i;
-
- if(fFiles){
- for(i=0;i<fMaxFiles;i++){
- if(fFiles[i]!=0) delete fFiles[i];
- } // end for i
+ if(fHData) delete[] fHData;
+ fHData = 0;
+ if(fTData)for(i=0;i<np;i++){
+ if(fTData[i]) delete[] fTData[i];
} // end if
-}
-//----------------------------------------------------------------------
-void AliITSspdTestBeam::DeletefBrstSize(){
- // Properly deletes fBrstSize object.
- // Inputs:
- // none.
- // Outputs:
- // none.
- // Return:
- // none.
- Int_t i,np=GetNumberOfPilots();
-
- if(fBrstSize){
- for(i=0;i<np;i++){
- if(fBrstSize[i]){
- delete[] fBrstSize[i];
- fBrstSize[i] = 0;
- } // end if
- } // end for i
- delete[] fBrstSize;
- fBrstSize = 0;
+ if(fTData) delete[] fTData;
+ fTData = 0;
+ for(i=0;i<fMaxFiles;i++){
+ if(fFiles[i]!=0) delete fFiles[i];
+ } // end for i
+ if(fBrstSize)for(i=0;i<np;i++){
+ if(fBrstSize[i]) delete[] fBrstSize[i];
} // end if
+ if(fBrstSize) {delete[] fBrstSize; fBrstSize = 0;}
+ delete[] fBuff;
+ fITS = 0; //delete fITS;
+ delete[] fFiles;
+ delete[] fNeventsStart;
+ delete[] fNeventsEnd;
}
//----------------------------------------------------------------------
Int_t AliITSspdTestBeam::OpenInputFile(const Char_t *filename,Int_t start,Int_t end){
if(fMaxFiles==0) {
fMaxFiles = 5;
fFiles = new ifstream*[fMaxFiles];
- for(i=0;i<fMaxFiles;i++) fFiles[i] = 0;
fNeventsStart = new Int_t[fMaxFiles];
fNeventsEnd = new Int_t[fMaxFiles];
} // end if
AliITSspdTestBeamBurst *b;
np = GetNumberOfPilots();
- cout << "Sizeof(Headder)=" << fRH.SizeOf() << endl;
- cout << "Sizeof(Tail)=" << fRT.SizeOf() << endl;
ivnt = new Int_t[np];
for(i=0;i<np;i++) ivnt[i] = 0;
- fRH.SetBuffer(fBuff);//Set Run Header
- size = fRT.SizeOf();
- size = fBuffSize - size;
- cout <<"fBuffSize-sizeof(AliITSspdTestBeamTail) "<< size << endl;
- fRT.SetBuffer(&(fBuff[size]));
+ fRH = (AliITSspdTestBeamHeader*) &(fBuff[0]); // Sets up the Run Header.
+ fRT = (AliITSspdTestBeamTail*)&(fBuff[fBuffSize-fRT->SizeOf()]);
// Check termination
- size -= sizeof(UInt_t);
- tr = (UInt_t*) &(fBuff[size]);
+ tr = (UInt_t*) &(fBuff[fBuffSize-(fRT->SizeOf())-sizeof(UInt_t)]);
if(!(*tr==fTermination)){
- cout << "Error Termination word not found at " << size << " tr=0x" <<
- hex << *tr << dec << endl;
+ cout << "Error Termination word not found at "<<tr<<endl;
exit(-1);
} // end if
- DeletefBrst();
- DeletefNData();
- DeletefData();
- DeletefHData();
- DeletefTData();
- DeletefBrstSize();
- fNEvents = fRH.GetNumberOfEvents();
- if(fRT.GetNumberOfEvents()>fNEvents) fNEvents = fRT.GetNumberOfEvents();
- fNBrst = fNEvents/fRH.GetBurstSize();
+ if(fNData)for(i=0;i<np;i++){
+ if(fNData[i]) delete[] fNData[i];
+ } // end if
+ if(fNData) {delete[] fNData; fNData = 0;}
+ if(fData)for(i=0;i<np;i++){
+ if(fData[i]) delete[] fData[i];
+ } // end if
+ if(fData) {delete[] fData; fData = 0;}
+ if(fHData)for(i=0;i<np;i++){
+ if(fHData[i]) delete[] fHData[i];
+ } // end if
+ if(fHData) {delete[] fHData; fHData = 0;}
+ if(fTData)for(i=0;i<np;i++){
+ if(fTData[i]) delete[] fTData[i];
+ } // end if
+ if(fTData) {delete[] fTData; fTData = 0;}
+ if(fBrstSize)for(i=0;i<np;i++){
+ if(fBrstSize[i]) delete[] fBrstSize[i];
+ } // end if
+ if(fBrstSize) {delete[] fBrstSize; fBrstSize = 0;}
+ fNEvents = fRH->GetNumberOfEvents();
+ fNBrst = fNEvents/fRH->GetBurstSize();
fBrst = new AliITSspdTestBeamBurst*[fNBrst];
fBrstSize = new Int_t*[np];
fNData = new Int_t*[np];
fTData[i][j] = 0;
} // end for j
} // end for i
- size = fRH.SizeOf();
+ if(fBrst){delete[] fBrst; fBrst = 0;}
+ size = fRH->SizeOf();
u.bt = &fBuff[size];
//
- for(iburst=0;(*(u.wd) != fTermination)&&(u.wd<tr);iburst++){
- // loop over Bursts
- b = new AliITSspdTestBeamBurst(u.bt);
+ for(iburst=0;(*(u.wd) != fTermination)&&(u.wd<tr);iburst++){ // loop over Bursts
+ b = (AliITSspdTestBeamBurst *) u.wd;
fBrst[iburst] = b;
u.bt += b->SizeOf(); // increment wd byte wise
for(ip=0;ip<np;ip++){ // loop over pilots
// Get size of data stored for this pilot.
- AliITSTestBeamData::Swapit(4,u.bt);
- fBrstSize[ip][iburst] = (UInt_t) *(u.wd);
+ fBrstSize[ip][iburst] = (UInt_t) u.wd;
u.bt += sizeof(UInt_t); // increment wd byte wise
for(i=0;i<fBrstSize[ip][iburst];i++){ // loop over data
- AliITSTestBeamData::Swapit(4,u.bt);
- d = new AliITSspdTestBeamData(u.bt);
+ d = (AliITSspdTestBeamData *) u.wd;
switch (d->Mode()){
case AliITSTestBeamData::kData :
fNData[ip][ivnt[ip]]++;
// set pointer to first data member
- if(fData[ip][ivnt[ip]] == 0 ){
- fData[ip][ivnt[ip]] = d;
- } // end if
+ if(fData[ip][ivnt[ip]] == 0 ) fData[ip][ivnt[ip]] = d;
break;
case AliITSTestBeamData::kHead :
- fHData[ip][ivnt[ip]] = d;
- fTData[ip][ivnt[ip]] = 0;
fNData[ip][ivnt[ip]] = 0;
fData[ip][ivnt[ip]] = 0;
+ fHData[ip][ivnt[ip]++] = d;
break;
case AliITSTestBeamData::kTail :
case AliITSTestBeamData::kAbort :
- fTData[ip][ivnt[ip]++] = d;
+ fTData[ip][ivnt[ip]] = d;
break;
default:
cout << "Unknown Data Type: wd="<<hex<<*(u.wd)<<dec<<endl;
delete[] ivnt;
return stat;
}
-//----------------------------------------------------------------------
-Int_t AliITSspdTestBeam::DecodeModule(Int_t pilot,Int_t chip){
- // Determines the Module number based on the pilot and chip
- // valules and the fVersion of the simulation.
- // Inputs:
- // Int_t pilot Pilot number
- // Int_t chip chip number
- // Outputs:
- // none.
- // Return:
- // The module number (see simulations geometry).
-
- switch (fVersion) {
- case 2002:
- if(pilot==0) return chip;
- if(pilot==1) return 2;
- if(pilot==2) return chip+3;
- break;
- default:
- if(pilot==0) return chip;
- if(pilot==1) return 2;
- if(pilot==2) return chip+3;
- break;
- } // end switch
- return -1;
-}
-//----------------------------------------------------------------------
-Int_t AliITSspdTestBeam::DecodeColumn(Int_t pilot,Int_t chip,Int_t colm){
- // Determines the Column number based on the pilot, chip, and column
- // valules and the fVersion of the simulation.
- // Inputs:
- // Int_t pilot Pilot number
- // Int_t chip chip number
- // Int_t colm Column number
- // Outputs:
- // none.
- // Return:
- // The Column number (see simulations geometry).
- const Int_t colmperchip = 160/5; // Should be gotten from AliITSsegmentationSPD
-
- switch (fVersion) {
- case 2002:
- if(pilot==0) return colm;
- if(pilot==1) return colm+chip*colmperchip;
- if(pilot==2) return colm;
- break;
- default:
- if(pilot==0) return colm;
- if(pilot==1) return colm+chip*colmperchip;
- if(pilot==2) return colm;
- break;
- } // end switch
- return -1;
-}
-//----------------------------------------------------------------------
-void AliITSspdTestBeam::Digitize(Int_t evnt){
- // Write out ITS SPD Digits.
- // Inputs:
- // Int_t evnt events number
- // Outputs:
- // none.
- // Return:
- // none.
- Int_t p,i;
- Int_t module,chip,row,colm,digit[3];
- Int_t oldmodule=-1;
-
- fLoader->GetRunLoader()->SetEventNumber(evnt);
- fLoader->SetEvent();
- if(!(fLoader->TreeD())){
- fLoader->MakeTree("D");
- } // end if
-
- fITS->MakeBranch("D");
- //fITS->SetTreeAddress();
- fITS->SetTreeAddressD(fLoader->TreeD());
-
- for(p=0;p<GetNumberOfPilots();p++)
- for(i=0;i<fNData[p][evnt];i++){
- chip = fData[p][evnt]->Chip(i);
- module = DecodeModule(p,chip);
- row = fData[p][evnt]->Row(i);
- colm = DecodeColumn(p,chip,fData[p][evnt]->Colm(i));
- digit[0] = row; digit[1] = colm, digit[2] = 1;
- fITS->AddRealDigit(0,digit);
- if(module!=oldmodule) { // New Module
- oldmodule= module;
- fLoader->TreeD()->Fill();
- fITS->ResetDigits();
- } // end if
- } // end for p
- fITS->ClearModules();
- fLoader->TreeD()->GetEntries();
- fLoader->TreeD()->AutoSave();
- fLoader->TreeD()->Reset();
-}
-//----------------------------------------------------------------------
-void AliITSspdTestBeam::PrintHeadder(ostream *os){
- // Prints the Run Headder.
- // Inputs:
- // ostream *os Output stream where the data should go to
- // Outputs:
- // none.
- // Return:
- // none.
- fRH.Print(os);
-}
-//----------------------------------------------------------------------
-void AliITSspdTestBeam::PrintTrailer(ostream *os){
- // Prints the Run Trailer.
- // Inputs:
- // ostream *os Output stream where the data should go to
- // Outputs:
- // none.
- // Return:
- // none.
- fRT.Print(os);
-}
-//----------------------------------------------------------------------
-void AliITSspdTestBeam::PrintBurstInfo(Int_t i,ostream *os){
- // Prints the specified burts information
- // Inputs:
- // Int_t i Specifies which burst to print.
- // ostream *os Output stream where the data should go to
- // Outputs:
- // none.
- // Return:
- // none.
- fBrst[i]->Print(os);
-}
-//----------------------------------------------------------------------
-void AliITSspdTestBeam::PrintEventData(Int_t evnt,ostream *os){
- // Prints the data for a specified event number.
- // Inputs:
- // Int_t evnt events number
- // ostream *os Output stream where the data should go to
- // Outputs:
- // none.
- // Return:
- // none.
- Int_t p,i;
-
- for(p=0;p<GetNumberOfPilots();p++)
- for(i=0;i<fNData[p][evnt];i++){
- *os << "Pilot=" << setw(3) << p << " ";
- fData[p][evnt]->Print(os,i);
- *os << endl;
- } // end for p
-}
-//----------------------------------------------------------------------
-void AliITSspdTestBeam::PrintEventHead(Int_t evnt,ostream *os){
- // Prints the data Headder for a specified event number.
- // Inputs:
- // Int_t evnt events number
- // ostream *os Output stream where the data should go to
- // Outputs:
- // none.
- // Return:
- // none.
- Int_t p;
-
- for(p=0;p<GetNumberOfPilots();p++){
- *os << "Pilot=" << setw(3) << p << " " << *(fHData[p][evnt]);
- } // end for p
-}
-//----------------------------------------------------------------------
-void AliITSspdTestBeam::PrintEventTail(Int_t evnt,ostream *os){
- // Prints the data Trailer for a specified event number.
- // Inputs:
- // Int_t evnt events number
- // ostream *os Output stream where the data should go to
- // Outputs:
- // none.
- // Return:
- // none.
- Int_t p;
-
- for(p=0;p<GetNumberOfPilots();p++){
- *os << "Pilot=" << setw(3) << p << " " << *(fTData[p][evnt]);
- } // end for p
-}
-//============================================================================
-void AliITSTestBeamData::Swapit(Int_t i,UChar_t *a){
- // Swap the order of the bits
- // Inputs:
- // Int_t i Size of UChar_t array a.
- // UChar_t a Array of bytes to be swapped.
- // Outputs:
- // UChar_t a Array with bytes swapped
- // Return:
- // none.
- Int_t j;
- UChar_t c[i];
-
- for(j=0;j<i;j++) c[j] = a[i-j-1];
- for(j=0;j<i;j++) a[j] = c[j];
-}
//============================================================================
void AliITSspdTestBeamHeader::Print(ostream *os){
// print out the header information
#endif
#endif
*/
- *os<<"Version: "<<GetVersion()<<" Written: "<<fUnion->fHead.fDate;
- *os<<" " << fUnion->fHead.fTime << endl;
- *os<<"Buffer Size [0], [1], [2]: " << GetBuffSize(0) << ",";
- *os<<GetBuffSize(1)<<"," <<GetBuffSize(2) << endl;
- *os<<"Test Pulse: " << GetTestPulse() << endl;
- *os<<"Trigger Mode General, [0], [1], [2]: " << GetTriggerMode();
- *os<<","<<GetTrigger(0)<<","<<GetTrigger(1)<< ",";
- *os<<GetTrigger(2) << endl;
- *os<<"Number of Events: " << GetNumberOfEvents() << " Burst Size: ";
- *os<<GetBurstSize() << endl;
+ *os<<"Version: "<<fUnion.fHead.fVersion<<" Written: "<<fUnion.fHead.fDate;
+ *os<<" " << fUnion.fHead.fTime << endl;
+ *os<<"Buffer Size [0], [1], [2]: " << fUnion.fHead.fBuffSize[0] << ",";
+ *os<<fUnion.fHead.fBuffSize[1]<<"," <<fUnion.fHead.fBuffSize[2] << endl;
+ *os<<"Test Pulse: " << fUnion.fHead.fTestPulse << endl;
+ *os<<"Trigger Mode General, [0], [1], [2]: " << fUnion.fHead.fTriggerMode;
+ *os<<","<<fUnion.fHead.fTrigger[0]<<","<<fUnion.fHead.fTrigger[1]<< ",";
+ *os<<fUnion.fHead.fTrigger[2] << endl;
+ *os<<"Number of Events: " << fUnion.fHead.fNEvents << " Burst Size: ";
+ *os<<fUnion.fHead.fBurstSize << endl;
return;
}
//----------------------------------------------------------------------
#endif
#endif
*/
- *os << "Number of Events: "<< GetNumberOfEvents() << " Written: "
- << fUnion->fTail.fDate;
- *os << " " << fUnion->fTail.fTime << endl;
- *os <<"Termination Flag: " << GetTermMode() << endl;
+ *os << "Number of Events: "<< fUnion.fTail.fEvents << " Written: "
+ << fUnion.fTail.fDate;
+ *os << " " << fUnion.fTail.fTime << endl;
+ *os <<"Termination Flag: " << fUnion.fTail.fTermMode << endl;
return;
}
//----------------------------------------------------------------------
#endif
#endif
*/
- *os << "Burst Number: "<< GetEventNumber()<< " Transfers: "
- << GetTransfers() << endl;
+ *os << "Burst Number: "<< fUnion.fBrst.fNumber << " Transfers: "
+ << fUnion.fBrst.fTransfers << endl;
return;
}
//----------------------------------------------------------------------
return os;
}
//======================================================================
-void AliITSspdTestBeamData::Print(ostream *os,Int_t i){
+void AliITSspdTestBeamData::Print(ostream *os){
// print out the the Test Beam Data information
// Inputs:
// ostream *os Pointer to the output stream.
#endif
#endif
*/
- //*os << "Word=" << hex << (fUnion+i)->fBuf[0] << hex << (fUnion+i)->fBuf[1]
- // << hex << (fUnion+i)->fBuf[2] << hex << (fUnion+i)->fBuf[3]
- *os << "Word=" << hex << (fUnion+i)->fIBuff
- << dec;
- switch (this->Mode(i)){
+ *os << "Word=" << hex << fUnion.fBuf[0] << hex << fUnion.fBuf[1]
+ << hex << fUnion.fBuf[2] << hex << fUnion.fBuf[3] << dec;
+ switch (this->Mode()){
case AliITSTestBeamData::kData :
- *os << " kData chip=" << setw(3) << Chip(i);
- *os << " Row=" << setw(3) << Row(i);
- *os << " Column=" << setw(3) << Colm(i);
+ *os << " kData chip=" << setw(3) << fUnion.fDataD.fChip;
+ *os << " Row=" << setw(3) << fUnion.fDataD.fRow;
+ *os << " Column=" << setw(3) << fUnion.fDataD.fColm;
break;
case AliITSTestBeamData::kHead :
- *os << " kHead Event Sync =" << EventCounter();
+ *os << " kHead Event Sync =" << fUnion.fDataH.fEventSync;
break;
case AliITSTestBeamData::kTail :
- *os << " kTail Transmitted word count =" << TransWordCount();
+ *os << " kTail Transmitted word count =" << fUnion.fDataT.fTrans;
break;
case AliITSTestBeamData::kAbort :
- *os << " kAbort Transmitted word count =" << TransWordCount();
+ *os << " kAbort Transmitted word count =" << fUnion.fDataA.fTrans;
break;
default:
*os << " Unknown Data Type";
// Return:
// ostream &os pointing now to the end of the present stream.
- p.Print(&os,0);
+ p.Print(&os);
return os;
}
#include <Rtypes.h>
+#ifndef ALIITSSPDTESTBEAM_H
+#define ALIITSSPDTESTBEAM_H
+
+/* Copyright (c) 1998-2001, ALICE Experiment at CERN, All rights reserved *
+ * See cxx source for full Copyright notice */
+
+#include <TTask.h>
+
+//class ifstream;
+class AliITS;
+class AliITSspdTestBeamHeader;
+class AliITSspdTestBeamTail;
+class AliITSspdTestBeamBurst;
+class AliITSspdTestBeamData;
+
+class AliITSspdTestBeam : public TTask{
+ public:
+ AliITSspdTestBeam();
+ AliITSspdTestBeam(const Char_t *filename,const Char_t *opt="2002",
+ AliITS *its=0);
+ virtual ~AliITSspdTestBeam();
+ //
+ virtual Int_t OpenInputFile(const Char_t *filename,Int_t start=0,
+ Int_t end=-1);
+ virtual Int_t Read(Int_t i=0);
+ virtual Int_t Decode();
+ virtual Int_t GetNumberOfPilots(){return 3;}
+ private:
+ void SetTerminationWord(){fTermination=0xffffd9f0;}
+ //
+ AliITSspdTestBeamHeader *fRH; //! Run Header
+ AliITSspdTestBeamTail *fRT; //! Run Trailer
+ Int_t fNBrst; //! Number of burts (size of array).
+ Int_t **fBrstSize; //! Size of each burst for each pilot
+ AliITSspdTestBeamBurst **fBrst; //! Array of bursts.
+ Int_t **fNData; //! array of the number of data points
+ AliITSspdTestBeamData ***fData; //! Data
+ AliITSspdTestBeamData ***fHData; //! pointer to headers
+ AliITSspdTestBeamData ***fTData; //! pointer to Tail and Aborts
+ UInt_t fTermination; //! Termination word
+ Int_t fNEvents; // Number of events in file
+ Int_t fBuffSize; // Read Buffere Size
+ UChar_t *fBuff; // Read buffer
+ AliITS *fITS; // Pointer to the ITS.
+ Int_t fNfiles; // Number of input files to read from
+ Int_t fMaxFiles; // The size of the pointer array fFiles.
+ ifstream **fFiles; //! Array of Pointer to the input streams
+ Int_t *fNeventsStart; // Starting event number for each file
+ Int_t *fNeventsEnd; // Ending number of events for each file.
+ ClassDef(AliITSspdTestBeam,1) // Task to read SPD test beam data
+};
+#endif
//======================================================================
#ifndef ALIITSTESTBEAMDATA_H
#define ALIITSTESTBEAMDATA_H
AliITSTestBeamData(){};
virtual ~AliITSTestBeamData(){};
virtual Int_t SizeOf(){return 0;}
- virtual Double_t Swap(Double_t a){union{Double_t b;UChar_t c[8];}d;d.b=a;
- Swapit(8,d.c);return d.b;};
- virtual UInt_t Swap(UInt_t a){union{UInt_t b;UChar_t c[4];}d;d.b=a;
- Swapit(4,d.c);return d.b;};
- static void Swapit(Int_t i,UChar_t *a);
enum {kData,kHead,kTail,kAbort,kFail};
private:
};
class AliITSspdTestBeamHeader : public AliITSTestBeamData{
public:
- AliITSspdTestBeamHeader(){fUnion=0;};
- AliITSspdTestBeamHeader(UChar_t *f){SetBuffer(f);}
- virtual ~AliITSspdTestBeamHeader(){fUnion=0;};
+ AliITSspdTestBeamHeader(){};
+ virtual ~AliITSspdTestBeamHeader(){};
virtual void Print(ostream *os);
- virtual Int_t GetNumberOfEvents(){return Swap(fUnion->fHead.fNEvents);};
- virtual Int_t GetBuffSize(Int_t i=0){
- return Swap(fUnion->fHead.fBuffSize[i]);};
- virtual Int_t GetTestPulse(){return Swap(fUnion->fHead.fTestPulse);};
- virtual Int_t GetTrigger(Int_t i=0){
- return Swap(fUnion->fHead.fTrigger[i]);};
- virtual Int_t GetTriggerMode(){return Swap(fUnion->fHead.fTriggerMode);};
- virtual Int_t GetBurstSize(){return Swap(fUnion->fHead.fBurstSize);};
- virtual Double_t GetVersion(){return Swap(fUnion->fHead.fVersion);}
- virtual Int_t SizeOf(){return sizeof(union headder);};
- virtual void SetBuffer(UChar_t *f){
- fUnion=(AliITSspdTestBeamHeader::headder*)f;}
- virtual UChar_t *GetBuffer(){return fUnion->fBuf;}
- virtual Char_t *GetDate(){return fUnion->fHead.fDate;}
- virtual Char_t *GetTime(){return fUnion->fHead.fTime;}
+ virtual Int_t GetNumberOfEvents(){return fUnion.fHead.fNEvents;};
+ virtual Int_t GetBurstSize(Int_t i=0){return fUnion.fHead.fBuffSize[i];};
+ virtual Int_t SizeOf(){return sizeof(AliITSspdTestBeamHeader);};
private:
union headder{
struct {
UChar_t fA12Matrix[3][8192]; //
} fHead;
UChar_t fBuf[24904];
- } *fUnion;
+ } fUnion;
};
ostream &operator<<(ostream &os,AliITSspdTestBeamHeader &source);
#endif
class AliITSspdTestBeamTail : public AliITSTestBeamData{
public:
- AliITSspdTestBeamTail(){fUnion=0;};
- AliITSspdTestBeamTail(UChar_t *f){SetBuffer(f);}
- virtual ~AliITSspdTestBeamTail(){fUnion=0;};
- virtual Int_t GetNumberOfEvents(){return Swap(fUnion->fTail.fEvents);};
- virtual Int_t GetTermMode(){return Swap(fUnion->fTail.fTermMode);};
- virtual Int_t SizeOf(){return sizeof(union tail);}
+ AliITSspdTestBeamTail(){};
+ virtual ~AliITSspdTestBeamTail(){};
+ virtual Int_t SizeOf(){return sizeof(AliITSspdTestBeamTail);}
virtual void Print(ostream *os);
- virtual void SetBuffer(UChar_t *f){fUnion=(AliITSspdTestBeamTail::tail*)f;}
private:
union tail{
struct {
Char_t fTime[12];// Time Field
} fTail;
UChar_t fBuf[32];
- } *fUnion;
+ } fUnion;
};
ostream &operator<<(ostream &os,AliITSspdTestBeamTail &source);
#endif
class AliITSspdTestBeamBurst : public AliITSTestBeamData{
public:
- AliITSspdTestBeamBurst(){fUnion=0;};
- AliITSspdTestBeamBurst(UChar_t *f){SetBuffer(f);}
- virtual ~AliITSspdTestBeamBurst(){fUnion=0;};
- virtual Int_t GetEventNumber(){return Swap(fUnion->fBrst.fNumber);};
- virtual Int_t GetTransfers(){return Swap(fUnion->fBrst.fTransfers);};
- virtual Int_t SizeOf(){return sizeof(union tail);}
+ AliITSspdTestBeamBurst(){};
+ virtual ~AliITSspdTestBeamBurst(){};
+ virtual Int_t SizeOf(){return sizeof(AliITSspdTestBeamBurst);}
virtual void Print(ostream *os);
- virtual void SetBuffer(UChar_t *f){
- fUnion=(AliITSspdTestBeamBurst::tail*)f;}
private:
union tail{
struct {
UInt_t fTransfers;// Number of Transfers
} fBrst;
ULong64_t fBuf; // a strictly 64 bit long unsinged int
- } *fUnion;
+ } fUnion;
};
ostream &operator<<(ostream &os,AliITSspdTestBeamBurst &source);
#endif
class AliITSspdTestBeamData : public AliITSTestBeamData {
public:
//
- AliITSspdTestBeamData(){fUnion=0;};
- AliITSspdTestBeamData(UChar_t *f){SetBuffer(f);}
- virtual Int_t SizeOf(){return sizeof(union data);}
+ AliITSspdTestBeamData(){};
+ //AliITSspdTestBeamData(UInt_t *i){SetAddress(i);}
+ virtual Int_t SizeOf(){return sizeof(AliITSspdTestBeamData);}
virtual ~AliITSspdTestBeamData(){};
//
- virtual Bool_t IsHeader(Int_t i=0){return ((fUnion+i)->fDataH.fFlag==2||
- (fUnion+i)->fDataH.fFlag==3);}
- virtual Bool_t IsData(Int_t i=0){return ((fUnion+i)->fDataD.fFlag>3)&&
- ((fUnion+i)->fDataD.fFlag<8);}
- virtual Bool_t IsTrailer(Int_t i=0){return ((fUnion+i)->fDataT.fFlag==0);}
- virtual Bool_t IsAbort(Int_t i=0){return ((fUnion+i)->fDataA.fFlag==1);}
- virtual Int_t Mode(Int_t i=0){if(IsData(i)) return kData;
- else if(IsHeader(i)) return kHead;
- else if(IsTrailer(i)) return kTail;
- else if(IsAbort(i)) return kAbort;
+ virtual Bool_t IsHeader(){return (fUnion.fDataH.fFlag==2||
+ fUnion.fDataH.fFlag==3);}
+ virtual Bool_t IsData(){return (fUnion.fDataD.fFlag>3)&&
+ (fUnion.fDataD.fFlag<8);}
+ virtual Bool_t IsTrailer(){return (fUnion.fDataT.fFlag==0);}
+ virtual Bool_t IsAbort(){return (fUnion.fDataA.fFlag==1);}
+ virtual Int_t Mode(){if(IsData()) return kData;
+ else if(IsHeader()) return kHead;
+ else if(IsTrailer()) return kTail;
+ else if(IsAbort()) return kAbort;
else return kFail;}
virtual Int_t TransWordCount(){if(IsTrailer()||IsAbort())
- return fUnion->fDataT.fTrans;
+ return fUnion.fDataT.fTrans;
else return -1;}
virtual Int_t EventCounter(){
- if(IsHeader()) return fUnion->fDataH.fEventSync;else return -1;}
- virtual Int_t Chip(Int_t i=0){if(IsData())
- return (fUnion+i)->fDataD.fChip; else return -1;}
- virtual Int_t Row(Int_t i=0) {if(IsData())
- return (fUnion+i)->fDataD.fRow; else return -1;}
- virtual Int_t Colm(Int_t i=0){if(IsData())
- return (fUnion+i)->fDataD.fColm;else return -1;}
- virtual void Data(Int_t &ch,Int_t &rw,Int_t &cl,Int_t i=0){
- ch=Chip(i);rw=Row(i);cl=Colm(i);}
- virtual void Print(ostream *os,Int_t i=0);
- virtual void SetBuffer(UChar_t *f){fUnion=(AliITSspdTestBeamData::data*)f;}
+ if(IsHeader()) return fUnion.fDataH.fEventSync;else return -1;}
+ virtual Int_t Chip(){if(IsData()) return fUnion.fDataD.fChip;else return -1;}
+ virtual Int_t Row() {if(IsData()) return fUnion.fDataD.fRow; else return -1;}
+ virtual Int_t Colm(){if(IsData()) return fUnion.fDataD.fColm;else return -1;}
+ virtual void Data(Int_t &ch,Int_t &rw,Int_t &cl){ch=Chip();rw=Row();
+ cl=Colm();}
+ virtual void Print(ostream *os);
private:
union data{
- struct { // Definingthe fDataH bit field
- unsigned fDate:11; // Not Used
+ struct {
+ unsigned fDate:12; // Not Used
unsigned fEventSync:6;// Event syncronization counter
unsigned fFlag:3; // =2or3 Header
unsigned fPadding:12; // Not used
} fDataH;
- struct { // Definingthe fDataD bit field
+ struct {
unsigned fColm:5; // Pixel (Hit) Column Address
unsigned fRow:8; // Pixel Row Adress
unsigned fChip:4; // Pixel Chip Address
unsigned fFlag:3; // =4or5or6or7 Data
unsigned fPadding:12; // Not used
} fDataD;
- struct { // Definingthe fDataT bit field
+ struct {
unsigned fTrans:17; // Transmitted word count
unsigned fFlag:3; // =0 Trialer
unsigned fPadding:12; // Not used
} fDataT;
- struct { // Definingthe fDataA bit field
+ struct {
unsigned fTrans:17; // Transmitted word count
unsigned fFlag:3; // =1 Abort
unsigned fPadding:12; // Not used
} fDataA;
UChar_t fBuf[4];
- UInt_t fIBuff;
- } *fUnion;
+ } fUnion;
};
ostream &operator<<(ostream &os,AliITSspdTestBeamData &source);
#endif
-//======================================================================
-#ifndef ALIITSSPDTESTBEAM_H
-#define ALIITSSPDTESTBEAM_H
-
-/* Copyright (c) 1998-2001, ALICE Experiment at CERN, All rights reserved *
- * See cxx source for full Copyright notice */
-
-#include <TTask.h>
-
-//class ostream;
-class AliITS;
-class AliITSspdTestBeamHeader;
-class AliITSspdTestBeamTail;
-class AliITSspdTestBeamBurst;
-class AliITSspdTestBeamData;
-class AliLoader;
-
-class AliITSspdTestBeam : public TTask{
- public:
- AliITSspdTestBeam();
- AliITSspdTestBeam(const Char_t *filename,const Char_t *opt="2002",
- AliITS *its=0);
- virtual ~AliITSspdTestBeam();
- //
- virtual Int_t OpenInputFile(const Char_t *filename,Int_t start=0,
- Int_t end=-1);
- virtual Int_t Read(Int_t i=0);
- virtual Int_t Decode();
- virtual Int_t DecodeModule(Int_t pilot,Int_t Chip);
- virtual Int_t DecodeColumn(Int_t pilot,Int_t Chip,Int_t Colm);
- virtual void Digitize(Int_t evnt);
- virtual void SetLoader(AliLoader *loader) {fLoader = loader;}
- virtual void SetITS(AliITS *its) {fITS = its;}
- virtual Int_t GetNumberOfPilots(){return 3;}
- virtual Int_t GetNumberOfEvents(){return fNEvents;}
- virtual void PrintHeadder(ostream *os = &cout);
- virtual void PrintTrailer(ostream *os = &cout);
- virtual void PrintBurstInfo(Int_t i,ostream *os=&cout);
- virtual void PrintEventData(Int_t i,ostream *os=&cout);
- virtual void PrintEventHead(Int_t i,ostream *os=&cout);
- virtual void PrintEventTail(Int_t i,ostream *os=&cout);
- private:
- void SetTerminationWord(){fTermination=0xf0d8ffff;}
- void DeletefBrst();
- void DeletefNData();
- void DeletefData();
- void DeletefHData();
- void DeletefTData();
- void DeletefFiles();
- void DeletefBrstSize();
- void DeletefBuff(){delete[] fBuff;};
- void DeletefITS(){fITS=0;}
- void DeletefNeventsStart(){delete[] fNeventsStart;}
- void DeletefNeventsEnd(){delete[] fNeventsEnd;}
- //
- AliITSspdTestBeamHeader fRH; //! Run Header
- AliITSspdTestBeamTail fRT; //! Run Trailer
- Int_t fNBrst; //! Number of burts (size of array).
- Int_t **fBrstSize; //! Size of each burst for each pilot
- AliITSspdTestBeamBurst **fBrst; //! Array of bursts.
- Int_t **fNData; //! array of the number of data points
- AliITSspdTestBeamData ***fData; //! Data
- AliITSspdTestBeamData ***fHData; //! pointer to headers
- AliITSspdTestBeamData ***fTData; //! pointer to Tail and Aborts
- UInt_t fTermination; //! Termination word
- Int_t fNEvents; // Number of events in file
- Int_t fBuffSize; // Read Buffere Size
- UChar_t *fBuff; // Read buffer
- Int_t fVersion; // Test Beam Version number
- AliITS *fITS; // Pointer to the ITS.
- AliLoader *fLoader; //! Pointer to AliITSLoader.
- Int_t fNfiles; // Number of input files to read from
- Int_t fMaxFiles; // The size of the pointer array fFiles.
- ifstream **fFiles; //! Array of Pointer to the input streams
- Int_t *fNeventsStart; // Starting event number for each file
- Int_t *fNeventsEnd; // Ending number of events for each file.
- ClassDef(AliITSspdTestBeam,1) // Task to read SPD test beam data
-};
-#endif