/************************************************************************** * Copyright(c) 1998-2003, 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$ */ //This class contains all the necessary methods to create the Raw Data //files (slides) for the ITS data challenges for: //SPD //SDD //SSD #include #include #include #include "AliITSdigit.h" #include "AliITSDDLRawData.h" #include "AliRawDataHeader.h" #include "AliITSRawStreamSPD.h" #include "AliITSRawStreamSDD.h" #include "AliITSRawStreamSSD.h" #include "AliBitPacking.h" #include "AliDAQ.h" ClassImp(AliITSDDLRawData) //////////////////////////////////////////////////////////////////////////////////////// AliITSDDLRawData::AliITSDDLRawData(): fVerbose(0), fIndex(-1), fHalfStaveModule(-1){ //Default constructor } //////////////////////////////////////////////////////////////////////////////////////// AliITSDDLRawData::AliITSDDLRawData(const AliITSDDLRawData &source) : TObject(source), fVerbose(source.fVerbose), fIndex(source.fIndex), fHalfStaveModule(source.fHalfStaveModule){ //Copy Constructor } //////////////////////////////////////////////////////////////////////////////////////// AliITSDDLRawData& AliITSDDLRawData::operator=(const AliITSDDLRawData &source){ //Assigment operator this->fIndex=source.fIndex; this->fHalfStaveModule=source.fHalfStaveModule; this->fVerbose=source.fVerbose; return *this; } //////////////////////////////////////////////////////////////////////////////////////// //STRIP // void AliITSDDLRawData::GetDigitsSSD(TClonesArray *ITSdigits,Int_t mod,Int_t modR,Int_t ddl,UInt_t *buf){ //This method packs the SSD digits in a proper 32 bits structure Int_t ix; Int_t iz; Int_t is; UInt_t word; UInt_t baseWord; Int_t ndigits = ITSdigits->GetEntries(); AliITSdigit *digs; ofstream ftxt; if(ndigits){ if (fVerbose==2){ ftxt.open("SSDdigits.txt",ios::app); } for (Int_t digit=0;digitUncheckedAt(digit); iz=digs->GetCoord1(); // If iz==0, N side and if iz=1 P side ix=digs->GetCoord2(); // Strip Numbar is=digs->GetCompressedSignal(); // ADC Signal // cout<<" Module:"<GetEntries(); AliITSdigit *digs; ofstream ftxt; if(ndigits){ //cout<<"Mudule "<UncheckedAt(digit); iz=digs->GetCoord1(); // Anode ix=digs->GetCoord2(); // Time is=digs->GetCompressedSignal(); // ADC Signal if (fVerbose==2) ftxt<<"DDL:"<255){Error("GetDigitsSDD", "bits words is needed)!!!");} baseWord=0; /* //10 bits words for amplitude value word=is; AliBitPacking::PackWord(word,baseWord,0,9);//ADC data word=ix; AliBitPacking::PackWord(word,baseWord,10,17);//Time bucket word=iz; AliBitPacking::PackWord(word,baseWord,18,26);//Anode Number word=mod; AliBitPacking::PackWord(word,baseWord,27,31);//Module number */ //8bits words for amplitude value word=is; AliBitPacking::PackWord(word,baseWord,0,7);//ADC data word=ix; AliBitPacking::PackWord(word,baseWord,8,15);//Time bucket word=iz; AliBitPacking::PackWord(word,baseWord,16,24);//Anode Number word=mod; AliBitPacking::PackWord(word,baseWord,25,31);//Module number fIndex++; buf[fIndex]=baseWord; }//end for }//end if if(fVerbose==2) ftxt.close(); return; }//end GetDigitsSDD //////////////////////////////////////////////////////////////////////////////////////// //PIXEL // void AliITSDDLRawData::GetDigitsSPD(TClonesArray *ITSdigits,Int_t mod,Int_t ddl, UInt_t *buf){ //This method packs the SPD digits in a proper 32 structure //Since data is zero suppressed,the coordinates for the chip having zero digits //doesn't get listed in the galice.root file. However the SPD format requires //the empty chip to be written with chip header and chip trailer. //The index of the half stave is calculated as (mod/2). Int_t ix; Int_t iz; Int_t chipNo=0; UInt_t baseWord=0; UInt_t hitRow=0; Int_t chipHitCount=0; //Number of Hit in the current chip Int_t previousChip=-1; //Previuos chip respect to the actual aone Int_t ndigits = ITSdigits->GetEntries(); //number of digits in the current module //cout<<" Number of digits in the current module:"<UncheckedAt(digit); /*--------------------------------------------------------------------------- * Each module contains 5 read out chips of 256 rows and 32 columns. * So, the cell number in Z direction varies from 0 to 159. Therefore, * to get the chip address (0 to 4), we need to divide column number by 32. * ---------------------------------------------------------------------*/ iz=digs->GetCoord1(); // Cell number in Z direction ix=digs->GetCoord2(); // Cell number in X direction chipNo=iz/32; if(fVerbose==2) ftxt<<"DDL:"<4) WriteChipHeader(i+5,(mod/2),baseWord); else WriteChipHeader(i,(mod/2),baseWord); WriteChipTrailer(buf,chipHitCount,baseWord); chipHitCount=0; }//end for WriteChipHeader(chipNo,(mod/2),baseWord); chipHitCount++; WriteHit(buf,ix,hitRow,baseWord); previousChip=chipNo; }//end if else{ if(previousChip!=chipNo){ WriteChipTrailer(buf,chipHitCount,baseWord); chipHitCount=0; for(Int_t i=previousChip+1;i4)end+=5; WriteChipTrailer(buf,chipHitCount,baseWord); chipHitCount=0; for(Int_t i=chipNo+1;i<=end;i++){ WriteChipHeader(i,(mod/2),baseWord); WriteChipTrailer(buf,0,baseWord); chipHitCount=0; }//end for }//end if else{ //In this module there aren't digits but //the chip header and chip trailer are store anyway if(fHalfStaveModule){ chipNo=5; fHalfStaveModule=-1; }//end if for(Int_t i=0;i<5;i++){ WriteChipHeader(chipNo+i,(mod/2),baseWord); WriteChipTrailer(buf,chipHitCount,baseWord); chipHitCount=0; }//end for }//end else if(fVerbose==2) ftxt.close(); return; }//end GetDigitsSPD ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Int_t AliITSDDLRawData::RawDataSPD(TBranch* branch){ //This method creates the Raw data files for SPD detectors const Int_t kSize=21000; //256*32*5=40960 max number of digits per module UInt_t buf[kSize]; //One buffer cell can contain 2 digits fIndex=-1; TClonesArray*& digits = * (TClonesArray**) branch->GetAddress(); char fileName[15]; ofstream outfile; // logical name of the output file AliRawDataHeader header; //loop over DDLs for(Int_t i=0;iClear(); branch->GetEvent(moduleNumber); //For each Module, buf contains the array of data words in Binary format //fIndex gives the number of 32 bits words in the buffer for each module GetDigitsSPD(digits,mod,i,buf); outfile.write((char *)buf,((fIndex+1)*sizeof(UInt_t))); for(Int_t i=0;i<(fIndex+1);i++){ buf[i]=0; }//end for fIndex=-1; }//end for //Write REAL DATA HEADER UInt_t currentFilePosition=outfile.tellp(); outfile.seekp(dataHeaderPosition); header.fSize=currentFilePosition-dataHeaderPosition; outfile.write((char*)(&header),sizeof(header)); outfile.close(); }//end for return 0; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Int_t AliITSDDLRawData::RawDataSSD(TBranch* branch){ //This method creates the Raw data files for SSD detectors const Int_t kSize=1536;//768*2 Number of stripe * number of sides(N and P) UInt_t buf[kSize]; fIndex=-1; TClonesArray*& digits = * (TClonesArray**) branch->GetAddress(); char fileName[15]; ofstream outfile; // logical name of the output file AliRawDataHeader header; //loop over DDLs for(Int_t i=0;iClear(); branch->GetEvent(moduleNumber); //For each Module, buf contains the array of data words in Binary format //fIndex gives the number of 32 bits words in the buffer for each module GetDigitsSSD(digits,mod,moduleNumber,i,buf); outfile.write((char *)buf,((fIndex+1)*sizeof(UInt_t))); fIndex=-1; }//end if }//end for //Write REAL DATA HEADER UInt_t currentFilePosition=outfile.tellp(); outfile.seekp(dataHeaderPosition); header.fSize=currentFilePosition-dataHeaderPosition; header.SetAttribute(0); // valid data outfile.write((char*)(&header),sizeof(header)); outfile.close(); }//end for return 0; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Int_t AliITSDDLRawData::RawDataSDD(TBranch* branch){ //This method creates the Raw data files for SDD detectors const Int_t kSize=131072; //256*512 UInt_t buf[kSize]; fIndex=-1; TClonesArray*& digits = * (TClonesArray**) branch->GetAddress(); char fileName[15]; ofstream outfile; // logical name of the output file AliRawDataHeader header; //loop over DDLs for(Int_t i=0;iClear(); branch->GetEvent(moduleNumber); //For each Module, buf contains the array of data words in Binary format //fIndex gives the number of 32 bits words in the buffer for each module // cout<<"MODULE NUMBER:"<