3 #include <TTimeStamp.h>
5 #include "AliPMDPreprocessor.h"
6 #include "AliPMDPedestal.h"
7 #include "AliPMDCalibData.h"
9 #include "AliShuttleInterface.h"
10 #include "AliCDBMetaData.h"
11 #include <TTimeStamp.h>
12 #include <TObjString.h>
17 ClassImp(AliPMDPreprocessor)
19 //______________________________________________________________________________________________
20 AliPMDPreprocessor::AliPMDPreprocessor(AliShuttleInterface* shuttle) :
21 AliPreprocessor("PMD", shuttle)
26 //______________________________________________________________________________________________
27 AliPMDPreprocessor::~AliPMDPreprocessor()
32 //______________________________________________________________________________________________
33 void AliPMDPreprocessor::Initialize(Int_t run, UInt_t startTime,
36 // Creates AliPMDDataDAQ object
38 AliPreprocessor::Initialize(run, startTime, endTime);
40 AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
41 TTimeStamp(startTime).AsString(),
42 TTimeStamp(endTime).AsString()));
45 fStartTime = startTime;
50 //______________________________________________________________________________________________
51 UInt_t AliPMDPreprocessor::Process(TMap* pdaqAliasMap)
54 if(!pdaqAliasMap) return 1;
55 TString runType = GetRunType();
56 if(runType == "PEDESTAL_RUN"){
57 AliPMDPedestal *pedestal = new AliPMDPedestal();
59 TList* filesources = GetFileSources(kDAQ, "PMD_PED");
62 Log(Form("No sources found for PMD_PED!"));
66 AliInfo("Here's the list of sources for PMD_PED");
69 TIter iter(filesources);
73 while((source=dynamic_cast<TObjString*> (iter.Next()))){
74 filename = GetFile(kDAQ, "PMD_PED", source->GetName());
75 if(filename.Length() == 0) {
76 Log(Form("Error retrieving file from source %s failed!", source->GetName()));
81 Log(Form("File with id PMD_PED got from %s", source->GetName()));
84 TFile *f= new TFile(filename.Data());
85 if(!f || !f->IsOpen())
87 Log(Form("Error opening file with Id PMD_PED from source %s!", source->GetName()));
90 TTree *tree = dynamic_cast<TTree *> (f->Get("ped"));
93 Log("Could not find object \"ped\" in PED file!");
97 tree->SetBranchAddress("DET", &DET);
98 tree->SetBranchAddress("SM", &SM);
99 tree->SetBranchAddress("ROW", &ROW);
100 tree->SetBranchAddress("COL", &COL);
101 tree->SetBranchAddress("MEAN", &MEAN);
102 tree->SetBranchAddress("RMS", &RMS);
103 Int_t nEntries = (Int_t) tree->GetEntries();
104 for(Int_t i = 0; i < nEntries; i++)
107 pedestal->SetPedMeanRms(DET,SM,ROW,COL,MEAN,RMS);
112 AliCDBMetaData metaData;
113 metaData.SetBeamPeriod(0);
114 metaData.SetComment("test PMD preprocessor");
116 result = Store("Calib","Ped", pedestal, &metaData);
120 Log("Error storing");
128 }else if (runType == "PHYSICS"){
130 AliPMDCalibData *calibda = new AliPMDCalibData();
132 TList* filesources = GetFileSources(kDAQ, "PMDGAINS");
135 Log(Form("No sources found for PMDGAINS!"));
139 AliInfo("Here's the list of sources for PMDGAINS");
140 filesources->Print();
142 TIter iter(filesources);
146 while((source=dynamic_cast<TObjString*> (iter.Next()))){
147 filename = GetFile(kDAQ, "PMDGAINS", source->GetName());
148 if(filename.Length() == 0) {
149 Log(Form("Error retrieving file from source %s failed!", source->GetName()));
154 Log(Form("File with id PMDGAINS got from %s", source->GetName()));
155 Int_t DET,SM,ROW,COL;
157 TFile *f1= new TFile(filename.Data());
158 if(!f1 || !f1->IsOpen())
160 Log(Form("Error opening file with Id PMDGAINS from source %s!", source->GetName()));
163 TTree *tree = dynamic_cast<TTree *> (f1->Get("ic"));
166 Log("Could not find object \"ic\" in DAQ file!");
170 tree->SetBranchAddress("DET", &DET);
171 tree->SetBranchAddress("SM", &SM);
172 tree->SetBranchAddress("ROW", &ROW);
173 tree->SetBranchAddress("COL", &COL);
174 tree->SetBranchAddress("GAIN", &GAIN);
175 Int_t nEntries = (Int_t) tree->GetEntries();
176 for(Int_t i = 0; i < nEntries; i++)
179 // if(DET>1 || SM>23 || ROW>95 || COL>95) {
180 // printf("Error! gain[%d,%d,%d,%d] = %f\n",DET,SM,ROW,COL,GAIN);
183 calibda->SetGainFact(DET,SM,ROW,COL,GAIN);
189 AliCDBMetaData metaData;
190 metaData.SetBeamPeriod(0);
191 metaData.SetComment("test PMD preprocessor");
192 result = Store("Calib","Gain", calibda, &metaData);
196 Log("Error storing");