fnDDLInStream(0x0),
fnDDLOutStream(0x0),
fLargeHisto(kFALSE),
-fSelectDDL(0),
-fDaOut(0),
-fFeeIn(0)
+fSelectDDL(0)
{
//
//constructor
//
fSigCut=3; //the standard cut
- fFeeIn="";
- fDaOut="";
-
-
+
for(Int_t iDDL=0; iDDL< AliHMPIDRawStream::kNDDL; iDDL++)
{
for(Int_t ierr=0; ierr <AliHMPIDRawStream::kSumErr ; ierr++) {
fLdcId=ldcId;
}//SetRunParams()
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-void AliHMPIDCalib::SetSigCutFromFile(Char_t* name)
+void AliHMPIDCalib::SetSigCutFromFile(TString hmpInFile)
{
//
//Set Sigma Cut from the file on the LDC, if the input file is not present default value is set!
//Returns: none
//
Int_t nSigCut=0;
- ifstream infile(name);
+ ifstream infile(hmpInFile.Data());
if(!infile.is_open()) {fSigCut=3; return;}
while(!infile.eof())
{
infile>>nSigCut;
}
infile.close();
+ if(nSigCut< 0 || nSigCut > 15 ) {Printf("WARNING: DAQ Sigma Cut from DAQ DB is out of bounds: %d, resetting it to 3!!!",nSigCut);nSigCut=3;}
+ Printf("DAQ Sigma Cut from DAQ DB is: %d",nSigCut);
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)
{
//
}//FillErrors()
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-Bool_t AliHMPIDCalib::CalcPedestal(Int_t nDDL, Char_t* name, Int_t nEv)
+Bool_t AliHMPIDCalib::CalcPedestal(Int_t nDDL, Char_t* name, Char_t *name2,Int_t nEv)
{
//
//Calculate pedestal for each pad
//
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];
+ ofstream feeInput; feeInput.open(Form("%s",name2)); //write thr file for Fe2C
- for(Int_t ir=0;ir<AliHMPIDRawStream::kNRows;ir++) feeInput[ir].open(Form("%sthr%d_%d.dat",fFeeIn.Data(),ddlOffset+nDDL,ir+1)); //for Fe2C every row has a file only with inhard
-
Double_t mean=0,sigma=0;
Double_t qs2m=0,qsm2=0;
- ofstream out; //to write the pedestal text files
+ ofstream out; //to write the pedestal text files
Int_t inhard;
Int_t nEvPerPad=0;
out.open(name);
out << Form("%8s %2d\n","TotDDLEvt", fnDDLInStream[nDDL]); //read number of bad events for DDL # nDDL processed
out << Form("%8s %2d\n","NumBadEvt", fnDDLInStream[nDDL]-fnDDLOutStream[nDDL]); //read number of bad events for DDL # nDDL processed
out << Form("%8s %2f\n","NBadE(%)", (fnDDLInStream[nDDL]-fnDDLOutStream[nDDL])*100.0/nEv); //read number of bad events (in %) for DDL # nDDL processed
- out << Form("%8s %2.2d\n","#SigCut", fSigCut); //# of sigma cuts
+ out << Form("%8s %d\n","#SigCut", fSigCut); //# of sigma cuts
for(Int_t row = 1; row <= AliHMPIDRawStream::kNRows; row++){
- //write thr file for Fe2C
+ feeInput << Form("0xabcdabcd \n"); //before each row we write a marker to separate the rows within a DDL
+
for(Int_t dil = 1; dil <= AliHMPIDRawStream::kNDILOGICAdd; dil++){
for(Int_t pad = 0; pad < AliHMPIDRawStream::kNPadAdd; pad++){
inhard=((Int_t(mean+fSigCut*sigma))<<9)+Int_t(mean); //right calculation, xchecked with Paolo 8/4/2008
out << Form("%2i %2i %2i %5.3f %5.3f %4.4x \n",row,dil,pad,mean,sigma,inhard);
- feeInput[row-1] << Form("0x%4.4x\n",inhard);
+ feeInput << Form("0x%4.4x\n",inhard);
//if(sigma > 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);
+ for(Int_t idd=0;idd<16;idd++) feeInput << Form("0x%4.4x\n",idd+feeOffset);
}//dil
}//row
out.close(); //write pedestal file
- for(Int_t ir=0;ir<AliHMPIDRawStream::kNRows;ir++) feeInput[ir].close();
+ feeInput.close();
return kTRUE;
}//CaclPedestal()
Int_t nEvPerPad2=0;
ofstream pped[3];
- for(Int_t iseg=1;iseg<4;iseg++) pped[iseg-1].open(Form("%sHmpidPed%d_%d.dat",fDaOut.Data(),nDDL+ddlOffset,iseg));
+ for(Int_t iseg=1;iseg<4;iseg++) pped[iseg-1].open(Form("HmpidPed%d_%d.dat",nDDL+ddlOffset,iseg));
for(Int_t row = 1; row <= AliHMPIDRawStream::kNRows/2; row++){
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
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); //Fill the errors from RawStream
void FillDDLCnt(Int_t iddl,Int_t inDDL, Int_t outDDL); //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 CalcPedestal(Int_t nDDL, Char_t* name, Char_t *name2,Int_t nEv); //number of the DDL, name of the output file and the number of events processed
Bool_t CalcPedestalPaolo(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 CloseFile(); //Close the file
void SetRunParams(ULong_t runNum,Int_t timeStamp, Int_t ldcId); //Set Run Parameters such as Run Number, TimeStamp, LDCid
void SetSigCut(Int_t nSigCut) { fSigCut=nSigCut;} //Set Sigma Cuts from Setter
- void SetSigCutFromFile(Char_t* name); //Set Sigma Cuts from File
- void SetSigCutFromShell(Char_t* name); //Set Sigma Cuts from Bash Shell
- void SetDaOutFromShell(Char_t* name); //Set out dir. of DA from Bash Shell
- void SetFeeInFromShell(Char_t* name); //Set out dir. for Fe2C from Bash Shell
-
- TString GetDaOutFromShell() {return fDaOut;} //Get out dir. of DA from Bash Shell
- TString GetFeeInFromShell() {return fFeeIn;} //Get out dir. for Fe2C from Bash Shell
+ void SetSigCutFromFile(TString name); //Set Sigma Cuts from File
void SetWriteHistoPads(Bool_t isOn) {fWritePads=isOn;} //Set wether ADC histos of pads are written or not
void SetWriteHistoPads(Bool_t isOn,Bool_t isLarge,Int_t nDDL) {fWritePads=isOn;fLargeHisto=isLarge;fSelectDDL=nDDL;} //Set wether ADC histos of pads are written or not
Bool_t GetWritePads() const{return fWritePads;} //Set wether ADC histos of pads are written or not
Bool_t fLargeHisto; //Default is kFALSE.if kTRUE then write large pad histograms with 4093 bins!!!! Only if you have 2GB of RAM!!!
Int_t fSelectDDL; //Select the DDL to write for the in the large histograms. Only ONE at one time!
- TString fDaOut; //Store the DA output files in this directory
- TString fFeeIn; //
private:
AliHMPIDCalib(const AliHMPIDCalib& c); //dummy copy constructor
AliHMPIDCalib &operator=(const AliHMPIDCalib& c); //dummy assignment operator
ClassDef(AliHMPIDCalib,3) //HMPID calibration and pedestal class
};
#endif
+
int main(int argc, char **argv){
int status;
+ const Char_t *hmpConfigFile = "HmpDaqDaConfig.txt";
+ const Int_t ddlOffset = 1536;
+ TString hmpIn;
+ TString feeIn;
+
/* log start of process */
printf("HMPID DA program started\n");
- gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
- "*",
- "TStreamerInfo",
- "RIO",
- "TStreamerInfo()");
+ gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo","*","TStreamerInfo","RIO","TStreamerInfo()");
/* check that we got some arguments = list of files */
if (argc<2) {
return -1;
}
- /* copy locally a file from daq detector config db
- status=daqDA_DB_getFile("myconfig","./myconfig.txt");
- if (status) {
- printf("Failed to get config file : %d\n",status);
- return -1;
- }
- and possibly use it */
+ /* copy locally a file from daq detector config db */
+ hmpIn=Form("./%s",hmpConfigFile);
+ status=daqDA_DB_getFile(hmpConfigFile,hmpIn.Data());
+ if (status) { printf("Failed to get HMPID config file status: %d\n",status); return -1; }
/* report progress */
daqDA_progressReport(10);
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");
- pCal->SetSigCutFromShell("HMPID_SIGMA_CUT"); //decision to make later: wether to use file or env variable...
- pCal->SetDaOutFromShell("HMPID_DA_OUT"); //decision to make later: wether to use file or env variable...
- pCal->SetFeeInFromShell("HMPID_FEE_IN"); //decision to make later: wether to use file or env variable...
-
+ pCal->SetSigCutFromFile(hmpIn);
/* 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! */
/* report progress */
daqDA_progressReport(90);
- TString sDaOut=pCal->GetDaOutFromShell();
- for(Int_t nDDL=0; nDDL < AliHMPIDRawStream::kNDDL; nDDL++) {
-
+ for(Int_t nDDL=0; nDDL < AliHMPIDRawStream::kNDDL; nDDL++) {
+ feeIn=Form("thr%d.dat",ddlOffset+nDDL);
/* Calculate pedestal for the given ddl, if there is no ddl go t next */
- if(!pCal->CalcPedestal(nDDL,Form("%sHmpidPedDdl%02i.txt",sDaOut.Data(),nDDL),iEvtNcal)) continue;
+ if(pCal->CalcPedestal(nDDL,Form("HmpidPedDdl%02i.txt",nDDL),Form("%s",feeIn.Data()),iEvtNcal)) {
+ status=daqDA_DB_storeFile(feeIn.Data(),feeIn.Data()); //store a single threshold file for a DDL in DAQ DB
+ if (status) { printf("Failed to store file %s in DAQ DB, status: %d\n",feeIn.Data(),status); }
+ status=daqDA_FES_storeFile(Form("HmpidPedDdl%02i.txt",nDDL),Form("HmpidPedDdl%02i.txt",nDDL)); //store a single pedestal file for a DDL
+ if (status) { printf("Failed to export file on FES: %d\n",status); }
+ }//pedestals and thresholds
+ if(pCal->WriteErrors(nDDL,Form("HmpidErrorsDdl%02i.txt",nDDL),iEvtNcal)) {
+ status=daqDA_FES_storeFile(Form("HmpidErrorsDdl%02i.txt",nDDL),Form("HmpidErrorsDdl%02i.txt",nDDL));
+ if (status) { printf("Failed to export file : %d\n",status); }
+ }//errors
/* to create pedestal file as Paolo uncomment the line */
- //if(!pCal->CalcPedestalPaolo(nDDL,Form("%sHmpidPedDdl%02i.txt",sDaOut.Data(),nDDL),iEvtNcal)) continue;
- if(!pCal->WriteErrors(nDDL,Form("%sHmpidErrorsDdl%02i.txt",sDaOut.Data(),nDDL),iEvtNcal)) continue;
-
- /* store the result file on FES */
-
- status=daqDA_FES_storeFile(Form("%sHmpidPedDdl%02i.txt",sDaOut.Data(),nDDL),Form("HmpidPedDdl%02i.txt",nDDL));
- if (status) { printf("Failed to export file : %d\n",status); }
- status=daqDA_FES_storeFile(Form("%sHmpidErrorsDdl%02i.txt",sDaOut.Data(),nDDL),Form("HmpidErrorsDdl%02i.txt",nDDL));
- if (status) { printf("Failed to export file : %d\n",status); }
-
+ //if(!pCal->CalcPedestalPaolo(nDDL,Form("%sHmpidPedDdl%02i.txt",sDaOut.Data(),nDDL),iEvtNcal)) continue;
}//nDDL
if(pCal->GetWritePads()==kTRUE) pCal->CloseFile();
return status;
}
+