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)
43 AddRunType("PHYSICS");
44 AddRunType("PEDESTAL");
47 //______________________________________________________________________________________________
48 AliPMDPreprocessor::~AliPMDPreprocessor()
53 //______________________________________________________________________________________________
54 void AliPMDPreprocessor::Initialize(Int_t run, UInt_t startTime,
57 // Creates AliPMDDataDAQ object
59 AliPreprocessor::Initialize(run, startTime, endTime);
61 AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
62 TTimeStamp(startTime).AsString(),
63 TTimeStamp(endTime).AsString()));
66 fStartTime = startTime;
71 //-----------------------------------------
72 Bool_t AliPMDPreprocessor::ProcessDAQ()
74 TString RunType = GetRunType();
75 Log(Form("RunType %s",RunType.Data()));
76 if (RunType !="PHYSICS" || RunType != "PEDESTAL") {
84 //______________________________________________________________________________________________
85 UInt_t AliPMDPreprocessor::Process(TMap* pdaqAliasMap)
88 if(!pdaqAliasMap) return 1;
89 TString runType = GetRunType();
90 if(runType == "PEDESTAL"){
91 AliPMDPedestal *pedestal = new AliPMDPedestal();
93 TList* filesources = GetFileSources(kDAQ, "PMD_PED.root");
96 Log(Form("No sources found for PMD_PED.root!"));
100 AliInfo("Here's the list of sources for PMD_PED.root");
101 filesources->Print();
103 TIter iter(filesources);
107 while((source=dynamic_cast<TObjString*> (iter.Next()))){
108 filename = GetFile(kDAQ, "PMD_PED.root", source->GetName());
109 if(filename.Length() == 0) {
110 Log(Form("Error retrieving file from source %s failed!", source->GetName()));
115 Log(Form("File with id PMD_PED.root got from %s", source->GetName()));
117 Int_t det, sm, row, col;
120 TFile *f= new TFile(filename.Data());
121 if(!f || !f->IsOpen())
123 Log(Form("Error opening file with Id PMD_PED.root from source %s!", source->GetName()));
126 TTree *tree = dynamic_cast<TTree *> (f->Get("ped"));
129 Log("Could not find object \"ped\" in PED file!");
133 tree->SetBranchAddress("det", &det);
134 tree->SetBranchAddress("sm", &sm);
135 tree->SetBranchAddress("row", &row);
136 tree->SetBranchAddress("col", &col);
137 tree->SetBranchAddress("mean", &mean);
138 tree->SetBranchAddress("rms", &rms);
140 Int_t nEntries = (Int_t) tree->GetEntries();
141 for(Int_t i = 0; i < nEntries; i++)
144 pedestal->SetPedMeanRms(det,sm,row,col,mean,rms);
149 AliCDBMetaData metaData;
150 metaData.SetBeamPeriod(0);
151 metaData.SetComment("test PMD preprocessor");
153 result = Store("Calib","Ped", pedestal, &metaData,0,kTRUE);
157 Log("Error storing");
165 }else if (runType == "PHYSICS"){
167 AliPMDCalibData *calibda = new AliPMDCalibData();
169 TList* filesources = GetFileSources(kDAQ, "PMDGAINS.root");
172 Log(Form("No sources found for PMDGAINS.root!"));
176 AliInfo("Here's the list of sources for PMDGAINS.root");
177 filesources->Print();
179 TIter iter(filesources);
183 while((source=dynamic_cast<TObjString*> (iter.Next()))){
184 filename = GetFile(kDAQ, "PMDGAINS.root", source->GetName());
185 if(filename.Length() == 0) {
186 Log(Form("Error retrieving file from source %s failed!", source->GetName()));
191 Log(Form("File with id PMDGAINS.root got from %s", source->GetName()));
193 Int_t det, sm, row, col;
196 TFile *f1= new TFile(filename.Data());
197 if(!f1 || !f1->IsOpen())
199 Log(Form("Error opening file with Id PMDGAINS.root from source %s!", source->GetName()));
202 TTree *tree = dynamic_cast<TTree *> (f1->Get("ic"));
205 Log("Could not find object \"ic\" in DAQ file!");
209 tree->SetBranchAddress("det", &det);
210 tree->SetBranchAddress("sm", &sm);
211 tree->SetBranchAddress("row", &row);
212 tree->SetBranchAddress("col", &col);
213 tree->SetBranchAddress("gain", &gain);
217 Int_t nEntries = (Int_t) tree->GetEntries();
218 for(Int_t i = 0; i < nEntries; i++)
222 //if(DET>1 || SM>23 || ROW>95 || COL>95) {
223 // printf("Error! gain[%d,%d,%d,%d] = %f\n",
224 // DET,SM,ROW,COL,GAIN);
228 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");
249 // Store DCS data for reference
250 AliCDBMetaData metadata;
251 metadata.SetComment("DCS data for PMD");
252 Bool_t resStore = kFALSE;
253 resStore = StoreReferenceData("DCS","Data",pdaqAliasMap,&metadata);
256 Log("Error storing");