]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSOnlineSDDTP.cxx
technial fix to suppress the warning
[u/mrichter/AliRoot.git] / ITS / AliITSOnlineSDDTP.cxx
index 0743fdce66fac2fb8a6b5d89c14246ae85504950..c684c15cd40c39faa2af0bdee6a1ca628050fe6a 100644 (file)
@@ -30,7 +30,7 @@
 ClassImp(AliITSOnlineSDDTP)
 
 //______________________________________________________________________
-AliITSOnlineSDDTP::AliITSOnlineSDDTP():AliITSOnlineSDD(),fDAC(0.),fNSigmaGain(0.),fNSigmaNoise(0.)
+AliITSOnlineSDDTP::AliITSOnlineSDDTP():AliITSOnlineSDD(),fDAC(0.),fLowThreshold(0),fHighThreshold(0),fNSigmaGain(0.),fNSigmaNoise(0.)
 {
   // default constructor
   Reset();
@@ -38,7 +38,7 @@ AliITSOnlineSDDTP::AliITSOnlineSDDTP():AliITSOnlineSDD(),fDAC(0.),fNSigmaGain(0.
   SetNSigmaNoise();
 }
 //______________________________________________________________________
-AliITSOnlineSDDTP::AliITSOnlineSDDTP(Int_t mod, Int_t sid, Float_t xDAC):AliITSOnlineSDD(mod,sid),fDAC(xDAC),fNSigmaGain(0.),fNSigmaNoise(0.)
+AliITSOnlineSDDTP::AliITSOnlineSDDTP(Int_t nddl, Int_t ncarlos, Int_t sid, Float_t xDAC):AliITSOnlineSDD(nddl,ncarlos,sid),fDAC(xDAC),fLowThreshold(0),fHighThreshold(0),fNSigmaGain(0.),fNSigmaNoise(0.)
 {
   // standard constructor
   Reset();
@@ -51,7 +51,7 @@ AliITSOnlineSDDTP::~AliITSOnlineSDDTP(){
 }
 //______________________________________________________________________
 void AliITSOnlineSDDTP::Reset(){
-  //
+  // reset all counters
   for(Int_t i=0;i<fgkNAnodes;i++){
     fNEvents[i]=0;
     fGoodAnode[i]=1;
@@ -67,7 +67,7 @@ void AliITSOnlineSDDTP::Reset(){
 
 //______________________________________________________________________
 void AliITSOnlineSDDTP::AddEvent(TH2F* hrawd){
-  // 
+  // analyzes current event and sum its contribution to the various counters
   for(Int_t ian=0;ian<fgkNAnodes;ian++){
     Float_t auxmax=0.;
     Int_t auxtb=0;
@@ -89,22 +89,31 @@ void AliITSOnlineSDDTP::AddEvent(TH2F* hrawd){
 //______________________________________________________________________
 void AliITSOnlineSDDTP::ReadBaselines(){
   // assume baselines and good anodes are taken from previous run
-  Char_t basfilnam[100];
-  sprintf(basfilnam,"SDDbase_step2_mod%03d_sid%d.data",fModuleId,fSide);
-  FILE* basf=fopen(basfilnam,"r");
+  TString basfilnam;
+  basfilnam.Form("SDDbase_step2_ddl%02dc%02d_sid%d.data",fDDL,fCarlos,fSide);
+  FILE* basf=fopen(basfilnam.Data(),"r");
   if(basf==0){
-    AliWarning("Baselinefile not present, Set all baselines to 50\n");
+    AliWarning(Form("Baseline file not present (ddl %d  carlos %d side %d, Set all baselines to 20",fDDL,fCarlos,fSide));
     for(Int_t ian=0;ian<fgkNAnodes;ian++){ 
-      fBaseline[ian]=50.;
+      fBaseline[ian]=20.;
+      fEqBaseline[ian]=20;
+      fOffsetBaseline[ian]=0;
       fGoodAnode[ian]=1;
     }
     return;
   }
-  Int_t n,ok;
+  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 %f %f %f\n",&n,&ok,&base,&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");
     fBaseline[ian]=base;
+    fEqBaseline[ian]=eqbase;
+    fOffsetBaseline[ian]=offbase;
     fGoodAnode[ian]=ok;
     fRawNoise[ian]=rms;
     fCMN[ian]=cmn;
@@ -125,7 +134,7 @@ Bool_t AliITSOnlineSDDTP::IsModuleGood() const{
 }
 //______________________________________________________________________
 void AliITSOnlineSDDTP::ValidateAnodes(){
-  //
+  // tag good/bad channels
   Float_t meang,rmsg;
   StatGain(meang,rmsg);
   Float_t lowlim=meang-fNSigmaGain*rmsg;
@@ -139,20 +148,23 @@ void AliITSOnlineSDDTP::ValidateAnodes(){
 
 
 //______________________________________________________________________
-void AliITSOnlineSDDTP::StatGain(Float_t &mean, Float_t  &rms){
-  //
+void AliITSOnlineSDDTP::StatGain(Float_t &mean, Float_t  &rms) const {
+  // compute average gain and rms
   Float_t sum=0.,sumq=0.;
   Int_t cnt=0;
   for(Int_t ian=0;ian<fgkNAnodes;ian++){
     if(!fGoodAnode[ian]) continue;
     if(fNEvents[ian]==0) continue;
-    sum+=GetChannelGain(ian);
-    sumq+=TMath::Power(GetChannelGain(ian),2);
+    Float_t chgain=GetChannelGain(ian);
+    sum+=chgain;
+    sumq+=chgain*chgain;
     cnt++;
   }
   if(cnt>0){ 
     mean=sum/(Float_t)cnt;
-    rms=TMath::Sqrt(sumq/(Float_t)cnt-mean*mean);
+    Float_t variance=sumq/(Float_t)cnt-mean*mean;
+    if(variance>0.) rms=TMath::Sqrt(variance);
+    else rms = 0;
   }else{ 
     mean=0.;
     rms=0.;
@@ -162,37 +174,109 @@ void AliITSOnlineSDDTP::StatGain(Float_t &mean, Float_t  &rms){
 
 //______________________________________________________________________
 void AliITSOnlineSDDTP::WriteToASCII(){
-  //
-  Char_t outfilnam[100];
-  sprintf(outfilnam,"SDDbase_mod%03d_sid%d.data",fModuleId,fSide);
-  FILE* outf=fopen(outfilnam,"w");
-  fprintf(outf,"%d %d %d\n",fModuleId,fSide,IsModuleGood());
+  // writes parameters of each channel into an ASCII file 
+  // to be sent to FXS by the DA and processed by the SHUTTLE
+
+  TString outfilnam;
+  outfilnam.Form("SDDbase_ddl%02dc%02d_sid%d.data",fDDL,fCarlos,fSide);
+  FILE* outf=fopen(outfilnam.Data(),"w");
+  fprintf(outf,"%d %d %d\n",fCarlos,fSide,IsModuleGood());
+  fprintf(outf,"%d\n",fHighThreshold);
+  fprintf(outf,"%d\n",fLowThreshold);
   for(Int_t ian=0;ian<fgkNAnodes;ian++){
-    fprintf(outf,"%d %d %8.3f %8.3f %8.3f %8.3f %8.3f\n",ian,IsAnodeGood(ian),GetAnodeBaseline(ian),GetAnodeRawNoise(ian),GetAnodeCommonMode(ian),GetAnodeCorrNoise(ian),GetChannelGain(ian));
+    fprintf(outf,"%d %d %8.3f %d %d %8.3f %8.3f %8.3f %8.3f\n",ian,IsAnodeGood(ian),GetAnodeBaseline(ian),GetAnodeEqualizedBaseline(ian),GetAnodeBaselineOffset(ian),GetAnodeRawNoise(ian),GetAnodeCommonMode(ian),GetAnodeCorrNoise(ian),GetChannelGain(ian));
   }
   fclose(outf);  
 }
 //______________________________________________________________________
+TH1F* AliITSOnlineSDDTP::GetBaselineAnodeHisto() const {
+  // 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));
+  }
+  return h;
+}
+//______________________________________________________________________
+TH1F* AliITSOnlineSDDTP::GetRawNoiseAnodeHisto() const {
+  // 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));
+  }
+  return h;
+}
+//______________________________________________________________________
+TH1F* AliITSOnlineSDDTP::GetCorrNoiseAnodeHisto() const {
+  // 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));
+  }
+  return h;
+}
+//______________________________________________________________________
+TH1F* AliITSOnlineSDDTP::GetCMNCoefAnodeHisto() const {
+  // 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));
+  }
+  return h;
+}
+//______________________________________________________________________
+TH1F* AliITSOnlineSDDTP::GetStatusAnodeHisto() const {
+  // 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)));
+  }
+  return h;
+}
+//______________________________________________________________________
+TH1F* AliITSOnlineSDDTP::GetGainAnodeHisto() const {
+  // produce histogram with gain vs. anode number
+  TString hisnam;  
+  hisnam.Form("hgain%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,GetChannelGain(ian));
+  }
+  return h;
+}
+//______________________________________________________________________
 Bool_t AliITSOnlineSDDTP::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%03ds%d",fModuleId,fSide);
-  TH1F hgood(hisnam,"",256,-0.5,255.5);
-  sprintf(hisnam,"hbase%03ds%d",fModuleId,fSide);
-  TH1F hbase(hisnam,"",256,-0.5,255.5);
-  sprintf(hisnam,"hnois%03ds%d",fModuleId,fSide);
-  TH1F hnois(hisnam,"",256,-0.5,255.5);
-  sprintf(hisnam,"hcmn%03ds%d",fModuleId,fSide);
-  TH1F hcmn(hisnam,"",256,-0.5,255.5);
-  sprintf(hisnam,"hcorn%03ds%d",fModuleId,fSide);
-  TH1F hcorn(hisnam,"",256,-0.5,255.5);
-  sprintf(hisnam,"hgain%03ds%d",fModuleId,fSide);
-  TH1F hgain(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);
+  hisnam.Form("hgain%02dc%02ds%d",fDDL,fCarlos,fSide);
+  TH1F hgain(hisnam.Data(),"",256,-0.5,255.5);
+  hisnam.Form("htptb%02dc%02ds%d",fDDL,fCarlos,fSide);
+  TH1F htptb(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));
@@ -200,6 +284,7 @@ Bool_t AliITSOnlineSDDTP::WriteToROOT(TFile *fil){
     hcmn.SetBinContent(ian+1,GetAnodeCommonMode(ian));
     hcorn.SetBinContent(ian+1,GetAnodeCorrNoise(ian));
     hgain.SetBinContent(ian+1,GetChannelGain(ian));
+    htptb.SetBinContent(ian+1,GetTimeBinTPPeak(ian));
   }
   hgood.Write();
   hbase.Write();
@@ -207,6 +292,7 @@ Bool_t AliITSOnlineSDDTP::WriteToROOT(TFile *fil){
   hcmn.Write();
   hcorn.Write();
   hgain.Write();
+  htptb.Write();
   return kTRUE;
 }