]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSOnlineSDDCMN.cxx
Fix of parsing bug related to the reading of the calib header. Added consistency...
[u/mrichter/AliRoot.git] / ITS / AliITSOnlineSDDCMN.cxx
index 071d88e82e3ee9d2176d5d8996f9a433def59244..7b83a351560b14ad20b1b4eb7d531049f0f03cf6 100644 (file)
@@ -12,6 +12,7 @@
  * about the suitability of this software for any purpose. It is          *
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
+#include <TFile.h>
 #include "AliITSOnlineSDDCMN.h"
 #include "AliLog.h"
 #include <TH2F.h>
@@ -57,6 +58,7 @@ void AliITSOnlineSDDCMN::Reset(){
   for(Int_t i=0;i<fgkNAnodes;i++){
     fGoodAnode[i]=1;
     fBaseline[i]=0.;
+    fRawNoise[i]=0.;
     fCMN[i]=0.;
     fSumCorrNoise[i]=0.;
   }
@@ -101,9 +103,9 @@ void  AliITSOnlineSDDCMN::ValidateAnodes(){
 void AliITSOnlineSDDCMN::AddEvent(TH2F* hrawd){
   // 
   fNEvents++;
-  Float_t tbmax=(Float_t)hrawd->GetNbinsX();
+  const Int_t kTimeBins=fLastGoodTB-fFirstGoodTB+1;
   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=0;itb<tbmax;itb++){
+  for(Int_t itb=fFirstGoodTB;itb<=fLastGoodTB;itb++){
     Float_t sumEven=0., sumOdd=0.;
     Int_t countEven=0, countOdd=0;
     for(Int_t ian=0;ian<fgkNAnodes;ian+=2){
@@ -129,10 +131,10 @@ void AliITSOnlineSDDCMN::AddEvent(TH2F* hrawd){
   for(Int_t ian=0;ian<fgkNAnodes;ian++){
     if(!fGoodAnode[ian]) continue;
     Float_t sumQ=0.;
-     for(Int_t itb=0;itb<tbmax;itb++){
+    for(Int_t itb=fFirstGoodTB;itb<=fLastGoodTB;itb++){
       sumQ+=TMath::Power(hcorrd->GetBinContent(itb+1,ian+1)-fBaseline[ian],2);      
     }
-    fSumCorrNoise[ian]+=TMath::Sqrt(sumQ/tbmax);
+    fSumCorrNoise[ian]+=TMath::Sqrt(sumQ/(Float_t)kTimeBins);
   }
   delete hcorrd;
 }
@@ -150,7 +152,7 @@ Float_t AliITSOnlineSDDCMN::CalcMeanNoise() const{
   return meanns;
 }
 //______________________________________________________________________
-void AliITSOnlineSDDCMN::WriteToFXS(){
+void AliITSOnlineSDDCMN::WriteToASCII(){
   //
   Char_t outfilnam[100];
   sprintf(outfilnam,"SDDbase_step2_mod%03d_sid%d.data",fModuleId,fSide);
@@ -160,3 +162,103 @@ void AliITSOnlineSDDCMN::WriteToFXS(){
   }
   fclose(outf);  
 }
+
+//______________________________________________________________________
+TH1F* AliITSOnlineSDDCMN::GetBaselineAnodeHisto() const {
+  //
+  Char_t hisnam[20];  
+  sprintf(hisnam,"hb%03ds%d",fModuleId,fSide);
+  TH1F* h=new TH1F(hisnam,"",256,-0.5,255.5);
+  for(Int_t ian=0;ian<fgkNAnodes;ian++){
+    h->SetBinContent(ian+1,GetAnodeBaseline(ian));
+  }
+  return h;
+}
+//______________________________________________________________________
+TH1F* AliITSOnlineSDDCMN::GetRawNoiseAnodeHisto() const {
+  //
+  Char_t hisnam[20];  
+  sprintf(hisnam,"hn%03ds%d",fModuleId,fSide);
+  TH1F* h=new TH1F(hisnam,"",256,-0.5,255.5);
+  for(Int_t ian=0;ian<fgkNAnodes;ian++){
+    h->SetBinContent(ian+1,GetAnodeRawNoise(ian));
+  }
+  return h;
+}
+//______________________________________________________________________
+TH1F* AliITSOnlineSDDCMN::GetCorrNoiseAnodeHisto() const {
+  //
+  Char_t hisnam[20];  
+  sprintf(hisnam,"hc%03ds%d",fModuleId,fSide);
+  TH1F* h=new TH1F(hisnam,"",256,-0.5,255.5);
+  for(Int_t ian=0;ian<fgkNAnodes;ian++){
+    h->SetBinContent(ian+1,GetAnodeCorrNoise(ian));
+  }
+  return h;
+}
+//______________________________________________________________________
+TH1F* AliITSOnlineSDDCMN::GetBaselineHisto() const {
+  //
+  Char_t hisnam[20];  
+  sprintf(hisnam,"hdb%03ds%d",fModuleId,fSide);
+  TH1F* h=new TH1F(hisnam,"",100,0.,150.);
+  for(Int_t ian=0;ian<fgkNAnodes;ian++){
+    h->Fill(GetAnodeBaseline(ian));
+  }
+  return h;
+}
+//______________________________________________________________________
+TH1F* AliITSOnlineSDDCMN::GetRawNoiseHisto() const {
+  //
+  Char_t hisnam[20];  
+  sprintf(hisnam,"hdn%03ds%d",fModuleId,fSide);
+  TH1F* h=new TH1F(hisnam,"",100,0.,8.);
+  for(Int_t ian=0;ian<fgkNAnodes;ian++){
+    h->Fill(GetAnodeRawNoise(ian));
+  }
+  return h;
+}
+//______________________________________________________________________
+TH1F* AliITSOnlineSDDCMN::GetCorrNoiseHisto() const {
+  //
+  Char_t hisnam[20];  
+  sprintf(hisnam,"hdc%03ds%d",fModuleId,fSide);
+  TH1F* h=new TH1F(hisnam,"",100,0.,8.);
+  for(Int_t ian=0;ian<fgkNAnodes;ian++){
+    h->Fill(GetAnodeCorrNoise(ian));
+  }
+  return h;
+}
+//______________________________________________________________________
+Bool_t AliITSOnlineSDDCMN::WriteToROOT(TFile *fil){
+  //
+  if(fil==0){ 
+    AliWarning("Invalid pointer to ROOT file");
+    return kFALSE;    
+  }
+  Char_t hisnam[20];
+  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);
+  for(Int_t ian=0;ian<fgkNAnodes;ian++){
+    hgood.SetBinContent(ian+1,float(IsAnodeGood(ian)));
+    hbase.SetBinContent(ian+1,GetAnodeBaseline(ian));
+    hnois.SetBinContent(ian+1,GetAnodeRawNoise(ian));
+    hcmn.SetBinContent(ian+1,GetAnodeCommonMode(ian));
+    hcorn.SetBinContent(ian+1,GetAnodeCorrNoise(ian));
+  }
+  hgood.Write();
+  hbase.Write();
+  hnois.Write();
+  hcmn.Write();
+  hcorn.Write();
+  return kTRUE;
+}