]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSOnlineSDDCMN.cxx
update for the NUA
[u/mrichter/AliRoot.git] / ITS / AliITSOnlineSDDCMN.cxx
index cb24f9e3deb123ccacb5d67aa06aa78dff09f25a..eefaa879c981a868bbd2584fcbf71fa23f3dc181 100644 (file)
@@ -53,7 +53,7 @@ AliITSOnlineSDDCMN::~AliITSOnlineSDDCMN(){
 }
 //______________________________________________________________________
 void AliITSOnlineSDDCMN::Reset(){
-  //
+  // Reset counters
   fNEvents=0;
   for(Int_t i=0;i<fgkNAnodes;i++){
     fGoodAnode[i]=1;
@@ -67,9 +67,9 @@ void AliITSOnlineSDDCMN::Reset(){
 //______________________________________________________________________
 void AliITSOnlineSDDCMN::ReadBaselines(){
   // assume baselines and good anodes are taken from previous run
-  Char_t basfilnam[100];
-  sprintf(basfilnam,"SDDbase_step1_ddl%02dc%02d_sid%d.data",fDDL,fCarlos,fSide);
-  FILE* basf=fopen(basfilnam,"r");
+  TString basfilnam;
+  basfilnam.Form("SDDbase_step1_ddl%02dc%02d_sid%d.data",fDDL,fCarlos,fSide);
+  FILE* basf=fopen(basfilnam.Data(),"r");
   if(basf==0){
     AliWarning(Form("Baseline file not present (ddl %d  carlos %d side %d, Set all baselines to 50\n",fDDL,fCarlos,fSide));
     for(Int_t ian=0;ian<fgkNAnodes;ian++){ 
@@ -80,12 +80,15 @@ void AliITSOnlineSDDCMN::ReadBaselines(){
     }
     return;
   }
-  fscanf(basf,"%d\n",&fHighThreshold);
-  fscanf(basf,"%d\n",&fLowThreshold);
+  Int_t check = fscanf(basf,"%d\n",&fHighThreshold);
+  if(check<1)AliError("Error while reading file with baselines");
+  check = fscanf(basf,"%d\n",&fLowThreshold);
+  if(check<1)AliError("Error while reading file with baselines");
   Int_t n,ok,eqbase,offbase;
   Float_t base,rms,cmn,corrnoi;
   for(Int_t ian=0;ian<fgkNAnodes;ian++){
-    fscanf(basf,"%d %d %f %d %d %f %f %f\n",&n,&ok,&base,&eqbase,&offbase,&rms,&cmn,&corrnoi);
+    check = fscanf(basf,"%d %d %f %d %d %f %f %f\n",&n,&ok,&base,&eqbase,&offbase,&rms,&cmn,&corrnoi);
+    if(check<1)AliError("Error while reading file with baselines");
     fGoodAnode[ian]=ok;
     fBaseline[ian]=base;
     fEqBaseline[ian]=eqbase;
@@ -97,7 +100,7 @@ void AliITSOnlineSDDCMN::ReadBaselines(){
 }
 //______________________________________________________________________
 void  AliITSOnlineSDDCMN::ValidateAnodes(){
-  //
+  // Tag good/bad anodes
   for(Int_t ian=0;ian<fgkNAnodes;ian++){
     if(!fGoodAnode[ian]) continue;
     if(GetAnodeCorrNoise(ian)>fMaxCorrNoise || GetAnodeCorrNoise(ian)<fMinCorrNoise) fGoodAnode[ian]=0;
@@ -106,8 +109,9 @@ void  AliITSOnlineSDDCMN::ValidateAnodes(){
 }
 
 //______________________________________________________________________
-TH2F* AliITSOnlineSDDCMN::GetCleanEvent(TH2F* hrawd) const {
-  // 
+TH2F* AliITSOnlineSDDCMN::GetCleanEvent(const TH2F* hrawd) const {
+  // Fills an histogram with counts corrected for common mode noise
+
   TH2F* hcorrd=new TH2F("hcorrd","",hrawd->GetNbinsX(),hrawd->GetXaxis()->GetXmin(),hrawd->GetXaxis()->GetXmax(),hrawd->GetNbinsY(),hrawd->GetYaxis()->GetXmin(),hrawd->GetYaxis()->GetXmax());
   for(Int_t itb=fFirstGoodTB;itb<=fLastGoodTB;itb++){
     Float_t sumEven=0., sumOdd=0.;
@@ -135,7 +139,8 @@ TH2F* AliITSOnlineSDDCMN::GetCleanEvent(TH2F* hrawd) const {
 }
 //______________________________________________________________________
 void AliITSOnlineSDDCMN::AddEvent(TH2F* hrawd){
-  // 
+  // analyzes one event and adds its ontribution to the various counters
+
   fNEvents++;
   TH2F* hcorrd=GetCleanEvent(hrawd);
 
@@ -148,13 +153,14 @@ void AliITSOnlineSDDCMN::AddEvent(TH2F* hrawd){
       sumQ+=cntdiff*cntdiff;
       cnt++;    
     }
-    fSumCorrNoise[ian]+=TMath::Sqrt(sumQ/(Float_t)cnt);
+    if(cnt != 0)fSumCorrNoise[ian]+=TMath::Sqrt(sumQ/(Float_t)cnt);
   }
   delete hcorrd;
 }
 //______________________________________________________________________
 Float_t AliITSOnlineSDDCMN::CalcMeanNoise() const{
-  //
+  // compute average noise
+
   Float_t meanns=0.;
   Int_t cnt=0;
   for(Int_t ian=0;ian<fgkNAnodes;ian++){
@@ -167,10 +173,12 @@ Float_t AliITSOnlineSDDCMN::CalcMeanNoise() const{
 }
 //______________________________________________________________________
 void AliITSOnlineSDDCMN::WriteToASCII(){
-  //
-  Char_t outfilnam[100];
-  sprintf(outfilnam,"SDDbase_step2_ddl%02dc%02d_sid%d.data",fDDL,fCarlos,fSide);
-  FILE* outf=fopen(outfilnam,"w");
+  // writes parameters of each channel into an ASCII file 
+  // to be then read by the PULSER DA (AliITSOnlineSDDTP)
+
+  TString outfilnam;
+  outfilnam.Form("SDDbase_step2_ddl%02dc%02d_sid%d.data",fDDL,fCarlos,fSide);
+  FILE* outf=fopen(outfilnam.Data(),"w");
   fprintf(outf,"%d\n",fHighThreshold);
   fprintf(outf,"%d\n",fLowThreshold);
   for(Int_t ian=0;ian<fgkNAnodes;ian++){
@@ -181,10 +189,10 @@ void AliITSOnlineSDDCMN::WriteToASCII(){
 
 //______________________________________________________________________
 TH1F* AliITSOnlineSDDCMN::GetBaselineAnodeHisto() const {
-  //
-  Char_t hisnam[20];  
-  sprintf(hisnam,"hbase%02dc%02ds%d",fDDL,fCarlos,fSide);
-  TH1F* h=new TH1F(hisnam,"",256,-0.5,255.5);
+  // produce histogram with baseline vs. anode number
+  TString hisnam;  
+  hisnam.Form("hbase%02dc%02ds%d",fDDL,fCarlos,fSide);
+  TH1F* h=new TH1F(hisnam.Data(),"",256,-0.5,255.5);
   for(Int_t ian=0;ian<fgkNAnodes;ian++){
     h->SetBinContent(ian+1,GetAnodeBaseline(ian));
   }
@@ -192,10 +200,10 @@ TH1F* AliITSOnlineSDDCMN::GetBaselineAnodeHisto() const {
 }
 //______________________________________________________________________
 TH1F* AliITSOnlineSDDCMN::GetRawNoiseAnodeHisto() const {
-  //
-  Char_t hisnam[20];  
-  sprintf(hisnam,"hnois%02dc%02ds%d",fDDL,fCarlos,fSide);
-  TH1F* h=new TH1F(hisnam,"",256,-0.5,255.5);
+  // produce histogram with raw noise vs. anode number
+  TString hisnam;  
+  hisnam.Form("hnois%02dc%02ds%d",fDDL,fCarlos,fSide);
+  TH1F* h=new TH1F(hisnam.Data(),"",256,-0.5,255.5);
   for(Int_t ian=0;ian<fgkNAnodes;ian++){
     h->SetBinContent(ian+1,GetAnodeRawNoise(ian));
   }
@@ -203,10 +211,10 @@ TH1F* AliITSOnlineSDDCMN::GetRawNoiseAnodeHisto() const {
 }
 //______________________________________________________________________
 TH1F* AliITSOnlineSDDCMN::GetCorrNoiseAnodeHisto() const {
-  //
-  Char_t hisnam[20];  
-  sprintf(hisnam,"hcorn%02dc%02ds%d",fDDL,fCarlos,fSide);
-  TH1F* h=new TH1F(hisnam,"",256,-0.5,255.5);
+  // produce histogram with corrected noise vs. anode number
+  TString hisnam;  
+  hisnam.Form("hcorn%02dc%02ds%d",fDDL,fCarlos,fSide);
+  TH1F* h=new TH1F(hisnam.Data(),"",256,-0.5,255.5);
   for(Int_t ian=0;ian<fgkNAnodes;ian++){
     h->SetBinContent(ian+1,GetAnodeCorrNoise(ian));
   }
@@ -214,10 +222,10 @@ TH1F* AliITSOnlineSDDCMN::GetCorrNoiseAnodeHisto() const {
 }
 //______________________________________________________________________
 TH1F* AliITSOnlineSDDCMN::GetCMNCoefAnodeHisto() const {
-//
-  Char_t hisnam[20];  
-  sprintf(hisnam,"hcmn%02dc%02ds%d",fDDL,fCarlos,fSide);
-  TH1F* h=new TH1F(hisnam,"",256,-0.5,255.5);
+  // produce histogram with coefficients for common mode noise subtraction
+  TString hisnam;  
+  hisnam.Form("hcmn%02dc%02ds%d",fDDL,fCarlos,fSide);
+  TH1F* h=new TH1F(hisnam.Data(),"",256,-0.5,255.5);
   for(Int_t ian=0;ian<fgkNAnodes;ian++){
     h->SetBinContent(ian+1,GetAnodeCommonMode(ian));
   }
@@ -225,10 +233,10 @@ TH1F* AliITSOnlineSDDCMN::GetCMNCoefAnodeHisto() const {
 }
 //______________________________________________________________________
 TH1F* AliITSOnlineSDDCMN::GetStatusAnodeHisto() const {
-//
-  Char_t hisnam[20];  
-  sprintf(hisnam,"hgood%02dc%02ds%d",fDDL,fCarlos,fSide);
-  TH1F* h=new TH1F(hisnam,"",256,-0.5,255.5);
+  // produce histogram with status bit of each anode
+  TString hisnam;  
+  hisnam.Form("hgood%02dc%02ds%d",fDDL,fCarlos,fSide);
+  TH1F* h=new TH1F(hisnam.Data(),"",256,-0.5,255.5);
   for(Int_t ian=0;ian<fgkNAnodes;ian++){
     h->SetBinContent(ian+1,float(IsAnodeGood(ian)));
   }
@@ -236,10 +244,10 @@ TH1F* AliITSOnlineSDDCMN::GetStatusAnodeHisto() const {
 }
 //______________________________________________________________________
 TH1F* AliITSOnlineSDDCMN::GetBaselineHisto() const {
-  //
-  Char_t hisnam[20];  
-  sprintf(hisnam,"hdbd%02dc%02ds%d",fDDL,fCarlos,fSide);
-  TH1F* h=new TH1F(hisnam,"",100,0.,150.);
+  // produce histogram with baseline distribution
+  TString hisnam;  
+  hisnam.Form("hdbd%02dc%02ds%d",fDDL,fCarlos,fSide);
+  TH1F* h=new TH1F(hisnam.Data(),"",100,0.,150.);
   for(Int_t ian=0;ian<fgkNAnodes;ian++){
     h->Fill(GetAnodeBaseline(ian));
   }
@@ -247,10 +255,10 @@ TH1F* AliITSOnlineSDDCMN::GetBaselineHisto() const {
 }
 //______________________________________________________________________
 TH1F* AliITSOnlineSDDCMN::GetRawNoiseHisto() const {
-  //
-  Char_t hisnam[20];  
-  sprintf(hisnam,"hdnd%02dc%02ds%d",fDDL,fCarlos,fSide);
-  TH1F* h=new TH1F(hisnam,"",100,0.,8.);
+  // produce histogram with raw noise distribution
+  TString hisnam;  
+  hisnam.Form("hdnd%02dc%02ds%d",fDDL,fCarlos,fSide);
+  TH1F* h=new TH1F(hisnam.Data(),"",100,0.,8.);
   for(Int_t ian=0;ian<fgkNAnodes;ian++){
     h->Fill(GetAnodeRawNoise(ian));
   }
@@ -258,10 +266,10 @@ TH1F* AliITSOnlineSDDCMN::GetRawNoiseHisto() const {
 }
 //______________________________________________________________________
 TH1F* AliITSOnlineSDDCMN::GetCorrNoiseHisto() const {
-  //
-  Char_t hisnam[20];  
-  sprintf(hisnam,"hdcd%02dc%02ds%d",fDDL,fCarlos,fSide);
-  TH1F* h=new TH1F(hisnam,"",100,0.,8.);
+  // produce histogram with corrected noise distribution
+  TString hisnam;  
+  hisnam.Form("hdcd%02dc%02ds%d",fDDL,fCarlos,fSide);
+  TH1F* h=new TH1F(hisnam.Data(),"",100,0.,8.);
   for(Int_t ian=0;ian<fgkNAnodes;ian++){
     h->Fill(GetAnodeCorrNoise(ian));
   }
@@ -269,23 +277,23 @@ TH1F* AliITSOnlineSDDCMN::GetCorrNoiseHisto() const {
 }
 //______________________________________________________________________
 Bool_t AliITSOnlineSDDCMN::WriteToROOT(TFile *fil){
-  //
+  // writes output into a root file
   if(fil==0){ 
     AliWarning("Invalid pointer to ROOT file");
     return kFALSE;    
   }
-  Char_t hisnam[20];
+  TString hisnam;
   fil->cd();
-  sprintf(hisnam,"hgood%02dc%02ds%d",fDDL,fCarlos,fSide);
-  TH1F hgood(hisnam,"",256,-0.5,255.5);
-  sprintf(hisnam,"hbase%02dc%02ds%d",fDDL,fCarlos,fSide);
-  TH1F hbase(hisnam,"",256,-0.5,255.5);
-  sprintf(hisnam,"hnois%02dc%02ds%d",fDDL,fCarlos,fSide);
-  TH1F hnois(hisnam,"",256,-0.5,255.5);
-  sprintf(hisnam,"hcmn%02dc%02ds%d",fDDL,fCarlos,fSide);
-  TH1F hcmn(hisnam,"",256,-0.5,255.5);
-  sprintf(hisnam,"hcorn%02dc%02ds%d",fDDL,fCarlos,fSide);
-  TH1F hcorn(hisnam,"",256,-0.5,255.5);
+  hisnam.Form("hgood%02dc%02ds%d",fDDL,fCarlos,fSide);
+  TH1F hgood(hisnam.Data(),"",256,-0.5,255.5);
+  hisnam.Form("hbase%02dc%02ds%d",fDDL,fCarlos,fSide);
+  TH1F hbase(hisnam.Data(),"",256,-0.5,255.5);
+  hisnam.Form("hnois%02dc%02ds%d",fDDL,fCarlos,fSide);
+  TH1F hnois(hisnam.Data(),"",256,-0.5,255.5);
+  hisnam.Form("hcmn%02dc%02ds%d",fDDL,fCarlos,fSide);
+  TH1F hcmn(hisnam.Data(),"",256,-0.5,255.5);
+  hisnam.Form("hcorn%02dc%02ds%d",fDDL,fCarlos,fSide);
+  TH1F hcorn(hisnam.Data(),"",256,-0.5,255.5);
   for(Int_t ian=0;ian<fgkNAnodes;ian++){
     hgood.SetBinContent(ian+1,float(IsAnodeGood(ian)));
     hbase.SetBinContent(ian+1,GetAnodeBaseline(ian));