/************************************************************************** * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * * * * Author: The ALICE Off-line Project. * * Contributors are mentioned in the code where appropriate. * * * * Permission to use, copy, modify and distribute this software and its * * documentation strictly for non-commercial purposes is hereby granted * * without fee, provided that the above copyright notice appears in all * * copies and that both the copyright notice and this permission notice * * appear in the supporting documentation. The authors make no claims * * about the suitability of this software for any purpose. It is * * provided "as is" without express or implied warranty. * **************************************************************************/ /* $Id$ */ // A set of classes/routines that can read the SPD test beam data of 2002 // and create AliITSdigits. The posibility to use these routines to do the // same for later and other detectors has yet to be demonstrated. At present // there remains a bug in that the TreeE of event headders isn't created // properly. See the macro AliITSspdTestBeam2Digits.C. The geometry from // the class AliITSvSPD002 must be read in, one way or the other, so that // the Geometry transoformation class AliITSgeom will prpoerly be inilized. //#include #include #include "AliITSspdTestBeam.h" ClassImp(AliITSspdTestBeam) //---------------------------------------------------------------------- AliITSspdTestBeam::AliITSspdTestBeam(){ // Default Constructor for the Task AliITSspdTestBeam. // Inputs: // none. // Outputs: // none. // Return: // A default constructed AliITSspdTestBeam class fRH = 0; fRT = 0; fNBrst = 0; fBrstSize = 0; fBrst = 0; fNData = 0; fData = 0; fHData = 0; fTData = 0; SetTerminationWord(); fNEvents = 0; fBuffSize = 0; fBuff = 0; fITS = 0; fNfiles = 0; fMaxFiles = 0; fFiles = 0; fNeventsStart = 0; fNeventsEnd = 0; } //---------------------------------------------------------------------- AliITSspdTestBeam::AliITSspdTestBeam(const Char_t *filename,const Char_t *opt, AliITS *its){ // Standard Constructor for the Task AliITSspdTestBeam. // Inputs: // const Char_t *filename File where to read in the SPD test beam data // const Char_t *opt Option, 2002 => 2002 test beam data. // Outputs: // none. // Return: // A default constructed AliITSspdTestBeam class fRH = 0; fRT = 0; fNBrst = 0; fBrstSize = 0; fBrst = 0; fNData = 0; fData = 0; fHData = 0; fTData = 0; SetTerminationWord(); fNEvents = 0; fBuffSize = 0; fBuff = 0; fITS = 0; fNfiles = 0; fMaxFiles = 0; fFiles = 0; fNeventsStart = 0; fNeventsEnd = 0; // fITS = its; fNfiles = 0; OpenInputFile(filename,0,-1); if(strcmp(opt,"2002")) cout << "2002 assumed" << endl; } //---------------------------------------------------------------------- AliITSspdTestBeam::~AliITSspdTestBeam(){ // Destructor. Frees up any memory allocated or closes any files opened. // Inputs: // none. // Outputs: // none. // Return: // nothing. Int_t i,np; 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;iseekg(0,ios::end); filesize = fFiles[i]->tellg(); fFiles[i]->seekg(0,ios::beg); if(fBuff) delete[] fBuff; fBuffSize = filesize; fBuff = new UChar_t[fBuffSize]; fFiles[i]->read((Char_t*)fBuff,fBuffSize); fFiles[i] ->close(); return filesize; } //---------------------------------------------------------------------- Int_t AliITSspdTestBeam::Decode(){ // Decode the fBuff read in. // Inputs: // none. // Outputs: // none. // Return: // sets up the array fData fRH, and fRT Int_t stat=0; UInt_t *tr; union { UInt_t *wd; UChar_t *bt; }u; // end union Int_t size; Int_t *ivnt,iburst,ip,np,i,j; AliITSspdTestBeamData *d; AliITSspdTestBeamBurst *b; np = GetNumberOfPilots(); ivnt = new Int_t[np]; for(i=0;iSizeOf()]); // Check termination tr = (UInt_t*) &(fBuff[fBuffSize-(fRT->SizeOf())-sizeof(UInt_t)]); if(!(*tr==fTermination)){ cout << "Error Termination word not found at "<GetNumberOfEvents(); fNBrst = fNEvents/fRH->GetBurstSize(); fBrst = new AliITSspdTestBeamBurst*[fNBrst]; fBrstSize = new Int_t*[np]; fNData = new Int_t*[np]; fData = new AliITSspdTestBeamData**[np]; fHData = new AliITSspdTestBeamData**[np]; fTData = new AliITSspdTestBeamData**[np]; for(i=0;iSizeOf(); u.bt = &fBuff[size]; // for(iburst=0;(*(u.wd) != fTermination)&&(u.wdSizeOf(); // increment wd byte wise for(ip=0;ipMode()){ case AliITSTestBeamData::kData : fNData[ip][ivnt[ip]]++; // set pointer to first data member if(fData[ip][ivnt[ip]] == 0 ) fData[ip][ivnt[ip]] = d; break; case AliITSTestBeamData::kHead : 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; break; default: cout << "Unknown Data Type: wd="<SizeOf(); // increment wd byte wise } // end for i (next data word). } // end for loop over pilots (ip). } // end for loop over bursts delete[] ivnt; return stat; } //============================================================================ void AliITSspdTestBeamHeader::Print(ostream *os)const{ // print out the header information // Inputs: // ostream *os Pointer to the output stream. // Outputs: // none. // Return: // none. /* #if defined __GNUC__ #if __GNUC__ > 2 ios::fmtflags fmt; #else Int_t fmt; #endif #else #if defined __ICC || defined __ECC ios::fmtflags fmt; #else Int_t fmt; #endif #endif */ *os<<"Version: "< 2 ios::fmtflags fmt; #else Int_t fmt; #endif #else #if defined __ICC || defined __ECC ios::fmtflags fmt; #else Int_t fmt; #endif #endif */ *os << "Number of Events: "<< fUnion.fTail.fEvents << " Written: " << fUnion.fTail.fDate; *os << " " << fUnion.fTail.fTime << endl; *os <<"Termination Flag: " << fUnion.fTail.fTermMode << endl; return; } //---------------------------------------------------------------------- ostream &operator<<(ostream &os,AliITSspdTestBeamTail &p){ // Standard output operator. See Print // Inputs: // ostream &os the output stream. // AliITSspdTestBeamHeader &p the data to be printed out. // Outputs: // none. // Return: // ostream &os pointing now to the end of the present stream. p.Print(&os); return os; } //============================================================================ void AliITSspdTestBeamBurst::Print(ostream *os)const{ // print out the Burst information // Inputs: // ostream *os Pointer to the output stream. // Outputs: // none. // Return: // none. /* #if defined __GNUC__ #if __GNUC__ > 2 ios::fmtflags fmt; #else Int_t fmt; #endif #else #if defined __ICC || defined __ECC ios::fmtflags fmt; #else Int_t fmt; #endif #endif */ *os << "Burst Number: "<< fUnion.fBrst.fNumber << " Transfers: " << fUnion.fBrst.fTransfers << endl; return; } //---------------------------------------------------------------------- ostream &operator<<(ostream &os,AliITSspdTestBeamBurst &p){ // Standard output operator. See Print // Inputs: // ostream &os the output stream. // AliITSspdTestBeamHeader &p the data to be printed out. // Outputs: // none. // Return: // ostream &os pointing now to the end of the present stream. p.Print(&os); return os; } //====================================================================== void AliITSspdTestBeamData::Print(ostream *os)const{ // print out the the Test Beam Data information // Inputs: // ostream *os Pointer to the output stream. // Outputs: // none. // Return: // none. /* #if defined __GNUC__ #if __GNUC__ > 2 ios::fmtflags fmt; #else Int_t fmt; #endif #else #if defined __ICC || defined __ECC ios::fmtflags fmt; #else Int_t fmt; #endif #endif */ *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) << 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 =" << fUnion.fDataH.fEventSync; break; case AliITSTestBeamData::kTail : *os << " kTail Transmitted word count =" << fUnion.fDataT.fTrans; break; case AliITSTestBeamData::kAbort : *os << " kAbort Transmitted word count =" << fUnion.fDataA.fTrans; break; default: *os << " Unknown Data Type"; break; } // end switch *os << endl; return; } //---------------------------------------------------------------------- ostream &operator<<(ostream &os,AliITSspdTestBeamData &p){ // Standard output operator. See Print // Inputs: // ostream &os the output stream. // AliITSspdTestBeamHeader &p the data to be printed out. // Outputs: // none. // Return: // ostream &os pointing now to the end of the present stream. p.Print(&os); return os; }