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 void AliITSPreprocessorSSD::Initialize(Int_t run, UInt_t startTime,
34 AliPreprocessor::Initialize(run, startTime, endTime);
36 Log(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
37 TTimeStamp(startTime).AsString(),
38 TTimeStamp(endTime).AsString()));
42 //______________________________________________________________________________________________
43 UInt_t AliITSPreprocessorSSD::Process(TMap* /*dcsAliasMap*/)
46 // Note. To be modified: dcsAliasMap is not needed but I can not get rid
47 // of it unless the base class AliPreprocessor is modified accordingly.
49 TObjArray calib_array(fgkNumberOfSSD);
50 TObjArray badch_array(fgkNumberOfSSD);
51 TObjArray ped_array(fgkNumberOfSSD);
52 //Float_t noise=0, gain=0;
54 TString runType = GetRunType();
55 if(runType == "ELECTRONICS_CALIBRATION_RUN") {
58 else if(runType == "PEDESTAL") {
60 TList* list = GetFileSources(kDAQ, "CALIBRATION");
61 if (list && list->GetEntries() > 0)
63 Log("The following sources produced files with the id CALIBRATION");
66 // create iterator over list of LDCs (provides list of TObjString)
70 // expect to iterate 3 times (LDC0, LDC1, LDC2)
71 while ( (ok = (TObjString*) next()) ) {
73 TString key = ok->String();
75 TString fileName = GetFile(kDAQ, "CALIBRATION", key.Data());
76 if (fileName.Length() > 0) {
78 Log(Form("Got the file %s, now we can extract some values.", fileName.Data()));
80 TFile *f = new TFile(fileName.Data());
81 if(!f || !f->IsOpen()){
82 Log("Error opening file!");
88 f->GetObject("Noise;1", cal);
90 Log("File does not contain expected data for the noise!");
95 //---------------------------------------
96 // in case some module was not calibrated!
97 for(Int_t i=0; i<fgkNumberOfSSD; i++) {
98 AliITSNoiseSSD *calib = new AliITSNoiseSSD();
99 calib->SetMod((UShort_t) i+500);
100 calib->SetNNoiseP(768);
101 calib->SetNNoiseN(768);
102 // take a reasonable averaged value for the noise on P- and N-side strips
103 for(Int_t j=0; j<768; j++) {
104 calib->AddNoiseP(j,2.);
105 calib->AddNoiseN(j,4.);
107 calib_array.AddAt(calib,i);
109 //-----------------------------------------
111 Int_t nmod = cal->GetEntries();
112 for(Int_t mod=0; mod<nmod; mod++) {
113 AliITSNoiseSSD *calib = (AliITSNoiseSSD*) cal->At(mod);
114 if((calib->GetMod()<500)||(calib->GetMod()>2198)) continue;
115 calib_array.AddAt(calib,calib->GetMod()-500);
119 //---------------------------------------
120 // in case some module was not calibrated!
121 for(Int_t i=0; i<fgkNumberOfSSD; i++) {
122 AliITSBadChannelsSSD *badch = new AliITSBadChannelsSSD();
123 badch->SetMod((UShort_t) i+500);
124 badch_array.AddAt(badch,i);
126 //-----------------------------------------
128 //-----------------------------------------
130 f->GetObject("BadChannels;1", bad);
132 Log("File does not contain expected data for bad channels !");
136 nmod = bad->GetEntries();
137 for(Int_t mod=0; mod<nmod; mod++) {
138 AliITSBadChannelsSSD *badch = (AliITSBadChannelsSSD*) bad->At(mod);
139 if((badch->GetMod()<500)||(badch->GetMod()>2198)) continue;
140 badch_array.AddAt(badch,badch->GetMod()-500);
143 //---------------------------------------
144 // in case some module was not calibrated!
145 for(Int_t i=0; i<fgkNumberOfSSD; i++) {
146 AliITSPedestalSSD *pedel = new AliITSPedestalSSD();
147 pedel->SetMod((UShort_t) i+500);
148 pedel->SetNPedestalP(768);
149 pedel->SetNPedestalN(768);
150 for(Int_t j=0; j<768; j++) {
151 pedel->AddPedestalP(j,0.);
152 pedel->AddPedestalN(j,0.);
154 ped_array.AddAt(pedel,i);
156 //-----------------------------------------
159 f->GetObject("Pedestal;1", ped);
161 Log("File does not contain expected data for the pedestals!");
165 nmod = ped->GetEntries();
166 for(Int_t mod=0; mod<nmod; mod++) {
167 AliITSPedestalSSD *pedel = (AliITSPedestalSSD*) ped->At(mod);
168 if((pedel->GetMod()<500)||(pedel->GetMod()>2198)) continue;
169 ped_array.AddAt(pedel,pedel->GetMod()-500);
172 f->Close(); delete f;
175 Log("GetFile error!");
179 } // end iteration over LDCs
183 Log("GetFileSources error!");
184 if(list) delete list;
188 //Now we have to store the final CDB file
189 AliCDBMetaData metaData;
190 metaData.SetBeamPeriod(0);
191 metaData.SetResponsible("Enrico Fragiacomo");
192 metaData.SetComment("Fills noise, pedestal and bad channels TObjArray");
194 if(!Store("Calib", "NoiseSSD", &calib_array, &metaData, 0, 1)) {
199 if(!Store("Calib", "BadChannelsSSD", &badch_array, &metaData, 0, 1)) {
204 if(!StoreReferenceData("Calib","PedestalSSD", &ped_array, &metaData)) {
209 } // end if noise_run
211 Log("Nothing to do");
215 Log("Database updated");
216 return 0; // 0 means success