]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PMD/AliPMDPreprocessor.cxx
Error message, consistent return value (Zubayer)
[u/mrichter/AliRoot.git] / PMD / AliPMDPreprocessor.cxx
CommitLineData
ad6005fa 1// --- ROOT system
2#include <TFile.h>
3#include <TTimeStamp.h>
4
5#include "AliPMDPreprocessor.h"
6#include "AliPMDCalibData.h"
7#include "AliLog.h"
8#include "AliShuttleInterface.h"
9#include "AliCDBMetaData.h"
10#include <TTimeStamp.h>
11#include <TObjString.h>
12#include <TTree.h>
13#include <TSystem.h>
14
15
16ClassImp(AliPMDPreprocessor)
17
18//______________________________________________________________________________________________
a80b0ff4 19AliPMDPreprocessor::AliPMDPreprocessor(AliShuttleInterface* shuttle) :
20 AliPreprocessor("PMD", shuttle)
ad6005fa 21{
22 // constructor
23}
24
25//______________________________________________________________________________________________
26AliPMDPreprocessor::~AliPMDPreprocessor()
27{
28 // destructor
29}
30
31//______________________________________________________________________________________________
32void AliPMDPreprocessor::Initialize(Int_t run, UInt_t startTime,
33 UInt_t endTime)
34{
35 // Creates AliPMDDataDAQ object
36
37 AliPreprocessor::Initialize(run, startTime, endTime);
38
39 AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
40 TTimeStamp(startTime).AsString(),
41 TTimeStamp(endTime).AsString()));
42
43 fRun = run;
44 fStartTime = startTime;
45 fEndTime = endTime;
46
47}
48
49//______________________________________________________________________________________________
50UInt_t AliPMDPreprocessor::Process(TMap* pdaqAliasMap)
51{
52
7fb72bea 53 if(!pdaqAliasMap) return 1;
ad6005fa 54
55 AliPMDCalibData *calibda = new AliPMDCalibData();
56
57 TList* filesources = GetFileSources(kDAQ, "PMDGAINS");
58
59 if(!filesources) {
a80b0ff4 60 Log(Form("No sources found for PMDGAINS!"));
7fb72bea 61 return 1;
ad6005fa 62 }
63
64 AliInfo("Here's the list of sources for PMDGAINS");
65 filesources->Print();
66
67 TIter iter(filesources);
68 TObjString* source;
69 int i=0;
70 UInt_t result = 0;
71 TString filename;
72 while((source=dynamic_cast<TObjString*> (iter.Next()))){
ad6005fa 73 filename = GetFile(kDAQ, "PMDGAINS", source->GetName());
a80b0ff4 74 if(filename.Length() == 0) {
75 Log(Form("Error retrieving file from source %s failed!", source->GetName()));
ad6005fa 76 delete filesources;
7fb72bea 77 return 1;
ad6005fa 78 }
79
a80b0ff4 80 Log(Form("File with id PMDGAINS got from %s", source->GetName()));
ad6005fa 81 Int_t DET,SM,ROW,COL;
82 Float_t GAIN;
83 TFile *f= new TFile(filename.Data());
a80b0ff4 84 if(!f || !f->IsOpen())
85 {
86 Log(Form("Error opening file with Id PMDGAINS from source %s!", source->GetName()));
7fb72bea 87 return 1;
a80b0ff4 88 }
89 TTree *tree = dynamic_cast<TTree *> (f->Get("ic"));
90 if (!tree)
91 {
92 Log("Could not find object \"ic\" in DAQ file!");
7fb72bea 93 return 1;
a80b0ff4 94 }
95
ad6005fa 96 tree->SetBranchAddress("DET", &DET);
97 tree->SetBranchAddress("SM", &SM);
98 tree->SetBranchAddress("ROW", &ROW);
99 tree->SetBranchAddress("COL", &COL);
100 tree->SetBranchAddress("GAIN", &GAIN);
101 Int_t nEntries = (Int_t) tree->GetEntries();
102 for(Int_t i = 0; i < nEntries; i++)
103 {
104 tree->GetEntry(i);
105// if(DET>1 || SM>23 || ROW>95 || COL>95) {
106// printf("Error! gain[%d,%d,%d,%d] = %f\n",DET,SM,ROW,COL,GAIN);
107// continue;
108 // }
109 calibda->SetGainFact(DET,SM,ROW,COL,GAIN);
110 }
111 f->Close();
112 delete f;
113 }
114
115 //Now we have to store the final CDB file
116 AliCDBMetaData metaData;
117 metaData.SetBeamPeriod(0);
118 metaData.SetComment("test PMD preprocessor");
119
120 result = Store("Calib","Data", calibda, &metaData);
121
122 delete calibda;
7a9a1d4d 123if(result==0)
124 { Log("Error storing");
125 return 1;
126 }
127 else
128 {
129 return 0;
130 }
131
ad6005fa 132}
133