1 #include "AliITSPreprocessorSSD.h"
3 #include "AliCDBMetaData.h"
7 #include <TTimeStamp.h>
8 #include <TObjString.h>
10 #include "AliITSRawStreamSSD.h"
11 #include "AliITSNoiseSSD.h"
12 #include "AliITSPedestalSSD.h"
13 #include "AliITSBadChannelsSSD.h"
14 #include <Riostream.h>
18 // Author: Enrico Fragiacomo
21 // SHUTTLE preprocessing class for SSD calibration files
25 const Int_t AliITSPreprocessorSSD::fgkNumberOfSSD = 1698;
27 ClassImp(AliITSPreprocessorSSD)
29 //-----------------------------------------------------------------------
30 AliITSPreprocessorSSD::AliITSPreprocessorSSD(AliShuttleInterface* shuttle) :
31 AliPreprocessor("SSD", shuttle)
35 AddRunType("ELECTRONICS_CALIBRATION_RUN");
36 AddRunType("PEDESTAL");
37 AddRunType("PHYSICS");
41 ///______________________________________________________________________________________________
42 void AliITSPreprocessorSSD::Initialize(Int_t run, UInt_t startTime,
46 AliPreprocessor::Initialize(run, startTime, endTime);
48 Log(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
49 TTimeStamp(startTime).AsString(),
50 TTimeStamp(endTime).AsString()));
54 //______________________________________________________________________________________________
55 UInt_t AliITSPreprocessorSSD::Process(TMap* /*dcsAliasMap*/)
58 // Note. To be modified: dcsAliasMap is not needed but I can not get rid
59 // of it unless the base class AliPreprocessor is modified accordingly.
61 TObjArray calib_array(fgkNumberOfSSD);
62 TObjArray badch_array(fgkNumberOfSSD);
63 TObjArray ped_array(fgkNumberOfSSD);
64 //Float_t noise=0, gain=0;
66 TString runType = GetRunType();
67 if(runType == "ELECTRONICS_CALIBRATION_RUN") {
70 else if(runType == "PEDESTAL") {
72 TList* list = GetFileSources(kDAQ, "CALIBRATION");
73 if (list && list->GetEntries() > 0)
75 Log("The following sources produced files with the id CALIBRATION");
78 // create iterator over list of LDCs (provides list of TObjString)
82 //---------------------------------------
83 // in case some module was not calibrated!
84 for(Int_t i=0; i<fgkNumberOfSSD; i++) {
85 AliITSNoiseSSD *calib = new AliITSNoiseSSD();
86 calib->SetMod((UShort_t) i+500);
87 calib->SetNNoiseP(768);
88 calib->SetNNoiseN(768);
89 // take a reasonable averaged value for the noise on P- and N-side strips
90 for(Int_t j=0; j<768; j++) {
91 calib->AddNoiseP(j,1000.);
92 calib->AddNoiseN(j,1000.);
94 calib_array.AddAt(calib,i);
96 //-----------------------------------------
97 //---------------------------------------
98 // in case some module was not calibrated!
99 for(Int_t i=0; i<fgkNumberOfSSD; i++) {
100 AliITSBadChannelsSSD *badch = new AliITSBadChannelsSSD();
101 badch->SetMod((UShort_t) i+500);
102 badch->SetNBadPChannelsList(768);
103 badch->SetNBadNChannelsList(768);
104 badch_array.AddAt(badch,i);
106 //-----------------------------------------
108 //---------------------------------------
109 // in case some module was not calibrated!
110 for(Int_t i=0; i<fgkNumberOfSSD; i++) {
111 AliITSPedestalSSD *pedel = new AliITSPedestalSSD();
112 pedel->SetMod((UShort_t) i+500);
113 pedel->SetNPedestalP(768);
114 pedel->SetNPedestalN(768);
115 for(Int_t j=0; j<768; j++) {
116 pedel->AddPedestalP(j,0.);
117 pedel->AddPedestalN(j,0.);
119 ped_array.AddAt(pedel,i);
121 //-----------------------------------------
125 // expect to iterate 3 times (LDC0, LDC1, LDC2)
126 while ( (ok = (TObjString*) next()) ) {
128 TString key = ok->String();
130 TString fileName = GetFile(kDAQ, "CALIBRATION", key.Data());
131 if (fileName.Length() > 0) {
133 Log(Form("Got the file %s, now we can extract some values.", fileName.Data()));
135 TFile *f = new TFile(fileName.Data());
136 if(!f || !f->IsOpen()){
137 Log("Error opening file!");
143 f->GetObject("Noise;1", cal);
145 Log("File does not contain expected data for the noise!");
150 Int_t nmod = cal->GetEntries();
151 Log(Form("\n#Mod %d", nmod ));
152 for(Int_t mod=0; mod<nmod; mod++) {
153 AliITSNoiseSSD *calib = (AliITSNoiseSSD*) cal->At(mod);
154 Log(Form("\nModId %d", calib->GetMod() ));
155 if((calib->GetMod()<500)||(calib->GetMod()>2198)) continue;
156 calib_array.AddAt(calib,calib->GetMod()-500);
160 f->GetObject("BadChannels;1", bad);
162 Log("File does not contain expected data for bad channels !");
166 nmod = bad->GetEntries();
167 for(Int_t mod=0; mod<nmod; mod++) {
168 AliITSBadChannelsSSD *badch = (AliITSBadChannelsSSD*) bad->At(mod);
169 if((badch->GetMod()<500)||(badch->GetMod()>2198)) continue;
170 badch_array.AddAt(badch,badch->GetMod()-500);
174 f->GetObject("Pedestal;1", ped);
176 Log("File does not contain expected data for the pedestals!");
180 nmod = ped->GetEntries();
181 for(Int_t mod=0; mod<nmod; mod++) {
182 AliITSPedestalSSD *pedel = (AliITSPedestalSSD*) ped->At(mod);
183 if((pedel->GetMod()<500)||(pedel->GetMod()>2198)) continue;
184 ped_array.AddAt(pedel,pedel->GetMod()-500);
187 f->Close(); delete f;
190 Log("GetFile error!");
194 } // end iteration over LDCs
198 Log("GetFileSources error!");
199 if(list) delete list;
203 //Now we have to store the final CDB file
204 AliCDBMetaData metaData;
205 metaData.SetBeamPeriod(0);
206 metaData.SetResponsible("Enrico Fragiacomo");
207 metaData.SetComment("Fills noise, pedestal and bad channels TObjArray");
209 if(!Store("Calib", "NoiseSSD", &calib_array, &metaData, 0, 1)) {
214 if(!Store("Calib", "BadChannelsSSD", &badch_array, &metaData, 0, 1)) {
219 if(!StoreReferenceData("Calib","PedestalSSD", &ped_array, &metaData)) {
224 } // end if pedestal run
226 Log("Nothing to do");
230 Log("Database updated");
231 return 0; // 0 means success