]>
Commit | Line | Data |
---|---|---|
68f6519c | 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 | ||
18 | #include "AliACORDEPreprocessor.h" | |
19 | #include "TRandom.h" | |
20 | #include "TFile.h" | |
21 | #include "AliCDBMetaData.h" | |
22 | #include "AliCDBEntry.h" | |
23 | #include "AliLog.h" | |
24 | #include "AliACORDECalibData.h" | |
f65a9862 | 25 | #include "AliACORDEDataDCS.h" |
68f6519c | 26 | |
27 | #include <TTimeStamp.h> | |
28 | #include <TObjString.h> | |
29 | #include <TList.h> | |
30 | #include <TH1F.h> | |
31 | ||
f65a9862 | 32 | //ACORDE Preprocessor |
68f6519c | 33 | // It takes data from DAQ and passes it to the class AliACORDECalibModule and |
34 | // stores reference data. | |
35 | // | |
36 | // Authors | |
37 | // Pedro Gonzalez pedro.gonzalez@fcfm.buap.mx | |
38 | // Irais Bautista irais@fcfm.buap.mx | |
39 | // Arturo Fernandez Tellez afernan@cern.ch | |
40 | ||
41 | ClassImp(AliACORDEPreprocessor) | |
42 | ||
43 | //______________________________________________________________________________________________ | |
44 | AliACORDEPreprocessor::AliACORDEPreprocessor(AliShuttleInterface* shuttle) : | |
45 | AliPreprocessor("ACO", shuttle), | |
f65a9862 | 46 | fCalData(0), |
47 | fDataDCS(0) | |
68f6519c | 48 | { |
49 | // constructor | |
f65a9862 | 50 | AddRunType("STANDALONE_BC"); |
51 | AddRunType("STANDALONE_PULSER"); | |
b09b89bb | 52 | AddRunType("PHYSICS"); |
f65a9862 | 53 | |
68f6519c | 54 | } |
55 | ||
56 | //______________________________________________________________________________________________ | |
57 | AliACORDEPreprocessor::~AliACORDEPreprocessor() | |
58 | { | |
59 | // destructor | |
60 | } | |
61 | ||
62 | //______________________________________________________________________________________________ | |
63 | void AliACORDEPreprocessor::Initialize(Int_t run, UInt_t startTime, | |
64 | UInt_t endTime) | |
65 | { | |
66 | // Creates AliACORDECalibModule object | |
67 | ||
68 | AliPreprocessor::Initialize(run, startTime, endTime); | |
69 | ||
70 | Log(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run, | |
71 | TTimeStamp(startTime).AsString(), | |
72 | TTimeStamp(endTime).AsString())); | |
73 | ||
74 | fCalData = new AliACORDECalibData(); | |
f65a9862 | 75 | fDataDCS = new AliACORDEDataDCS(); |
68f6519c | 76 | } |
77 | ||
78 | //______________________________________________________________________________________________ | |
f65a9862 | 79 | UInt_t AliACORDEPreprocessor::Process(TMap* dcsAliasMap) |
68f6519c | 80 | { |
81 | ||
68f6519c | 82 | |
f65a9862 | 83 | // TH1D *fH1,*fH2,*fH3,*fH4; //Histogram of the rates per module |
84 | ||
85 | TH1D *fH[4]; | |
68f6519c | 86 | TFile *daqFile=0x0; |
87 | ||
88 | ||
f65a9862 | 89 | |
68f6519c | 90 | // retrieve the run type from the Shuttle, |
91 | ||
f65a9862 | 92 | if(!dcsAliasMap) |
93 | { | |
94 | ||
95 | Log(Form("Error there isn't dcsAliasMap")); | |
96 | return 1; | |
97 | ||
98 | } | |
68f6519c | 99 | |
100 | ||
f65a9862 | 101 | fDataDCS->ProcessData(*dcsAliasMap); |
68f6519c | 102 | |
68f6519c | 103 | |
f65a9862 | 104 | |
105 | AliCDBMetaData metaData1; | |
106 | metaData1.SetBeamPeriod(0); | |
107 | metaData1.SetResponsible("Pedro and Irais"); | |
108 | metaData1.SetComment("This preprocessor fills an AliACORDECalibModule object."); | |
109 | ||
110 | Bool_t result1 = StoreReferenceData("Calib", "DataDCS",fDataDCS, &metaData1); | |
111 | ||
112 | if(!result1) | |
113 | return 2; | |
114 | ||
115 | TString runType = GetRunType(); | |
68f6519c | 116 | |
117 | ||
118 | Log(Form("Run type for run %d: %s", fRun, runType.Data())); | |
119 | TString SourcesId = "CALIB"; | |
120 | ||
f65a9862 | 121 | |
68f6519c | 122 | |
123 | ||
124 | //retrieve the list of sources that produced the file with id RATES | |
125 | ||
126 | TList* sourceList = GetFileSources(kDAQ,SourcesId.Data()); | |
127 | ||
128 | if (!sourceList) | |
129 | { | |
130 | Log(Form("Error: No sources found for id %s", SourcesId.Data())); | |
f65a9862 | 131 | return 3; |
68f6519c | 132 | } |
133 | ||
134 | // TODO We have the list of sources that produced the files with Id RATES | |
135 | // Now we will loop on the list and we'll query the files one by one. | |
136 | ||
137 | ||
138 | ||
139 | Log(Form("The following sources produced files with the id %s",SourcesId.Data())); | |
140 | sourceList->Print(); | |
141 | ||
142 | TIter iter(sourceList); | |
143 | TObjString *source = 0; | |
144 | ||
145 | ||
146 | ||
147 | while((source=dynamic_cast<TObjString*> (iter.Next()))) | |
148 | { | |
149 | ||
150 | TString fileName = GetFile(kDAQ,SourcesId.Data(), source->GetName()); | |
151 | ||
152 | if (fileName.Length() > 0) | |
153 | Log(Form("Got the file %s, now we can extract some values.", fileName.Data())); | |
154 | ||
155 | daqFile = new TFile(fileName.Data(),"READ"); | |
156 | ||
157 | if(!daqFile) | |
158 | { | |
159 | ||
160 | Log(Form("There are not histos 1")); | |
f65a9862 | 161 | return 4; |
68f6519c | 162 | |
163 | } | |
164 | ||
165 | ||
166 | ||
f65a9862 | 167 | fH[0] = (TH1D*)daqFile->Get("fHist1"); |
168 | fH[1] = (TH1D*)daqFile->Get("fHist2"); | |
169 | fH[2] = (TH1D*)daqFile->Get("fHist3"); | |
170 | fH[3] = (TH1D*)daqFile->Get("fHist4"); | |
68f6519c | 171 | |
172 | ||
173 | ||
f65a9862 | 174 | if(fH[0]!=NULL&&fH[1]!=NULL&&fH[2]!=NULL&&fH[3]!=NULL) |
68f6519c | 175 | { |
f65a9862 | 176 | fCalData->AddHHits(fH[0]); |
177 | fCalData->AddHTHits(fH[1]); | |
178 | fCalData->AddHMultiHits(fH[2]); | |
179 | fCalData->AddHTMultiHits(fH[3]); | |
68f6519c | 180 | } |
181 | ||
f65a9862 | 182 | else |
68f6519c | 183 | { |
184 | Log(Form("There are not histos 2")); | |
185 | return 4; | |
186 | } | |
187 | ||
188 | ||
189 | } | |
190 | ||
191 | ||
192 | ||
193 | delete sourceList; | |
194 | ||
195 | ||
196 | //Now we have to store | |
197 | ||
198 | AliCDBMetaData metaData; | |
199 | metaData.SetBeamPeriod(0); | |
200 | metaData.SetResponsible("Pedro and Irais"); | |
201 | metaData.SetComment("This preprocessor fills an AliACORDECalibModule object."); | |
202 | ||
f65a9862 | 203 | Bool_t result2 = StoreReferenceData("Calib", "Data",fCalData, &metaData); |
68f6519c | 204 | |
205 | delete fCalData; | |
f65a9862 | 206 | delete fDataDCS; |
207 | fDataDCS = 0; | |
68f6519c | 208 | fCalData = 0; |
209 | ||
210 | ||
f65a9862 | 211 | if (!result2) |
212 | return 5; | |
68f6519c | 213 | |
214 | return 0; | |
215 | } | |
216 |