/************************************************************************** * 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$ */ #include #include #include #include #include #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 fNBrst = 0; fBrstSize = 0; fBrst = 0; fNData = 0; fData = 0; fHData = 0; fTData = 0; SetTerminationWord(); fNEvents = 0; fBuffSize = 0; fBuff = 0; fVersion = 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 fNBrst = 0; fBrstSize = 0; fBrst = 0; fNData = 0; fData = 0; fHData = 0; fTData = 0; SetTerminationWord(); fNEvents = 0; fBuffSize = 0; fBuff = 0; fVersion = 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. 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;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(); cout << "Sizeof(Headder)=" << fRH.SizeOf() << endl; cout << "Sizeof(Tail)=" << fRT.SizeOf() << endl; ivnt = new Int_t[np]; for(i=0;ifNEvents) fNEvents = fRT.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(); // 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; } // end if break; case AliITSTestBeamData::kHead : fHData[ip][ivnt[ip]] = d; fTData[ip][ivnt[ip]] = 0; fNData[ip][ivnt[ip]] = 0; fData[ip][ivnt[ip]] = 0; 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; } //---------------------------------------------------------------------- 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; } //---------------------------------------------------------------------- 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;pChip(i); module = DecodeModule(p,chip); row = fData[p][evnt]->Row(i); colm = 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;pPrint(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 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: "<fHead.fDate; *os<<" " << fUnion->fHead.fTime << endl; *os<<"Buffer Size [0], [1], [2]: " << GetBuffSize(0) << ","; *os< 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: "<< GetNumberOfEvents() << " Written: " << fUnion->fTail.fDate; *os << " " << fUnion->fTail.fTime << endl; *os <<"Termination Flag: " << GetTermMode() << 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){ // 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: "<< GetEventNumber()<< " Transfers: " << GetTransfers() << 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,Int_t i){ // 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+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)){ case AliITSTestBeamData::kData : *os << " kData chip=" << setw(3) << Chip(i); *os << " Row=" << setw(3) << Row(i); *os << " Column=" << setw(3) << Colm(i); break; case AliITSTestBeamData::kHead : *os << " kHead Event Sync =" << EventCounter(); break; case AliITSTestBeamData::kTail : *os << " kTail Transmitted word count =" << TransWordCount(); break; case AliITSTestBeamData::kAbort : *os << " kAbort Transmitted word count =" << TransWordCount(); 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,0); return os; }