}
//______________________________________________________________________
void AliITSOnlineSDDCMN::Reset(){
- //
+ // Reset counters
fNEvents=0;
for(Int_t i=0;i<fgkNAnodes;i++){
fGoodAnode[i]=1;
//______________________________________________________________________
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++){
}
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;
}
//______________________________________________________________________
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;
}
//______________________________________________________________________
-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.;
}
//______________________________________________________________________
void AliITSOnlineSDDCMN::AddEvent(TH2F* hrawd){
- //
+ // analyzes one event and adds its ontribution to the various counters
+
fNEvents++;
TH2F* hcorrd=GetCleanEvent(hrawd);
Float_t sumQ=0.;
Int_t cnt=0;
for(Int_t itb=fFirstGoodTB;itb<=fLastGoodTB;itb++){
- sumQ+=TMath::Power(hcorrd->GetBinContent(itb+1,ian+1)-fBaseline[ian],2);
+ Float_t cntdiff=hcorrd->GetBinContent(itb+1,ian+1)-fBaseline[ian];
+ 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++){
}
//______________________________________________________________________
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++){
//______________________________________________________________________
TH1F* AliITSOnlineSDDCMN::GetBaselineAnodeHisto() const {
- //
- Char_t hisnam[20];
- sprintf(hisnam,"hbd%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));
}
}
//______________________________________________________________________
TH1F* AliITSOnlineSDDCMN::GetRawNoiseAnodeHisto() const {
- //
- Char_t hisnam[20];
- sprintf(hisnam,"hnd%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));
}
}
//______________________________________________________________________
TH1F* AliITSOnlineSDDCMN::GetCorrNoiseAnodeHisto() const {
- //
- Char_t hisnam[20];
- sprintf(hisnam,"hcd%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));
}
return h;
}
//______________________________________________________________________
+TH1F* AliITSOnlineSDDCMN::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* AliITSOnlineSDDCMN::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* 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));
}
}
//______________________________________________________________________
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));
}
}
//______________________________________________________________________
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));
}
}
//______________________________________________________________________
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));