From 1ee299a5e5df4d617f01c09fa86761ab914a975f Mon Sep 17 00:00:00 2001 From: coppedis Date: Sun, 6 Jul 2008 13:58:28 +0000 Subject: [PATCH] Calibration strategy updated: mapping + LASER data --- ZDC/AliZDCDigitizer.cxx | 2 +- ZDC/AliZDCPreprocessor.cxx | 167 ++++++++++-- ZDC/AliZDCRawStream.cxx | 493 +++++++++++++++++++++++++++++------- ZDC/AliZDCRawStream.h | 114 +++++++-- ZDC/AliZDCReconstructor.cxx | 2 +- ZDC/TestZDCPreprocessor.C | 29 ++- 6 files changed, 657 insertions(+), 150 deletions(-) diff --git a/ZDC/AliZDCDigitizer.cxx b/ZDC/AliZDCDigitizer.cxx index e9bc2aa0e0e..6adb203edb7 100644 --- a/ZDC/AliZDCDigitizer.cxx +++ b/ZDC/AliZDCDigitizer.cxx @@ -505,7 +505,7 @@ AliZDCCalib* AliZDCDigitizer::GetCalibData() const // Getting calibration object for ZDC set - AliCDBEntry *entry = AliCDBManager::Instance()->Get("ZDC/Calib/Calib"); + AliCDBEntry *entry = AliCDBManager::Instance()->Get("ZDC/Calib/EMDCalib"); if(!entry) AliFatal("No calibration data loaded!"); AliZDCCalib *calibdata = dynamic_cast (entry->GetObject()); diff --git a/ZDC/AliZDCPreprocessor.cxx b/ZDC/AliZDCPreprocessor.cxx index 299a0202b6b..03b70bbdb4b 100644 --- a/ZDC/AliZDCPreprocessor.cxx +++ b/ZDC/AliZDCPreprocessor.cxx @@ -14,7 +14,9 @@ #include "AliAlignObjParams.h" #include "AliLog.h" #include "AliZDCDataDCS.h" +#include "AliZDCChMap.h" #include "AliZDCPedestals.h" +#include "AliZDCLaserCalib.h" #include "AliZDCCalib.h" ///////////////////////////////////////////////////////////////////// @@ -34,8 +36,9 @@ AliZDCPreprocessor::AliZDCPreprocessor(AliShuttleInterface* shuttle) : { // constructor AddRunType("STANDALONE_PEDESTAL"); + AddRunType("STANDALONE_LASER"); AddRunType("STANDALONE_EMD"); - AddRunType("PHYSICS"); + AddRunType("ALL"); } @@ -114,15 +117,74 @@ UInt_t AliZDCPreprocessor::Process(TMap* dcsAliasMap) resultAl = Store("Align","Data", array, &md, 0, 0); // *************** From DAQ ****************** -Bool_t resPedCal = kTRUE, resECal = kTRUE, resRecPar = kTRUE; +Bool_t resChMap=kTRUE, resPedCal=kTRUE, resLaserCal=kTRUE, resECal=kTRUE; // const char* beamType = GetRunParameter("beamType"); TString runType = GetRunType(); printf("\n\t AliZDCPreprocessor -> beamType %s\n",beamType); printf("\t AliZDCPreprocessor -> runType %s\n\n",runType.Data()); + +// ****************************************** +// ZDC ADC channel mapping +// ****************************************** +TList* daqAllSources = GetFileSources(kDAQ, "ALL"); +if(!daqAllSources){ + AliError(Form("No sources run %d !", fRun)); + return 1; +} +Log("\t List of sources "); daqAllSources->Print(); // +TIter iterAll(daqAllSources); +TObjString* sourceAll = 0; +Int_t iAll=0; +while((sourceAll = dynamic_cast (iterAll.Next()))){ + Log(Form("\n\t Getting file #%d\n",++iAll)); + TString fileName = GetFile(kDAQ, "ALL", sourceAll->GetName()); + if(fileName.Length() <= 0){ + Log(Form("No file from source %s!", sourceAll->GetName())); + return 1; + } + // --- Initializing pedestal calibration object + AliZDCChMap *mapCalib = new AliZDCChMap("ZDC"); + // --- Reading file with pedestal calibration data + const char* fname = fileName.Data(); + if(fname){ + FILE *fileAll; + if((fileAll = fopen(fname,"r")) == NULL){ + printf("Cannot open file %s \n",fname); + return 1; + } + Log(Form("File %s connected to process data for ADC mapping", fname)); + // + Int_t chMap[48][6]; + for(Int_t j=0; j<48; j++){ + for(Int_t k=0; k<6; k++){ + fscanf(fileAll,"%d",&chMap[j][k]); + } + mapCalib->SetADCModule(j,chMap[j][1]); + mapCalib->SetADCChannel(j,chMap[j][2]); + mapCalib->SetDetector(j,chMap[j][4]); + mapCalib->SetSector(j,chMap[j][5]); + } + fclose(fileAll); + } + else{ + Log(Form("File %s not found", fname)); + return 1; + } + //mapCalib->Print(""); + // + AliCDBMetaData metaData; + metaData.SetBeamPeriod(0); + metaData.SetResponsible("Chiara Oppedisano"); + metaData.SetComment("Filling AliZDCChMap object"); + // + resChMap = Store("Calib","ChMap",mapCalib, &metaData, 0, 1); +} + // if(strcmp(beamType,"p-p")==0){ + // --- Initializing pedestal calibration object AliZDCCalib *eCalib = new AliZDCCalib("ZDC"); // @@ -137,10 +199,10 @@ if(strcmp(beamType,"p-p")==0){ // AliCDBMetaData metaData; metaData.SetBeamPeriod(0); - metaData.SetResponsible("Chiara"); + metaData.SetResponsible("Chiara Oppedisano"); metaData.SetComment("AliZDCCalib object"); // - resECal = Store("Calib","Calib",eCalib, &metaData, 0, 1); + resECal = Store("Calib","EMDCalib",eCalib, &metaData, 0, 1); } // // ***************************************************** @@ -197,6 +259,7 @@ if(runType=="STANDALONE_PEDESTAL"){ pedCalib->SetPedCorrCoeff(k-(2*knZDCch),pedVal[k][1],pedVal[k][2]); } } + fclose(file); } else{ Log(Form("File %s not found", pedFileName)); @@ -207,7 +270,7 @@ if(runType=="STANDALONE_PEDESTAL"){ // AliCDBMetaData metaData; metaData.SetBeamPeriod(0); - metaData.SetResponsible("Chiara"); + metaData.SetResponsible("Chiara Oppedisano"); metaData.SetComment("Filling AliZDCPedestals object"); // resPedCal = Store("Calib","Pedestals",pedCalib, &metaData, 0, 1); @@ -215,7 +278,79 @@ if(runType=="STANDALONE_PEDESTAL"){ delete daqSources; daqSources = 0; } // ***************************************************** -// [b] EMD EVENTS -> Energy calibration and equalization +// [b] STANDALONE_LASER EVENTS -> Signal stability +// ***************************************************** +else if(runType=="STANDALONE_LASER"){ + TList* daqSources = GetFileSources(kDAQ, "LASER"); + if(!daqSources){ + AliError(Form("No sources for STANDALONE_LASER run %d !", fRun)); + return 1; + } + Log("\t List of sources for STANDALONE_LASER"); + daqSources->Print(); + // + TIter iter2(daqSources); + TObjString* source = 0; + Int_t i=0; + while((source = dynamic_cast (iter2.Next()))){ + Log(Form("\n\t Getting file #%d\n",++i)); + TString stringLASERFileName = GetFile(kDAQ, "LASER", source->GetName()); + if(stringLASERFileName.Length() <= 0){ + Log(Form("No LASER file from source %s!", source->GetName())); + return 1; + } + // --- Initializing pedestal calibration object + AliZDCLaserCalib *lCalib = new AliZDCLaserCalib("ZDC"); + // --- Reading file with pedestal calibration data + const char* laserFileName = stringLASERFileName.Data(); + if(laserFileName){ + FILE *file; + if((file = fopen(laserFileName,"r")) == NULL){ + printf("Cannot open file %s \n",laserFileName); + return 1; + } + Log(Form("File %s connected to process data from LASER events", laserFileName)); + // + Float_t ivalRef[2], ivalRead[2][4]; + for(Int_t j=0; j<3; j++){ + if(j==0){ + for(Int_t k=0; k<2; k++){ + fscanf(file,"%f",&ivalRef[k]); + printf(" %1.0f ",ivalRef[k]); + lCalib->SetReferenceValue(k,ivalRef[k]); + } + } + else{ + for(Int_t k=0; k<4; k++){ + fscanf(file,"%f",&ivalRead[j-1][k]); + printf(" %d %1.0f ",k, ivalRead[j-1][k]); + } + lCalib->SetSector(j-1, ivalRead[j-1][0]); + lCalib->SetGain(j-1, ivalRead[j-1][1]); + lCalib->SetfPMRefValue(j-1, ivalRead[j-1][2]); + lCalib->SetfPMRefWidth(j-1, ivalRead[j-1][3]); + } + printf("\n"); + } + fclose(file); + } + else{ + Log(Form("File %s not found", laserFileName)); + return 1; + } + //lCalib->Print(""); + // + AliCDBMetaData metaData; + metaData.SetBeamPeriod(0); + metaData.SetResponsible("Chiara Oppedisano"); + metaData.SetComment("Filling AliZDCLaserCalib object"); + // + resLaserCal = Store("Calib","LaserCalib",lCalib, &metaData, 0, 1); + } + +} +// ***************************************************** +// [c] EMD EVENTS -> Energy calibration and equalization // ***************************************************** else if(runType=="STANDALONE_EMD"){ TList* daqSources = GetFileSources(kDAQ, "EMDCALIB"); @@ -269,6 +404,7 @@ else if(runType=="STANDALONE_EMD"){ } } } + fclose(file); } else{ Log(Form("File %s not found", emdFileName)); @@ -278,10 +414,10 @@ else if(runType=="STANDALONE_EMD"){ // AliCDBMetaData metaData; metaData.SetBeamPeriod(0); - metaData.SetResponsible("Chiara"); + metaData.SetResponsible("Chiara Oppedisano"); metaData.SetComment("Filling AliZDCCalib object"); // - resECal = Store("Calib","Calib",eCalib, &metaData, 0, 1); + resECal = Store("Calib","EMDCalib",eCalib, &metaData, 0, 1); } } else { @@ -295,13 +431,14 @@ else { else Log(Form("Number of events not put in logbook!")); UInt_t result = 0; - if(resDCSRef==kFALSE || resultAl==kFALSE || - resPedCal==kFALSE || resECal==kFALSE || resRecPar==kFALSE){ - if(resDCSRef == kFALSE) result = 1; - else if(resultAl == kFALSE) result = 2; - else if(resPedCal == kFALSE) result = 3; - else if(resECal == kFALSE) result = 4; - else if(resRecPar == kFALSE) result = 5; + if(resDCSRef==kFALSE || resultAl==kFALSE || resPedCal==kFALSE || + resLaserCal==kFALSE || resECal==kFALSE || resChMap==kFALSE){ + if(resDCSRef == kFALSE) result = 1; + else if(resultAl == kFALSE) result = 2; + else if(resChMap == kFALSE) result = 3; + else if(resPedCal == kFALSE) result = 4; + else if(resLaserCal == kFALSE) result = 5; + else if(resECal == kFALSE) result = 6; } return result; diff --git a/ZDC/AliZDCRawStream.cxx b/ZDC/AliZDCRawStream.cxx index d1379b2de86..368731e0f95 100644 --- a/ZDC/AliZDCRawStream.cxx +++ b/ZDC/AliZDCRawStream.cxx @@ -28,6 +28,8 @@ #include "AliZDCRawStream.h" #include "AliRawReader.h" +#include "AliRawDataHeader.h" +#include "AliRawEventHeaderBase.h" #include "AliLog.h" ClassImp(AliZDCRawStream) @@ -36,32 +38,71 @@ ClassImp(AliZDCRawStream) //_____________________________________________________________________________ AliZDCRawStream::AliZDCRawStream(AliRawReader* rawReader) : fRawReader(rawReader), - fRawADC(0), - fADCModule(0), + fBuffer(0), + fEvType(0), + fPosition(0), + fIsCalib(kFALSE), + fIsDARCHeader(kFALSE), + fIsChMapping(kFALSE), + fIsADCDataWord(kFALSE), + fIsADCHeader(kFALSE), + fIsADCEOB(kFALSE), + fDARCEvBlockLenght(0), + fDARCBlockAttributes(0), + fDeadfaceOffset(0), + fDeadbeefOffset(0), + fDataOffset(0), + fModType(-1), + fADCModule(-1), + fADCNChannels(-1), fADCChannel(-1), fADCValue(-1), - fADCGain(0), - fIsADCDataWord(kFALSE) + fADCGain(-1), + fNConnCh(-1), + fCabledSignal(-1) { // Create an object to read ZDC raw digits - + fRawReader->Reset(); fRawReader->Select("ZDC"); + // + for(Int_t i=0; i<48; i++){ + for(Int_t j=0; j<3; j++) fMapADC[i][j]=-1; + } + } //_____________________________________________________________________________ AliZDCRawStream::AliZDCRawStream(const AliZDCRawStream& stream) : TObject(stream), fRawReader(stream.fRawReader), - fRawADC(stream.GetADCRaw()), + fBuffer(stream.GetRawBuffer()), + fEvType(stream.fEvType), + fPosition(stream.fPosition), + fIsCalib(stream.fIsCalib), + fIsDARCHeader(stream.fIsDARCHeader), + fIsChMapping(stream.fIsChMapping), + fIsADCDataWord(stream.fIsADCDataWord), + fIsADCHeader(stream.fIsADCHeader), + fIsADCEOB(stream.fIsADCEOB), + fDARCEvBlockLenght(stream.fDARCEvBlockLenght), + fDARCBlockAttributes(stream.fDARCBlockAttributes), + fDeadfaceOffset(stream.GetDeadfaceOffset()), + fDeadbeefOffset(stream.GetDeadbeefOffset()), + fDataOffset(stream.GetDataOffset()), + fModType(stream.GetModType()), fADCModule(stream.GetADCModule()), + fADCNChannels(stream.GetADCNChannels()), fADCChannel(stream.GetADCChannel()), fADCValue(stream.GetADCValue()), fADCGain(stream.GetADCGain()), - fIsADCDataWord(stream.IsADCDataWord()) + fNConnCh(stream.fNConnCh), + fCabledSignal(stream.GetCabledSignal()) { // Copy constructor for(Int_t j=0; j<2; j++) fSector[j] = stream.GetSector(j); - + for(Int_t i=0; i<48; i++){ + for(Int_t j=0; j<3; j++) fMapADC[i][j] = stream.fMapADC[i][j]; + } } //_____________________________________________________________________________ @@ -80,6 +121,96 @@ AliZDCRawStream::~AliZDCRawStream() } +//_____________________________________________________________________________ +void AliZDCRawStream::ReadCDHHeader() +{ + // Reading CDH + const AliRawDataHeader* header = fRawReader->GetDataHeader(); + if(!header) { + AliError("\t No CDH in raw data streaming\n"); + fRawReader->AddMajorErrorLog(kCDHError); + // + // For the moment to debug the classe the event is read + // also if the CDH is not present in the data buffer + // ******* TO BE CHANGED!!! *************************** + //return; + } + else{ + //printf("\t AliZDCRawStream::ReadCDHHeader -> Data Size = %d\n",fRawReader->GetDataSize()); + + fDARCEvBlockLenght = header->fSize; + //printf("\t AliZDCRawStream::ReadCDHHeader -> fDARCEvBlockLenght = %d\n",fDARCEvBlockLenght); + + //UChar_t message = header->GetAttributes(); + //printf("\t AliZDCRawStream::ReadCDHHeader -> Attributes %x\n",message); + + /*if(message & 0x10){ // COSMIC RUN + printf("\t STANDALONE_COSMIC RUN raw data found\n"); + } + else if(message & 0x20){ // PEDESTAL RUN + printf("\t STANDALONE_PEDESTAL RUN raw data found\n"); + } + else if(message & 0x30){ // LASER RUN + printf("\t STANDALONE_LASER RUN raw data found\n"); + }*/ + + if(header->GetL1TriggerMessage() & 0x1){ // Calibration bit set in CDH + fIsCalib = kTRUE; + } + //printf("\t AliZDCRawStream::ReadCDHHeader -> L1TriggerMessage %x\n",header->GetL1TriggerMessage()); + printf("\t AliZDCRawStream::ReadCDHHeader -> fIsCalib = %d\n",fIsCalib); + + + UInt_t status = header->GetStatus(); + //printf("\t AliZDCRawStream::ReadCDHHeader -> status = %d\n",status); + if(status & 0x000f == 0x0001){ + AliWarning("CDH -> DARC trg0 overlap error\n"); + fRawReader->AddMajorErrorLog(kDARCError); + } + if(status & 0x000f == 0x0002){ + AliWarning("CDH -> DARC trg0 missing error\n"); + fRawReader->AddMajorErrorLog(kDARCError); + } + if(status & 0x000f == 0x0004){ + AliWarning("CDH -> DARC data parity error\n"); + fRawReader->AddMajorErrorLog(kDARCError); + } + if(status & 0x000f == 0x0008){ + AliWarning("CDH -> DARC ctrl parity error\n"); + fRawReader->AddMajorErrorLog(kDARCError); + } + // + if(status & 0x00f0 == 0x0010){ + AliWarning("CDH -> DARC trg unavailable\n"); + fRawReader->AddMajorErrorLog(kDARCError); + } + if(status & 0x00f0 == 0x0020){ + AliWarning("CDH -> DARC FEE error\n"); + fRawReader->AddMajorErrorLog(kDARCError); + } + // + if(status & 0x0f00 == 0x0200){ + AliWarning("CDH -> DARC L1 time violation\n"); + fRawReader->AddMajorErrorLog(kDARCError); + } + if(status & 0x0f00 == 0x0400){ + AliWarning("CDH -> DARC L2 time-out\n"); + fRawReader->AddMajorErrorLog(kDARCError); + } + if(status & 0x0f00 == 0x0800){ + AliWarning("CDH -> DARC prepulse time violation\n"); + fRawReader->AddMajorErrorLog(kDARCError); + } + // + if(status & 0xf000 == 0x1000){ + AliWarning("CDH -> DARC other error\n"); + fRawReader->AddMajorErrorLog(kDARCError); + } + } + // + fIsDARCHeader = kTRUE; +} + //_____________________________________________________________________________ Bool_t AliZDCRawStream::Next() @@ -87,100 +218,268 @@ Bool_t AliZDCRawStream::Next() // Read the next raw digit // Returns kFALSE if there is no digit left - if(!fRawReader->ReadNextInt((UInt_t&) fRawADC)) return kFALSE; - fIsADCDataWord = kFALSE; - // + if(!fRawReader->ReadNextInt((UInt_t&) fBuffer)) return kFALSE; + fIsChMapping = kFALSE; fIsADCHeader = kFALSE; + fIsADCDataWord = kFALSE; fIsADCEOB = kFALSE; + + fEvType = fRawReader->GetType(); + //printf("\n\t AliZDCRawStream::Next() -> ev. type %d\n",fEvType); + + if(fPosition==0){ + //if(fEvType==7 || fEvType ==8){ //Physics or calibration event + //ReadEventHeader(); + ReadCDHHeader(); + //} + fNConnCh=0; + } + //printf("\n AliZDCRawStream::Next() - fBuffer[%d] = %x\n",fPosition, fBuffer); + + // ------------------------------------------- // --- DARC header - if((fRawADC == 0xe52b6300) || (fRawADC == 0xe52c0300) || (fRawADC == 0xffffffff) || - (fRawADC == 0xdeadface) || (fRawADC == 0xdeadbeef)){ - //printf(" This is a DARC header!!!\n"); + // ------------------------------------------- + if(fIsDARCHeader){ + printf("\t ---- DARC header ----\n"); + if(fIsCalib){ + fDeadfaceOffset = 9; + fDeadbeefOffset = 25; + } + else{ + fDeadfaceOffset = 1; + fDeadbeefOffset = 7; + } + fDataOffset = 1+fDeadbeefOffset; + fIsDARCHeader = kFALSE; } - // --- End of data - else if(fRawADC == 0xcafefade){ - //printf(" End of data!\n"); - } - // --- ADC buffer - else{ - Bool_t firstADCHeader = kTRUE; - // - if((fRawADC & 0x6000000) == 0x6000000){ // Not valid datum BEFORE valid data! - firstADCHeader = kFALSE; - //printf(" AliZDCRawStream -> Not valid datum in ADC module!!! %d\n",fADCModule); - } - else if((fRawADC & 0x4000000) == 0x4000000){ // ADC EOB - //printf(" AliZDCRawStream -> ADC %d End Of Block - Event no. %d\n\n",fADCModule, (fRawADC & 0xffffff)); - fSector[0] = fSector[1] = 99; - } - else if((fRawADC & 0x2000000) == 0x2000000){ // ADC Header - //printf(" fRawADC %x\n",fRawADC); - // Reading the GEO address to determine ADC module - fADCModule = (fRawADC & 0xf8000000) >> 27; - fADCModule ++; - // If the not valid datum isn't followed by the 1st ADC header - // the event is corrupted (i.e., 2 gates arrived before trigger) - if(fADCModule == 1) firstADCHeader = kTRUE; - //if(fADCModule == 1) printf(" fADCModule %d, firstADCHeader %d\n",fADCModule,firstADCHeader); - //printf(" AliZDCRawStream -> HEADER: ADC mod. %d contains %d data words \n",fADCModule,((fRawADC & 0x3f00) >> 8)); - } - else{ // ADC data word - fIsADCDataWord = kTRUE; - //printf(" fRawADC = %x firstADCHeader %d\n",fRawADC,firstADCHeader); - // - if(!(fRawADC & 0x1000) && !(fRawADC & 0x2000) && firstADCHeader){ // Valid ADC data - fADCGain = (fRawADC & 0x10000) >> 16; - fADCValue = (fRawADC & 0xfff); - // - fADCChannel = (fRawADC & 0x1e0000) >> 17; - // - // If raw data corresponds to an ADC ch. without physical signal - // fsector[0] = fSector[1] = -1 - for(Int_t i=0; i<2; i++)fSector[i] = -1; - //if(fSector[0]!=-1) printf(" \t \t ADC Data Word: ADC ch. %d",fADCChannel); - // - if(fADCModule==1 || fADCModule==3){ //1st & 3rd ADC modules - if(fADCChannel >= 0 && fADCChannel <= 4){ - fSector[0] = 1; // ZN1 - fSector[1] = fADCChannel; - } - else if(fADCChannel >= 8 && fADCChannel <= 12){ - fSector[0] = 2; // ZP1 - fSector[1] = fADCChannel-8; - } - else if(fADCChannel == 5 || fADCChannel == 13){ - fSector[0] = 3; // ZEM 1,2 - fSector[1] = ((fADCChannel-5)/8)+1; - } - } - else if(fADCModule==2 || fADCModule==4){ //2nd & 4rth ADC modules - if(fADCChannel >= 0 && fADCChannel <= 4){ - fSector[0] = 4; // ZN2 - fSector[1] = fADCChannel; - } - else if(fADCChannel >= 8 && fADCChannel <= 12){ - fSector[0] = 5; // ZP2 - fSector[1] = fADCChannel-8; - } - else if(fADCChannel == 5 || fADCChannel == 13){ - fSector[0] = (fADCChannel-5)*3/8+1; // PM Ref 1,2 - fSector[1] = 5; - } - } - else{ - AliWarning(" AliZDCRawStream -> No valid ADC module\n"); - fRawReader->AddMajorErrorLog(kInvalidADCModule); + + + // ------------------------------------------- + // --- Start of data event + // --- decoding mapping of connected ADC ch. + // ------------------------------------------- + if(fEvType==10){ + if(fPosition>fDataOffset){ + if((fBuffer&0xff000000) == 0xff000000){ + if(fPosition==(fDataOffset+1)){ + printf("\n\n\t Reading ZDC mapping from StartOfData event\n"); + fNConnCh=0; } - //printf(" ADC %d ch %d range %d -> det %d quad %d value %x\n", - // fADCModule, fADCChannel, fADCGain, fSector[0], fSector[1], fADCValue);//Chiara debugging - - }// Valid ADC data - else if(fRawADC & 0x1000){ - //printf(" ADC %d ch %d range %d overflow\n",fADCModule, (fRawADC & 0x1e0000) >> 17, fADCGain); // Overflow + else{ + printf("\n\t End of StartOfData event\n\n"); + return kTRUE; + } + } + else if((fBuffer&0x80000000)>>31 == 1){ + // Mapping identification + fADCModule = ((fBuffer & 0x7f000000)>>24); + fModType = ((fBuffer & 0xfff000)>>8); + fADCNChannels = (fBuffer & 0xff); + // + //printf("\tGEO %d, mod. type %d, #ch. %d\n",fADCModule,fModType,fADCNChannels); } - else if(fRawADC & 0x2000){ - //printf(" ADC %d ch %d range %d underflow\n",fADCModule, (fRawADC & 0x1e0000) >> 17, fADCGain); // Underflow + else if(fModType==0 && (fBuffer&0x80000000)>>31 == 0){ + // Channel signal + if((fBuffer&0x40000000)>>30==0){ // high range chain ADC + fIsChMapping = kTRUE; + fADCChannel = ((fBuffer & 0x3fff0000)>>16); + fCabledSignal = (fBuffer&0xffff); + fMapADC[fNConnCh][0] = fADCModule; + fMapADC[fNConnCh][1] = fADCChannel; + fMapADC[fNConnCh][2] = fCabledSignal; + //printf(" RawData%d mod. %d ch. %d signal %d\n",fNConnCh,fADCModule, + // fADCChannel, fBuffer&0xffff); + // + fNConnCh++; + if(fNConnCh>48){ + // Protection manually set since it returns: + // RawData48 mod. 3 ch. 2048 signal 515 + // to be checked with Pietro!!!!!!!!!!!!!!!!!!!!!!! + AliWarning("\t AliZDCRawStream -> ERROR: no. of cabled channels > 48!!!\n"); + return kFALSE; + } + } } - }// ADC word - }//Not DARC Header + } + fPosition++; + return kTRUE; + } + + // ------------------------------------------- + // --- DARC data + // ------------------------------------------- + if(fPosition NO deadface after DARC data\n"); + fRawReader->AddMajorErrorLog(kDARCError); + } + else{ + fPosition++; + return kTRUE; + } + } + + // ------------------------------------------- + // --- DARC global data + // ------------------------------------------- + else if(fPosition>fDeadfaceOffset && fPosition NO deadbeef after DARC global data\n"); + fRawReader->AddMajorErrorLog(kDARCError); + } + else{ + fPosition++; + return kTRUE; + } + } + + // ------------------------------------------- + // --- ZDC data + // --- ADC buffer + scaler + // ------------------------------------------- + else if(fPosition>=fDataOffset){ + + // Not valid datum before the event + // there MUST be a NOT valid datum before the event!!! + if(fPosition==fDataOffset){ + printf("\t **** ZDC data begin ****\n"); + if((fBuffer & 0x07000000) == 0x06000000){ + //printf(" AliZDCRawStream -> Not valid datum in ADC %d," + // "position %d in word data buffer\n",fADCModule,fPosition); + } + else fRawReader->AddMajorErrorLog(kZDCDataError); + } + + // If the not valid datum isn't followed by the 1st ADC header + // the event is corrupted (i.e., 2 gates arrived before trigger) + else if(fPosition==fDataOffset+1){ + if((fBuffer & 0x07000000) != 0x02000000){ + AliWarning("ZDC ADC -> The not valid datum is NOT followed by an ADC header!\n"); + fRawReader->AddMajorErrorLog(kZDCDataError); + } + } + + // Get geo address of current word to determine + // if it is a scaler word (geo address == kScalerAddress) + // if it is an ADC word (geo address != 8) + Int_t kScalerAddress=8; + fADCModule = ((fBuffer & 0xf8000000)>>27); + if(fADCModule == kScalerAddress){ + DecodeScaler(); + } + else{//ADC module + // *** End of event + if(fBuffer == 0xcafefade){ + printf(" AliZDCRawStream -> End of ZDC event!\n"); + } + // *** ADC header + else if((fBuffer & 0x07000000) == 0x02000000){ + fIsADCHeader = kTRUE; + fADCNChannels = ((fBuffer & 0x00003f00)>>8); + printf(" AliZDCRawStream -> HEADER: ADC mod.%d has %d ch. \n",fADCModule,fADCNChannels); + } + // *** ADC data word + else if((fBuffer & 0x07000000) == 0x00000000){ + fIsADCDataWord = kTRUE; + fADCChannel = ((fBuffer & 0x1e0000) >> 17); + fADCGain = ((fBuffer & 0x10000) >> 16); + fADCValue = (fBuffer & 0xfff); + + printf(" AliZDCRawStream -> DATA: ADC mod. %d ch. %d gain %d value %d\n", + fADCModule,fADCChannel,fADCGain,fADCValue); + + // Valid ADC data (not underflow nor overflow) + if(!(fBuffer & 0x1000) && !(fBuffer & 0x2000)){ + Int_t indSig = -1; + for(Int_t k=0; k<48; k++){ + if(fMapADC[k][0]==fADCModule && fMapADC[k][1]==fADCChannel){ + // + for(Int_t ci=0; ci<48; ci++) + printf(" %d mod. %d ch. %d signal %d\n",ci,fMapADC[ci][0], + fMapADC[ci][1], fMapADC[ci][2]); + + indSig=k; + break; + } + } + // ++++++++++++++++++++++++++++++++++++++++++++++++++++++ + // To understand the assignment of fSector[i] + // have a look at the enum in AliZDCRawStream.h + // fSector[0] = 1(ZNC+PMRefC), 2(ZPC), 3(ZEM), + // 4(ZNA+PMRefA), 5(ZPA) + // ++++++++++++++++++++++++++++++++++++++++++++++++++++++ + if((fMapADC[indSig][2]>=2 && fMapADC[indSig][2]<=6) || (fMapADC[indSig][2]>=26 && fMapADC[indSig][2]<=30) + || fMapADC[indSig][2]==24 || fMapADC[indSig][2]==48){ + fSector[0] = 4; + // + if(fMapADC[indSig][2]==2 || fMapADC[indSig][2]==26) fSector[1]=0; + else if(fMapADC[indSig][2]==3 || fMapADC[indSig][2]==27) fSector[1]=1; + else if(fMapADC[indSig][2]==4 || fMapADC[indSig][2]==28) fSector[1]=2; + else if(fMapADC[indSig][2]==5 || fMapADC[indSig][2]==29) fSector[1]=3; + else if(fMapADC[indSig][2]==6 || fMapADC[indSig][2]==30) fSector[1]=4; + else if(fMapADC[indSig][2]==24 || fMapADC[indSig][2]==48) fSector[1]=5; + } + else if((fMapADC[indSig][2]>=7 && fMapADC[indSig][2]<=11) || (fMapADC[indSig][2]>=31 && fMapADC[indSig][2]<=35)){ + fSector[0] = 5; + // + if(fMapADC[indSig][2]==7 || fMapADC[indSig][2]==31) fSector[1]=0; + else if(fMapADC[indSig][2]==8 || fMapADC[indSig][2]==32) fSector[1]=1; + else if(fMapADC[indSig][2]==9 || fMapADC[indSig][2]==33) fSector[1]=2; + else if(fMapADC[indSig][2]==10 || fMapADC[indSig][2]==34) fSector[1]=3; + else if(fMapADC[indSig][2]==11 || fMapADC[indSig][2]==35) fSector[1]=4; + } + else if((fMapADC[indSig][2]>=12 && fMapADC[indSig][2]<=16) || (fMapADC[indSig][2]>=36 && fMapADC[indSig][2]<=40) + || fMapADC[indSig][2]==25 || fMapADC[indSig][2]==49){ + fSector[0] = 1; + // + if(fMapADC[indSig][2]==12 || fMapADC[indSig][2]==36) fSector[1]=0; + else if(fMapADC[indSig][2]==13 || fMapADC[indSig][2]==37) fSector[1]=1; + else if(fMapADC[indSig][2]==14 || fMapADC[indSig][2]==38) fSector[1]=2; + else if(fMapADC[indSig][2]==15 || fMapADC[indSig][2]==39) fSector[1]=3; + else if(fMapADC[indSig][2]==16 || fMapADC[indSig][2]==40) fSector[1]=4; + else if(fMapADC[indSig][2]==25 || fMapADC[indSig][2]==49) fSector[1]=5; + } + else if((fMapADC[indSig][2]>=17 && fMapADC[indSig][2]<=21) || (fMapADC[indSig][2]>=41 && fMapADC[indSig][2]<=45)){ + fSector[0] = 2; + // + if(fMapADC[indSig][2]==17 || fMapADC[indSig][2]==41) fSector[1]=0; + else if(fMapADC[indSig][2]==18 || fMapADC[indSig][2]==42) fSector[1]=1; + else if(fMapADC[indSig][2]==19 || fMapADC[indSig][2]==43) fSector[1]=2; + else if(fMapADC[indSig][2]==20 || fMapADC[indSig][2]==44) fSector[1]=3; + else if(fMapADC[indSig][2]==21 || fMapADC[indSig][2]==45) fSector[1]=4; + } + else if(fMapADC[indSig][2]==22 || fMapADC[indSig][2]==23 || fMapADC[indSig][2]==46 || fMapADC[indSig][2]==47){ + fSector[0] = 3; + // + if(fMapADC[indSig][2]==22 || fMapADC[indSig][2]==46) fSector[1]=1; + else if(fMapADC[indSig][2]==23 || fMapADC[indSig][2]==49) fSector[1]=2; + } + // + printf("\t Signal %d -> fSector[0] %d, fSector[1] %d\n", fMapADC[indSig][2], fSector[0], fSector[1]); + + if(fADCModule<0 || fADCModule>3){ + AliWarning(Form(" AliZDCRawStream -> No valid ADC module: %d\n",fADCModule)); + fRawReader->AddMajorErrorLog(kInvalidADCModule); + } + + }//No underflow nor overflow + }//ADC data word + // *** ADC EOB + else if((fBuffer & 0x07000000) == 0x04000000){ + fIsADCEOB = kTRUE; + //printf(" AliZDCRawStream -> EOB --------------------------\n"); + } + }//ADC module + + + } + fPosition++; return kTRUE; } diff --git a/ZDC/AliZDCRawStream.h b/ZDC/AliZDCRawStream.h index b8982bc9bb8..1ec6c07f96d 100644 --- a/ZDC/AliZDCRawStream.h +++ b/ZDC/AliZDCRawStream.h @@ -5,15 +5,17 @@ /* $Id$ */ -/////////////////////////////////////////////////////////////////////////////// -/// -/// This class provides access to ZDC digits in raw data. -/// -/////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////// +// // +// Class to provide access to ZDC raw data // +// Author: Chiara Oppedisano // +// // +////////////////////////////////////////////////// #include class AliRawReader; +class AliRawDataHeader; class AliZDCRawStream: public TObject { @@ -22,33 +24,97 @@ class AliZDCRawStream: public TObject { virtual ~AliZDCRawStream(); virtual Bool_t Next(); - UInt_t GetADCRaw() const {return fRawADC;}; - Int_t GetSector(Int_t i) const {return fSector[i];}; - Int_t GetADCModule() const {return fADCModule;}; - Int_t GetADCChannel() const {return fADCChannel;}; - Int_t GetADCValue() const {return fADCValue;}; - Int_t GetADCGain() const {return fADCGain;}; - Bool_t IsADCDataWord() const {return fIsADCDataWord;}; + virtual void ReadCDHHeader(); + virtual void DecodeScaler() {;} - enum EZDCRawStreamError { - kInvalidADCModule = 1 - }; + UInt_t GetRawBuffer() const {return fBuffer;} + + Int_t GetDeadfaceOffset() const {return fDeadfaceOffset;} + Int_t GetDeadbeefOffset() const {return fDeadbeefOffset;} + Int_t GetDataOffset() const {return fDataOffset;} + Int_t GetSector(Int_t i) const {return fSector[i];} + Int_t GetModType() const {return fModType;} + Int_t GetADCModule() const {return fADCModule;} + Int_t GetADCNChannels() const {return fADCNChannels;} + Int_t GetADCChannel() const {return fADCChannel;} + Int_t GetADCValue() const {return fADCValue;} + Int_t GetADCGain() const {return fADCGain;} + + Int_t GetCabledSignal() const {return fCabledSignal;} + + Bool_t IsDARCHeader() const {return fIsDARCHeader;} + Bool_t IsChMapping() const {return fIsChMapping;} + Bool_t IsADCDataWord() const {return fIsADCDataWord;} + Bool_t IsADCHeader() const {return fIsADCHeader;} + Bool_t IsADCEOB() const {return fIsADCEOB;} + + void SetSector(Int_t i, Int_t val) {fSector[i] = val;} + void SetMapADCMod(Int_t iraw, Int_t imod) {fMapADC[iraw][0]=imod;} + void SetMapADCCh(Int_t iraw, Int_t ich) {fMapADC[iraw][1]=ich;} + void SetMapADCSig(Int_t iraw, Int_t isig) {fMapADC[iraw][2]=isig;} + + enum EZDCRawStreamError{ + kCDHError = 1, + kDARCError = 2, + kZDCDataError = 3, + kInvalidADCModule = 4 + }; + + enum ZDCSignal{kNotConnected=0, kVoid=1, + kZNAC=2, kZNA1=3, kZNA2=4, kZNA3=5, kZNA4=6, + kZPAC=7, kZPA1=8, kZPA2=9, kZPA3=10, kZPA4=11, + kZNCC=12, kZNC1=13, kZNC2=14, kZNC3=15, kZNC4=16, + kZPCC=17, kZPC1=18, kZPC2=19, kZPC3=20, kZPC4=21, + kZEM1=22, kZEM2=23, + kZDCAMon=24, kZDCCMon=25, + kZNACoot=26, kZNA1oot=27, kZNA2oot=28, kZNA3oot=29, kZNA4oot=30, + kZPACoot=31, kZPA1oot=32, kZPA2oot=33, kZPA3oot=34, kZPA4oot=35, + kZNCCoot=36, kZNC1oot=37, kZNC2oot=38, kZNC3oot=39, kZNC4oot=40, + kZPCCoot=41, kZPC1oot=42, kZPC2oot=43, kZPC3oot=44, kZPC4oot=45, + kZEM1oot=46, kZEM2oot=47, + kZDCAMonoot=48, kZDCCMonoot=49}; + private : AliZDCRawStream(const AliZDCRawStream& stream); AliZDCRawStream& operator = (const AliZDCRawStream& stream); - AliRawReader* fRawReader; // object for reading the raw data + AliRawReader* fRawReader; // object for reading the raw data - UInt_t fRawADC; // raw ADC - Int_t fSector[2]; // index of current sector - Int_t fADCModule; // ADC module; - Int_t fADCChannel; // ADC module; - Int_t fADCValue; // ADC channel; - Int_t fADCGain; // ADC gain (0=high range; 1=low range) - Bool_t fIsADCDataWord; //True when data word + UInt_t fBuffer; // DARC header + ADC buffer + UInt_t fEvType; // Event type + Int_t fPosition; // bit position in buffer data word + + Bool_t fIsCalib; // True when calibration run + Bool_t fIsDARCHeader; // True when DARC header + Bool_t fIsChMapping; // True when reading ch. mapping + Bool_t fIsADCDataWord; // True when data word + Bool_t fIsADCHeader; // True when ADC header + Bool_t fIsADCEOB; // True when EOB + + // From CDH + UInt_t fDARCEvBlockLenght; // DARC block length + UInt_t fDARCBlockAttributes;// DARC block attributes - ClassDef(AliZDCRawStream, 3) // class for reading ZDC raw digits + Int_t fDeadfaceOffset; // deadface offset + Int_t fDeadbeefOffset; // deadbeef offset + Int_t fDataOffset; // data offset + + // ADC signal + Int_t fSector[2]; // [detector, sector] + Int_t fModType; // Module type + Int_t fADCModule; // ADC module + Int_t fADCNChannels; // number of ADC ch. + Int_t fADCChannel; // ADC channel + Int_t fADCValue; // ADC channel + Int_t fADCGain; // ADC gain (0=high range; 1=low range) + + // Channel mapping + Int_t fNConnCh; // current mapped ch. + Int_t fCabledSignal; // physics signal (from enum) + Int_t fMapADC[48][3]; // ADC map for the current run + + ClassDef(AliZDCRawStream, 4) // class for reading ZDC raw digits }; #endif diff --git a/ZDC/AliZDCReconstructor.cxx b/ZDC/AliZDCReconstructor.cxx index a98df0e8830..2e05ad29d12 100644 --- a/ZDC/AliZDCReconstructor.cxx +++ b/ZDC/AliZDCReconstructor.cxx @@ -625,7 +625,7 @@ AliZDCCalib* AliZDCReconstructor::GetECalibData() const // Getting energy and equalization calibration object for ZDC set - AliCDBEntry *entry = AliCDBManager::Instance()->Get("ZDC/Calib/Calib"); + AliCDBEntry *entry = AliCDBManager::Instance()->Get("ZDC/Calib/EMDCalib"); if(!entry) AliFatal("No calibration data loaded!"); AliZDCCalib *calibdata = dynamic_cast (entry->GetObject()); diff --git a/ZDC/TestZDCPreprocessor.C b/ZDC/TestZDCPreprocessor.C index 41f31220712..71db0f02247 100644 --- a/ZDC/TestZDCPreprocessor.C +++ b/ZDC/TestZDCPreprocessor.C @@ -61,18 +61,20 @@ void TestZDCPreprocessor() // Three files originating from different LDCs but with the same id are also added // Note that the test preprocessor name is TPC. The name of the detector's preprocessor must follow // the "online" naming convention ALICE-INT-2003-039. + shuttle->AddInputFile(AliTestShuttle::kDAQ, "ZDC", "ALL", "LDC0", "ZDCChMapping.dat"); + // shuttle->AddInputFile(AliTestShuttle::kDAQ, "ZDC", "PEDESTALS", "LDC0", "ZDCPedestal.dat"); + shuttle->AddInputFile(AliTestShuttle::kDAQ, "ZDC", "LASER", "LDC0", "ZDCLaserCalib.dat"); shuttle->AddInputFile(AliTestShuttle::kDAQ, "ZDC", "EMDCALIB", "LDC0", "ZDCEMDCalib.dat"); - shuttle->AddInputFile(AliTestShuttle::kDAQ, "ZDC", "PHYSICS", "LDC0", "ZDCRecParam.dat"); // TODO(3) // // The shuttle can read run type stored in the DAQ logbook. // To test it, we must provide the run type manually. They will be retrieved in the preprocessor // using GetRunType function. - shuttle->SetInputRunType("STANDALONE_PEDESTAL"); + //shuttle->SetInputRunType("STANDALONE_PEDESTAL"); + shuttle->SetInputRunType("STANDALONE_LASER"); //shuttle->SetInputRunType("STANDALONE_EMD"); - //shuttle->SetInputRunType("PHYSICS"); // TODO(4) // @@ -80,8 +82,8 @@ void TestZDCPreprocessor() // To test it, we must provide the run parameters manually. They will be retrieved in the preprocessor // using GetRunParameter function. // In real life the parameters will be retrieved automatically from the run logbook; - //shuttle->AddInputRunParameter("beamType", "Pb-Pb"); - shuttle->AddInputRunParameter("beamType", "p-p"); + shuttle->AddInputRunParameter("beamType", "Pb-Pb"); + //shuttle->AddInputRunParameter("beamType", "p-p"); shuttle->AddInputRunParameter("totalEvents", "1000"); shuttle->AddInputRunParameter("NumberOfGDCs", "1"); @@ -100,14 +102,15 @@ void TestZDCPreprocessor() // The shuttle can query condition parameters valid from the current run from the OCDB // To test it, we must first store the object into the OCDB. It will be retrieved in the preprocessor // using GetFromOCDB function. -/* - TObjString obj("This is a condition parameter stored in OCDB"); + + /*TObjString obj("This is a condition parameter stored in OCDB"); AliCDBId id("ZDC/Calib/Data", 0, AliCDBRunRange::Infinity()); AliCDBMetaData md; AliCDBEntry entry(&obj, id, &md); shuttle->AddInputCDBEntry(&entry); -*/ + */ + // TODO(6) // Create the preprocessor that should be tested, it registers itself automatically to the shuttle AliPreprocessor* test = new AliZDCPreprocessor(shuttle); @@ -121,15 +124,17 @@ void TestZDCPreprocessor() // $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB//SHUTTLE/Data // // Check the file which should have been created + AliCDBEntry* chkEntry0 = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB()) + ->Get("ZDC/Calib/ChMap", 7); /*AliCDBEntry* chkEntry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB()) ->Get("ZDC/Calib/Pedestals", 7); */ - AliCDBEntry* chkEntry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB()) - ->Get("ZDC/Calib/Calib", 7); - /*AliCDBEntry* chkEntry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB()) - ->Get("ZDC/Calib/RecParam", 7); + ->Get("ZDC/Calib/EMDCalib", 7); */ + AliCDBEntry* chkEntry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB()) + ->Get("ZDC/Calib/LaserCalib", 7); + if (!chkEntry) { -- 2.43.0