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_RUN") {
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!");
93 Int_t nmod = cal->GetEntries();
94 for(Int_t mod=0; mod<nmod; mod++) {
95 AliITSNoiseSSD *calib = (AliITSNoiseSSD*) cal->At(mod);
96 if((calib->GetMod()<500)||(calib->GetMod()>2198)) continue;
97 calib_array.AddAt(calib,calib->GetMod()-500);
101 f->GetObject("BadChannels;1", bad);
103 Log("File does not contain expected data for bad channels !");
106 nmod = bad->GetEntries();
107 for(Int_t mod=0; mod<nmod; mod++) {
108 AliITSBadChannelsSSD *badch = (AliITSBadChannelsSSD*) bad->At(mod);
109 if((badch->GetMod()<500)||(badch->GetMod()>2198)) continue;
110 badch_array.AddAt(badch,badch->GetMod()-500);
114 f->GetObject("Pedestal;1", ped);
116 Log("File does not contain expected data for the pedestals!");
119 nmod = ped->GetEntries();
120 for(Int_t mod=0; mod<nmod; mod++) {
121 AliITSPedestalSSD *pedel = (AliITSPedestalSSD*) ped->At(mod);
122 if((pedel->GetMod()<500)||(pedel->GetMod()>2198)) continue;
123 ped_array.AddAt(pedel,pedel->GetMod()-500);
126 f->Close(); delete f;
129 Log("GetFile error!");
133 } // end iteration over LDCs
137 Log("GetFileSources error!");
138 if(list) delete list;
142 //Now we have to store the final CDB file
143 AliCDBMetaData metaData;
144 metaData.SetBeamPeriod(0);
145 metaData.SetResponsible("Enrico Fragiacomo");
146 metaData.SetComment("Fills noise, pedestal and bad channels TObjArray");
148 if(!Store("Calib", "NoiseSSD", &calib_array, &metaData, 0, 1)) {
153 if(!Store("Calib", "BadChannelsSSD", &badch_array, &metaData, 0, 1)) {
158 if(!StoreReferenceData("Calib","PedestalSSD", &ped_array, &metaData)) {
163 } // end if noise_run
165 Log("Nothing to do");
169 Log("Database updated");
170 return 0; // 0 means success