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 **************************************************************************/
15 #include "AliITSOnlineSDDTP.h"
20 ///////////////////////////////////////////////////////////////////
22 // Implemetation of the class SDD Test Pulse analysis //
23 // Origin: F.Prino, Torino, prino@to.infn.it //
25 ///////////////////////////////////////////////////////////////////
28 ClassImp(AliITSOnlineSDDTP)
30 //______________________________________________________________________
31 AliITSOnlineSDDTP::AliITSOnlineSDDTP():AliITSOnlineSDD(),fNEvents(0),fDAQ(0.),fNSigmaGain(0.)
33 // default constructor
37 //______________________________________________________________________
38 AliITSOnlineSDDTP::AliITSOnlineSDDTP(Int_t mod, Int_t sid, Float_t xDAQ):AliITSOnlineSDD(mod,sid),fNEvents(0),fDAQ(xDAQ),fNSigmaGain(0.)
40 // standard constructor
44 //______________________________________________________________________
45 AliITSOnlineSDDTP::~AliITSOnlineSDDTP(){
48 //______________________________________________________________________
49 void AliITSOnlineSDDTP::Reset(){
51 for(Int_t i=0;i<fgkNAnodes;i++){
60 //______________________________________________________________________
61 void AliITSOnlineSDDTP::AddEvent(TH2F* hrawd){
64 Double_t tbmax=(Double_t)hrawd->GetNbinsX();
65 for(Int_t ian=0;ian<fgkNAnodes;ian++){
68 if(!fGoodAnode[ian]) continue;
69 for(Int_t itb=0;itb<tbmax;itb++){
70 Float_t cnt=hrawd->GetBinContent(itb+1,ian+1);
76 fSumTPPeak[ian]+=auxmax-fBaseline[ian];
80 //______________________________________________________________________
81 void AliITSOnlineSDDTP::ReadBaselines(){
82 // assume baselines and good anodes are taken from previous run
83 Char_t basfilnam[100];
84 sprintf(basfilnam,"SDDbase_step1_mod%03d_sid%d.data",fModuleId,fSide);
85 FILE* basf=fopen(basfilnam,"r");
87 printf("Baselinefile not present, Set all baselines to 50\n");
88 for(Int_t ian=0;ian<fgkNAnodes;ian++){
95 Float_t base,rms,cmn,corrnoi;
96 for(Int_t ian=0;ian<fgkNAnodes;ian++){
97 fscanf(basf,"%d %d %f %f %f %f\n",&n,&ok,&base,&rms,&cmn,&corrnoi);
104 //______________________________________________________________________
105 void AliITSOnlineSDDTP::ValidateAnodes(){
107 StatGain(meang,rmsg);
108 printf("<gain>=%f,rms=%f\n",meang,rmsg);
109 Float_t lowlim=meang-fNSigmaGain*rmsg;
110 Float_t hilim=meang+fNSigmaGain*rmsg;
112 for(Int_t ian=0;ian<fgkNAnodes;ian++){
113 if(!fGoodAnode[ian]) continue;
114 if(GetChannelGain(ian)<lowlim||GetChannelGain(ian)>hilim) fGoodAnode[ian]=0;
119 //______________________________________________________________________
120 void AliITSOnlineSDDTP::StatGain(Float_t &mean, Float_t &rms){
121 Float_t sum=0.,sumq=0.;
123 for(Int_t ian=0;ian<fgkNAnodes;ian++){
124 if(!fGoodAnode[ian]) continue;
125 sum+=GetChannelGain(ian);
126 sumq+=TMath::Power(GetChannelGain(ian),2);
130 mean=sum/(Float_t)cnt;
131 rms=TMath::Sqrt(sumq/(Float_t)cnt-mean*mean);
139 //______________________________________________________________________
140 void AliITSOnlineSDDTP::WriteToFXS(){
142 Char_t basfilnam[100];
143 sprintf(basfilnam,"SDDbase_step1_mod%03d_sid%d.data",fModuleId,fSide);
144 FILE* basf=fopen(basfilnam,"r");
146 Float_t base,rms,cmn,corrnoi;
147 Float_t noise[fgkNAnodes],cmncoef[fgkNAnodes],corrnoise[fgkNAnodes];
148 for(Int_t ian=0;ian<fgkNAnodes;ian++){
149 fscanf(basf,"%d %d %f %f %f %f\n",&n,&ok,&base,&rms,&cmn,&corrnoi);
152 corrnoise[ian]=corrnoi;
155 printf("Read All******************\n");
156 Char_t outfilnam[100];
157 sprintf(outfilnam,"SDDbase_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 %8.3f\n",ian,IsAnodeGood(ian),fBaseline[ian], noise[ian],cmncoef[ian],corrnoise[ian],GetChannelGain(ian));