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 "AliITSOnlineSDDTP.h"
22 ///////////////////////////////////////////////////////////////////
24 // Implemetation of the class SDD Test Pulse analysis //
25 // Origin: F.Prino, Torino, prino@to.infn.it //
27 ///////////////////////////////////////////////////////////////////
30 ClassImp(AliITSOnlineSDDTP)
32 //______________________________________________________________________
33 AliITSOnlineSDDTP::AliITSOnlineSDDTP():AliITSOnlineSDD(),fDAC(0.),fLowThreshold(0),fHighThreshold(0),fNSigmaGain(0.),fNSigmaNoise(0.)
35 // default constructor
40 //______________________________________________________________________
41 AliITSOnlineSDDTP::AliITSOnlineSDDTP(Int_t nddl, Int_t ncarlos, Int_t sid, Float_t xDAC):AliITSOnlineSDD(nddl,ncarlos,sid),fDAC(xDAC),fLowThreshold(0),fHighThreshold(0),fNSigmaGain(0.),fNSigmaNoise(0.)
43 // standard constructor
48 //______________________________________________________________________
49 AliITSOnlineSDDTP::~AliITSOnlineSDDTP(){
52 //______________________________________________________________________
53 void AliITSOnlineSDDTP::Reset(){
55 for(Int_t i=0;i<fgkNAnodes;i++){
68 //______________________________________________________________________
69 void AliITSOnlineSDDTP::AddEvent(TH2F* hrawd){
71 for(Int_t ian=0;ian<fgkNAnodes;ian++){
74 if(!fGoodAnode[ian]) continue;
75 for(Int_t itb=fFirstGoodTB;itb<=fLastGoodTB;itb++){
76 Float_t cnt=hrawd->GetBinContent(itb+1,ian+1);
82 if(auxmax>fBaseline[ian]+fNSigmaNoise*fRawNoise[ian]){
83 fSumTPPeak[ian]+=auxmax-fBaseline[ian];
89 //______________________________________________________________________
90 void AliITSOnlineSDDTP::ReadBaselines(){
91 // assume baselines and good anodes are taken from previous run
93 basfilnam.Form("SDDbase_step2_ddl%02dc%02d_sid%d.data",fDDL,fCarlos,fSide);
94 FILE* basf=fopen(basfilnam.Data(),"r");
96 AliWarning(Form("Baseline file not present (ddl %d carlos %d side %d, Set all baselines to 20",fDDL,fCarlos,fSide));
97 for(Int_t ian=0;ian<fgkNAnodes;ian++){
100 fOffsetBaseline[ian]=0;
105 fscanf(basf,"%d\n",&fHighThreshold);
106 fscanf(basf,"%d\n",&fLowThreshold);
107 Int_t n,ok,eqbase,offbase;
108 Float_t base,rms,cmn,corrnoi;
109 for(Int_t ian=0;ian<fgkNAnodes;ian++){
110 fscanf(basf,"%d %d %f %d %d %f %f %f\n",&n,&ok,&base,&eqbase,&offbase,&rms,&cmn,&corrnoi);
112 fEqBaseline[ian]=eqbase;
113 fOffsetBaseline[ian]=offbase;
117 fCorrNoise[ian]=corrnoi;
122 //______________________________________________________________________
123 Bool_t AliITSOnlineSDDTP::IsModuleGood() const{
125 // Check if there is at least 1 good anode
127 for(Int_t ian=0;ian<fgkNAnodes;ian++){
128 if(fGoodAnode[ian]) return kTRUE;
132 //______________________________________________________________________
133 void AliITSOnlineSDDTP::ValidateAnodes(){
136 StatGain(meang,rmsg);
137 Float_t lowlim=meang-fNSigmaGain*rmsg;
138 Float_t hilim=meang+fNSigmaGain*rmsg;
140 for(Int_t ian=0;ian<fgkNAnodes;ian++){
141 if(!fGoodAnode[ian]) continue;
142 if(GetChannelGain(ian)<lowlim||GetChannelGain(ian)>hilim) fGoodAnode[ian]=0;
147 //______________________________________________________________________
148 void AliITSOnlineSDDTP::StatGain(Float_t &mean, Float_t &rms){
150 Float_t sum=0.,sumq=0.;
152 for(Int_t ian=0;ian<fgkNAnodes;ian++){
153 if(!fGoodAnode[ian]) continue;
154 if(fNEvents[ian]==0) continue;
155 Float_t chgain=GetChannelGain(ian);
161 mean=sum/(Float_t)cnt;
162 Float_t variance=sumq/(Float_t)cnt-mean*mean;
163 if(variance>0.) rms=TMath::Sqrt(variance);
172 //______________________________________________________________________
173 void AliITSOnlineSDDTP::WriteToASCII(){
176 outfilnam.Form("SDDbase_ddl%02dc%02d_sid%d.data",fDDL,fCarlos,fSide);
177 FILE* outf=fopen(outfilnam.Data(),"w");
178 fprintf(outf,"%d %d %d\n",fCarlos,fSide,IsModuleGood());
179 fprintf(outf,"%d\n",fHighThreshold);
180 fprintf(outf,"%d\n",fLowThreshold);
181 for(Int_t ian=0;ian<fgkNAnodes;ian++){
182 fprintf(outf,"%d %d %8.3f %d %d %8.3f %8.3f %8.3f %8.3f\n",ian,IsAnodeGood(ian),GetAnodeBaseline(ian),GetAnodeEqualizedBaseline(ian),GetAnodeBaselineOffset(ian),GetAnodeRawNoise(ian),GetAnodeCommonMode(ian),GetAnodeCorrNoise(ian),GetChannelGain(ian));
186 //______________________________________________________________________
187 TH1F* AliITSOnlineSDDTP::GetBaselineAnodeHisto() const {
190 hisnam.Form("hbase%02dc%02ds%d",fDDL,fCarlos,fSide);
191 TH1F* h=new TH1F(hisnam.Data(),"",256,-0.5,255.5);
192 for(Int_t ian=0;ian<fgkNAnodes;ian++){
193 h->SetBinContent(ian+1,GetAnodeBaseline(ian));
197 //______________________________________________________________________
198 TH1F* AliITSOnlineSDDTP::GetRawNoiseAnodeHisto() const {
201 hisnam.Form("hnois%02dc%02ds%d",fDDL,fCarlos,fSide);
202 TH1F* h=new TH1F(hisnam.Data(),"",256,-0.5,255.5);
203 for(Int_t ian=0;ian<fgkNAnodes;ian++){
204 h->SetBinContent(ian+1,GetAnodeRawNoise(ian));
208 //______________________________________________________________________
209 TH1F* AliITSOnlineSDDTP::GetCorrNoiseAnodeHisto() const {
212 hisnam.Form("hcorn%02dc%02ds%d",fDDL,fCarlos,fSide);
213 TH1F* h=new TH1F(hisnam.Data(),"",256,-0.5,255.5);
214 for(Int_t ian=0;ian<fgkNAnodes;ian++){
215 h->SetBinContent(ian+1,GetAnodeCorrNoise(ian));
219 //______________________________________________________________________
220 TH1F* AliITSOnlineSDDTP::GetCMNCoefAnodeHisto() const {
223 hisnam.Form("hcmn%02dc%02ds%d",fDDL,fCarlos,fSide);
224 TH1F* h=new TH1F(hisnam.Data(),"",256,-0.5,255.5);
225 for(Int_t ian=0;ian<fgkNAnodes;ian++){
226 h->SetBinContent(ian+1,GetAnodeCommonMode(ian));
230 //______________________________________________________________________
231 TH1F* AliITSOnlineSDDTP::GetStatusAnodeHisto() const {
234 hisnam.Form("hgood%02dc%02ds%d",fDDL,fCarlos,fSide);
235 TH1F* h=new TH1F(hisnam.Data(),"",256,-0.5,255.5);
236 for(Int_t ian=0;ian<fgkNAnodes;ian++){
237 h->SetBinContent(ian+1,float(IsAnodeGood(ian)));
241 //______________________________________________________________________
242 TH1F* AliITSOnlineSDDTP::GetGainAnodeHisto() const {
245 hisnam.Form("hgain%02dc%02ds%d",fDDL,fCarlos,fSide);
246 TH1F* h=new TH1F(hisnam.Data(),"",256,-0.5,255.5);
247 for(Int_t ian=0;ian<fgkNAnodes;ian++){
248 h->SetBinContent(ian+1,GetChannelGain(ian));
252 //______________________________________________________________________
253 Bool_t AliITSOnlineSDDTP::WriteToROOT(TFile *fil){
256 AliWarning("Invalid pointer to ROOT file");
261 hisnam.Form("hgood%02dc%02ds%d",fDDL,fCarlos,fSide);
262 TH1F hgood(hisnam.Data(),"",256,-0.5,255.5);
263 hisnam.Form("hbase%02dc%02ds%d",fDDL,fCarlos,fSide);
264 TH1F hbase(hisnam.Data(),"",256,-0.5,255.5);
265 hisnam.Form("hnois%02dc%02ds%d",fDDL,fCarlos,fSide);
266 TH1F hnois(hisnam.Data(),"",256,-0.5,255.5);
267 hisnam.Form("hcmn%02dc%02ds%d",fDDL,fCarlos,fSide);
268 TH1F hcmn(hisnam.Data(),"",256,-0.5,255.5);
269 hisnam.Form("hcorn%02dc%02ds%d",fDDL,fCarlos,fSide);
270 TH1F hcorn(hisnam.Data(),"",256,-0.5,255.5);
271 hisnam.Form("hgain%02dc%02ds%d",fDDL,fCarlos,fSide);
272 TH1F hgain(hisnam.Data(),"",256,-0.5,255.5);
273 hisnam.Form("htptb%02dc%02ds%d",fDDL,fCarlos,fSide);
274 TH1F htptb(hisnam.Data(),"",256,-0.5,255.5);
275 for(Int_t ian=0;ian<fgkNAnodes;ian++){
276 hgood.SetBinContent(ian+1,float(IsAnodeGood(ian)));
277 hbase.SetBinContent(ian+1,GetAnodeBaseline(ian));
278 hnois.SetBinContent(ian+1,GetAnodeRawNoise(ian));
279 hcmn.SetBinContent(ian+1,GetAnodeCommonMode(ian));
280 hcorn.SetBinContent(ian+1,GetAnodeCorrNoise(ian));
281 hgain.SetBinContent(ian+1,GetChannelGain(ian));
282 htptb.SetBinContent(ian+1,GetTimeBinTPPeak(ian));