Retrieving and merging the raw data tags - output object/file location should be...
[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;
c2bd28b6 46 Char_t command[100];
dfb8947f 47 while (sourceList->At(ind)!=NULL) {
48 TObjString* tarId = (TObjString*) sourceList->At(ind);
49 TString tarName = GetFile(kDAQ, "SDD_Calib", tarId->GetString().Data());
5a9fd7dd 50// gSystem->cd(tempDir);
c2bd28b6 51 sprintf(command,"tar -xf %s",tarName.Data());
52 gSystem->Exec(command);
53 ind++;
54 }
55
56 sourceList = GetFileSources(kDAQ, "SDD_Injec");
57 if (!sourceList){
58 Log("Error: no sources found for SDD_Injec");
59 return 2;
60 }
61
62 ind = 0;
63 while (sourceList->At(ind)!=NULL) {
64 TObjString* tarId = (TObjString*) sourceList->At(ind);
65 TString tarName = GetFile(kDAQ, "SDD_Injec", tarId->GetString().Data());
66// gSystem->cd(tempDir);
dfb8947f 67 sprintf(command,"tar -xf %s",tarName.Data());
68 gSystem->Exec(command);
69 ind++;
70 }
71
72 delete sourceList;
73
e56160b8 74 for(Int_t imod=0;imod<fgkNumberOfSDD;imod++){
75 AliITSCalibrationSDD *cal = new AliITSCalibrationSDD("simulated");
afa07040 76 numOfBadChannels[imod]=0;
77 Int_t badch[fgkNumberOfChannels];
78 for(Int_t isid=0;isid<=1;isid++){
dfb8947f 79 Char_t basFileName[100];
5a9fd7dd 80// sprintf(basFileName,"%s/SDDbase_mod%03d_sid%d.data",tempDir,imod,isid);
81 sprintf(basFileName,"./SDDbase_mod%03d_sid%d.data",imod,isid);
dfb8947f 82 FILE* basFil = fopen(basFileName,"read");
83 if (basFil == 0) {
84 Log(Form("File %s not found.",basFileName));
85 return 2;
86 }
87 fscanf(basFil,"%d %d %d\n",&im,&is,&isgoodmod);
afa07040 88 if(!isgoodmod) cal->SetDead();
89 for(Int_t ian=0;ian<(fgkNumberOfChannels/2);ian++){
dfb8947f 90 fscanf(basFil,"%d %d %f %f %f %f\n",&i,&isgoodan,&baseline,&rawnoise,&cmn,&gain);
afa07040 91 Int_t ich=ian;
92 if(isid==1) ich+=256;
93 if(!isgoodan){
94 Int_t ibad=numOfBadChannels[imod];
95 numOfBadChannels[imod]++;
96 badch[ibad]=ich;
97 }
98 cal->SetBaseline(ich,baseline);
dfb8947f 99 cal->SetNoiseAfterElectronics(ich,rawnoise);
100 Int_t iChip=ian/fgkNumberOfChannelsPerChip;
101 Int_t iChInChip=ian%fgkNumberOfChannelsPerChip;
102 cal->SetGain(gain,isid,iChip,iChInChip);
afa07040 103 }
104 cal->SetDeadChannels(numOfBadChannels[imod]);
105 for(Int_t ibad=0;ibad<numOfBadChannels[imod];ibad++){
106 cal->SetBadChannel(ibad,badch[ibad]);
107 }
dfb8947f 108 fclose(basFil);
c2bd28b6 109
110 Char_t injFileName[100];
111 Int_t evNumb;
112 UInt_t timeStamp;
113 Float_t param[4];
114 sprintf(injFileName,"./SDDinj_mod%03d_sid%d.data",imod,isid);
115 FILE* injFil = fopen(injFileName,"read");
116 if (injFil == 0) {
117 Log(Form("File %s not found.",basFileName));
118 return 2;
119 }
120 while (!feof(injFil)){
121 fscanf(injFil,"%d %d %",&evNumb,&timeStamp);
122 if(feof(injFil)) break;
123 for(Int_t ic=0;ic<4;ic++) fscanf(injFil,"%f",&param[ic]);
124 cal->SetDriftSpeedParam(isid,param);
125 }
e56160b8 126 }
127 respSDD.Add(cal);
128 }
129
dfb8947f 130 AliCDBMetaData *md1= new AliCDBMetaData(); // metaData describing the object
131 md1->SetObjectClassName("AliITSCalibration");
132 md1->SetResponsible("Elisabetta Crescio, Francesco Prino");
133 md1->SetBeamPeriod(0);
134 md1->SetAliRootVersion("head 5 April 2007"); //root version
135 md1->SetComment("This is a test");
e56160b8 136
dfb8947f 137 Bool_t retcode = Store("Calib","CalibSDD",&respSDD,md1, 0, kTRUE);
e56160b8 138
afa07040 139 if(retcode) return 0;
140 else return 1;
e56160b8 141}