From 3c8e86a0eb8231181848eea2dd5c2069666a95d5 Mon Sep 17 00:00:00 2001 From: dibari Date: Thu, 7 Feb 2008 16:59:28 +0000 Subject: [PATCH] Better error monitoring. Pedestal structure updated. Set the sigma cut from a file on the LDC. Possible to switch on single pad monitoring. Minors. --- HMPID/AliHMPIDCalib.cxx | 235 ++++++++++++++++++++++++------- HMPID/AliHMPIDCalib.h | 46 +++--- HMPID/AliHMPIDQADataMakerRec.cxx | 26 ++-- HMPID/AliHMPIDRawStream.cxx | 152 ++++++++++++-------- HMPID/AliHMPIDRawStream.h | 78 +++++----- HMPID/HMPIDda.cxx | 77 +++++----- 6 files changed, 408 insertions(+), 206 deletions(-) diff --git a/HMPID/AliHMPIDCalib.cxx b/HMPID/AliHMPIDCalib.cxx index d7fda0446fe..3576f2b6a05 100644 --- a/HMPID/AliHMPIDCalib.cxx +++ b/HMPID/AliHMPIDCalib.cxx @@ -14,6 +14,8 @@ // ************************************************************************** #include "AliHMPIDCalib.h" //class header +#include "AliHMPIDParam.h" //class header +#include "AliHMPIDRawStream.h" //class header #include #include @@ -23,11 +25,26 @@ ClassImp(AliHMPIDCalib) //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -AliHMPIDCalib::AliHMPIDCalib() +AliHMPIDCalib::AliHMPIDCalib(): +faddl(0x0), +fPadAdc(0x0), +fIsPad(0x0), +fFile(0x0), +fLdcId(0), +fTimeStamp(0), +fRunNum(0), +fSigCut(0), +fWritePads(0) { // //constructor // + faddl = new Bool_t[AliHMPIDRawStream::kNDDL]; + Int_t nPads = (AliHMPIDParam::kMaxCh+1)*(AliHMPIDParam::kMaxPcx+1)*(AliHMPIDParam::kMaxPcy+1); + fPadAdc=new TH1I*[nPads]; + fIsPad=new Bool_t[nPads]; + for(Int_t np=0;np>nSigCut; + } + infile.close(); + fSigCut=nSigCut; +}//SetSigCutFromFile() +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +void AliHMPIDCalib::InitHisto(Int_t q,Int_t histocnt,Char_t* name) +{ + // + //Init the pad histos. For one DDL we have 11520 pads. ONLY if ENABLED! + //Arguments: q-charge, the absolute number of the histogram (AliHMPIDParam::kMaxCh+1)*(AliHMPIDParam::kMaxPcx+1)*(AliHMPIDParam::kMaxPcy+1) and the name of the histogram (unique) + //Returns: none + // + + fFile->cd(); + Double_t lowbin,highbin=0; +// Printf("InitHisto: histocnt: %d Name: %s",histocnt,name); + if(fIsPad[histocnt]==kTRUE) return; + + lowbin=q-40.5; highbin=q+40.5; + fPadAdc[histocnt]=new TH1I(name,name,81,lowbin,highbin); + fPadAdc[histocnt]->Sumw2(); + fIsPad[histocnt]=kTRUE; + +}//InitHisto() +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +void AliHMPIDCalib::FillHisto(Int_t histocnt,Int_t q) +{ + // + //Fill the ADC histograms for each pad + //Arguments: q-charge, the absolute number of the histogram (AliHMPIDParam::kMaxCh+1)*(AliHMPIDParam::kMaxPcx+1)*(AliHMPIDParam::kMaxPcy+1) + //Returns: none + // + fFile->cd(); + if(fIsPad[histocnt]==kFALSE) return; + fPadAdc[histocnt]->Fill(q); + +}//InitHisto() +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +void AliHMPIDCalib::InitFile(Int_t ldcId) +{ + // + //Initialize the ADC histo output file (one per LDC) + //Arguments: LDC Id + //Returns: none + // + fFile=new TFile(Form("HmpidPadsOnLdc%2d.root",ldcId),"RECREATE"); +}//InitFile() +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +void AliHMPIDCalib::CloseFile(Int_t /*ldcId*/) +{ + // + //Close the ADC histo output file (one per LDC) + //Arguments: LDC Id + //Returns: none + // + fFile->cd(); + Int_t nPads = (AliHMPIDParam::kMaxCh+1)*(AliHMPIDParam::kMaxPcx+1)*(AliHMPIDParam::kMaxPcy+1); + for(Int_t np=0;npWrite();} + fFile->Close(); +}//CloseFile() +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +void AliHMPIDCalib::FillPedestal(Int_t abspad,Int_t q) +{ + // + //Called from the HMPIDda and fills the pedestal values + //Arguments: absulote pad number as from AliHMPIDParam and q-charge + //Returns: none // Int_t nDDL=0, row=0, dil=0, adr=0; //The decoding (abs. pad -> ddl,dil,...) is the same as in AliHMPIDDigit::Raw Int_t y2a[6]={5,3,1,0,2,4}; - nDDL= 2*AliHMPIDParam::A2C(pad)+AliHMPIDParam::A2P(pad)%2; //DDL# 0..13 - Int_t tmp= 1+AliHMPIDParam::A2P(pad)/2*8+AliHMPIDParam::A2Y(pad)/6; //temp variable - row= (AliHMPIDParam::A2P(pad)%2)? 25-tmp:tmp; //row r=1..24 - dil= 1+AliHMPIDParam::A2X(pad)/8; //DILOGIC - adr=y2a[AliHMPIDParam::A2Y(pad)%6]+6*(AliHMPIDParam::A2X(pad)%8); //ADDRESS 0..47 - - // Printf("AbsPadNum: %d nDDL: %d tmp %d row: %d dil: %d adr: %d",pad,nDDL,tmp,row,dil,adr); + nDDL= 2*AliHMPIDParam::A2C(abspad)+AliHMPIDParam::A2P(abspad)%2; //DDL# 0..13 + Int_t tmp= 1+AliHMPIDParam::A2P(abspad)/2*8+AliHMPIDParam::A2Y(abspad)/6; //temp variable + row= (AliHMPIDParam::A2P(abspad)%2)? 25-tmp:tmp; //row r=1..24 + dil= 1+AliHMPIDParam::A2X(abspad)/8; //DILOGIC + adr=y2a[AliHMPIDParam::A2Y(abspad)%6]+6*(AliHMPIDParam::A2X(abspad)%8); //ADDRESS 0..47 //........... decoding done - + + if(q>0) { fsq[nDDL][row][dil][adr]+=q; fsq2[nDDL][row][dil][adr]+=(q*q); faddl[nDDL]=kTRUE; } - - - + Int_t histocnt=0; + histocnt=(nDDL)*11520+(row-1)*480+(dil-1)*48+adr; //Histo counter for a single DDL + if(fWritePads==kTRUE) + { + InitHisto(q,histocnt,Form("hPad_Ch_%d_Pc_%d_Px_%d_Py_%d", + AliHMPIDParam::A2C(abspad),AliHMPIDParam::A2P(abspad),AliHMPIDParam::A2X(abspad),AliHMPIDParam::A2Y(abspad))); + FillHisto(histocnt,q); + } + }//FillPedestal() //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -void AliHMPIDCalib::FillErrors(Int_t nDDL,Int_t nErrType, Int_t nErr) +void AliHMPIDCalib::FillErrors(Int_t nDDL,Int_t eType, Int_t nErr) { // - //Fill decoding errors + //Fill decoding errors from AliHMPIDRawStream + //Arguments: nDDL-DDL number, eType- error type as in AliHMPIDRawStream.h and the # of occurence for eType + //Retutns: none // - // fhDdlDecodErrors[nDDL]->Fill(nErrType,nErr); //select DDL, select bin and add the occurence - fNumOfErr[nDDL][nErrType]+=nErr; + if(nErr<=0) return; + if(eType < 0 || eType> AliHMPIDRawStream::kSumErr ) return; + fErr[nDDL][eType]=fErr[nDDL][eType]+nErr; }//FillErrors() //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -Bool_t AliHMPIDCalib::WriteErrors(ULong_t runNum, Int_t nDDL, Char_t* name, Int_t /*nEv*/) +Bool_t AliHMPIDCalib::WriteErrors(Int_t nDDL, Char_t* name, Int_t nEv) { // //Write decoding errors to a txt file + //Arguments: nDDL-DDL number, name of the error file and number of the read events + //Retutns: kTRUE/kFALSE // - if(faddl[nDDL]==kFALSE) return kFALSE; //if ddl is missing no error file is created - ofstream outerr; - outerr.open(name); //open error file - - outerr << Form("%d \n",(Int_t)runNum); - for(Int_t ierr=1; ierr < AliHMPIDRawStream::kSumErr; ierr++) outerr << Form("%2d\t",fNumOfErr[nDDL][ierr]); - outerr << Form("\n"); - outerr.close(); //write error file + if(faddl[nDDL]==kFALSE) return kFALSE; //if ddl is missing no error file is created + ofstream outerr; outerr.open(name); //open error file + outerr << Form("%6s %2d\n","RunNum",(Int_t)fRunNum); //read run number + outerr << Form("%6s %2d\n","LdcId" , fLdcId); //read LDC Id + outerr << Form("%6s %2d\n","TimeSt", fTimeStamp); //read time stamp + outerr << Form("%6s %2d\n","NumEvt", nEv); //read number of events processed + + for(Int_t ierr=0; ierr #include #include +#include #include "AliHMPIDParam.h" #include "AliHMPIDRawStream.h" +class TH1I; +class TFile; class AliHMPIDCalib: public TObject { @@ -24,24 +27,33 @@ public: AliHMPIDCalib(); virtual ~AliHMPIDCalib(); void Init(); -// void FillPedestal(Int_t nDDL,Int_t row, Int_t dil,Int_t adr,Int_t q); void FillPedestal(Int_t pad,Int_t q); //absolute pad number and the charge of the pad - void FillErrors(Int_t nDDL,Int_t nErrType, Int_t nErr); - Bool_t CalcPedestal(ULong_t runNum, Int_t nDDL, Char_t* name, Int_t nEv); //number of the DDL, name of the output file and the number of events processed - Bool_t WriteErrors(ULong_t runNum, Int_t nDDL, Char_t* name, Int_t nEv); //number of the DDL, name of the output file and the number of events processed - - enum { - kNRows = 24, // Number of rows (starting from 1 !)//was25 - kNDILOGICAdd = 10, // Number of DILOGIC addresses in a row (starting from 1 !) //was11 - kNPadAdd = 48, // Number of pad row - kNDDL = 14 - }; - + void FillErrors(Int_t nDDL,Int_t nErrType, Int_t nErr); //Fill the errors from RawStream + Bool_t CalcPedestal(Int_t nDDL, Char_t* name, Int_t nEv); //number of the DDL, name of the output file and the number of events processed + Bool_t WriteErrors(Int_t nDDL, Char_t* name, Int_t nEv); //number of the DDL, name of the output file and the number of events processed + void InitHisto(Int_t q,Int_t histocnt,Char_t* name); //Init the pad histograms + void FillHisto(Int_t histocnt,Int_t q); //Fill the ADC histograms + void InitFile(Int_t nDDL); //Init the ADC histo output file (one per LDC) + void CloseFile(Int_t nDDL); //Close the file + void SetRunParams(ULong_t runNum,Int_t timeStamp, Int_t ldcId); //Set Run Parameters such as Run Number, TimeStamp, LDCid + inline void SetSigCut(Int_t nSigCut) { fSigCut=nSigCut;} //Set Sigma Cuts from Setter + void SetSigCutFromFile(Char_t* name); //Set Sigma Cuts from File + inline void SetWriteHistoPads(Bool_t isOn) {fWritePads=isOn;} //Set wether ADC histos of pads are written or not + inline Bool_t GetWritePads() {return fWritePads;} //Set wether ADC histos of pads are written or not protected: - Bool_t faddl[11]; //check is ddl is filled - Float_t fsq[kNDDL][kNRows][kNDILOGICAdd][kNPadAdd]; //Sum of pad Q - Float_t fsq2[kNDDL][kNRows][kNDILOGICAdd][kNPadAdd]; //Sum of pad Q^2 - Int_t fNumOfErr[kNDDL][AliHMPIDRawStream::kSumErr]; // Store the numner of errors for a given error type and a given DDL - ClassDef(AliHMPIDCalib,2) //HMPID calibration and pedestal class + + Bool_t *faddl; //check is ddl is filled + Float_t fsq[AliHMPIDRawStream::kNDDL+1][AliHMPIDRawStream::kNRows+1][AliHMPIDRawStream::kNDILOGICAdd+1][AliHMPIDRawStream::kNPadAdd+1]; //Sum of pad Q + Float_t fsq2[AliHMPIDRawStream::kNDDL+1][AliHMPIDRawStream::kNRows+1][AliHMPIDRawStream::kNDILOGICAdd+1][AliHMPIDRawStream::kNPadAdd+1]; //Sum of pad Q^2 + Int_t fErr[AliHMPIDRawStream::kNDDL+1][AliHMPIDRawStream::kSumErr+1]; // Store the numner of errors for a given error type and a given DDL + TH1I **fPadAdc; //Charge distribution for pads + Bool_t *fIsPad; //Check if the ADC histo for the pad is booked or not + TFile *fFile; //ADC histo output file (one per LDC) + UInt_t fLdcId; //Ldc ID + UInt_t fTimeStamp; //Time Stamp + Int_t fRunNum; //Run Number + Int_t fSigCut; //n. of pedestal distribution sigmas used to create zero suppresion table + Bool_t fWritePads; //Select wether to write ADC pad histograms or not + ClassDef(AliHMPIDCalib,2) //HMPID calibration and pedestal class }; #endif diff --git a/HMPID/AliHMPIDQADataMakerRec.cxx b/HMPID/AliHMPIDQADataMakerRec.cxx index 01dc6ef4905..7c81e6ec744 100644 --- a/HMPID/AliHMPIDQADataMakerRec.cxx +++ b/HMPID/AliHMPIDQADataMakerRec.cxx @@ -90,21 +90,21 @@ void AliHMPIDQADataMakerRec::InitRaws() // Booking QA histo for Raw data // const Int_t nerr = (Int_t)AliHMPIDRawStream::kSumErr+1; - const char *hnames[nerr]={"RawDataSize","RawMarkerSize","WrongRow","WrongDilogic","WrongPad","EoEFlag", - "EoESize","EoEDILOGIC","EoERow","BadSegWord","WrongSeg","RowMarkerSize","NoErrors","Invalid"}; TH1F *hqPad[14], *hSumErr[14]; - for(Int_t iddl =0; iddl<14; iddl++) { - - hqPad[iddl] = new TH1F(Form("hqPadDDL%i",iddl), Form("Pad Q Entries at DDL %i",iddl), 500,0,5000); - Add2RawsList(hqPad[iddl],iddl); - hSumErr[iddl] = new TH1F(Form("SumErrDDL%i",iddl), Form("Error summary for ddl %i",iddl), 2*nerr,0,2*nerr); - hSumErr[iddl]->SetYTitle("%"); - for(Int_t ilabel=0; ilabel< nerr; ilabel++) { - hSumErr[iddl]->GetXaxis()->CenterLabels(kTRUE); - hSumErr[iddl]->GetXaxis()->SetBinLabel((2*ilabel+1),Form("%i %s",ilabel+1,hnames[ilabel])); - } - Add2RawsList(hSumErr[iddl],iddl+14); + for(Int_t iddl =0; iddlSetYTitle("%"); + + for(Int_t ilabel=0; ilabel< nerr; ilabel++) { + hSumErr[iddl]->GetXaxis()->CenterLabels(kTRUE); + //hSumErr[iddl]->GetXaxis()->SetBinLabel((2*ilabel+1),Form("%i %s",ilabel+1,hnames[ilabel])); + hSumErr[iddl]->GetXaxis()->SetBinLabel((2*ilabel+1),Form("%i %s",ilabel+1,AliHMPIDRawStream::GetErrName(ilabel))); + } + + Add2RawsList(hSumErr[iddl],iddl+14); } TH1F *hNevRaws = new TH1F("NevRaws","Events per DDL",15,0,15); Add2RawsList(hNevRaws,28); diff --git a/HMPID/AliHMPIDRawStream.cxx b/HMPID/AliHMPIDRawStream.cxx index 89657a1087d..53a8b070794 100644 --- a/HMPID/AliHMPIDRawStream.cxx +++ b/HMPID/AliHMPIDRawStream.cxx @@ -36,6 +36,8 @@ AliHMPIDRawStream::AliHMPIDRawStream(AliRawReader* rawReader) : fCharge(0x0), fPad(0x0), fDDLNumber(-1), + fLDCNumber( 0), + fTimeStamp( 0), fRawReader(rawReader), fData(0x0), fNumOfErr(0x0), @@ -43,10 +45,18 @@ AliHMPIDRawStream::AliHMPIDRawStream(AliRawReader* rawReader) : fWord(0), fZeroSup(kTRUE), fPos(0x0), - iPos(0) + fiPos(0) { + // // Constructor - + // + fNumOfErr = new Int_t*[kNDDL]; // Store the numner of errors for a given error type and a given DD + for(Int_t i=0;iReset(); fRawReader->Select("HMPID"); } @@ -56,21 +66,35 @@ AliHMPIDRawStream::AliHMPIDRawStream() : fCharge(0x0), fPad(0x0), fDDLNumber(-1), + fLDCNumber( 0), + fTimeStamp( 0), fRawReader(0x0), fData(0x0), - fNumOfErr(0x0), + fNumOfErr(0x0), fPosition(-1), fWord(0), fZeroSup(kTRUE), fPos(0x0), - iPos(0) + fiPos(0) { + // + // Constructor + // + fNumOfErr = new Int_t*[kNDDL]; // Store the numner of errors for a given error type and a given DD + for(Int_t i=0;iReset(); @@ -114,16 +140,16 @@ Bool_t AliHMPIDRawStream::Next() fPosition = 0; Bool_t status; - + Int_t rawDataSize=0; if(fRawReader->GetType() == 7) { //New: Select Physics events, Old: Raw data size is not 0 and not 47148 (pedestal) fDDLNumber = fRawReader->GetDDLID(); - if (fDDLNumber<0) { - AliWarning("Negative DDL number!"); - return kFALSE; - } + fLDCNumber = fRawReader->GetLDCId(); + fTimeStamp = fRawReader->GetTimestamp(); - if(stDeb) Printf("DDL %i started to be decoded!.",fDDLNumber); - InitVars(fRawReader->GetDataSize()/4); + if(stDeb) Printf("DDL %i started to be decoded!",fDDLNumber); + rawDataSize=fRawReader->GetDataSize()/4; + InitVars(rawDataSize); + status = ReadHMPIDRawData(); if(stDeb) { @@ -131,58 +157,60 @@ Bool_t AliHMPIDRawStream::Next() else Printf("Event DDL %i ERROR in decoding!.",fDDLNumber); // DumpData(fRawReader->GetDataSize()); } - DelVars(); // stDeb=kFALSE; } // return status; - return kTRUE; + return kTRUE; } //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ void AliHMPIDRawStream::InitVars(Int_t n) { + // + // + // fNPads = 0; - if (n>0) fCharge = new Int_t[n]; - if (n>0) fPad = new Int_t[n]; - fNumOfErr = new Int_t*[kNDDL]; // Store the numner of errors for a given error type and a given DD - for(Int_t i=0;i0) fPos = new Int_t[4*n]; //reset debug - iPos = 0; + fPos = new Int_t[4*n+4]; //reset debug + fiPos = 0; } //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ void AliHMPIDRawStream::DelVars() { + // + // + // fNPads = 0; - if (fCharge) { - delete [] fCharge; - fCharge = 0x0; - } - if (fPad) { - delete [] fPad; - fPad = 0x0; - } - if (fNumOfErr) { - for(Int_t i=0;iGetDataSize()/4; + if(cntGlob==0) {fNumOfErr[fDDLNumber][kRawDataSizeErr]++; return kFALSE; } + Int_t cnt = cntGlob; Int_t nwSeg; Int_t cntSegment; - fWord = GetWord(cnt);cnt--; + if(!GetWord(cnt)) return kFALSE; + cnt--; while (cnt>0) { @@ -192,7 +220,7 @@ Bool_t AliHMPIDRawStream::ReadHMPIDRawData() if(!ReadSegment(cntSegment)) return kFALSE; if(nwSeg != cntSegment) {if(stDeb){Printf("Error in Segment counters: %i different wrt %i",nwSeg,cntSegment);} return kFALSE;} - fWord = GetWord(cntSegment+1,kBwd); + if(!GetWord(cntSegment+1,kBwd)) return kFALSE; cnt-=cntSegment+1; } @@ -207,7 +235,7 @@ Bool_t AliHMPIDRawStream::ReadSegment(Int_t &cntSegment) Int_t cntRow; Int_t nwRow; - fWord = GetWord(cnt,kBwd); + if(!GetWord(cnt,kBwd)) return kFALSE; while (cnt>0) { @@ -216,7 +244,7 @@ Bool_t AliHMPIDRawStream::ReadSegment(Int_t &cntSegment) if(!ReadRow(nwRow)) return kFALSE; if(nwRow != cntRow) {if(stDeb){Printf("Error in Row counters: %i different wrt %i",nwRow,cntRow);} return kFALSE;} - fWord = GetWord(cntRow+1); + if(!GetWord(cntRow+1)) return kFALSE; cnt -= cntRow+1; } @@ -236,7 +264,7 @@ Bool_t AliHMPIDRawStream::ReadRow(Int_t &cntRow) cntRow = (fWord >> kbit16) & 0xfff; cnt = cntRow; - fWord = GetWord(cntRow); + if(!GetWord(cntRow)) return kFALSE; while (cnt>0) { @@ -245,7 +273,7 @@ Bool_t AliHMPIDRawStream::ReadRow(Int_t &cntRow) if(nwDil != cntDilogic) {if(stDeb){Printf("Error in Dilogic counters: %i different wrt %i",nwDil,cntDilogic);}return kFALSE;} cnt -= cntDilogic; - fWord = GetWord(1,kBwd); // go to next Dilogic bank... + if(!GetWord(1,kBwd)) return kFALSE; // go to next Dilogic bank... cnt--; // Printf(" cnt %i cntDilogic %i ",cnt,cntDilogic); } @@ -266,7 +294,7 @@ Bool_t AliHMPIDRawStream::ReadDilogic(Int_t &cntDilogic) for(Int_t iDil=0;iDil> kbit22) & 0x1f; @@ -414,27 +442,34 @@ Bool_t AliHMPIDRawStream::CheckRowMarker() return kTRUE; } //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -UInt_t AliHMPIDRawStream::GetWord(Int_t n,EDirection dir) +Bool_t AliHMPIDRawStream::GetWord(Int_t n,EDirection dir) { // This method returns the n-th 32 bit word // inside the raw data payload. // The method is supposed to be endian (platform) // independent. - if (!fData || fPosition < 0) AliFatal("Raw data payload buffer is not yet initialized !"); - - UInt_t word = 0; + fWord = 0; + if (!fData || fPosition < 0) AliFatal("Raw data payload buffer is not yet initialized !"); + if(dir==kBwd) n = -n; fPosition+=4*n-4; + + if(fPosition==-4) return kTRUE; + if(fPosition<0 || fPosition > fRawReader->GetDataSize()) { + if(stDeb) Printf("fPosition out of boundaries %i",fPosition); + return kFALSE; + } + StorePosition(); - word |= fData[fPosition++]; - word |= fData[fPosition++] << 8; - word |= fData[fPosition++] << 16; - word |= fData[fPosition++] << 24; + fWord |= fData[fPosition++]; + fWord |= fData[fPosition++] << 8; + fWord |= fData[fPosition++] << 16; + fWord |= fData[fPosition++] << 24; - return word; + return kTRUE; } //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ void AliHMPIDRawStream::DumpData(Int_t nw) @@ -448,12 +483,13 @@ void AliHMPIDRawStream::DumpData(Int_t nw) //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ void AliHMPIDRawStream::StorePosition() { +// Printf("@@@@@@@@@ fPos: %x fPosition: %d",fPos,fPosition); if(fPos[fPosition]!=0) { // Printf("Position already stored!!! Value %i at address %i",fPos[fPosition],fPosition); return; } - iPos++; - fPos[fPosition] = iPos; + fiPos++; + fPos[fPosition] = fiPos; // if(stDeb)Printf("%i - Actual position %i",iPos,fPosition); } //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/HMPID/AliHMPIDRawStream.h b/HMPID/AliHMPIDRawStream.h index d95a3fae05b..82dcc4fff22 100644 --- a/HMPID/AliHMPIDRawStream.h +++ b/HMPID/AliHMPIDRawStream.h @@ -35,18 +35,27 @@ class AliHMPIDRawStream: public TObject { void DelVars(); Int_t GetDDLNumber() const { return fDDLNumber; } // Provide current DDL number - static inline Int_t GetPad(Int_t ddl,Int_t row,Int_t dil,Int_t pad); // - Int_t GetNPads() const { return fNPads;} + static inline Int_t GetPad(Int_t ddl,Int_t row,Int_t dil,Int_t pad); // + static inline Int_t GetNDDL() { return kNDDL;} //return the number of max # of DDLs + static inline Int_t GetNErrors() { return kSumErr;} //return the number of max # of Error Types + + Int_t GetNPads() const { return fNPads;} Int_t* GetPadArray() const { return fPad;} Int_t* GetChargeArray() const { return fCharge;} Int_t Pc ( Int_t ddl,Int_t row,Int_t dil,Int_t pad ) {return AliHMPIDParam::A2P(GetPad(ddl,row,dil,pad));} //PC position number Int_t PadPcX ( Int_t ddl,Int_t row,Int_t dil,Int_t pad ) {return AliHMPIDParam::A2X(GetPad(ddl,row,dil,pad));} //pad pc x # 0..79 Int_t PadPcY ( Int_t ddl,Int_t row,Int_t dil,Int_t pad ) {return AliHMPIDParam::A2Y(GetPad(ddl,row,dil,pad));} //pad pc y # 0..47 - - inline Bool_t SetZeroSup (Bool_t isSup); + + static inline Char_t* GetErrName(Int_t eType); + inline Bool_t SetZeroSup (Bool_t isSup); inline Bool_t GetZeroSup(); inline Int_t GetErrors(Int_t ddl,Int_t eType); //Get errors and occurance - + inline Int_t GetDDLNumber() { return fDDLNumber;} //return the number of DDL actually being decoded + inline UInt_t GetLDCNumber() { return fLDCNumber;} //return the number of LDC actually being decoded + inline UInt_t GetTimeStamp() { return fTimeStamp;} //return the time stamp of the event actually being decoded + + + Bool_t ReadHMPIDRawData(); // Read HMPID Raw data Bool_t ReadSegment(Int_t &cntSegment); // Read Segment Bool_t ReadRow(Int_t &cntRow); // Read Row @@ -77,30 +86,20 @@ enum Ebits {kbit0,kbit1 , kbit2, kbit3, kbit4, kbit5, kbit6, kbit7, kbit8, kbit17,kbit18,kbit19,kbit20,kbit21,kbit22,kbit23,kbit24, kbit25,kbit26,kbit27,kbit28,kbit29,kbit30,kbit31,kbit32}; - enum EHMPIDRawStreamError { - kRawDataSizeErr = 1, - kRowMarkerErr = 2, - kWrongRowErr = 3, - kWrongDilogicErr = 4, - kWrongPadErr = 5, - kEoEFlagErr = 6, - kEoESizeErr = 7, - kEoEDILOGICErr = 8, - kEoERowErr = 9, - kBadSegWordErr = 10, - kWrongSegErr = 11, - kRowMarkerSizeErr = 12, - kSumErr = 13 //This is always the last one, to retreive the number of errors - }; - - enum { + enum EHMPIDRawStreamError { kRawDataSizeErr = 0, kRowMarkerErr = 1, kWrongRowErr = 2, kWrongDilogicErr = 3, + kWrongPadErr = 4, kEoEFlagErr = 5, kEoESizeErr = 6, kEoEDILOGICErr = 7, + kEoERowErr = 8, kBadSegWordErr = 9, kWrongSegErr = 10, kRowMarkerSizeErr = 11, + kSumErr = 12 //This is always the last one, to retreive the number of errors + }; //Always check the updated list of names in the .cxx file for print-out! + + enum { kNRows = 24, // Number of rows (starting from 1 !)//was25 kNDILOGICAdd = 10, // Number of DILOGIC addresses in a row (starting from 1 !) //was11 kNPadAdd = 48, // Number of pad row kNRowsPerSegment = 8, // Number of rows per segment kNDDL = 14 }; - enum EHMPIDRawError { + enum EHMPIDRawError { kInvalidRawDataWord = 1 }; @@ -110,12 +109,14 @@ enum Ebits {kbit0,kbit1 , kbit2, kbit3, kbit4, kbit5, kbit6, kbit7, kbit8, AliHMPIDRawStream& operator = (const AliHMPIDRawStream& stream); AliHMPIDRawStream(const AliHMPIDRawStream& stream); - UInt_t GetWord(Int_t n=1,EDirection dir=kFwd); // Get n-th word + Bool_t GetWord(Int_t n=1,EDirection dir=kFwd); // Get n-th word UInt_t GetNextWord(); // Get next word Int_t fNPads; // counter of pads in one DDL Int_t *fCharge; // Array for charge values for all channels in one DDL Int_t *fPad; // Array for abs pad values for all channels in one DDL Int_t fDDLNumber; // index of current DDL number + UInt_t fLDCNumber; // index of current LDC number + UInt_t fTimeStamp; // TimeStamp AliRawReader *fRawReader; // object for reading the raw data UChar_t *fData; // raw data Int_t **fNumOfErr; // Store the numner of errors for a given error type and a given DDL @@ -123,7 +124,7 @@ enum Ebits {kbit0,kbit1 , kbit2, kbit3, kbit4, kbit5, kbit6, kbit7, kbit8, UInt_t fWord; // current position in fData Bool_t fZeroSup; // set if zero suppression is applied Int_t *fPos; // for debug purposes - Int_t iPos; // counter for debug + Int_t fiPos; // counter for debug ClassDef(AliHMPIDRawStream, 2) // base class for reading HMPID raw digits }; @@ -333,8 +334,7 @@ void AliHMPIDRawStream::WriteRaw(TObjArray *pDigAll) AliHMPIDDigit *pDig=(AliHMPIDDigit*)pDigCh->At(isDigThere[iddl][row][dil][pad]); pDig->Raw(w32,ddl,r,d,a); if(pDig->Q() < 0 ) continue; //We can turn of the zero sup for pedestal simulation - //Printf("::::::::::::::: ddl from Digit : %d",ddl); - if(ddl%2){ //write raw digit selecting on DDL + if(ddl%2){ //write raw digit selecting on DDL ddlL->WriteBuffer((char*)&w32,sizeof(w32)); cntL++; cntLpad++; cntLrow++; cntLdig++; cntwInLseg++;//Printf(" WL: %x isDig: %d",w32,isDigThere[iddl][row][dil][pad]); }else{ ddlR->WriteBuffer((char*)&w32,sizeof(w32)); cntR++; cntRpad++; cntRrow++; cntRdig++;cntwInRseg++;//Printf(" WR: %x isDig: %d",w32,isDigThere[iddl][row][dil][pad]); @@ -364,13 +364,27 @@ Int_t AliHMPIDRawStream::GetErrors(Int_t ddl,Int_t eType) { // Return the number of errors for a given error tye during raw data reading // Arguments: errorType -// Returns: error or -999 if error Type does not exist +// Returns: error or -999 if error Type does not exist - if(eType < 1 || eType> kSumErr-1 ) return -999; - else if( ddl < 0 || ddl > kNDDL-1 ) return -999; - else if (!fNumOfErr) return -999; + if(eType < 0 || eType> kSumErr || ddl < 0 || ddl > kNDDL-1 ) return -999; else return fNumOfErr[ddl][eType]; } //GetErrors() //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - +Char_t* AliHMPIDRawStream::GetErrName(Int_t eType) +{ + // Return the name of the error for a given error tye during raw data reading + // Arguments: errorType + // Returns: error or -999 if error Type does not exist + Char_t *eName[]={ "kRawDataSizeErr", "kRowMarkerErr" , "kWrongRowErr" , "kWrongDilogicErr", + "kWrongPadErr" , "kEoEFlagErr" , "kEoESizeErr" , "kEoEDILOGICErr", + "kEoERowErr" , "kBadSegWordErr", "kWrongSegErr" , "kRowMarkerSizeErr", + "kSumErr" }; + Char_t *eNoErr="NotDefinedErrorType"; + if(eType<0 || eType>kSumErr) return eNoErr; + else return eName[eType]; +}//GetErrName() +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + + #endif diff --git a/HMPID/HMPIDda.cxx b/HMPID/HMPIDda.cxx index 3062170aae4..6743bb85ab1 100644 --- a/HMPID/HMPIDda.cxx +++ b/HMPID/HMPIDda.cxx @@ -7,7 +7,7 @@ Link: http://richpc1.ba.infn.it/~levente/Files4Public/ValidateHmpidDA/ Run Type: PEDESTAL -- but we select on the PHYSICS_EVENTS in th HMPIDda.cxx DA Type: LDC Number of events needed: 1000 events -Input Files: Raw pedestal file, no external config file +Input Files: Raw pedestal file, EXTERNAL config file: HmpidSigmaCut.txt on both HMPID LDCs Output Files: 14 txt files including pedestal values Trigger types used: PEDESTAL RUN (selecting on PHYSICS_EVENT) @@ -29,17 +29,11 @@ extern "C" { #include "AliHMPIDCalib.h" #include "AliRawReaderDate.h" #include "AliBitPacking.h" -#include "TMath.h" //ROOT #include "TFile.h" -#include "TSystem.h" -#include "TKey.h" -#include "TH2S.h" +#include "TROOT.h" #include "TObject.h" -#include "TBenchmark.h" -#include "TMath.h" -#include "TRandom.h" int main(int argc, char **argv){ @@ -48,7 +42,13 @@ int main(int argc, char **argv){ /* log start of process */ printf("HMPID DA program started\n"); - +/* + gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo", + "*", + "TStreamerInfo", + "RIO", + "TStreamerInfo()"); + */ /* check that we got some arguments = list of files */ if (argc<2) { printf("Wrong number of arguments\n"); @@ -74,11 +74,18 @@ int main(int argc, char **argv){ /* init the pedestal calculation */ AliHMPIDCalib *pCal=new AliHMPIDCalib(); + /* Set the number of sigma cuts inside the file HmpidSigmaCut.txt on BOTH LDCs! */ + /* If the file is NOT present then the default cut 3 will be used!*/ + pCal->SetSigCutFromFile("HmpidSigmaCut.txt"); + /* ONLY set this option to kTRUE if you want to create the ADC dsitributions for all 161280 pads!!!!*/ + /* kTRUE is not suggested for production mode b/c of the memory consumption! */ + pCal->SetWriteHistoPads(kFALSE); /* init event counter */ Int_t iEvtNcal=0; ULong_t runNum=0; - + ULong_t ldcId=0; + int n; for (n=1;neventRunNb; //assuming that only one run is processed at a time - - iEvtNcal++; + ldcId=(unsigned long)event->eventLdcId; + if(iEvtNcal==0 && pCal->GetWritePads()==kTRUE) pCal->InitFile((Int_t)ldcId); + iEvtNcal++; AliRawReader *reader = new AliRawReaderDate((void*)event); AliHMPIDRawStream stream(reader); - while(stream.Next()) { for(Int_t iPad=0;iPadFillPedestal(stream.GetPadArray()[iPad],stream.GetChargeArray()[iPad]); - } - - for(Int_t iddl=0;iddlFillErrors(iddl,ierr,stream.GetErrors(iddl,ierr)); + } //pads + }//while + for(Int_t iddl=0;iddlFillErrors(iddl,ierr,stream.GetErrors(iddl,ierr)); } - } + }//err - }//Next() + pCal->SetRunParams(runNum,stream.GetTimeStamp(),stream.GetLDCNumber()); //Get the last TimeStam read and the LDC ID stream.Delete(); - }// if CALIBRATION_EVENT /* exit when last event received, no need to wait for TERM signal */ @@ -162,7 +168,7 @@ int main(int argc, char **argv){ }//arg /* write report */ - printf("HMPID DA processed RUN #%s, with %d calibration events\n",getenv("DATE_RUN_NUMBER"),iEvtNcal); + printf("HMPID DA processed RUN #%s on LDC#%d, with %d calibration events\n",getenv("DATE_RUN_NUMBER"),ldcId,iEvtNcal); if (!iEvtNcal) { printf("No calibration events have been read. Exiting\n"); @@ -171,34 +177,33 @@ int main(int argc, char **argv){ /* report progress */ daqDA_progressReport(90); - - - for(Int_t nDDL=0; nDDL < AliHMPIDCalib::kNDDL; nDDL++) { + + for(Int_t nDDL=0; nDDL < AliHMPIDRawStream::kNDDL; nDDL++) { /* Calculate pedestal for the given ddl, if there is no ddl go t next */ - if(!pCal->CalcPedestal(runNum,nDDL,Form("./HmpidPedDdl%02i.txt",nDDL),iEvtNcal)) continue; - if(!pCal->WriteErrors(runNum,nDDL,Form("./HmpidErrorsDdl%02i.txt",nDDL),iEvtNcal)) continue; + if(!pCal->CalcPedestal(nDDL,Form("./HmpidPedDdl%02i.txt",nDDL),iEvtNcal)) continue; + if(!pCal->WriteErrors(nDDL,Form("./HmpidErrorsDdl%02i.txt",nDDL),iEvtNcal)) continue; /* store the result file on FES */ - /* - status=daqDA_FES_storeFile(Form("./HmpidPedDdl%02i.txt",nDDL),Form("HMPID_DA_Pedestals_ddl=%02i",nDDL)); - if (status) { - printf("Failed to export file : %d\n",status); - return -1; - } - */ + status=daqDA_FES_storeFile(Form("./HmpidPedDdl%02i.txt",nDDL),Form("HMPID_DA_Pedestals_ddl=%02i",nDDL)); if (status) { printf("Failed to export file : %d\n",status); } status=daqDA_FES_storeFile(Form("./HmpidErrorsDdl%02i.txt",nDDL),Form("HMPID_DA_Errors_ddl=%02i",nDDL)); if (status) { printf("Failed to export file : %d\n",status); } }//nDDL - delete pCal; + + if(pCal->GetWritePads()==kTRUE) { + pCal->CloseFile((Int_t)ldcId); + status=daqDA_FES_storeFile(Form("HmpidPadsOnLdc%2d.root",ldcId),Form("HMPID_PADS_ON_LDC=%2d",ldcId)); + } + + delete pCal; if (status) return -1; /* report progress */ daqDA_progressReport(100); - + return status; } -- 2.39.3