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 **************************************************************************/
18 ///////////////////////////////////////////////////////////////////
20 // Implementation of the class for SDD preprocessing //
21 // Origin: E.Crescio, Torino, crescio@to.infn.it //
22 // F.Prino, Torino, prino@to.infn.it //
24 ///////////////////////////////////////////////////////////////////
26 #include "AliITSPreprocessorSDD.h"
27 #include "AliITSCalibrationSDD.h"
28 #include "AliITSDriftSpeedSDD.h"
29 #include "AliITSDDLModuleMapSDD.h"
30 #include "AliITSDriftSpeedArraySDD.h"
31 #include "AliITSDCSAnalyzerSDD.h"
32 #include "AliShuttleInterface.h"
33 #include "AliCDBEntry.h"
34 #include "AliCDBMetaData.h"
35 #include "TObjArray.h"
37 #include <TObjString.h>
41 const TString AliITSPreprocessorSDD::fgkNameHistoPedestals = "hpedestal";
42 const TString AliITSPreprocessorSDD::fgkNameHistoNoise = "hnoise";
43 ClassImp(AliITSPreprocessorSDD)
46 UInt_t AliITSPreprocessorSDD::Process(TMap* dcsAliasMap){
48 // Get DDL map from OCDB
49 AliCDBEntry* entry = GetFromOCDB("Calib", "DDLMapSDD");
51 Log("DDL map file not found in OCDB.");
54 AliITSDDLModuleMapSDD* ddlmap = (AliITSDDLModuleMapSDD*)entry->GetObject();
56 Log("AliITSDDLModuleMapSDD object not in file.");
61 TString runType = GetRunType();
64 Char_t inpFileName[100];
65 AliCDBMetaData *md1= new AliCDBMetaData();
66 md1->SetResponsible("Francesco Prino");
67 md1->SetBeamPeriod(0);
68 md1->SetAliRootVersion("head 30 November 2007"); //root version
69 md1->SetComment("This is a test");
71 if (runType == "PULSER_RUN"){
72 TObjArray calSDD(kNumberOfSDD);
73 calSDD.SetOwner(kFALSE);
74 Float_t baseline,rawnoise,cmn,corn,gain;
75 Int_t isgoodan,i,im,is,isgoodmod,basmin,basoff;
76 Int_t numOfBadChannels[kNumberOfSDD];
78 TList* sourceList = GetFileSources(kDAQ, "SDD_Calib");
80 Log("Error: no sources found for SDD_Calib");
85 while (sourceList->At(ind)!=NULL) {
86 TObjString* tarId = (TObjString*) sourceList->At(ind);
87 TString tarName = GetFile(kDAQ, "SDD_Calib", tarId->GetString().Data());
88 if(tarName.Length()==0){
89 Log(Form("Baseline tar file from source %d not found.",ind));
92 sprintf(command,"tar -xf %s",tarName.Data());
93 gSystem->Exec(command);
98 for(Int_t iddl=0;iddl<kNumberOfDDL;iddl++){
99 for(Int_t imod=0;imod<kModulesPerDDL;imod++){
100 Int_t modID=ddlmap->GetModuleNumber(iddl,imod);
101 if(modID==-1) continue;
102 modID-=240; // to have SDD modules numbering from 0 to 260
103 AliITSCalibrationSDD *cal = new AliITSCalibrationSDD("simulated");
104 numOfBadChannels[modID]=0;
105 Int_t badch[kNumberOfChannels];
106 for(Int_t isid=0;isid<=1;isid++){
107 sprintf(inpFileName,"./SDDbase_ddl%02dc%02d_sid%d.data",iddl,imod,isid);
108 FILE* basFil = fopen(inpFileName,"read");
110 Log(Form("File %s not found.",inpFileName));
113 fscanf(basFil,"%d %d %d\n",&im,&is,&isgoodmod);
114 if(!isgoodmod) cal->SetDead();
115 for(Int_t ian=0;ian<(kNumberOfChannels/2);ian++){
116 fscanf(basFil,"%d %d %f %d %d %f %f %f %f\n",&i,&isgoodan,&baseline,&basmin,&basoff,&rawnoise,&cmn,&corn,&gain);
118 if(isid==1) ich+=256;
120 Int_t ibad=numOfBadChannels[modID];
122 numOfBadChannels[modID]++;
124 cal->SetBaseline(ich,baseline);
125 cal->SetNoiseAfterElectronics(ich,rawnoise);
126 Int_t iChip=cal->GetChip(ich);
127 Int_t iChInChip=cal->GetChipChannel(ich);
128 cal->SetGain(gain,isid,iChip,iChInChip);
130 cal->SetDeadChannels(numOfBadChannels[modID]);
131 for(Int_t ibad=0;ibad<numOfBadChannels[modID];ibad++){
132 cal->SetBadChannel(ibad,badch[ibad]);
136 calSDD.AddAt(cal,modID);
139 md1->SetObjectClassName("AliITSCalibration");
140 retcode = Store("Calib","CalibSDD",&calSDD,md1, 0, kTRUE);
141 }else if(runType == "PHYSICS"){
143 TObjArray vdrift(2*kNumberOfSDD);
144 vdrift.SetOwner(kFALSE);
149 TList* sourceList = GetFileSources(kDAQ, "SDD_Injec");
151 Log("Error: no sources found for SDD_Injec");
155 while (sourceList->At(ind)!=NULL) {
156 TObjString* tarId = (TObjString*) sourceList->At(ind);
157 TString tarName = GetFile(kDAQ, "SDD_Injec", tarId->GetString().Data());
158 if(tarName.Length()==0){
159 Log(Form("Injector tar file from source %d not found.",ind));
162 sprintf(command,"tar -xf %s",tarName.Data());
163 gSystem->Exec(command);
168 for(Int_t iddl=0;iddl<kNumberOfDDL;iddl++){
169 for(Int_t imod=0;imod<kModulesPerDDL;imod++){
170 Int_t modID=ddlmap->GetModuleNumber(iddl,imod);
171 if(modID==-1) continue;
172 modID-=240; // to have SDD modules numbering from 0 to 260
173 for(Int_t isid=0;isid<=1;isid++){
174 AliITSDriftSpeedArraySDD *arr=new AliITSDriftSpeedArraySDD();
175 sprintf(inpFileName,"./SDDinj_ddl%02dc%02d_sid%d.data",iddl,imod,isid);
176 FILE* injFil = fopen(inpFileName,"read");
178 Log(Form("File %s not found.",inpFileName));
181 fscanf(injFil,"%d",&polDeg);
182 while (!feof(injFil)){
183 fscanf(injFil,"%d %d",&evNumb,&timeStamp);
184 if(feof(injFil)) break;
185 for(Int_t ic=0;ic<4;ic++) fscanf(injFil,"%f",¶m[ic]);
186 AliITSDriftSpeedSDD *dsp=new AliITSDriftSpeedSDD(evNumb,timeStamp,polDeg,param);
187 arr->AddDriftSpeed(dsp);
189 vdrift.AddAt(arr,2*modID+isid);
193 md1->SetObjectClassName("AliITSDriftSpeedArraySDD");
194 retcode = Store("Calib","DriftSpeedSDD",&vdrift,md1,0, kTRUE);
196 // do nothing for other run types
201 AliITSDCSAnalyzerSDD *dcs=new AliITSDCSAnalyzerSDD();
202 dcs->AnalyzeData(dcsAliasMap);
203 TObjArray refDCS(kNumberOfSDD);
204 refDCS.SetOwner(kFALSE);
205 for(Int_t imod=0;imod<kNumberOfSDD;imod++){
206 AliITSDCSDataSDD *dcsdata=dcs->GetDCSData(imod);
210 AliCDBMetaData *mddcs= new AliCDBMetaData();
211 mddcs->SetResponsible("Francesco Prino");
212 mddcs->SetBeamPeriod(0);
213 mddcs->SetAliRootVersion("head 18 December 2007"); //root version
214 mddcs->SetComment("This is a test");
215 mddcs->SetObjectClassName("AliITSDCSDataSDD");
216 Int_t retcodedcs = StoreReferenceData("DCS","DataSDD",&refDCS,mddcs);
218 if(retcodedcs) return 0;