]>
Commit | Line | Data |
---|---|---|
5ca85244 | 1 | #include "AliITSPreprocessorSSD.h" |
2 | ||
3 | #include "AliCDBMetaData.h" | |
4 | #include "AliLog.h" | |
5 | #include "TFile.h" | |
6 | ||
7 | #include <TTimeStamp.h> | |
8 | #include <TObjString.h> | |
9 | ||
10 | #include "AliITSRawStreamSSD.h" | |
11 | #include "AliITSNoiseSSD.h" | |
12 | #include <Riostream.h> | |
13 | ||
14 | ||
15 | // | |
16 | // Author: Enrico Fragiacomo | |
17 | // Date: 13/10/2006 | |
18 | // | |
19 | // SHUTTLE preprocessing class for SSD calibration files | |
20 | ||
21 | /* $Id$ */ | |
22 | ||
23 | ClassImp(AliITSPreprocessorSSD) | |
24 | ||
25 | //______________________________________________________________________________________________ | |
26 | void AliITSPreprocessorSSD::Initialize(Int_t run, UInt_t startTime, | |
27 | UInt_t endTime) | |
28 | { | |
29 | ||
30 | AliPreprocessor::Initialize(run, startTime, endTime); | |
31 | ||
32 | Log(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run, | |
33 | TTimeStamp(startTime).AsString(), | |
34 | TTimeStamp(endTime).AsString())); | |
35 | ||
36 | } | |
37 | ||
38 | //______________________________________________________________________________________________ | |
39 | UInt_t AliITSPreprocessorSSD::Process(TMap* /*dcsAliasMap*/) | |
40 | { | |
41 | ||
42 | // Note. To be modified: dcsAliasMap is not needed but I can not get rid | |
43 | // of it unless the base class AliPreprocessor is modified accordingly. | |
44 | ||
45 | TObjArray calib_array(1698); | |
46 | //Float_t noise=0, gain=0; | |
47 | ||
48 | TString runType = GetRunType(); | |
49 | if(runType == "ELECTRONICS_CALIBRATION_RUN") { | |
50 | ||
51 | } | |
52 | else if(runType == "PEDESTAL_RUN") { | |
53 | ||
54 | TList* list = GetFileSources(kDAQ, "CALIBRATION"); | |
55 | if (list && list->GetEntries() > 0) | |
56 | { | |
57 | Log("The following sources produced files with the id CALIBRATION"); | |
58 | list->Print(); | |
59 | ||
60 | // create iterator over list of LDCs (provides list of TObjString) | |
61 | TIter next(list); | |
62 | TObjString *ok; | |
63 | ||
64 | // expect to iterate 3 times (LDC0, LDC1, LDC2) | |
65 | while ( (ok = (TObjString*) next()) ) { | |
66 | ||
67 | TString key = ok->String(); | |
68 | ||
69 | TString fileName = GetFile(kDAQ, "CALIBRATION", key.Data()); | |
70 | if (fileName.Length() > 0) { | |
71 | ||
72 | Log(Form("Got the file %s, now we can extract some values.", fileName.Data())); | |
73 | ||
74 | TFile *f = new TFile(fileName.Data()); | |
75 | if(!f || !f->IsOpen()){ | |
76 | Log("Error opening file!"); | |
77 | delete list; | |
78 | return 2; | |
79 | } | |
80 | ||
81 | TObjArray *cal; | |
82 | f->GetObject("TObjArray;1", cal); | |
83 | f->Close(); delete f; | |
84 | ||
85 | if(!cal) { | |
86 | Log("File does not contain expected data!"); | |
87 | delete list; | |
88 | } | |
89 | ||
90 | Int_t nmod = cal->GetEntries(); | |
91 | ||
92 | for(Int_t mod=0; mod<nmod; mod++) { | |
93 | ||
94 | AliITSNoiseSSD *calib = (AliITSNoiseSSD*) cal->At(mod); | |
95 | calib_array.AddAt(calib,calib->GetMod()); | |
96 | } | |
97 | ||
98 | } else { | |
99 | Log("GetFile error!"); | |
100 | delete list; | |
101 | return 3; | |
102 | } // if filename | |
103 | } // end iteration over LDCs | |
104 | ||
105 | delete list; | |
106 | } else { | |
107 | Log("GetFileSources error!"); | |
108 | if(list) delete list; | |
109 | return 4; | |
110 | } // if list | |
111 | ||
112 | //Now we have to store the final CDB file | |
113 | AliCDBMetaData metaData; | |
114 | metaData.SetBeamPeriod(0); | |
115 | metaData.SetResponsible("Enrico Fragiacomo"); | |
116 | metaData.SetComment("This preprocessor fills the TObjArray of AliITSNoiseSSD"); | |
117 | ||
118 | if(!Store("Calib", "NoiseSSD", &calib_array, &metaData, 0, 1)) { | |
119 | Log("no store"); | |
120 | return 1; | |
121 | } | |
122 | ||
123 | } // end if noise_run | |
124 | else { | |
125 | Log("Nothing to do"); | |
126 | return 0; | |
127 | } | |
128 | ||
129 | Log("Database updated"); | |
130 | return 0; // 0 means success | |
131 | ||
132 | } | |
133 |