]>
Commit | Line | Data |
---|---|---|
7f347565 | 1 | /************************************************************************** |
2 | * Copyright(c) 2007-2009, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
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 | **************************************************************************/ | |
e44f571c | 15 | #include <TFile.h> |
7f347565 | 16 | #include "AliITSOnlineSDDCMN.h" |
17 | #include "AliLog.h" | |
18 | #include <TH2F.h> | |
19 | #include <TMath.h> | |
20 | ||
21 | ||
22 | /////////////////////////////////////////////////////////////////// | |
23 | // // | |
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 // | |
27 | // // | |
28 | /////////////////////////////////////////////////////////////////// | |
29 | ||
30 | ||
31 | ClassImp(AliITSOnlineSDDCMN) | |
32 | //______________________________________________________________________ | |
33 | AliITSOnlineSDDCMN::AliITSOnlineSDDCMN():AliITSOnlineSDD(),fNEvents(0),fMinCorrNoise(0.),fMaxCorrNoise(0.),fNSigmaNoise(0.) | |
34 | { | |
35 | // default constructor | |
36 | Reset(); | |
37 | SetMinNoise(); | |
38 | SetMaxNoise(); | |
39 | SetNSigmaNoise(); | |
40 | } | |
41 | //______________________________________________________________________ | |
42 | AliITSOnlineSDDCMN::AliITSOnlineSDDCMN(Int_t mod, Int_t sid):AliITSOnlineSDD(mod,sid),fNEvents(0),fMinCorrNoise(0.),fMaxCorrNoise(0.),fNSigmaNoise(0.) | |
43 | { | |
44 | // default constructor | |
45 | Reset(); | |
46 | SetMinNoise(); | |
47 | SetMaxNoise(); | |
48 | SetNSigmaNoise(); | |
49 | } | |
50 | //______________________________________________________________________ | |
51 | AliITSOnlineSDDCMN::~AliITSOnlineSDDCMN(){ | |
52 | // Destructor | |
53 | } | |
54 | //______________________________________________________________________ | |
55 | void AliITSOnlineSDDCMN::Reset(){ | |
beb262b4 | 56 | // |
7f347565 | 57 | fNEvents=0; |
58 | for(Int_t i=0;i<fgkNAnodes;i++){ | |
59 | fGoodAnode[i]=1; | |
60 | fBaseline[i]=0.; | |
61 | fCMN[i]=0.; | |
62 | fSumCorrNoise[i]=0.; | |
63 | } | |
64 | ReadBaselines(); | |
65 | } | |
66 | //______________________________________________________________________ | |
67 | void AliITSOnlineSDDCMN::ReadBaselines(){ | |
68 | // assume baselines and good anodes are taken from previous run | |
69 | Char_t basfilnam[100]; | |
70 | sprintf(basfilnam,"SDDbase_step1_mod%03d_sid%d.data",fModuleId,fSide); | |
71 | FILE* basf=fopen(basfilnam,"r"); | |
72 | if(basf==0){ | |
73 | AliWarning("Baselinefile not present, Set all baselines to 50\n"); | |
74 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ | |
75 | fBaseline[ian]=50.; | |
76 | fGoodAnode[ian]=1; | |
77 | } | |
78 | return; | |
79 | } | |
80 | Int_t n,ok; | |
81 | Float_t base,rms,cmn,corrnoi; | |
82 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ | |
83 | fscanf(basf,"%d %d %f %f %f %f\n",&n,&ok,&base,&rms,&cmn,&corrnoi); | |
84 | fGoodAnode[ian]=ok; | |
85 | fBaseline[ian]=base; | |
86 | fRawNoise[ian]=rms; | |
87 | fCMN[ian]=cmn; | |
88 | } | |
89 | fclose(basf); | |
90 | } | |
91 | //______________________________________________________________________ | |
92 | void AliITSOnlineSDDCMN::ValidateAnodes(){ | |
beb262b4 | 93 | // |
7f347565 | 94 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ |
95 | if(!fGoodAnode[ian]) continue; | |
96 | if(GetAnodeCorrNoise(ian)>fMaxCorrNoise || GetAnodeCorrNoise(ian)<fMinCorrNoise) fGoodAnode[ian]=0; | |
97 | if(GetAnodeCorrNoise(ian)>fNSigmaNoise*CalcMeanNoise()) fGoodAnode[ian]=0; | |
98 | } | |
99 | } | |
100 | ||
101 | //______________________________________________________________________ | |
102 | void AliITSOnlineSDDCMN::AddEvent(TH2F* hrawd){ | |
103 | // | |
104 | fNEvents++; | |
105 | Float_t tbmax=(Float_t)hrawd->GetNbinsX(); | |
106 | TH2F* hcorrd=new TH2F("hcorrd","",hrawd->GetNbinsX(),hrawd->GetXaxis()->GetXmin(),hrawd->GetXaxis()->GetXmax(),hrawd->GetNbinsY(),hrawd->GetYaxis()->GetXmin(),hrawd->GetYaxis()->GetXmax()); | |
107 | for(Int_t itb=0;itb<tbmax;itb++){ | |
108 | Float_t sumEven=0., sumOdd=0.; | |
109 | Int_t countEven=0, countOdd=0; | |
110 | for(Int_t ian=0;ian<fgkNAnodes;ian+=2){ | |
111 | if(!fGoodAnode[ian]) continue; | |
112 | sumEven+=hrawd->GetBinContent(itb+1,ian+1)-fBaseline[ian]; | |
113 | countEven++; | |
114 | } | |
115 | for(Int_t ian=1;ian<fgkNAnodes;ian+=2){ | |
116 | if(!fGoodAnode[ian]) continue; | |
117 | sumOdd+=hrawd->GetBinContent(itb+1,ian+1)-fBaseline[ian]; | |
118 | countOdd++; | |
119 | } | |
120 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ | |
121 | if(!fGoodAnode[ian]) continue; | |
122 | Float_t meanN; | |
123 | if(ian%2==0) meanN=sumEven/(Float_t)countEven; | |
124 | else meanN=sumOdd/(Float_t)countOdd; | |
125 | Float_t cntCorr=hrawd->GetBinContent(itb+1,ian+1)-fCMN[ian]*meanN; | |
126 | hcorrd->SetBinContent(itb+1,ian+1,cntCorr); | |
127 | } | |
128 | } | |
129 | ||
130 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ | |
131 | if(!fGoodAnode[ian]) continue; | |
132 | Float_t sumQ=0.; | |
133 | for(Int_t itb=0;itb<tbmax;itb++){ | |
134 | sumQ+=TMath::Power(hcorrd->GetBinContent(itb+1,ian+1)-fBaseline[ian],2); | |
135 | } | |
136 | fSumCorrNoise[ian]+=TMath::Sqrt(sumQ/tbmax); | |
137 | } | |
138 | delete hcorrd; | |
139 | } | |
140 | //______________________________________________________________________ | |
beb262b4 | 141 | Float_t AliITSOnlineSDDCMN::CalcMeanNoise() const{ |
7f347565 | 142 | // |
143 | Float_t meanns=0.; | |
144 | Int_t cnt=0; | |
145 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ | |
146 | if(!fGoodAnode[ian]) continue; | |
147 | meanns+=GetAnodeCorrNoise(ian); | |
148 | cnt++; | |
149 | } | |
150 | if(cnt>0) meanns/=(Float_t)cnt; | |
151 | return meanns; | |
152 | } | |
153 | //______________________________________________________________________ | |
e44f571c | 154 | void AliITSOnlineSDDCMN::WriteToASCII(){ |
7f347565 | 155 | // |
156 | Char_t outfilnam[100]; | |
157 | sprintf(outfilnam,"SDDbase_step2_mod%03d_sid%d.data",fModuleId,fSide); | |
158 | FILE* outf=fopen(outfilnam,"w"); | |
159 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ | |
160 | fprintf(outf,"%d %d %8.3f %8.3f %8.3f %8.3f\n",ian,IsAnodeGood(ian),GetAnodeBaseline(ian),GetAnodeRawNoise(ian),GetAnodeCommonMode(ian),GetAnodeCorrNoise(ian)); | |
161 | } | |
162 | fclose(outf); | |
163 | } | |
e44f571c | 164 | //______________________________________________________________________ |
165 | Bool_t AliITSOnlineSDDCMN::WriteToROOT(TFile *fil){ | |
166 | if(fil==0){ | |
167 | AliWarning("Invalid pointer to ROOT file"); | |
168 | return kFALSE; | |
169 | } | |
170 | Char_t hisnam[20]; | |
171 | fil->cd(); | |
172 | sprintf(hisnam,"hgood%03ds%d",fModuleId,fSide); | |
173 | TH1F hgood(hisnam,"",256,-0.5,255.5); | |
174 | sprintf(hisnam,"hbase%03ds%d",fModuleId,fSide); | |
175 | TH1F hbase(hisnam,"",256,-0.5,255.5); | |
176 | sprintf(hisnam,"hnois%03ds%d",fModuleId,fSide); | |
177 | TH1F hnois(hisnam,"",256,-0.5,255.5); | |
178 | sprintf(hisnam,"hcmn%03ds%d",fModuleId,fSide); | |
179 | TH1F hcmn(hisnam,"",256,-0.5,255.5); | |
180 | sprintf(hisnam,"hcorn%03ds%d",fModuleId,fSide); | |
181 | TH1F hcorn(hisnam,"",256,-0.5,255.5); | |
182 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ | |
183 | hgood.SetBinContent(ian+1,float(IsAnodeGood(ian))); | |
184 | hbase.SetBinContent(ian+1,GetAnodeBaseline(ian)); | |
185 | hnois.SetBinContent(ian+1,GetAnodeRawNoise(ian)); | |
186 | hcmn.SetBinContent(ian+1,GetAnodeCommonMode(ian)); | |
187 | hcorn.SetBinContent(ian+1,GetAnodeCorrNoise(ian)); | |
188 | } | |
189 | hgood.Write(); | |
190 | hbase.Write(); | |
191 | hnois.Write(); | |
192 | hcmn.Write(); | |
193 | hcorn.Write(); | |
194 | return kTRUE; | |
195 | } |