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_array.AddAt(badch,i);
104 //-----------------------------------------
106 //---------------------------------------
107 // in case some module was not calibrated!
108 for(Int_t i=0; i<fgkNumberOfSSD; i++) {
109 AliITSPedestalSSD *pedel = new AliITSPedestalSSD();
110 pedel->SetMod((UShort_t) i+500);
111 pedel->SetNPedestalP(768);
112 pedel->SetNPedestalN(768);
113 for(Int_t j=0; j<768; j++) {
114 pedel->AddPedestalP(j,0.);
115 pedel->AddPedestalN(j,0.);
117 ped_array.AddAt(pedel,i);
119 //-----------------------------------------
123 // expect to iterate 3 times (LDC0, LDC1, LDC2)
124 while ( (ok = (TObjString*) next()) ) {
126 TString key = ok->String();
128 TString fileName = GetFile(kDAQ, "CALIBRATION", key.Data());
129 if (fileName.Length() > 0) {
131 Log(Form("Got the file %s, now we can extract some values.", fileName.Data()));
133 TFile *f = new TFile(fileName.Data());
134 if(!f || !f->IsOpen()){
135 Log("Error opening file!");
141 f->GetObject("Noise;1", cal);
143 Log("File does not contain expected data for the noise!");
148 Int_t nmod = cal->GetEntries();
149 Log(Form("\n#Mod %d", nmod ));
150 for(Int_t mod=0; mod<nmod; mod++) {
151 AliITSNoiseSSD *calib = (AliITSNoiseSSD*) cal->At(mod);
152 Log(Form("\nModId %d", calib->GetMod() ));
153 if((calib->GetMod()<500)||(calib->GetMod()>2198)) continue;
154 calib_array.AddAt(calib,calib->GetMod()-500);
158 f->GetObject("BadChannels;1", bad);
160 Log("File does not contain expected data for bad channels !");
164 nmod = bad->GetEntries();
165 for(Int_t mod=0; mod<nmod; mod++) {
166 AliITSBadChannelsSSD *badch = (AliITSBadChannelsSSD*) bad->At(mod);
167 if((badch->GetMod()<500)||(badch->GetMod()>2198)) continue;
168 badch_array.AddAt(badch,badch->GetMod()-500);
172 f->GetObject("Pedestal;1", ped);
174 Log("File does not contain expected data for the pedestals!");
178 nmod = ped->GetEntries();
179 for(Int_t mod=0; mod<nmod; mod++) {
180 AliITSPedestalSSD *pedel = (AliITSPedestalSSD*) ped->At(mod);
181 if((pedel->GetMod()<500)||(pedel->GetMod()>2198)) continue;
182 ped_array.AddAt(pedel,pedel->GetMod()-500);
185 f->Close(); delete f;
188 Log("GetFile error!");
192 } // end iteration over LDCs
196 Log("GetFileSources error!");
197 if(list) delete list;
201 //Now we have to store the final CDB file
202 AliCDBMetaData metaData;
203 metaData.SetBeamPeriod(0);
204 metaData.SetResponsible("Enrico Fragiacomo");
205 metaData.SetComment("Fills noise, pedestal and bad channels TObjArray");
207 if(!Store("Calib", "NoiseSSD", &calib_array, &metaData, 0, 1)) {
212 if(!Store("Calib", "BadChannelsSSD", &badch_array, &metaData, 0, 1)) {
217 if(!StoreReferenceData("Calib","PedestalSSD", &ped_array, &metaData)) {
222 } // end if pedestal run
224 Log("Nothing to do");
228 Log("Database updated");
229 return 0; // 0 means success