1 /**************************************************************************
2 * Copyright(c) 2007-2009, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
16 #include "AliITSOnlineSDDCMN.h"
22 ///////////////////////////////////////////////////////////////////
24 // Implementation of the class used for analysis of SDD noise //
25 // corrected for common mode //
26 // Origin: F.Prino, Torino, prino@to.infn.it //
28 ///////////////////////////////////////////////////////////////////
31 ClassImp(AliITSOnlineSDDCMN)
32 //______________________________________________________________________
33 AliITSOnlineSDDCMN::AliITSOnlineSDDCMN():AliITSOnlineSDD(),fNEvents(0),fLowThreshold(0),fHighThreshold(0),fMinCorrNoise(0.),fMaxCorrNoise(0.),fNSigmaNoise(0.)
35 // default constructor
41 //______________________________________________________________________
42 AliITSOnlineSDDCMN::AliITSOnlineSDDCMN(Int_t nddl, Int_t ncarlos, Int_t sid):AliITSOnlineSDD(nddl,ncarlos,sid),fNEvents(0),fLowThreshold(0),fHighThreshold(0),fMinCorrNoise(0.),fMaxCorrNoise(0.),fNSigmaNoise(0.)
44 // default constructor
50 //______________________________________________________________________
51 AliITSOnlineSDDCMN::~AliITSOnlineSDDCMN(){
54 //______________________________________________________________________
55 void AliITSOnlineSDDCMN::Reset(){
58 for(Int_t i=0;i<fgkNAnodes;i++){
67 //______________________________________________________________________
68 void AliITSOnlineSDDCMN::ReadBaselines(){
69 // assume baselines and good anodes are taken from previous run
70 Char_t basfilnam[100];
71 sprintf(basfilnam,"SDDbase_step1_ddl%02dc%02d_sid%d.data",fDDL,fCarlos,fSide);
72 FILE* basf=fopen(basfilnam,"r");
74 AliWarning(Form("Baseline file not present (ddl %d carlos %d side %d, Set all baselines to 50\n",fDDL,fCarlos,fSide));
75 for(Int_t ian=0;ian<fgkNAnodes;ian++){
78 fOffsetBaseline[ian]=0;
83 fscanf(basf,"%d\n",&fHighThreshold);
84 fscanf(basf,"%d\n",&fLowThreshold);
85 Int_t n,ok,eqbase,offbase;
86 Float_t base,rms,cmn,corrnoi;
87 for(Int_t ian=0;ian<fgkNAnodes;ian++){
88 fscanf(basf,"%d %d %f %d %d %f %f %f\n",&n,&ok,&base,&eqbase,&offbase,&rms,&cmn,&corrnoi);
91 fEqBaseline[ian]=eqbase;
92 fOffsetBaseline[ian]=offbase;
98 //______________________________________________________________________
99 void AliITSOnlineSDDCMN::ValidateAnodes(){
101 for(Int_t ian=0;ian<fgkNAnodes;ian++){
102 if(!fGoodAnode[ian]) continue;
103 if(GetAnodeCorrNoise(ian)>fMaxCorrNoise || GetAnodeCorrNoise(ian)<fMinCorrNoise) fGoodAnode[ian]=0;
104 if(GetAnodeCorrNoise(ian)>fNSigmaNoise*CalcMeanNoise()) fGoodAnode[ian]=0;
108 //______________________________________________________________________
109 TH2F* AliITSOnlineSDDCMN::GetCleanEvent(TH2F* hrawd) const {
111 TH2F* hcorrd=new TH2F("hcorrd","",hrawd->GetNbinsX(),hrawd->GetXaxis()->GetXmin(),hrawd->GetXaxis()->GetXmax(),hrawd->GetNbinsY(),hrawd->GetYaxis()->GetXmin(),hrawd->GetYaxis()->GetXmax());
112 for(Int_t itb=fFirstGoodTB;itb<=fLastGoodTB;itb++){
113 Float_t sumEven=0., sumOdd=0.;
114 Int_t countEven=0, countOdd=0;
115 for(Int_t ian=0;ian<fgkNAnodes;ian+=2){
116 if(!fGoodAnode[ian]) continue;
117 sumEven+=hrawd->GetBinContent(itb+1,ian+1)-fBaseline[ian];
120 for(Int_t ian=1;ian<fgkNAnodes;ian+=2){
121 if(!fGoodAnode[ian]) continue;
122 sumOdd+=hrawd->GetBinContent(itb+1,ian+1)-fBaseline[ian];
125 for(Int_t ian=0;ian<fgkNAnodes;ian++){
126 if(!fGoodAnode[ian]) continue;
128 if(ian%2==0) meanN=sumEven/(Float_t)countEven;
129 else meanN=sumOdd/(Float_t)countOdd;
130 Float_t cntCorr=hrawd->GetBinContent(itb+1,ian+1)-fCMN[ian]*meanN;
131 hcorrd->SetBinContent(itb+1,ian+1,cntCorr);
136 //______________________________________________________________________
137 void AliITSOnlineSDDCMN::AddEvent(TH2F* hrawd){
140 TH2F* hcorrd=GetCleanEvent(hrawd);
142 for(Int_t ian=0;ian<fgkNAnodes;ian++){
143 if(!fGoodAnode[ian]) continue;
146 for(Int_t itb=fFirstGoodTB;itb<=fLastGoodTB;itb++){
147 Float_t cntdiff=hcorrd->GetBinContent(itb+1,ian+1)-fBaseline[ian];
148 sumQ+=cntdiff*cntdiff;
151 fSumCorrNoise[ian]+=TMath::Sqrt(sumQ/(Float_t)cnt);
155 //______________________________________________________________________
156 Float_t AliITSOnlineSDDCMN::CalcMeanNoise() const{
160 for(Int_t ian=0;ian<fgkNAnodes;ian++){
161 if(!fGoodAnode[ian]) continue;
162 meanns+=GetAnodeCorrNoise(ian);
165 if(cnt>0) meanns/=(Float_t)cnt;
168 //______________________________________________________________________
169 void AliITSOnlineSDDCMN::WriteToASCII(){
171 Char_t outfilnam[100];
172 sprintf(outfilnam,"SDDbase_step2_ddl%02dc%02d_sid%d.data",fDDL,fCarlos,fSide);
173 FILE* outf=fopen(outfilnam,"w");
174 fprintf(outf,"%d\n",fHighThreshold);
175 fprintf(outf,"%d\n",fLowThreshold);
176 for(Int_t ian=0;ian<fgkNAnodes;ian++){
177 fprintf(outf,"%d %d %8.3f %d %d %8.3f %8.3f %8.3f\n",ian,IsAnodeGood(ian),GetAnodeBaseline(ian),GetAnodeEqualizedBaseline(ian),GetAnodeBaselineOffset(ian),GetAnodeRawNoise(ian),GetAnodeCommonMode(ian),GetAnodeCorrNoise(ian));
182 //______________________________________________________________________
183 TH1F* AliITSOnlineSDDCMN::GetBaselineAnodeHisto() const {
186 sprintf(hisnam,"hbase%02dc%02ds%d",fDDL,fCarlos,fSide);
187 TH1F* h=new TH1F(hisnam,"",256,-0.5,255.5);
188 for(Int_t ian=0;ian<fgkNAnodes;ian++){
189 h->SetBinContent(ian+1,GetAnodeBaseline(ian));
193 //______________________________________________________________________
194 TH1F* AliITSOnlineSDDCMN::GetRawNoiseAnodeHisto() const {
197 sprintf(hisnam,"hnois%02dc%02ds%d",fDDL,fCarlos,fSide);
198 TH1F* h=new TH1F(hisnam,"",256,-0.5,255.5);
199 for(Int_t ian=0;ian<fgkNAnodes;ian++){
200 h->SetBinContent(ian+1,GetAnodeRawNoise(ian));
204 //______________________________________________________________________
205 TH1F* AliITSOnlineSDDCMN::GetCorrNoiseAnodeHisto() const {
208 sprintf(hisnam,"hcorn%02dc%02ds%d",fDDL,fCarlos,fSide);
209 TH1F* h=new TH1F(hisnam,"",256,-0.5,255.5);
210 for(Int_t ian=0;ian<fgkNAnodes;ian++){
211 h->SetBinContent(ian+1,GetAnodeCorrNoise(ian));
215 //______________________________________________________________________
216 TH1F* AliITSOnlineSDDCMN::GetCMNCoefAnodeHisto() const {
219 sprintf(hisnam,"hcmn%02dc%02ds%d",fDDL,fCarlos,fSide);
220 TH1F* h=new TH1F(hisnam,"",256,-0.5,255.5);
221 for(Int_t ian=0;ian<fgkNAnodes;ian++){
222 h->SetBinContent(ian+1,GetAnodeCommonMode(ian));
226 //______________________________________________________________________
227 TH1F* AliITSOnlineSDDCMN::GetStatusAnodeHisto() const {
230 sprintf(hisnam,"hgood%02dc%02ds%d",fDDL,fCarlos,fSide);
231 TH1F* h=new TH1F(hisnam,"",256,-0.5,255.5);
232 for(Int_t ian=0;ian<fgkNAnodes;ian++){
233 h->SetBinContent(ian+1,float(IsAnodeGood(ian)));
237 //______________________________________________________________________
238 TH1F* AliITSOnlineSDDCMN::GetBaselineHisto() const {
241 sprintf(hisnam,"hdbd%02dc%02ds%d",fDDL,fCarlos,fSide);
242 TH1F* h=new TH1F(hisnam,"",100,0.,150.);
243 for(Int_t ian=0;ian<fgkNAnodes;ian++){
244 h->Fill(GetAnodeBaseline(ian));
248 //______________________________________________________________________
249 TH1F* AliITSOnlineSDDCMN::GetRawNoiseHisto() const {
252 sprintf(hisnam,"hdnd%02dc%02ds%d",fDDL,fCarlos,fSide);
253 TH1F* h=new TH1F(hisnam,"",100,0.,8.);
254 for(Int_t ian=0;ian<fgkNAnodes;ian++){
255 h->Fill(GetAnodeRawNoise(ian));
259 //______________________________________________________________________
260 TH1F* AliITSOnlineSDDCMN::GetCorrNoiseHisto() const {
263 sprintf(hisnam,"hdcd%02dc%02ds%d",fDDL,fCarlos,fSide);
264 TH1F* h=new TH1F(hisnam,"",100,0.,8.);
265 for(Int_t ian=0;ian<fgkNAnodes;ian++){
266 h->Fill(GetAnodeCorrNoise(ian));
270 //______________________________________________________________________
271 Bool_t AliITSOnlineSDDCMN::WriteToROOT(TFile *fil){
274 AliWarning("Invalid pointer to ROOT file");
279 sprintf(hisnam,"hgood%02dc%02ds%d",fDDL,fCarlos,fSide);
280 TH1F hgood(hisnam,"",256,-0.5,255.5);
281 sprintf(hisnam,"hbase%02dc%02ds%d",fDDL,fCarlos,fSide);
282 TH1F hbase(hisnam,"",256,-0.5,255.5);
283 sprintf(hisnam,"hnois%02dc%02ds%d",fDDL,fCarlos,fSide);
284 TH1F hnois(hisnam,"",256,-0.5,255.5);
285 sprintf(hisnam,"hcmn%02dc%02ds%d",fDDL,fCarlos,fSide);
286 TH1F hcmn(hisnam,"",256,-0.5,255.5);
287 sprintf(hisnam,"hcorn%02dc%02ds%d",fDDL,fCarlos,fSide);
288 TH1F hcorn(hisnam,"",256,-0.5,255.5);
289 for(Int_t ian=0;ian<fgkNAnodes;ian++){
290 hgood.SetBinContent(ian+1,float(IsAnodeGood(ian)));
291 hbase.SetBinContent(ian+1,GetAnodeBaseline(ian));
292 hnois.SetBinContent(ian+1,GetAnodeRawNoise(ian));
293 hcmn.SetBinContent(ian+1,GetAnodeCommonMode(ian));
294 hcorn.SetBinContent(ian+1,GetAnodeCorrNoise(ian));