1 /***************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 //-----------------------------------------------------//
17 // Source File : AliPMDPreprocessor.cxx //
20 //-----------------------------------------------------//
24 #include <TTimeStamp.h>
25 #include <TObjString.h>
29 #include "AliShuttleInterface.h"
30 #include "AliCDBMetaData.h"
31 #include "AliPMDCalibData.h"
32 #include "AliPMDHotData.h"
33 #include "AliPMDPedestal.h"
34 #include "AliPMDPreprocessor.h"
37 ClassImp(AliPMDPreprocessor)
39 //______________________________________________________________________________________________
40 AliPMDPreprocessor::AliPMDPreprocessor(AliShuttleInterface* shuttle) :
41 AliPreprocessor("PMD", shuttle)
44 AddRunType("PHYSICS");
45 AddRunType("PEDESTAL");
48 //______________________________________________________________________________________________
49 AliPMDPreprocessor::~AliPMDPreprocessor()
54 //______________________________________________________________________________________________
55 void AliPMDPreprocessor::Initialize(Int_t run, UInt_t startTime,
58 // Creates AliPMDDataDAQ object
60 AliPreprocessor::Initialize(run, startTime, endTime);
62 AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
63 TTimeStamp(startTime).AsString(),
64 TTimeStamp(endTime).AsString()));
67 fStartTime = startTime;
72 //-----------------------------------------
73 Bool_t AliPMDPreprocessor::ProcessDAQ()
75 TString RunType = GetRunType();
76 Log(Form("RunType %s",RunType.Data()));
77 if (RunType !="PHYSICS" || RunType != "PEDESTAL") {
85 //_____________________________________________________________________
86 UInt_t AliPMDPreprocessor::Process(TMap* pdaqAliasMap)
89 if(!pdaqAliasMap) return 1;
90 TString runType = GetRunType();
91 if(runType == "PEDESTAL"){
92 AliPMDPedestal *pedestal = new AliPMDPedestal();
94 TList* filesources = GetFileSources(kDAQ, "PMD_PED.root");
97 Log(Form("No sources found for PMD_PED.root!"));
101 AliInfo("Here's the list of sources for PMD_PED.root");
102 filesources->Print();
104 TIter iter(filesources);
108 while((source=dynamic_cast<TObjString*> (iter.Next()))){
109 filename = GetFile(kDAQ, "PMD_PED.root", source->GetName());
110 if(filename.Length() == 0) {
111 Log(Form("Error retrieving file from source %s failed!", source->GetName()));
116 Log(Form("File with id PMD_PED.root got from %s", source->GetName()));
118 Int_t det, sm, row, col;
121 TFile *f= new TFile(filename.Data());
122 if(!f || !f->IsOpen())
124 Log(Form("Error opening file with Id PMD_PED.root from source %s!", source->GetName()));
127 TTree *tree = dynamic_cast<TTree *> (f->Get("ped"));
130 Log("Could not find object \"ped\" in PED file!");
134 tree->SetBranchAddress("det", &det);
135 tree->SetBranchAddress("sm", &sm);
136 tree->SetBranchAddress("row", &row);
137 tree->SetBranchAddress("col", &col);
138 tree->SetBranchAddress("mean", &mean);
139 tree->SetBranchAddress("rms", &rms);
141 Int_t nEntries = (Int_t) tree->GetEntries();
142 for(Int_t i = 0; i < nEntries; i++)
145 pedestal->SetPedMeanRms(det,sm,row,col,mean,rms);
150 AliCDBMetaData metaData;
151 metaData.SetBeamPeriod(0);
152 metaData.SetComment("test PMD preprocessor");
154 result = Store("Calib","Ped", pedestal, &metaData,0,kTRUE);
158 Log("Error storing");
166 }else if (runType == "PHYSICS"){
168 AliPMDCalibData *calibda = new AliPMDCalibData();
170 TList* filesources = GetFileSources(kDAQ, "PMDGAINS.root");
173 Log(Form("No sources found for PMDGAINS.root!"));
177 AliInfo("Here's the list of sources for PMDGAINS.root");
178 filesources->Print();
180 TIter iter(filesources);
184 while((source=dynamic_cast<TObjString*> (iter.Next()))){
185 filename = GetFile(kDAQ, "PMDGAINS.root", source->GetName());
186 if(filename.Length() == 0) {
187 Log(Form("Error retrieving file from source %s failed!", source->GetName()));
192 Log(Form("File with id PMDGAINS.root got from %s", source->GetName()));
194 Int_t det, sm, row, col;
197 TFile *f1= new TFile(filename.Data());
198 if(!f1 || !f1->IsOpen())
200 Log(Form("Error opening file with Id PMDGAINS.root from source %s!", source->GetName()));
203 TTree *tree = dynamic_cast<TTree *> (f1->Get("ic"));
206 Log("Could not find object \"ic\" in DAQ file!");
210 tree->SetBranchAddress("det", &det);
211 tree->SetBranchAddress("sm", &sm);
212 tree->SetBranchAddress("row", &row);
213 tree->SetBranchAddress("col", &col);
214 tree->SetBranchAddress("gain", &gain);
218 Int_t nEntries = (Int_t) tree->GetEntries();
219 for(Int_t i = 0; i < nEntries; i++)
223 //if(DET>1 || SM>23 || ROW>95 || COL>95) {
224 // printf("Error! gain[%d,%d,%d,%d] = %f\n",
225 // DET,SM,ROW,COL,GAIN);
229 calibda->SetGainFact(det,sm,row,col,gain);
234 AliCDBMetaData metaData;
235 metaData.SetBeamPeriod(0);
236 metaData.SetComment("test PMD preprocessor");
237 result = Store("Calib","Gain", calibda, &metaData);
241 Log("Error storing");
244 //----------------------------------------------------
245 AliPMDHotData *hotda = new AliPMDHotData();
246 TList* filesource = GetFileSources(kDAQ, "PMD_HOT.root");
249 Log(Form("No sources found for PMD_HOT.root!"));
253 AliInfo("Here's the list of sources for PMD_HOT.root");
256 TIter iter2(filesource);
258 UInt_t hotresult = 0;
260 while((sources=dynamic_cast<TObjString*> (iter2.Next()))){
261 filenames = GetFile(kDAQ, "PMD_HOT.root", sources->GetName());
262 if(filenames.Length() == 0) {
263 Log(Form("Error retrieving file from source %s failed!", sources->GetName()));
268 Log(Form("File with id PMD_HOT.root got from %s", sources->GetName()));
270 Int_t det, sm, row, col;
273 TFile *f2= new TFile(filenames.Data());
274 if(!f2 || !f2->IsOpen())
276 Log(Form("Error opening file with Id PMD_HOT.root from source %s!", sources->GetName()));
279 TTree *tree1 = dynamic_cast<TTree *> (f2->Get("hot"));
282 Log("Could not find object \"hot\" in DAQ file!");
286 tree1->SetBranchAddress("det", &det);
287 tree1->SetBranchAddress("sm", &sm);
288 tree1->SetBranchAddress("row", &row);
289 tree1->SetBranchAddress("col", &col);
290 tree1->SetBranchAddress("flag", &flag);
294 Int_t nEntries = (Int_t) tree1->GetEntries();
295 for(Int_t j = 0; j < nEntries; j++)
299 //if(det>1 || sm>23 || row>95 || col>95) {
300 // printf("Error! gain[%d,%d,%d,%d] = %f\n",
301 // det,sm,row,col,flag);
305 hotda->SetHotChannel(det,sm,row,col,flag);
310 hotresult = Store("Calib","Hot", hotda, &metaData);
314 Log("Error storing");
317 //-------------------------------------------------------------------
320 // Store DCS data for reference
321 AliCDBMetaData metadata;
322 metadata.SetComment("DCS data for PMD");
323 Bool_t resStore = kFALSE;
324 resStore = StoreReferenceData("DCS","Data",pdaqAliasMap,&metadata);
327 Log("Error storing");