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