1 #include "AliITSPreprocessorSSD.h"
3 #include "AliCDBMetaData.h"
7 #include <TTimeStamp.h>
8 #include <TObjString.h>
10 #include "AliITSRawStreamSSD.h"
11 #include "AliITSNoiseSSDv2.h"
12 #include "AliITSPedestalSSDv2.h"
13 #include "AliITSBadChannelsSSDv2.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 //---------------------------------------
67 // initialize the calibration objects
68 AliITSNoiseSSDv2 *calib = new AliITSNoiseSSDv2();
69 AliITSBadChannelsSSDv2 *badch = new AliITSBadChannelsSSDv2();
70 AliITSPedestalSSDv2 *pedel = new AliITSPedestalSSDv2();
72 TString runType = GetRunType();
73 if(runType == "ELECTRONICS_CALIBRATION_RUN") {
76 else if(runType == "PEDESTAL") {
78 TList* list = GetFileSources(kDAQ, "CALIBRATION");
79 if (list && list->GetEntries() > 0)
81 Log("The following sources produced files with the id CALIBRATION");
84 // create iterator over list of LDCs (provides list of TObjString)
88 // expect to iterate 3 times (LDC0, LDC1, LDC2)
89 while ( (ok = (TObjString*) next()) ) {
91 TString key = ok->String();
93 TString fileName = GetFile(kDAQ, "CALIBRATION", key.Data());
94 if (fileName.Length() > 0) {
96 Log(Form("Got the file %s, now we can extract some values.", fileName.Data()));
98 TFile *f = new TFile(fileName.Data());
99 if(!f || !f->IsOpen()){
100 Log("Error opening file!");
105 AliITSNoiseSSDv2 *cal;
106 f->GetObject("AliITSNoiseSSDv2;1", cal);
108 Log("File does not contain expected data for the noise!");
112 AliITSPedestalSSDv2 *ped;
113 f->GetObject("AliITSPedestalSSDv2;1", ped);
115 Log("File does not contain expected data for the pedestals!");
119 AliITSBadChannelsSSDv2 *bad;
120 f->GetObject("AliITSBadChannelsSSDv2;1", bad);
122 Log("File does not contain expected data for bad channels !");
127 for(Int_t module=0; module<fgkNumberOfSSD; module++) {
128 for(Int_t strip=0; strip<768; strip++) {
129 if(cal->GetNoiseP(module,strip))
130 calib->AddNoiseP(module,strip,cal->GetNoiseP(module,strip));
131 if(cal->GetNoiseN(module,strip))
132 calib->AddNoiseN(module,strip,cal->GetNoiseN(module,strip));
133 if(ped->GetPedestalP(module,strip))
134 pedel->AddPedestalP(module,strip,
135 ped->GetPedestalP(module,strip));
136 if(ped->GetPedestalN(module,strip))
137 pedel->AddPedestalN(module,strip,
138 ped->GetPedestalN(module,strip));
139 if(bad->GetBadChannelP(module,strip))
140 badch->AddBadChannelP(module,strip,
141 bad->GetBadChannelP(module,strip));
142 if(bad->GetBadChannelN(module,strip))
143 badch->AddBadChannelN(module,strip,
144 bad->GetBadChannelN(module,strip));
148 f->Close(); delete f;
151 Log("GetFile error!");
155 } // end iteration over LDCs
159 Log("GetFileSources error!");
160 if(list) delete list;
164 //Now we have to store the final CDB file
165 AliCDBMetaData metaData;
166 metaData.SetBeamPeriod(0);
167 metaData.SetResponsible("Enrico Fragiacomo");
168 metaData.SetComment("Fills noise, pedestal and bad channels TObjArray");
170 if(!Store("Calib", "NoiseSSD", (TObject *)calib, &metaData, 0, 1)) {
175 if(!Store("Calib", "BadChannelsSSD", (TObject*)badch, &metaData, 0, 1)) {
180 if(!StoreReferenceData("Ref","PedestalSSD", (TObject*)pedel, &metaData)) {
185 } // end if pedestal run
187 Log("Nothing to do");
191 Log("Database updated");
192 return 0; // 0 means success