]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSPreprocessorSDD.cxx
preprocessor does no longer use AliShuttle::GetShuttleTempDir (A. Colla)
[u/mrichter/AliRoot.git] / ITS / AliITSPreprocessorSDD.cxx
1 /////////////////////////////////////////
2 // Class for SDD digits preprocessing  //
3 //                                     //
4 //                                     //
5 ////////////////////////////////////////
6
7 /* $Id$ */
8
9 #include "AliITSPreprocessorSDD.h"
10 #include "AliITSCalibrationSDD.h"
11 #include "AliShuttleInterface.h"
12 #include "AliCDBMetaData.h"
13 #include "TObjArray.h"
14 #include "AliLog.h"
15 #include <TObjString.h>
16 #include <TSystem.h>
17 #include <TList.h>
18
19 const Int_t AliITSPreprocessorSDD::fgkNumberOfSDD = 260;
20 const Int_t AliITSPreprocessorSDD::fgkNumberOfChannels = 512;
21 const Int_t AliITSPreprocessorSDD::fgkNumberOfChannelsPerChip = 64;
22 const TString AliITSPreprocessorSDD::fgkNameHistoPedestals = "hpedestal";
23 const TString AliITSPreprocessorSDD::fgkNameHistoNoise = "hnoise";
24 ClassImp(AliITSPreprocessorSDD)
25
26
27 UInt_t AliITSPreprocessorSDD::Process(TMap*/* dcsAliasMap*/){
28
29   //preprocessing. 
30
31   TObjArray respSDD(fgkNumberOfSDD);
32   respSDD.SetOwner(kFALSE);
33   Float_t baseline,rawnoise,cmn,gain;
34   Int_t isgoodan,i,im,is,isgoodmod;
35   Int_t numOfBadChannels[fgkNumberOfSDD];
36   //TString pwd = gSystem->pwd();
37 //  const Char_t* tempDir=AliShuttleInterface::GetShuttleTempDir();
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());
49 //    gSystem->cd(tempDir);
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
58   for(Int_t imod=0;imod<fgkNumberOfSDD;imod++){
59     AliITSCalibrationSDD *cal = new AliITSCalibrationSDD("simulated");
60     numOfBadChannels[imod]=0;
61     Int_t badch[fgkNumberOfChannels];
62     for(Int_t isid=0;isid<=1;isid++){
63       Char_t basFileName[100];
64 //      sprintf(basFileName,"%s/SDDbase_mod%03d_sid%d.data",tempDir,imod,isid);
65       sprintf(basFileName,"./SDDbase_mod%03d_sid%d.data",imod,isid);
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);
72       if(!isgoodmod) cal->SetDead();
73       for(Int_t ian=0;ian<(fgkNumberOfChannels/2);ian++){
74         fscanf(basFil,"%d %d %f %f %f %f\n",&i,&isgoodan,&baseline,&rawnoise,&cmn,&gain);
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);
83         cal->SetNoiseAfterElectronics(ich,rawnoise);
84         Int_t iChip=ian/fgkNumberOfChannelsPerChip;
85         Int_t iChInChip=ian%fgkNumberOfChannelsPerChip;
86         cal->SetGain(gain,isid,iChip,iChInChip);
87       }
88       cal->SetDeadChannels(numOfBadChannels[imod]);
89       for(Int_t ibad=0;ibad<numOfBadChannels[imod];ibad++){
90         cal->SetBadChannel(ibad,badch[ibad]);
91       }
92       fclose(basFil);
93     }
94     respSDD.Add(cal);
95   }
96
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");
103
104   Bool_t retcode = Store("Calib","CalibSDD",&respSDD,md1, 0, kTRUE);
105
106   if(retcode) return 0;
107   else return 1;
108 }