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 "AliPMDMeanSm.h"
34 #include "AliPMDPedestal.h"
35 #include "AliPMDPreprocessor.h"
38 ClassImp(AliPMDPreprocessor)
40 //______________________________________________________________________________________________
41 AliPMDPreprocessor::AliPMDPreprocessor(AliShuttleInterface* shuttle) :
42 AliPreprocessor("PMD", shuttle)
45 AddRunType("PHYSICS");
46 AddRunType("PEDESTAL");
49 //______________________________________________________________________________________________
50 AliPMDPreprocessor::~AliPMDPreprocessor()
55 //______________________________________________________________________________________________
56 void AliPMDPreprocessor::Initialize(Int_t run, UInt_t startTime,
59 // Creates AliPMDDataDAQ object
61 AliPreprocessor::Initialize(run, startTime, endTime);
63 AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
64 TTimeStamp(startTime).AsString(),
65 TTimeStamp(endTime).AsString()));
68 fStartTime = startTime;
73 //-----------------------------------------
74 Bool_t AliPMDPreprocessor::ProcessDAQ()
76 TString RunType = GetRunType();
77 Log(Form("RunType %s",RunType.Data()));
78 if (RunType !="PHYSICS" || RunType != "PEDESTAL") {
86 //_____________________________________________________________________
87 UInt_t AliPMDPreprocessor::Process(TMap* pdaqAliasMap)
90 if(!pdaqAliasMap) return 1;
91 TString runType = GetRunType();
92 if(runType == "PEDESTAL"){
93 AliPMDPedestal *pedestal = new AliPMDPedestal();
95 TList* filesources = GetFileSources(kDAQ, "PMD_PED.root");
98 Log(Form("No sources found for PMD_PED.root!"));
102 AliInfo("Here's the list of sources for PMD_PED.root");
103 filesources->Print();
105 TIter iter(filesources);
109 while((source=dynamic_cast<TObjString*> (iter.Next()))){
110 filename = GetFile(kDAQ, "PMD_PED.root", source->GetName());
111 if(filename.Length() == 0) {
112 Log(Form("Error retrieving file from source %s failed!", source->GetName()));
117 Log(Form("File with id PMD_PED.root got from %s", source->GetName()));
119 Int_t det, sm, row, col;
122 TFile *f= new TFile(filename.Data());
123 if(!f || !f->IsOpen())
125 Log(Form("Error opening file with Id PMD_PED.root from source %s!", source->GetName()));
128 TTree *tree = dynamic_cast<TTree *> (f->Get("ped"));
131 Log("Could not find object \"ped\" in PED file!");
135 tree->SetBranchAddress("det", &det);
136 tree->SetBranchAddress("sm", &sm);
137 tree->SetBranchAddress("row", &row);
138 tree->SetBranchAddress("col", &col);
139 tree->SetBranchAddress("mean", &mean);
140 tree->SetBranchAddress("rms", &rms);
142 Int_t nEntries = (Int_t) tree->GetEntries();
143 for(Int_t i = 0; i < nEntries; i++)
146 pedestal->SetPedMeanRms(det,sm,row,col,mean,rms);
151 AliCDBMetaData metaData;
152 metaData.SetBeamPeriod(0);
153 metaData.SetComment("test PMD preprocessor");
155 result = Store("Calib","Ped", pedestal, &metaData,0,kTRUE);
159 Log("Error storing");
167 }else if (runType == "PHYSICS"){
169 AliPMDCalibData *calibda = new AliPMDCalibData();
171 TList* filesources = GetFileSources(kDAQ, "PMDGAINS.root");
174 Log(Form("No sources found for PMDGAINS.root!"));
178 AliInfo("Here's the list of sources for PMDGAINS.root");
179 filesources->Print();
181 TIter iter(filesources);
185 while((source=dynamic_cast<TObjString*> (iter.Next()))){
186 filename = GetFile(kDAQ, "PMDGAINS.root", source->GetName());
187 if(filename.Length() == 0) {
188 Log(Form("Error retrieving file from source %s failed!", source->GetName()));
193 Log(Form("File with id PMDGAINS.root got from %s", source->GetName()));
195 Int_t det, sm, row, col;
198 TFile *f1= new TFile(filename.Data());
199 if(!f1 || !f1->IsOpen())
201 Log(Form("Error opening file with Id PMDGAINS.root from source %s!", source->GetName()));
204 TTree *tree = dynamic_cast<TTree *> (f1->Get("ic"));
207 Log("Could not find object \"ic\" in DAQ file!");
211 tree->SetBranchAddress("det", &det);
212 tree->SetBranchAddress("sm", &sm);
213 tree->SetBranchAddress("row", &row);
214 tree->SetBranchAddress("col", &col);
215 tree->SetBranchAddress("gain", &gain);
219 Int_t nEntries = (Int_t) tree->GetEntries();
220 for(Int_t i = 0; i < nEntries; i++)
224 //if(DET>1 || SM>23 || ROW>95 || COL>95) {
225 // printf("Error! gain[%d,%d,%d,%d] = %f\n",
226 // DET,SM,ROW,COL,GAIN);
230 calibda->SetGainFact(det,sm,row,col,gain);
235 AliCDBMetaData metaData;
236 metaData.SetBeamPeriod(0);
237 metaData.SetComment("test PMD preprocessor");
238 result = Store("Calib","Gain", calibda, &metaData);
242 Log("Error storing");
245 //------------------For Storing HOT Data-------------------------//
246 AliPMDHotData *hotda = new AliPMDHotData();
247 TList* filesource = GetFileSources(kDAQ, "PMD_HOT.root");
250 Log(Form("No sources found for PMD_HOT.root!"));
254 AliInfo("Here's the list of sources for PMD_HOT.root");
257 TIter iter2(filesource);
259 UInt_t hotresult = 0;
261 while((sources=dynamic_cast<TObjString*> (iter2.Next()))){
262 filenames = GetFile(kDAQ, "PMD_HOT.root", sources->GetName());
263 if(filenames.Length() == 0) {
264 Log(Form("Error retrieving file from source %s failed!", sources->GetName()));
269 Log(Form("File with id PMD_HOT.root got from %s", sources->GetName()));
271 Int_t det, sm, row, col;
274 TFile *f2= new TFile(filenames.Data());
275 if(!f2 || !f2->IsOpen())
277 Log(Form("Error opening file with Id PMD_HOT.root from source %s!", sources->GetName()));
280 TTree *tree1 = dynamic_cast<TTree *> (f2->Get("hot"));
283 Log("Could not find object \"hot\" in DAQ file!");
287 tree1->SetBranchAddress("det", &det);
288 tree1->SetBranchAddress("sm", &sm);
289 tree1->SetBranchAddress("row", &row);
290 tree1->SetBranchAddress("col", &col);
291 tree1->SetBranchAddress("flag", &flag);
295 Int_t nEntries = (Int_t) tree1->GetEntries();
296 for(Int_t j = 0; j < nEntries; j++)
300 //if(det>1 || sm>23 || row>95 || col>95) {
301 // printf("Error! gain[%d,%d,%d,%d] = %f\n",
302 // det,sm,row,col,flag);
306 hotda->SetHotChannel(det,sm,row,col,flag);
311 hotresult = Store("Calib","Hot", hotda, &metaData);
315 Log("Error storing");
318 //-------------------------------------------------------------------
319 //-----------------------------------for storing SM MEAN--------------//
321 //------------------For Storing HOT Data-------------------------//
322 AliPMDMeanSm *smmeanda = new AliPMDMeanSm();
323 TList* filesourc = GetFileSources(kDAQ, "PMD_MEAN_SM.root");
326 Log(Form("No sources found for PMD_MEAN_SM.root!"));
330 AliInfo("Here's the list of sources for PMD_MEAN_SM.root");
333 TIter iter3(filesourc);
335 UInt_t meanresult = 0;
337 while((sourc=dynamic_cast<TObjString*> (iter3.Next()))){
338 filenam = GetFile(kDAQ, "PMD_MEAN_SM.root", sourc->GetName());
339 if(filenam.Length() == 0) {
340 Log(Form("Error retrieving file from source %s failed!", sourc->GetName()));
345 Log(Form("File with id PMD_MEAN_SM.root got from %s", sourc->GetName()));
350 TFile *f3= new TFile(filenam.Data());
351 if(!f3 || !f3->IsOpen())
353 Log(Form("Error opening file with Id PMD_MEAN_SM.root from source %s!", sourc->GetName()));
356 TTree *tree2 = dynamic_cast<TTree *> (f3->Get("mean"));
359 Log("Could not find object \"hot\" in DAQ file!");
363 tree2->SetBranchAddress("det", &det);
364 tree2->SetBranchAddress("sm", &sm);
365 tree2->SetBranchAddress("smmean", &smmean);
367 Int_t nEntries = (Int_t) tree2->GetEntries();
368 for(Int_t j = 0; j < nEntries; j++)
371 smmeanda->SetMeanSm(det,sm,smmean);
376 meanresult = Store("Calib","SMMEAN", smmeanda, &metaData);
380 Log("Error storing");
383 // -------------Store DCS data for reference------------//
384 AliCDBMetaData metadata;
385 metadata.SetComment("DCS data for PMD");
386 Bool_t resStore = kFALSE;
387 resStore = StoreReferenceData("DCS","Data",pdaqAliasMap,&metadata);
390 Log("Error storing");