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