// ************************************************************************** // * 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. * // ************************************************************************** #include "AliHMPIDCalib.h" //class header #include "AliHMPIDParam.h" //class header #include "AliHMPIDRawStream.h" //class header #include "AliHMPIDDigit.h" //class header #include #include #include #include ClassImp(AliHMPIDCalib) //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ AliHMPIDCalib::AliHMPIDCalib(): faddl(0x0), fsq(0x0), fsq2(0x0), fnpc(0x0), fpedQ0(0x0), fErr(0x0), fPadAdc(0x0), fIsPad(0x0), fFile(0x0), fLdcId(0), fTimeStamp(0), fRunNum(0), fSigCut(0), fWritePads(0), fnDDLInStream(0x0), fnDDLOutStream(0x0), fLargeHisto(kFALSE), fSelectDDL(0), fDaOut(0), fFeeIn(0) { // //constructor // faddl = new Bool_t[AliHMPIDRawStream::kNDDL]; Int_t nPads = (AliHMPIDParam::kMaxCh+1)*(AliHMPIDParam::kMaxPcx+1)*(AliHMPIDParam::kMaxPcy+1); fpedQ0 = new Int_t***[AliHMPIDRawStream::kNDDL+1]; fsq2 = new Float_t ***[AliHMPIDRawStream::kNDDL+1]; fsq = new Float_t ***[AliHMPIDRawStream::kNDDL+1]; fnpc = new Int_t ***[AliHMPIDRawStream::kNDDL+1]; fErr = new Int_t*[AliHMPIDRawStream::kNDDL+1]; fnDDLInStream = new Int_t[AliHMPIDRawStream::kNDDL+1]; fnDDLOutStream = new Int_t[AliHMPIDRawStream::kNDDL+1]; for(Int_t iDDL=0;iDDL>nSigCut; } infile.close(); fSigCut=nSigCut; }//SetSigCutFromFile() //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ void AliHMPIDCalib::SetSigCutFromShell(Char_t *env) { // //Set Sigma Cut from the Shell on the LDC, if the input file is not present default value is set! //Arguments: none //Returns: none // Int_t nSigCut=0; TString ssc(gSystem->Getenv(env)); //make it nicer later... if(ssc=="1") { nSigCut=1; Printf("DAQ Sigma Cut from shell is: %d",nSigCut);} else if(ssc=="2") { nSigCut=2; Printf("DAQ Sigma Cut from shell is: %d",nSigCut);} else if(ssc=="3") { nSigCut=3; Printf("DAQ Sigma Cut from shell is: %d",nSigCut);} else if(ssc=="4") { nSigCut=4; Printf("DAQ Sigma Cut from shell is: %d",nSigCut);} else if(ssc=="5") { nSigCut=5; Printf("DAQ Sigma Cut from shell is: %d",nSigCut);} else if(ssc=="6") { nSigCut=6; Printf("DAQ Sigma Cut from shell is: %d",nSigCut);} else if(ssc=="7") { nSigCut=7; Printf("DAQ Sigma Cut from shell is: %d",nSigCut);} else if(ssc=="8") { nSigCut=8; Printf("DAQ Sigma Cut from shell is: %d",nSigCut);} else if(ssc=="9") { nSigCut=9; Printf("DAQ Sigma Cut from shell is: %d",nSigCut);} else if(ssc=="10") { nSigCut=10; Printf("DAQ Sigma Cut from shell is: %d",nSigCut);} else if(ssc=="11") { nSigCut=11; Printf("DAQ Sigma Cut from shell is: %d",nSigCut);} else if(ssc=="12") { nSigCut=12; Printf("DAQ Sigma Cut from shell is: %d",nSigCut);} else if(ssc=="13") { nSigCut=13; Printf("DAQ Sigma Cut from shell is: %d",nSigCut);} else if(ssc=="14") { nSigCut=14; Printf("DAQ Sigma Cut from shell is: %d",nSigCut);} else if(ssc=="15") { nSigCut=15; Printf("DAQ Sigma Cut from shell is: %d",nSigCut);} else { nSigCut=3; Printf("DAQ Sigma Cut from shell is too large set it back to default: %d",nSigCut);} fSigCut=nSigCut; }//SetSigCutFromFile() //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ void SetDaOutFromShell(Char_t* name); //Set out dir. of DA from Bash Shell void AliHMPIDCalib::SetFeeInFromShell(Char_t* env) { // //Set the path where the Fe2C is looking for the threshold files //Arguments: none //Returns: none // TString sFeeIn(gSystem->Getenv(env)); if(sFeeIn.Data()=="") sFeeIn="/local/home/hmpid/"; if(sFeeIn.EndsWith("/")) fFeeIn=sFeeIn; else fFeeIn=Form("%s/",sFeeIn.Data()); if(gSystem->OpenDirectory(fFeeIn.Data())==0) { Printf("========== HMPID-DA WARNING: directory %s does not exist! Switching to /tmp! ==========",fFeeIn.Data()); fFeeIn="/tmp/"; } Printf("HMPID_FEE_IN=%s",fFeeIn.Data()); } //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ void SetDaOutFromShell(Char_t* name); //Set out dir. of DA from Bash Shell void AliHMPIDCalib::SetDaOutFromShell(Char_t* env) { // //Set the standard path where the DA write the output //Arguments: none //Returns: none // TString sDaOut(gSystem->Getenv(env)); if(sDaOut=="") sDaOut="/local/home/hmpid/"; if(sDaOut.EndsWith("/")) fDaOut=sDaOut; else fDaOut=Form("%s/",sDaOut.Data()); if(gSystem->OpenDirectory(fDaOut.Data())==0) { Printf("========== HMPID-DA WARNING: directory %s does not exist! Switching to /tmp! ==========",fDaOut.Data()); fDaOut="/tmp/"; } Printf("HMPID_DA_OUT=%s",fDaOut.Data()); } //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 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 // if(fWritePads==kFALSE) return; fFile->cd(); Double_t lowbin,highbin=0; lowbin=q-40.5; highbin=q+40.5; if(fIsPad[histocnt]==kTRUE) return; if(fLargeHisto==kFALSE) fPadAdc[histocnt]=new TH1I(name,name,81,lowbin,highbin); if(fLargeHisto==kTRUE) fPadAdc[histocnt]=new TH1I(name,name,4093,-0.5,4092.5); 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 // if(fIsPad[histocnt]==kFALSE) return; fFile->cd(); fPadAdc[histocnt]->Fill(q); }//InitHisto() //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ void AliHMPIDCalib::InitFile(Int_t inVal) { // //Initialize the ADC histo output file (one per LDC) //Arguments: LDC Id //Returns: none // if(fWritePads==kFALSE ) return; if(fLargeHisto==kFALSE) fFile=new TFile(Form("HmpidPadsOnLdc%2d.root",inVal),"RECREATE"); if(fLargeHisto==kTRUE) fFile=new TFile(Form("Run%d_DDL%d.root",inVal,fSelectDDL),"RECREATE"); }//InitFile() //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ void AliHMPIDCalib::CloseFile() { // //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: absolute pad number as from AliHMPIDParam and q-charge //Returns: none // if(q<0) AliFatal("Negative charge is read!!!!!!"); UInt_t w32; Int_t nDDL=0, row=0, dil=0, adr=0; //The decoding (abs. pad -> ddl,dil,...) is the same as in AliHMPIDDigit::Raw AliHMPIDDigit dig(abspad,q); dig.Raw(w32,nDDL,row,dil,adr); //........... decoding done if(q>0) { fsq[nDDL][row][dil][adr]+=q; fsq2[nDDL][row][dil][adr]+=q*q; fnpc[nDDL][row][dil][adr]++; //Count how many times the pad is good (can be different from the good DDL count) faddl[nDDL]=kTRUE; } else { fpedQ0[nDDL][row][dil][adr]++; //Count how many times a pad charge is zero } Int_t histocnt=0; histocnt=(nDDL)*11520+(row-1)*480+(dil-1)*48+adr; //Histo counter for a single DDL if(fWritePads==kTRUE) //works but make it nicer later.... { if( fLargeHisto==kTRUE && nDDL==fSelectDDL) { InitHisto(q,histocnt,Form("hDDL_%d_Row_%d_Dil_%d_Pad_%d",nDDL,row,dil,adr)); //for large histos use hardware naming FillHisto(histocnt,q); } if(fLargeHisto==kFALSE) { 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); } }//fWritePads }//FillPedestal() //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ void AliHMPIDCalib::FillErrors(Int_t nDDL,Int_t eType, Int_t nErr) { // //Fill decoding errors from AliHMPIDRawStream //Arguments: nDDL-DDL number, eType- error type as in AliHMPIDRawStream.h and the # of occurence for eType //Retutns: none // if(nErr<=0) return; if(eType < 0 || eType> AliHMPIDRawStream::kSumErr ) return; fErr[nDDL][eType]=fErr[nDDL][eType]+nErr; }//FillErrors() //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ void AliHMPIDCalib::FillDDLCnt(Int_t iddl,Int_t inDDL, Int_t outDDL) { // //Fill decoding DDL check from RawStream //Arguments: iddl - DDL under setting, inDDL- How many times the DDL is present in the raw stream, outDDL - How many time sthe DDL is succesfylly decoded //Retutns: none // if(inDDL==-1) return; if(fnDDLInStream[iddl]==-1) {fnDDLInStream[iddl]=0; fnDDLOutStream[iddl]=0;} fnDDLInStream[iddl]+=inDDL; fnDDLOutStream[iddl]+=outDDL; }//FillDDLCnt() //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 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("%8s %2d\n","RunNumber",(Int_t)fRunNum); //read run number outerr << Form("%8s %2d\n","LdcId" , fLdcId); //read LDC Id outerr << Form("%8s %2d\n","TimeStamp", fTimeStamp); //read time stamp outerr << Form("%8s %2d\n","TotNumEvt", nEv); //read number of total events processed outerr << Form("%8s %2d\n","TotDDLEvt", fnDDLInStream[nDDL]); //read number of bad events for DDL # nDDL processed outerr << Form("%8s %2d\n","NumBadEvt", fnDDLInStream[nDDL]-fnDDLOutStream[nDDL]); //read number of bad events for DDL # nDDL processed outerr << Form("%8s %2.2f\n","NBadE(%)", (fnDDLInStream[nDDL]-fnDDLOutStream[nDDL])*100.0/nEv); //read number of bad events (in %) for DDL # nDDL processed for(Int_t ierr=0; ierr 0) outerr<< Form("%2d %2d %2d %3d\n",row,dil,pad,fpedQ0[nDDL][row][dil][pad]); } } } outerr.close(); //write error file return kTRUE; }//FillErrors() //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Bool_t AliHMPIDCalib::CalcPedestal(Int_t nDDL, Char_t* name, Int_t nEv) { // //Calculate pedestal for each pad //Arguments: nDDL-DDL number, name of the pedestal file and number of the read events //Retutns: kTRUE/kFALSE // if(faddl[nDDL]==kFALSE) return kFALSE; //if ddl is missing no ped file is created (and also for LDC selection). Check with Paolo what he checks for?! Int_t ddlOffset=1536; Int_t feeOffset=196657; ofstream feeInput[24]; for(Int_t ir=0;ir 3.0) Printf("WARNING SIGMA DDL: %2d row: %2d dil: %2d pad: %2d mean: %3.2f sigma: %2.2f nEvPerPad: %02d fnDDLOutStream: %02d fpedQ0: %02d",nDDL,row,dil,pad,mean,sigma,nEvPerPad,fnDDLOutStream[nDDL],fpedQ0[nDDL][row][dil][pad]); }//adr //we have to write up to 64 not 48 in the DILOGIC since they are daisy chained! //offset and format is defined for the Fe2C code for(Int_t idd=0;idd<16;idd++) feeInput[row-1] << Form("0x%4.4x\n",idd+feeOffset); }//dil }//row out.close(); //write pedestal file for(Int_t ir=0;ir