]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSPreprocessorSDD.cxx
Fixes for some mem-leaks: most changes where pretty basic (i.e. adding deletes).
[u/mrichter/AliRoot.git] / ITS / AliITSPreprocessorSDD.cxx
CommitLineData
e56160b8 1/////////////////////////////////////////
2// Class for SDD digits preprocessing //
7537d03c 3// //
4// //
e56160b8 5////////////////////////////////////////
6
5a9fd7dd 7/* $Id$ */
8
e56160b8 9#include "AliITSPreprocessorSDD.h"
10#include "AliITSCalibrationSDD.h"
11#include "AliShuttleInterface.h"
12#include "AliCDBMetaData.h"
13#include "TObjArray.h"
e56160b8 14#include "AliLog.h"
dfb8947f 15#include <TObjString.h>
16#include <TSystem.h>
17#include <TList.h>
e56160b8 18
19const Int_t AliITSPreprocessorSDD::fgkNumberOfSDD = 260;
20const Int_t AliITSPreprocessorSDD::fgkNumberOfChannels = 512;
dfb8947f 21const Int_t AliITSPreprocessorSDD::fgkNumberOfChannelsPerChip = 64;
7537d03c 22const TString AliITSPreprocessorSDD::fgkNameHistoPedestals = "hpedestal";
23const TString AliITSPreprocessorSDD::fgkNameHistoNoise = "hnoise";
e56160b8 24ClassImp(AliITSPreprocessorSDD)
25
26
27UInt_t AliITSPreprocessorSDD::Process(TMap*/* dcsAliasMap*/){
28
29 //preprocessing.
30
afa07040 31 TObjArray respSDD(fgkNumberOfSDD);
e56160b8 32 respSDD.SetOwner(kFALSE);
afa07040 33 Float_t baseline,rawnoise,cmn,gain;
34 Int_t isgoodan,i,im,is,isgoodmod;
35 Int_t numOfBadChannels[fgkNumberOfSDD];
dfb8947f 36 //TString pwd = gSystem->pwd();
5a9fd7dd 37// const Char_t* tempDir=AliShuttleInterface::GetShuttleTempDir();
dfb8947f 38
39 TList* sourceList = GetFileSources(kDAQ, "SDD_Calib");
40 if (!sourceList){
41 Log("Error: no sources found for SDD_Calib");
42 return 2;
43 }
44
45 Int_t ind = 0;
46 while (sourceList->At(ind)!=NULL) {
47 TObjString* tarId = (TObjString*) sourceList->At(ind);
48 TString tarName = GetFile(kDAQ, "SDD_Calib", tarId->GetString().Data());
5a9fd7dd 49// gSystem->cd(tempDir);
dfb8947f 50 Char_t command[100];
51 sprintf(command,"tar -xf %s",tarName.Data());
52 gSystem->Exec(command);
53 ind++;
54 }
55
56 delete sourceList;
57
e56160b8 58 for(Int_t imod=0;imod<fgkNumberOfSDD;imod++){
59 AliITSCalibrationSDD *cal = new AliITSCalibrationSDD("simulated");
afa07040 60 numOfBadChannels[imod]=0;
61 Int_t badch[fgkNumberOfChannels];
62 for(Int_t isid=0;isid<=1;isid++){
dfb8947f 63 Char_t basFileName[100];
5a9fd7dd 64// sprintf(basFileName,"%s/SDDbase_mod%03d_sid%d.data",tempDir,imod,isid);
65 sprintf(basFileName,"./SDDbase_mod%03d_sid%d.data",imod,isid);
dfb8947f 66 FILE* basFil = fopen(basFileName,"read");
67 if (basFil == 0) {
68 Log(Form("File %s not found.",basFileName));
69 return 2;
70 }
71 fscanf(basFil,"%d %d %d\n",&im,&is,&isgoodmod);
afa07040 72 if(!isgoodmod) cal->SetDead();
73 for(Int_t ian=0;ian<(fgkNumberOfChannels/2);ian++){
dfb8947f 74 fscanf(basFil,"%d %d %f %f %f %f\n",&i,&isgoodan,&baseline,&rawnoise,&cmn,&gain);
afa07040 75 Int_t ich=ian;
76 if(isid==1) ich+=256;
77 if(!isgoodan){
78 Int_t ibad=numOfBadChannels[imod];
79 numOfBadChannels[imod]++;
80 badch[ibad]=ich;
81 }
82 cal->SetBaseline(ich,baseline);
dfb8947f 83 cal->SetNoiseAfterElectronics(ich,rawnoise);
84 Int_t iChip=ian/fgkNumberOfChannelsPerChip;
85 Int_t iChInChip=ian%fgkNumberOfChannelsPerChip;
86 cal->SetGain(gain,isid,iChip,iChInChip);
afa07040 87 }
88 cal->SetDeadChannels(numOfBadChannels[imod]);
89 for(Int_t ibad=0;ibad<numOfBadChannels[imod];ibad++){
90 cal->SetBadChannel(ibad,badch[ibad]);
91 }
dfb8947f 92 fclose(basFil);
e56160b8 93 }
94 respSDD.Add(cal);
95 }
96
dfb8947f 97 AliCDBMetaData *md1= new AliCDBMetaData(); // metaData describing the object
98 md1->SetObjectClassName("AliITSCalibration");
99 md1->SetResponsible("Elisabetta Crescio, Francesco Prino");
100 md1->SetBeamPeriod(0);
101 md1->SetAliRootVersion("head 5 April 2007"); //root version
102 md1->SetComment("This is a test");
e56160b8 103
dfb8947f 104 Bool_t retcode = Store("Calib","CalibSDD",&respSDD,md1, 0, kTRUE);
e56160b8 105
afa07040 106 if(retcode) return 0;
107 else return 1;
e56160b8 108}