]>
Commit | Line | Data |
---|---|---|
c1e70747 | 1 | /*************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | //-----------------------------------------------------// | |
16 | // // | |
17 | // Source File : AliPMDPreprocessor.cxx // | |
18 | // // | |
19 | // // | |
20 | //-----------------------------------------------------// | |
21 | ||
ad6005fa | 22 | // --- ROOT system |
23 | #include <TFile.h> | |
51e6156c | 24 | #include <TTimeStamp.h> |
25 | #include <TObjString.h> | |
26 | #include <TTree.h> | |
ad6005fa | 27 | |
ad6005fa | 28 | #include "AliLog.h" |
29 | #include "AliShuttleInterface.h" | |
30 | #include "AliCDBMetaData.h" | |
51e6156c | 31 | #include "AliPMDCalibData.h" |
32 | #include "AliPMDPedestal.h" | |
33 | #include "AliPMDPreprocessor.h" | |
ad6005fa | 34 | |
35 | ||
36 | ClassImp(AliPMDPreprocessor) | |
cda4fe9e | 37 | |
ad6005fa | 38 | //______________________________________________________________________________________________ |
a80b0ff4 | 39 | AliPMDPreprocessor::AliPMDPreprocessor(AliShuttleInterface* shuttle) : |
40 | AliPreprocessor("PMD", shuttle) | |
ad6005fa | 41 | { |
42 | // constructor | |
43 | } | |
44 | ||
45 | //______________________________________________________________________________________________ | |
46 | AliPMDPreprocessor::~AliPMDPreprocessor() | |
47 | { | |
48 | // destructor | |
49 | } | |
50 | ||
51 | //______________________________________________________________________________________________ | |
52 | void AliPMDPreprocessor::Initialize(Int_t run, UInt_t startTime, | |
53 | UInt_t endTime) | |
54 | { | |
55 | // Creates AliPMDDataDAQ object | |
56 | ||
cda4fe9e | 57 | AliPreprocessor::Initialize(run, startTime, endTime); |
ad6005fa | 58 | |
cda4fe9e | 59 | AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run, |
60 | TTimeStamp(startTime).AsString(), | |
61 | TTimeStamp(endTime).AsString())); | |
ad6005fa | 62 | |
cda4fe9e | 63 | fRun = run; |
64 | fStartTime = startTime; | |
65 | fEndTime = endTime; | |
ad6005fa | 66 | |
67 | } | |
68 | ||
69 | //______________________________________________________________________________________________ | |
70 | UInt_t AliPMDPreprocessor::Process(TMap* pdaqAliasMap) | |
71 | { | |
51e6156c | 72 | |
cda4fe9e | 73 | if(!pdaqAliasMap) return 1; |
74 | TString runType = GetRunType(); | |
75 | if(runType == "PEDESTAL_RUN"){ | |
76 | AliPMDPedestal *pedestal = new AliPMDPedestal(); | |
77 | ||
78 | TList* filesources = GetFileSources(kDAQ, "PMD_PED"); | |
79 | ||
80 | if(!filesources) { | |
81 | Log(Form("No sources found for PMD_PED!")); | |
82 | return 1; | |
83 | } | |
84 | ||
85 | AliInfo("Here's the list of sources for PMD_PED"); | |
86 | filesources->Print(); | |
87 | ||
88 | TIter iter(filesources); | |
89 | TObjString* source; | |
90 | UInt_t result = 0; | |
91 | TString filename; | |
92 | while((source=dynamic_cast<TObjString*> (iter.Next()))){ | |
93 | filename = GetFile(kDAQ, "PMD_PED", source->GetName()); | |
94 | if(filename.Length() == 0) { | |
95 | Log(Form("Error retrieving file from source %s failed!", source->GetName())); | |
96 | delete filesources; | |
97 | return 1; | |
98 | } | |
99 | ||
100 | Log(Form("File with id PMD_PED got from %s", source->GetName())); | |
c1e70747 | 101 | |
51e6156c | 102 | Int_t det, sm, row, col; |
c1e70747 | 103 | Float_t mean, rms; |
104 | ||
cda4fe9e | 105 | TFile *f= new TFile(filename.Data()); |
106 | if(!f || !f->IsOpen()) | |
107 | { | |
108 | Log(Form("Error opening file with Id PMD_PED from source %s!", source->GetName())); | |
109 | return 1; | |
110 | } | |
111 | TTree *tree = dynamic_cast<TTree *> (f->Get("ped")); | |
112 | if (!tree) | |
113 | { | |
114 | Log("Could not find object \"ped\" in PED file!"); | |
115 | return 1; | |
116 | } | |
117 | ||
c1e70747 | 118 | tree->SetBranchAddress("det", &det); |
119 | tree->SetBranchAddress("sm", &sm); | |
120 | tree->SetBranchAddress("row", &row); | |
121 | tree->SetBranchAddress("col", &col); | |
122 | tree->SetBranchAddress("mean", &mean); | |
123 | tree->SetBranchAddress("rms", &rms); | |
51e6156c | 124 | |
cda4fe9e | 125 | Int_t nEntries = (Int_t) tree->GetEntries(); |
126 | for(Int_t i = 0; i < nEntries; i++) | |
127 | { | |
128 | tree->GetEntry(i); | |
c1e70747 | 129 | pedestal->SetPedMeanRms(det,sm,row,col,mean,rms); |
cda4fe9e | 130 | } |
131 | f->Close(); | |
132 | delete f; | |
133 | } | |
134 | AliCDBMetaData metaData; | |
135 | metaData.SetBeamPeriod(0); | |
136 | metaData.SetComment("test PMD preprocessor"); | |
137 | ||
30aa6410 | 138 | result = Store("Calib","Ped", pedestal, &metaData,0,kTRUE); |
cda4fe9e | 139 | delete pedestal; |
140 | if(result==0) | |
141 | { | |
142 | Log("Error storing"); | |
143 | return 1; | |
144 | } | |
145 | else | |
146 | { | |
147 | return 0; | |
148 | } | |
149 | ||
150 | }else if (runType == "PHYSICS"){ | |
ad6005fa | 151 | |
152 | AliPMDCalibData *calibda = new AliPMDCalibData(); | |
cda4fe9e | 153 | |
ad6005fa | 154 | TList* filesources = GetFileSources(kDAQ, "PMDGAINS"); |
cda4fe9e | 155 | |
ad6005fa | 156 | if(!filesources) { |
cda4fe9e | 157 | Log(Form("No sources found for PMDGAINS!")); |
158 | return 1; | |
159 | } | |
160 | ||
ad6005fa | 161 | AliInfo("Here's the list of sources for PMDGAINS"); |
162 | filesources->Print(); | |
cda4fe9e | 163 | |
ad6005fa | 164 | TIter iter(filesources); |
165 | TObjString* source; | |
ad6005fa | 166 | UInt_t result = 0; |
167 | TString filename; | |
168 | while((source=dynamic_cast<TObjString*> (iter.Next()))){ | |
cda4fe9e | 169 | filename = GetFile(kDAQ, "PMDGAINS", source->GetName()); |
170 | if(filename.Length() == 0) { | |
171 | Log(Form("Error retrieving file from source %s failed!", source->GetName())); | |
172 | delete filesources; | |
173 | return 1; | |
174 | } | |
175 | ||
176 | Log(Form("File with id PMDGAINS got from %s", source->GetName())); | |
c1e70747 | 177 | |
51e6156c | 178 | Int_t det, sm, row, col; |
c1e70747 | 179 | Float_t gain; |
180 | ||
cda4fe9e | 181 | TFile *f1= new TFile(filename.Data()); |
182 | if(!f1 || !f1->IsOpen()) | |
183 | { | |
184 | Log(Form("Error opening file with Id PMDGAINS from source %s!", source->GetName())); | |
185 | return 1; | |
186 | } | |
187 | TTree *tree = dynamic_cast<TTree *> (f1->Get("ic")); | |
188 | if (!tree) | |
189 | { | |
190 | Log("Could not find object \"ic\" in DAQ file!"); | |
191 | return 1; | |
192 | } | |
193 | ||
c1e70747 | 194 | tree->SetBranchAddress("det", &det); |
195 | tree->SetBranchAddress("sm", &sm); | |
196 | tree->SetBranchAddress("row", &row); | |
197 | tree->SetBranchAddress("col", &col); | |
198 | tree->SetBranchAddress("gain", &gain); | |
51e6156c | 199 | |
30aa6410 | 200 | |
201 | ||
cda4fe9e | 202 | Int_t nEntries = (Int_t) tree->GetEntries(); |
203 | for(Int_t i = 0; i < nEntries; i++) | |
204 | { | |
205 | tree->GetEntry(i); | |
51e6156c | 206 | |
207 | //if(DET>1 || SM>23 || ROW>95 || COL>95) { | |
30aa6410 | 208 | // printf("Error! gain[%d,%d,%d,%d] = %f\n", |
51e6156c | 209 | // DET,SM,ROW,COL,GAIN); |
210 | // continue; | |
30aa6410 | 211 | //} |
51e6156c | 212 | |
c1e70747 | 213 | calibda->SetGainFact(det,sm,row,col,gain); |
cda4fe9e | 214 | } |
215 | f1->Close(); | |
216 | delete f1; | |
217 | } | |
218 | ||
219 | AliCDBMetaData metaData; | |
220 | metaData.SetBeamPeriod(0); | |
221 | metaData.SetComment("test PMD preprocessor"); | |
222 | result = Store("Calib","Gain", calibda, &metaData); | |
223 | delete calibda; | |
224 | if(result==0) | |
225 | { | |
226 | Log("Error storing"); | |
227 | return 1; | |
228 | } | |
229 | else | |
230 | { | |
231 | return 0; | |
232 | } | |
233 | ||
51e6156c | 234 | // Store DCS data for reference |
235 | AliCDBMetaData metadata; | |
236 | metadata.SetComment("DCS data for PMD"); | |
237 | Bool_t resStore = kFALSE; | |
238 | resStore = StoreReferenceData("DCS","Data",pdaqAliasMap,&metadata); | |
239 | if(resStore==0) | |
240 | { | |
241 | Log("Error storing"); | |
242 | return 1; | |
243 | } | |
244 | else | |
245 | { | |
246 | return 0; | |
247 | } | |
248 | ||
cda4fe9e | 249 | } |
250 | ||
251 | return 2; | |
ad6005fa | 252 | } |
30aa6410 | 253 | |
254 |