2 // Author: Enrico Fragiacomo
5 // SHUTTLE preprocessing class for SSD calibration files
9 #include "AliITSPreprocessorSSD.h"
11 #include "AliCDBMetaData.h"
15 #include <TTimeStamp.h>
16 #include <TObjString.h>
18 #include "AliITSRawStreamSSD.h"
19 #include "AliITSNoiseSSDv2.h"
20 #include "AliITSPedestalSSDv2.h"
21 #include "AliITSBadChannelsSSDv2.h"
22 #include <Riostream.h>
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,
47 AliPreprocessor::Initialize(run, startTime, endTime);
49 Log(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
50 TTimeStamp(startTime).AsString(),
51 TTimeStamp(endTime).AsString()));
55 //______________________________________________________________________________________________
56 UInt_t AliITSPreprocessorSSD::Process(TMap* /*dcsAliasMap*/)
59 // Note. To be modified: dcsAliasMap is not needed but I can not get rid
60 // of it unless the base class AliPreprocessor is modified accordingly.
62 // TObjArray calib_array(fgkNumberOfSSD);
63 //TObjArray badch_array(fgkNumberOfSSD);
64 //TObjArray ped_array(fgkNumberOfSSD);
65 //Float_t noise=0, gain=0;
67 //---------------------------------------
68 // initialize the calibration objects
69 AliITSNoiseSSDv2 *calib = new AliITSNoiseSSDv2();
70 AliITSBadChannelsSSDv2 *badch = new AliITSBadChannelsSSDv2();
71 AliITSPedestalSSDv2 *pedel = new AliITSPedestalSSDv2();
73 TString runType = GetRunType();
74 if(runType == "ELECTRONICS_CALIBRATION_RUN") {
77 else if(runType == "PEDESTAL") {
79 TList* list = GetFileSources(kDAQ, "CALIBRATION");
80 if (list && list->GetEntries() > 0)
82 Log("The following sources produced files with the id CALIBRATION");
85 // create iterator over list of LDCs (provides list of TObjString)
89 // expect to iterate 3 times (LDC0, LDC1, LDC2)
90 while ( (ok = (TObjString*) next()) ) {
92 TString key = ok->String();
94 TString fileName = GetFile(kDAQ, "CALIBRATION", key.Data());
95 if (fileName.Length() > 0) {
97 Log(Form("Got the file %s, now we can extract some values.", fileName.Data()));
99 TFile *f = new TFile(fileName.Data());
100 if(!f || !f->IsOpen()){
101 Log("Error opening file!");
106 AliITSNoiseSSDv2 *cal;
107 f->GetObject("AliITSNoiseSSDv2;1", cal);
109 Log("File does not contain expected data for the noise!");
113 AliITSPedestalSSDv2 *ped;
114 f->GetObject("AliITSPedestalSSDv2;1", ped);
116 Log("File does not contain expected data for the pedestals!");
120 AliITSBadChannelsSSDv2 *bad;
121 f->GetObject("AliITSBadChannelsSSDv2;1", bad);
123 Log("File does not contain expected data for bad channels !");
128 for(Int_t module=0; module<fgkNumberOfSSD; module++) {
129 for(Int_t strip=0; strip<768; strip++) {
130 if(cal->GetNoiseP(module,strip))
131 calib->AddNoiseP(module,strip,cal->GetNoiseP(module,strip));
132 if(cal->GetNoiseN(module,strip))
133 calib->AddNoiseN(module,strip,cal->GetNoiseN(module,strip));
134 if(ped->GetPedestalP(module,strip))
135 pedel->AddPedestalP(module,strip,
136 ped->GetPedestalP(module,strip));
137 if(ped->GetPedestalN(module,strip))
138 pedel->AddPedestalN(module,strip,
139 ped->GetPedestalN(module,strip));
140 if(bad->GetBadChannelP(module,strip))
141 badch->AddBadChannelP(module,strip,
142 bad->GetBadChannelP(module,strip));
143 if(bad->GetBadChannelN(module,strip))
144 badch->AddBadChannelN(module,strip,
145 bad->GetBadChannelN(module,strip));
149 f->Close(); delete f;
152 Log("GetFile error!");
156 } // end iteration over LDCs
160 Log("GetFileSources error!");
161 if(list) delete list;
165 //Now we have to store the final CDB file
166 AliCDBMetaData metaData;
167 metaData.SetBeamPeriod(0);
168 metaData.SetResponsible("Enrico Fragiacomo");
169 metaData.SetComment("Fills noise, pedestal and bad channels TObjArray");
171 if(!Store("Calib", "NoiseSSD", (TObject *)calib, &metaData, 0, 1)) {
176 if(!Store("Calib", "BadChannelsSSD", (TObject*)badch, &metaData, 0, 1)) {
181 if(!StoreReferenceData("Ref","PedestalSSD", (TObject*)pedel, &metaData)) {
186 } // end if pedestal run
188 Log("Nothing to do");
192 Log("Database updated");
193 return 0; // 0 means success