]>
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 | **************************************************************************/ | |
15 | #include "AliITSOnlineSDDCMN.h" | |
16 | #include "AliLog.h" | |
17 | #include <TH2F.h> | |
18 | #include <TMath.h> | |
19 | ||
20 | ||
21 | /////////////////////////////////////////////////////////////////// | |
22 | // // | |
23 | // Implementation of the class used for analysis of SDD noise // | |
24 | // corrected for common mode // | |
25 | // Origin: F.Prino, Torino, prino@to.infn.it // | |
26 | // // | |
27 | /////////////////////////////////////////////////////////////////// | |
28 | ||
29 | ||
30 | ClassImp(AliITSOnlineSDDCMN) | |
31 | //______________________________________________________________________ | |
32 | AliITSOnlineSDDCMN::AliITSOnlineSDDCMN():AliITSOnlineSDD(),fNEvents(0),fMinCorrNoise(0.),fMaxCorrNoise(0.),fNSigmaNoise(0.) | |
33 | { | |
34 | // default constructor | |
35 | Reset(); | |
36 | SetMinNoise(); | |
37 | SetMaxNoise(); | |
38 | SetNSigmaNoise(); | |
39 | } | |
40 | //______________________________________________________________________ | |
41 | AliITSOnlineSDDCMN::AliITSOnlineSDDCMN(Int_t mod, Int_t sid):AliITSOnlineSDD(mod,sid),fNEvents(0),fMinCorrNoise(0.),fMaxCorrNoise(0.),fNSigmaNoise(0.) | |
42 | { | |
43 | // default constructor | |
44 | Reset(); | |
45 | SetMinNoise(); | |
46 | SetMaxNoise(); | |
47 | SetNSigmaNoise(); | |
48 | } | |
49 | //______________________________________________________________________ | |
50 | AliITSOnlineSDDCMN::~AliITSOnlineSDDCMN(){ | |
51 | // Destructor | |
52 | } | |
53 | //______________________________________________________________________ | |
54 | void AliITSOnlineSDDCMN::Reset(){ | |
beb262b4 | 55 | // |
7f347565 | 56 | fNEvents=0; |
57 | for(Int_t i=0;i<fgkNAnodes;i++){ | |
58 | fGoodAnode[i]=1; | |
59 | fBaseline[i]=0.; | |
60 | fCMN[i]=0.; | |
61 | fSumCorrNoise[i]=0.; | |
62 | } | |
63 | ReadBaselines(); | |
64 | } | |
65 | //______________________________________________________________________ | |
66 | void AliITSOnlineSDDCMN::ReadBaselines(){ | |
67 | // assume baselines and good anodes are taken from previous run | |
68 | Char_t basfilnam[100]; | |
69 | sprintf(basfilnam,"SDDbase_step1_mod%03d_sid%d.data",fModuleId,fSide); | |
70 | FILE* basf=fopen(basfilnam,"r"); | |
71 | if(basf==0){ | |
72 | AliWarning("Baselinefile not present, Set all baselines to 50\n"); | |
73 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ | |
74 | fBaseline[ian]=50.; | |
75 | fGoodAnode[ian]=1; | |
76 | } | |
77 | return; | |
78 | } | |
79 | Int_t n,ok; | |
80 | Float_t base,rms,cmn,corrnoi; | |
81 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ | |
82 | fscanf(basf,"%d %d %f %f %f %f\n",&n,&ok,&base,&rms,&cmn,&corrnoi); | |
83 | fGoodAnode[ian]=ok; | |
84 | fBaseline[ian]=base; | |
85 | fRawNoise[ian]=rms; | |
86 | fCMN[ian]=cmn; | |
87 | } | |
88 | fclose(basf); | |
89 | } | |
90 | //______________________________________________________________________ | |
91 | void AliITSOnlineSDDCMN::ValidateAnodes(){ | |
beb262b4 | 92 | // |
7f347565 | 93 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ |
94 | if(!fGoodAnode[ian]) continue; | |
95 | if(GetAnodeCorrNoise(ian)>fMaxCorrNoise || GetAnodeCorrNoise(ian)<fMinCorrNoise) fGoodAnode[ian]=0; | |
96 | if(GetAnodeCorrNoise(ian)>fNSigmaNoise*CalcMeanNoise()) fGoodAnode[ian]=0; | |
97 | } | |
98 | } | |
99 | ||
100 | //______________________________________________________________________ | |
101 | void AliITSOnlineSDDCMN::AddEvent(TH2F* hrawd){ | |
102 | // | |
103 | fNEvents++; | |
104 | Float_t tbmax=(Float_t)hrawd->GetNbinsX(); | |
105 | TH2F* hcorrd=new TH2F("hcorrd","",hrawd->GetNbinsX(),hrawd->GetXaxis()->GetXmin(),hrawd->GetXaxis()->GetXmax(),hrawd->GetNbinsY(),hrawd->GetYaxis()->GetXmin(),hrawd->GetYaxis()->GetXmax()); | |
106 | for(Int_t itb=0;itb<tbmax;itb++){ | |
107 | Float_t sumEven=0., sumOdd=0.; | |
108 | Int_t countEven=0, countOdd=0; | |
109 | for(Int_t ian=0;ian<fgkNAnodes;ian+=2){ | |
110 | if(!fGoodAnode[ian]) continue; | |
111 | sumEven+=hrawd->GetBinContent(itb+1,ian+1)-fBaseline[ian]; | |
112 | countEven++; | |
113 | } | |
114 | for(Int_t ian=1;ian<fgkNAnodes;ian+=2){ | |
115 | if(!fGoodAnode[ian]) continue; | |
116 | sumOdd+=hrawd->GetBinContent(itb+1,ian+1)-fBaseline[ian]; | |
117 | countOdd++; | |
118 | } | |
119 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ | |
120 | if(!fGoodAnode[ian]) continue; | |
121 | Float_t meanN; | |
122 | if(ian%2==0) meanN=sumEven/(Float_t)countEven; | |
123 | else meanN=sumOdd/(Float_t)countOdd; | |
124 | Float_t cntCorr=hrawd->GetBinContent(itb+1,ian+1)-fCMN[ian]*meanN; | |
125 | hcorrd->SetBinContent(itb+1,ian+1,cntCorr); | |
126 | } | |
127 | } | |
128 | ||
129 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ | |
130 | if(!fGoodAnode[ian]) continue; | |
131 | Float_t sumQ=0.; | |
132 | for(Int_t itb=0;itb<tbmax;itb++){ | |
133 | sumQ+=TMath::Power(hcorrd->GetBinContent(itb+1,ian+1)-fBaseline[ian],2); | |
134 | } | |
135 | fSumCorrNoise[ian]+=TMath::Sqrt(sumQ/tbmax); | |
136 | } | |
137 | delete hcorrd; | |
138 | } | |
139 | //______________________________________________________________________ | |
beb262b4 | 140 | Float_t AliITSOnlineSDDCMN::CalcMeanNoise() const{ |
7f347565 | 141 | // |
142 | Float_t meanns=0.; | |
143 | Int_t cnt=0; | |
144 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ | |
145 | if(!fGoodAnode[ian]) continue; | |
146 | meanns+=GetAnodeCorrNoise(ian); | |
147 | cnt++; | |
148 | } | |
149 | if(cnt>0) meanns/=(Float_t)cnt; | |
150 | return meanns; | |
151 | } | |
152 | //______________________________________________________________________ | |
153 | void AliITSOnlineSDDCMN::WriteToFXS(){ | |
154 | // | |
155 | Char_t outfilnam[100]; | |
156 | sprintf(outfilnam,"SDDbase_step2_mod%03d_sid%d.data",fModuleId,fSide); | |
157 | FILE* outf=fopen(outfilnam,"w"); | |
158 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ | |
159 | fprintf(outf,"%d %d %8.3f %8.3f %8.3f %8.3f\n",ian,IsAnodeGood(ian),GetAnodeBaseline(ian),GetAnodeRawNoise(ian),GetAnodeCommonMode(ian),GetAnodeCorrNoise(ian)); | |
160 | } | |
161 | fclose(outf); | |
162 | } |