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