/************************************************************************** * 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$ */ /////////////////////////////////////////////////////////////////////////////// // // // T0 raw data conversion class // // // /////////////////////////////////////////////////////////////////////////////// //#include //#include #include #include "AliT0.h" #include "AliT0RawData.h" #include "AliT0digit.h" #include "AliBitPacking.h" #include "AliRawDataHeader.h" #include "AliRawDataHeaderSim.h" #include "AliBitPacking.h" #include "AliFstream.h" #include "AliRunLoader.h" #include "AliDAQ.h" #include "AliT0LookUpValue.h" #include "AliT0LookUpKey.h" ClassImp(AliT0RawData) //_____________________________________________________________________________ AliT0RawData::AliT0RawData():TObject(), fVerbose(0), fIndex(-1) , fEventNumber(0), fTimeCFD(new TArrayI(24)), fADC1( new TArrayI(24)), fTimeLED( new TArrayI(24)), fADC0( new TArrayI(24)), fFile(0x0), fDataHeaderPos(0), fDRMDataHeaderPos(0), fTRMDataHeaderPos(0), fDigits(0), fParam(0), fLookUp(0) { /* - 48 channels (2 words each as in TOF DDL) for : word 1 :0-5bit number of PMT; word 2: 0-7 error sign, 8-31 TDC and the same but for amplified signal. Now I wrote the same time because CDF are not ready and differences didn't measured yet. - 48 channel for amplitude: very preliminary, QTC features are not known now, preliminary i put as T1 time signal for this PMT in first channel and T1+A in second, where A=Log(Amplitude); and the same for amplified but A=Log(10*Amplitude). - T0-A and T0-C 2 channels - T0A-T0C vertex information - Time Meaner where T0C TOF increase to the T0A TOF distance - 6 multiplicity signals the same way as amplitude and with the same uncertances */ //open the output file char fileName[15]; strcpy(fileName,AliDAQ::DdlFileName("T0",0)); //The name of the output file fFile = new AliFstream(fileName); memset(fBuffer,0,512*sizeof(UInt_t)); //get event number AliRunLoader *runloader = AliRunLoader::GetRunLoader(); if (runloader) { fEventNumber = runloader->GetEventNumber(); } // Inverse lookup table for simulation fParam = AliT0Parameters::Instance(); fParam->Init(); AliT0LookUpKey* lookkey= new AliT0LookUpKey(); AliT0LookUpValue* lookvalue= new AliT0LookUpValue(); TMap *lookup = fParam->GetMapLookup(); TMapIter iter(lookup); for( Int_t iline=0; iline<106; iline++) { lookvalue = ( AliT0LookUpValue*) iter.Next(); lookkey = (AliT0LookUpKey*) lookup->GetValue(lookvalue); fLookUp.Add(lookkey, lookvalue); lookkey= new AliT0LookUpKey(); lookvalue= new AliT0LookUpValue(); } } //_____________________________________________________________________________ AliT0RawData::AliT0RawData(const AliT0RawData &r):TObject(), fVerbose(0), fIndex(-1) , fEventNumber(0), fTimeCFD(new TArrayI(24)), fADC1( new TArrayI(24)), fTimeLED( new TArrayI(24)), fADC0( new TArrayI(24)), fFile(0x0), fDataHeaderPos(0), fDRMDataHeaderPos(0), fTRMDataHeaderPos(0), fDigits(0) , fParam(0), fLookUp(0) { // // AliT0rawData copy constructor // ((AliT0RawData &) r).Copy(*this); } //_____________________________________________________________________________ AliT0RawData::~AliT0RawData() { // // Destructor // if (fDigits) { delete fDigits; fDigits = NULL; } delete fTimeCFD; delete fADC1; delete fTimeLED; delete fADC0; } //_____________________________________________________________________________ AliT0RawData &AliT0RawData::operator=(const AliT0RawData &r) { // // Assignment operator // if (this != &r) ((AliT0RawData &) r).Copy(*this); return *this; } //_____________________________________________________________________________ void AliT0RawData::GetDigits(AliT0digit *fDigits) { //This method packs the T0 digits in a proper 32 bits structure //read T0 digits and fill TDC and ADC arrays // Int_t error=0; Int_t time, positionOfTRMHeader; // Get the digits array fDigits->GetTimeCFD(*fTimeCFD); fDigits->GetQT0(*fADC1); fDigits->GetTimeLED(*fTimeLED); fDigits->GetQT1(*fADC0); Int_t meantime = fDigits->MeanTime(); Int_t timediff = fDigits->TimeDiff(); Int_t mult0=fDigits->SumMult(); Int_t mult1=fDigits->SumMult(); Int_t timeA = fDigits->BestTimeC(); Int_t timeC = fDigits->BestTimeA(); TArrayI *allData = new TArrayI(110); Int_t i=0; allData->AddAt(0,0); for (i=1; i<25; i++) { allData->AddAt(fTimeLED->At(i-1),i); allData->AddAt(fTimeCFD->At(i-1),i+24); allData->AddAt(fADC0->At(i-1),i+56); allData->AddAt(fADC1->At(i-1),i+80); } allData->AddAt(meantime,49); allData->AddAt(timediff,50); allData->AddAt(timeA,51); allData->AddAt(timeC,52); allData->AddAt(mult0,53); allData->AddAt(mult1,54); allData->AddAt(mult0,55); allData->AddAt(mult1,56); cout.setf( ios_base::hex, ios_base::basefield ); //space for DRM header fIndex += 6; Int_t startTRM=fIndex; //space for 1st TRM header fIndex ++; positionOfTRMHeader= fIndex; //space for chain header fIndex ++; WriteChainDataHeader(1, 1); // // fIndex++; // Loop through all PMT Int_t chain=0; Int_t iTDC = 0; Int_t channel=0; Int_t trm1words=0; Int_t itrm=7; Int_t inside =0; Int_t isData = 0; AliT0LookUpKey * lookkey = new AliT0LookUpKey(); AliT0LookUpValue * lookvalue ;//= new AliT0LookUpValue(trm,tdc,chain,channel); for (Int_t det = 0; det < 105; det++) { time = allData->At(det); if (time >0) { lookkey->SetKey(det); lookvalue = (AliT0LookUpValue*) fLookUp.GetValue((TObject*)lookkey); if (lookvalue ) { isData++; itrm= lookvalue->GetTRM(); if (det >56 &&inside ==0) { WriteChainDataTrailer(1); // 1st chain trailer fIndex++; WriteChainDataHeader(2, 1); // fIndex++; inside++; } chain = lookvalue->GetChain(); iTDC = lookvalue->GetTDC(); channel = lookvalue->GetChannel(); FillTime(channel, iTDC, time); } else { cout<<" no lookup value for key "< mask){ Error("PackWord", "Word to be filled is not within desired length\n" "Word:%d Start bit:%d Stop Bit:%d",Word,StartBit,StopBit); return; } BaseWord=(BaseWord&~(mask<Tellp(); fFile->WriteBuffer((char*)(&header), sizeof(header)); } else { UInt_t currentFilePos = fFile->Tellp(); fFile->Seekp(fDataHeaderPos); header.fSize = currentFilePos-fDataHeaderPos; header.SetAttribute(0); // valid data if (compressed) header.SetAttribute(1); fFile->WriteBuffer((char*)(&header), sizeof(header)); fFile->Seekp(currentFilePos); } } //___ __________________________________________________________________________ void AliT0RawData::WriteTrailer(UInt_t slot, Int_t word1, UInt_t word2, UInt_t word3) { //Write a (dummy or real) DDL Chain data trailer UInt_t word; UInt_t baseWord=0; word = slot; PackWord(baseWord,word,0, 3); // 0001 word=word1; PackWord(baseWord,word,4, 15); // CRC ? word = word2; PackWord(baseWord,word,16,27); // event counter word=word3; PackWord(baseWord,word,28,31); // marks trailer fIndex++; fBuffer[fIndex] = baseWord; // cout<<" trailer "<WriteBuffer((char*) fBuffer,((fIndex+1)*sizeof(UInt_t))); //write real data header on its place WriteDataHeader(kFALSE, kFALSE); //end for return 0; }