//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-AliHMPIDCalib::AliHMPIDCalib():
- fPedTree(0x0),
- fa(-1),
- fd(-1),
- fr(-1),
- fq(-1),
- fPedHisto(0)
+AliHMPIDCalib::AliHMPIDCalib()
{
+ //
+ //constructor
+ //
Init();
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
AliHMPIDCalib::~AliHMPIDCalib()
{
+ //
//destructor
-}
+ //
+}//ctor
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
void AliHMPIDCalib::Init()
{
- //..
- for(Int_t iddl=0;iddl<11;iddl++) faddl[iddl]=kFALSE;
//
- // Called to initialize the TTree in which the raw data words will be stored
+ //Init the q calc.
//
- fPedHisto=new TH1F("fPedHisto","Temporary pedestal",4096,-0.5,4095.5); //init pedestal histo
- fPedTree = new TTree("PedTree","HMPID Pedestal Tree"); //init pedestal tree
- fPedTree->Branch("diladd",&fa,"diladd/I");
- fPedTree->Branch("dilnum",&fd,"dilnum/I");
- fPedTree->Branch("dilrow",&fr,"dilrow/I");
- fPedTree->Branch("qdc" ,&fq,"qdc/F ");
-}
+ for(Int_t iDDL=0; iDDL< AliHMPIDCalib::kNDDL; iDDL++)
+ {
+ faddl[iDDL]=kFALSE;
+ for(Int_t row = 1; row <=AliHMPIDCalib::kNRows; row++){
+ for(Int_t dil = 1; dil <=AliHMPIDCalib::kNDILOGICAdd; dil++){
+ for(Int_t pad = 0; pad < AliHMPIDCalib::kNPadAdd; pad++){
+ fsq[iDDL][row][dil][pad]=0;
+ fsq2[iDDL][row][dil][pad]=0;
+ }
+ }
+ }
+ }
+}//Init()
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-void AliHMPIDCalib::FillPedestal(Int_t ddl,Int_t row, Int_t dil,Int_t adr,Int_t q)
+void AliHMPIDCalib::FillPedestal(Int_t nDDL,Int_t row, Int_t dil,Int_t adr,Int_t q)
{
//
//Called from the HMPIDda and fills the pedestal tree
//
- fq=q;
- fr=row;
- fd=dil;
- fa=adr;
- faddl[ddl]=kTRUE;
- if(fq>-1) fPedTree->Fill();
+ if(q>0) {
+ fsq[nDDL][row][dil][adr]+=q;
+ fsq2[nDDL][row][dil][adr]+=(q*q);
+ faddl[nDDL]=kTRUE;
+ }
+
}//FillPedestal()
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-Bool_t AliHMPIDCalib::CalcPedestal(Int_t ddl, Char_t* name)
+Bool_t AliHMPIDCalib::CalcPedestal(Int_t nDDL, Char_t* name, Int_t nEv)
{
//
//Calculate pedestal for each pad
//
-
+ Float_t mean=0,sigma=0;
+ Float_t qs2m=0,qsm2=0;
ofstream out; //to write the pedestal text files
- Double_t mean,sigma;
Int_t inhard;
- if(faddl[ddl]==kFALSE) return kFALSE; //if ddl is missing no ped file is created (and also for LDC selection). Check with Paolo what he checks for?!
- out.open(name);
- for(Int_t row=1; row < 25; row++){
- for(Int_t dil=1; dil < 11; dil++){
- for(Int_t adr=0; adr < 48; adr++){
- fPedHisto->Reset();
- fPedTree->Draw("fq>>fPedHisto",Form("fr==%d&&fd==%d&&fa==%d",row,dil,adr));
- mean=fPedHisto->GetMean();
- sigma=fPedHisto->GetRMS();
- inhard=((Int_t(mean))<<9)+Int_t(mean+3*sigma);
- out << Form("%2i %2i %2i %5.2f %5.2f %x\n",row,dil,adr,mean,sigma,inhard);
+ 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?!
+ out.open(name);
+ for(Int_t row = 1; row <= AliHMPIDCalib::kNRows; row++){
+ for(Int_t dil = 1; dil <= AliHMPIDCalib::kNDILOGICAdd; dil++){
+ for(Int_t pad = 0; pad < AliHMPIDCalib::kNPadAdd; pad++){
+
+ mean = fsq[nDDL][row][dil][pad]/1.0/nEv;
+
+ qs2m = fsq2[nDDL][row][dil][pad]/1.0/nEv;
+ qsm2 = TMath::Power(fsq[nDDL][row][dil][pad]/1.0/nEv,2);
+ sigma= TMath::Sqrt(qs2m-qsm2);
+
+ inhard=((Int_t(mean))<<9)+Int_t(mean+3*sigma);
+ out << Form("%2i %2i %2i %5.2f %5.2f %x\n",row,dil,pad,mean,sigma,inhard);
}//adr
}//dil
}//row
//.
//.
//.
-#include "TTreePlayer.h"
-#include <TTree.h>
+
+//#include "TTreePlayer.h"
+//#include <TTree.h>
#include <TH1.h>
+#include <TMath.h>
class AliHMPIDCalib: public TObject {
AliHMPIDCalib();
virtual ~AliHMPIDCalib();
void Init();
- void FillPedestal(Int_t ddl,Int_t row, Int_t dil,Int_t adr,Int_t q);
- Bool_t CalcPedestal(Int_t ddl, Char_t* name);
+ void FillPedestal(Int_t nDDL,Int_t row, Int_t dil,Int_t adr,Int_t q);
+ Bool_t CalcPedestal(Int_t nDDL, Char_t* name, Int_t nEv);
+ 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
+ };
protected:
- TTree *fPedTree; //Pedestal Tree
- Int_t fa; //DILOGIC address
- Int_t fd; //DILOGIC number
- Int_t fr; //DILOGIC row
Bool_t faddl[11]; //check is ddl is filled
- Int_t fq; //Qdc value
- TH1F *fPedHisto; //temporary histo for mean and sigma calculation
-
+ Float_t fsq[kNDDL][kNRows][kNDILOGICAdd][kNPadAdd]; //Sum of pad Q
+ Float_t fsq2[kNDDL][kNRows][kNDILOGICAdd][kNPadAdd]; //Sum of pad Q^2
ClassDef(AliHMPIDCalib,1) //HMPID calibration and pedestal class
};
#endif
#include "TBenchmark.h"
#include "TMath.h"
#include "TRandom.h"
-#include "TTree.h"
-#include "TTreePlayer.h"
int main(int argc, char **argv){
/* init the pedestal calculation */
AliHMPIDCalib *pCal=new AliHMPIDCalib();
- //pCal->Init(); //Init the pedestal calculation
/* init event counter */
Int_t iEvtNcal=0;
+ Int_t cnt=0;
+
int n;
for (n=1;n<argc;n++) {
/* get next event */
status=monitorGetEventDynamic((void **)&event);
- if (status==MON_ERR_EOF) break; /* end of monitoring file has been reached */
+ if (status==MON_ERR_EOF) /* end of monitoring file has been reached */
+ {
+ printf("End of monitoring file has been reached! \n");
+ break;
+ }
+
+
if (status!=0) {
printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
return -1;
/* retry if got no event */
if (event==NULL) {
- break;
+ //break;
+ continue;
}
/* use event - here, just write event id to result file */
if (eventT==PHYSICS_EVENT) { //we use PHYSICS_EVENT for pedestal not CALIBRATION_EVENT
iEvtNcal++;
-
+
AliRawReader *reader = new AliRawReaderDate((void*)event);
// Temporary there. Shall be removed as soon as the equipment ID is set correctly
AliHMPIDRawStream stream(reader);
while(stream.Next()) {
- Int_t ddl=stream.GetDDLNumber();
+ Int_t nDDL=stream.GetDDLNumber();
for(Int_t row = 1; row <=AliHMPIDRawStream::kNRows; row++){
for(Int_t dil = 1; dil <=AliHMPIDRawStream::kNDILOGICAdd; dil++){
for(Int_t pad = 0; pad < AliHMPIDRawStream::kNPadAdd; pad++){
- pCal->FillPedestal(ddl,row,dil,pad,stream.GetCharge(ddl,row,dil,pad));
+ pCal->FillPedestal(nDDL,row,dil,pad,stream.GetCharge(nDDL,row,dil,pad));
}//pad
}//dil
}//row
free(event);
}
- }
+ }//arg
/* write report */
printf("Run #%s, received %d calibration events\n",getenv("DATE_RUN_NUMBER"),iEvtNcal);
/* report progress */
daqDA_progressReport(90);
- for(Int_t ddl=0; ddl < 14; ddl++) {
+ for(Int_t nDDL=0; nDDL < AliHMPIDCalib::kNDDL; nDDL++) {
/* Calculate pedestal for the given ddl, if there is no ddl go t next */
- if(!pCal->CalcPedestal(ddl,Form("./HmpidPedDdl%02i.txt",ddl))) continue;
+ if(!pCal->CalcPedestal(nDDL,Form("./HmpidPedDdl%02i.txt",nDDL),iEvtNcal)) continue;
/* store the result file on FES */
- status=daqDA_FES_storeFile(Form("./HmpidPedDdl%02i.txt",ddl),Form("HMPID_DA_Pedestals_ddl=%02i",ddl));
+
+ 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;
}
- }//ddl
-
+
+ }//nDDL
+
/* report progress */
daqDA_progressReport(100);