new SDD preprocessor + removal of eff C++ warning (base) - E. Crescio
[u/mrichter/AliRoot.git] / ITS / AliITSPreprocessorSDD.cxx
CommitLineData
e56160b8 1/////////////////////////////////////////
2// Class for SDD digits preprocessing //
3////////////////////////////////////////
4
5#include "AliITSPreprocessorSDD.h"
6#include "AliITSCalibrationSDD.h"
7#include "AliShuttleInterface.h"
8#include "AliCDBMetaData.h"
9#include "TObjArray.h"
10#include "TH1F.h"
11#include "AliLog.h"
12#include "TFile.h"
13
14const Int_t AliITSPreprocessorSDD::fgkNumberOfSDD = 260;
15const Int_t AliITSPreprocessorSDD::fgkNumberOfChannels = 512;
16const char* AliITSPreprocessorSDD::fgkNameHistoPedestals ="hpedestal";
17const char* AliITSPreprocessorSDD::fgkNameHistoNoise="hnoise";
18
19ClassImp(AliITSPreprocessorSDD)
20
21
22UInt_t AliITSPreprocessorSDD::Process(TMap*/* dcsAliasMap*/){
23
24 //preprocessing.
25
26 UInt_t result = 0;
27 const char* filename = GetFile(kDAQ,"PEDESTALS","GDC");
28 const char* filenamen= GetFile(kDAQ,"NOISE","GDC");
29 const char* filenamed= GetFile(kDAQ,"DEADCHANNELS","GDC");
30 TFile* f1 = TFile::Open(filename,"r");
31 TFile* f2 = TFile::Open(filenamen,"r");
32 Char_t namehisto[20];
33 Char_t namehisto2[20];
34
35 FILE* filed = fopen(filenamed,"read");
36 Int_t numOfBadChannels[fgkNumberOfSDD];
37 Int_t** badCh = new Int_t*[fgkNumberOfSDD];
38
39 Char_t row[50];
40 Int_t nSDD=0;
41 Char_t str[20];
42 char dims[1];
43 Int_t dim;
44 sprintf(str,"MODULE=%d",0);
45 while(!feof(filed)){
46 fscanf(filed,"%s\n",row);
47 if(strcmp(row,str)==0){
48 fscanf(filed,"%s %d\n",dims,&dim);
49 badCh[nSDD] = new Int_t[dim];
50 numOfBadChannels[nSDD]=dim;
51 for(Int_t ibad=0;ibad<dim;ibad++){
52 fscanf(filed,"%d\n",&badCh[nSDD][ibad]);
53 }
54 }
55 nSDD++;
56 sprintf(str,"MODULE=%d",nSDD);
57 }
58
59
60
61 AliCDBMetaData *md1= new AliCDBMetaData(); // metaData describing the object
62 md1->SetObjectClassName("AliITSCalibration");
63 md1->SetResponsible("Elisabetta Crescio");
64 md1->SetBeamPeriod(0);
65 md1->SetAliRootVersion("head September 2005"); //root version
66 md1->SetComment("This is a test");
67
68 TObjArray respSDD(260);
69 respSDD.SetOwner(kFALSE);
70
71 for(Int_t imod=0;imod<fgkNumberOfSDD;imod++){
72 AliITSCalibrationSDD *cal = new AliITSCalibrationSDD("simulated");
73 cal->SetDeadChannels(numOfBadChannels[imod]);
74 for(Int_t ich=0;ich<numOfBadChannels[imod];ich++){
75 cal->SetBadChannel(ich,badCh[imod][ich]);
76 }
77 sprintf(namehisto,"%s_%d",fgkNameHistoPedestals,imod);
78 sprintf(namehisto2,"%s_%d",fgkNameHistoNoise,imod);
79 TH1F* hbas = (TH1F*)f1->Get(namehisto);
80 TH1F* hnoi = (TH1F*)f2->Get(namehisto2);
81 for(Int_t ien=0;ien<fgkNumberOfChannels;ien++){
82 cal->SetBaseline(ien,hbas->GetBinContent(ien+1));
83 cal->SetNoiseAfterElectronics(ien,hnoi->GetBinContent(ien+1));
84 }
85 respSDD.Add(cal);
86 }
87
88 result = Store("Calib","Data",&respSDD,md1);
89
90 for(Int_t i=0;i<fgkNumberOfSDD;i++){
91 delete badCh[i];
92 }
93 delete [] badCh;
94 f1->Close();
95 f2->Close();
96 fclose(filed);
97 return result;
98
99}