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 "AliPMDPedestal.h"
33 #include "AliPMDPreprocessor.h"
36 ClassImp(AliPMDPreprocessor)
38 //______________________________________________________________________________________________
39 AliPMDPreprocessor::AliPMDPreprocessor(AliShuttleInterface* shuttle) :
40 AliPreprocessor("PMD", shuttle)
45 //______________________________________________________________________________________________
46 AliPMDPreprocessor::~AliPMDPreprocessor()
51 //______________________________________________________________________________________________
52 void AliPMDPreprocessor::Initialize(Int_t run, UInt_t startTime,
55 // Creates AliPMDDataDAQ object
57 AliPreprocessor::Initialize(run, startTime, endTime);
59 AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
60 TTimeStamp(startTime).AsString(),
61 TTimeStamp(endTime).AsString()));
64 fStartTime = startTime;
69 //______________________________________________________________________________________________
70 UInt_t AliPMDPreprocessor::Process(TMap* pdaqAliasMap)
73 if(!pdaqAliasMap) return 1;
74 TString runType = GetRunType();
75 if(runType == "PEDESTAL_RUN"){
76 AliPMDPedestal *pedestal = new AliPMDPedestal();
78 TList* filesources = GetFileSources(kDAQ, "PMD_PED");
81 Log(Form("No sources found for PMD_PED!"));
85 AliInfo("Here's the list of sources for PMD_PED");
88 TIter iter(filesources);
92 while((source=dynamic_cast<TObjString*> (iter.Next()))){
93 filename = GetFile(kDAQ, "PMD_PED", source->GetName());
94 if(filename.Length() == 0) {
95 Log(Form("Error retrieving file from source %s failed!", source->GetName()));
100 Log(Form("File with id PMD_PED got from %s", source->GetName()));
102 Int_t det, sm, row, col;
105 TFile *f= new TFile(filename.Data());
106 if(!f || !f->IsOpen())
108 Log(Form("Error opening file with Id PMD_PED from source %s!", source->GetName()));
111 TTree *tree = dynamic_cast<TTree *> (f->Get("ped"));
114 Log("Could not find object \"ped\" in PED file!");
118 tree->SetBranchAddress("det", &det);
119 tree->SetBranchAddress("sm", &sm);
120 tree->SetBranchAddress("row", &row);
121 tree->SetBranchAddress("col", &col);
122 tree->SetBranchAddress("mean", &mean);
123 tree->SetBranchAddress("rms", &rms);
125 Int_t nEntries = (Int_t) tree->GetEntries();
126 for(Int_t i = 0; i < nEntries; i++)
129 pedestal->SetPedMeanRms(det,sm,row,col,mean,rms);
134 AliCDBMetaData metaData;
135 metaData.SetBeamPeriod(0);
136 metaData.SetComment("test PMD preprocessor");
138 result = Store("Calib","Ped", pedestal, &metaData,0,kTRUE);
142 Log("Error storing");
150 }else if (runType == "PHYSICS"){
152 AliPMDCalibData *calibda = new AliPMDCalibData();
154 TList* filesources = GetFileSources(kDAQ, "PMDGAINS");
157 Log(Form("No sources found for PMDGAINS!"));
161 AliInfo("Here's the list of sources for PMDGAINS");
162 filesources->Print();
164 TIter iter(filesources);
168 while((source=dynamic_cast<TObjString*> (iter.Next()))){
169 filename = GetFile(kDAQ, "PMDGAINS", source->GetName());
170 if(filename.Length() == 0) {
171 Log(Form("Error retrieving file from source %s failed!", source->GetName()));
176 Log(Form("File with id PMDGAINS got from %s", source->GetName()));
178 Int_t det, sm, row, col;
181 TFile *f1= new TFile(filename.Data());
182 if(!f1 || !f1->IsOpen())
184 Log(Form("Error opening file with Id PMDGAINS from source %s!", source->GetName()));
187 TTree *tree = dynamic_cast<TTree *> (f1->Get("ic"));
190 Log("Could not find object \"ic\" in DAQ file!");
194 tree->SetBranchAddress("det", &det);
195 tree->SetBranchAddress("sm", &sm);
196 tree->SetBranchAddress("row", &row);
197 tree->SetBranchAddress("col", &col);
198 tree->SetBranchAddress("gain", &gain);
202 Int_t nEntries = (Int_t) tree->GetEntries();
203 for(Int_t i = 0; i < nEntries; i++)
207 //if(DET>1 || SM>23 || ROW>95 || COL>95) {
208 // printf("Error! gain[%d,%d,%d,%d] = %f\n",
209 // DET,SM,ROW,COL,GAIN);
213 calibda->SetGainFact(det,sm,row,col,gain);
219 AliCDBMetaData metaData;
220 metaData.SetBeamPeriod(0);
221 metaData.SetComment("test PMD preprocessor");
222 result = Store("Calib","Gain", calibda, &metaData);
226 Log("Error storing");
234 // Store DCS data for reference
235 AliCDBMetaData metadata;
236 metadata.SetComment("DCS data for PMD");
237 Bool_t resStore = kFALSE;
238 resStore = StoreReferenceData("DCS","Data",pdaqAliasMap,&metadata);
241 Log("Error storing");