]>
Commit | Line | Data |
---|---|---|
348f80b7 | 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 "AliITSOnlineSDDTP.h" | |
7f347565 | 16 | #include "AliLog.h" |
348f80b7 | 17 | #include <TH2F.h> |
18 | #include <TMath.h> | |
19 | ||
20 | ||
21 | /////////////////////////////////////////////////////////////////// | |
22 | // // | |
23 | // Implemetation of the class SDD Test Pulse analysis // | |
24 | // Origin: F.Prino, Torino, prino@to.infn.it // | |
25 | // // | |
26 | /////////////////////////////////////////////////////////////////// | |
27 | ||
28 | ||
29 | ClassImp(AliITSOnlineSDDTP) | |
30 | ||
31 | //______________________________________________________________________ | |
beb262b4 | 32 | AliITSOnlineSDDTP::AliITSOnlineSDDTP():AliITSOnlineSDD(),fNEvents(0),fDAC(0.),fNSigmaGain(0.) |
348f80b7 | 33 | { |
34 | // default constructor | |
35 | Reset(); | |
36 | SetNSigmaGain(); | |
37 | } | |
38 | //______________________________________________________________________ | |
beb262b4 | 39 | AliITSOnlineSDDTP::AliITSOnlineSDDTP(Int_t mod, Int_t sid, Float_t xDAC):AliITSOnlineSDD(mod,sid),fNEvents(0),fDAC(xDAC),fNSigmaGain(0.) |
348f80b7 | 40 | { |
41 | // standard constructor | |
42 | Reset(); | |
43 | SetNSigmaGain(); | |
44 | } | |
45 | //______________________________________________________________________ | |
46 | AliITSOnlineSDDTP::~AliITSOnlineSDDTP(){ | |
47 | // Destructor | |
48 | } | |
49 | //______________________________________________________________________ | |
50 | void AliITSOnlineSDDTP::Reset(){ | |
beb262b4 | 51 | // |
348f80b7 | 52 | fNEvents=0; |
53 | for(Int_t i=0;i<fgkNAnodes;i++){ | |
54 | fGoodAnode[i]=1; | |
55 | fBaseline[i]=0.; | |
56 | fSumTPPeak[i]=0.; | |
57 | fTPPos[i]=0.; | |
58 | } | |
59 | ReadBaselines(); | |
60 | } | |
61 | ||
62 | //______________________________________________________________________ | |
63 | void AliITSOnlineSDDTP::AddEvent(TH2F* hrawd){ | |
64 | // | |
65 | fNEvents++; | |
66 | Double_t tbmax=(Double_t)hrawd->GetNbinsX(); | |
67 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ | |
68 | Float_t auxmax=0.; | |
69 | Int_t auxtb=0; | |
70 | if(!fGoodAnode[ian]) continue; | |
71 | for(Int_t itb=0;itb<tbmax;itb++){ | |
72 | Float_t cnt=hrawd->GetBinContent(itb+1,ian+1); | |
73 | if(cnt>auxmax){ | |
74 | auxmax=cnt; | |
75 | auxtb=itb; | |
76 | } | |
77 | } | |
78 | fSumTPPeak[ian]+=auxmax-fBaseline[ian]; | |
79 | fTPPos[ian]+=auxtb; | |
80 | } | |
81 | } | |
82 | //______________________________________________________________________ | |
83 | void AliITSOnlineSDDTP::ReadBaselines(){ | |
84 | // assume baselines and good anodes are taken from previous run | |
85 | Char_t basfilnam[100]; | |
7f347565 | 86 | sprintf(basfilnam,"SDDbase_step2_mod%03d_sid%d.data",fModuleId,fSide); |
348f80b7 | 87 | FILE* basf=fopen(basfilnam,"r"); |
88 | if(basf==0){ | |
7f347565 | 89 | AliWarning("Baselinefile not present, Set all baselines to 50\n"); |
348f80b7 | 90 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ |
91 | fBaseline[ian]=50.; | |
92 | fGoodAnode[ian]=1; | |
93 | } | |
94 | return; | |
95 | } | |
96 | Int_t n,ok; | |
97 | Float_t base,rms,cmn,corrnoi; | |
98 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ | |
99 | fscanf(basf,"%d %d %f %f %f %f\n",&n,&ok,&base,&rms,&cmn,&corrnoi); | |
100 | fBaseline[ian]=base; | |
101 | fGoodAnode[ian]=ok; | |
102 | } | |
103 | fclose(basf); | |
104 | } | |
105 | ||
106 | //______________________________________________________________________ | |
107 | void AliITSOnlineSDDTP::ValidateAnodes(){ | |
beb262b4 | 108 | // |
348f80b7 | 109 | Float_t meang,rmsg; |
110 | StatGain(meang,rmsg); | |
348f80b7 | 111 | Float_t lowlim=meang-fNSigmaGain*rmsg; |
112 | Float_t hilim=meang+fNSigmaGain*rmsg; | |
113 | ||
114 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ | |
115 | if(!fGoodAnode[ian]) continue; | |
116 | if(GetChannelGain(ian)<lowlim||GetChannelGain(ian)>hilim) fGoodAnode[ian]=0; | |
117 | } | |
118 | } | |
119 | ||
120 | ||
121 | //______________________________________________________________________ | |
122 | void AliITSOnlineSDDTP::StatGain(Float_t &mean, Float_t &rms){ | |
beb262b4 | 123 | // |
348f80b7 | 124 | Float_t sum=0.,sumq=0.; |
125 | Int_t cnt=0; | |
126 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ | |
127 | if(!fGoodAnode[ian]) continue; | |
128 | sum+=GetChannelGain(ian); | |
129 | sumq+=TMath::Power(GetChannelGain(ian),2); | |
130 | cnt++; | |
131 | } | |
132 | if(cnt>0){ | |
133 | mean=sum/(Float_t)cnt; | |
134 | rms=TMath::Sqrt(sumq/(Float_t)cnt-mean*mean); | |
135 | }else{ | |
136 | mean=0.; | |
137 | rms=0.; | |
138 | } | |
139 | return; | |
140 | } | |
141 | ||
142 | //______________________________________________________________________ | |
e44f571c | 143 | void AliITSOnlineSDDTP::WriteToASCII(){ |
348f80b7 | 144 | // |
145 | Char_t basfilnam[100]; | |
7f347565 | 146 | sprintf(basfilnam,"SDDbase_step2_mod%03d_sid%d.data",fModuleId,fSide); |
348f80b7 | 147 | FILE* basf=fopen(basfilnam,"r"); |
7f347565 | 148 | if(basf==0){ |
149 | AliWarning("Baseline file not present, launch baseline analysis first\n"); | |
150 | return; | |
151 | } | |
348f80b7 | 152 | Int_t n,ok; |
153 | Float_t base,rms,cmn,corrnoi; | |
154 | Float_t noise[fgkNAnodes],cmncoef[fgkNAnodes],corrnoise[fgkNAnodes]; | |
155 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ | |
156 | fscanf(basf,"%d %d %f %f %f %f\n",&n,&ok,&base,&rms,&cmn,&corrnoi); | |
157 | noise[ian]=rms; | |
158 | cmncoef[ian]=cmn; | |
159 | corrnoise[ian]=corrnoi; | |
160 | } | |
161 | fclose(basf); | |
348f80b7 | 162 | Char_t outfilnam[100]; |
163 | sprintf(outfilnam,"SDDbase_mod%03d_sid%d.data",fModuleId,fSide); | |
164 | FILE* outf=fopen(outfilnam,"w"); | |
165 | for(Int_t ian=0;ian<fgkNAnodes;ian++){ | |
166 | fprintf(outf,"%d %d %8.3f %8.3f %8.3f %8.3f %8.3f\n",ian,IsAnodeGood(ian),fBaseline[ian], noise[ian],cmncoef[ian],corrnoise[ian],GetChannelGain(ian)); | |
167 | } | |
168 | fclose(outf); | |
169 | } | |
170 |