]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PMD/AliPMDPreprocessor.cxx
EMCAL geometry can be created independently form anything now
[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//______________________________________________________________________________________________
19AliPMDPreprocessor::AliPMDPreprocessor(const char* detector, AliShuttleInterface* shuttle) :
20 AliPreprocessor(detector, shuttle)
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
53 if(!pdaqAliasMap) return 0;
54
55 AliPMDCalibData *calibda = new AliPMDCalibData();
56
57 TList* filesources = GetFileSources(kDAQ, "PMDGAINS");
58
59 if(!filesources) {
60 AliError(Form("No sources found for PMDGAINS for run %d !", fRun));
61 return 0;
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()))){
73 AliInfo(Form("\n\n Getting file #%d\n",++i));
74 filename = GetFile(kDAQ, "PMDGAINS", source->GetName());
75 if(!filename.Data()) {
76 AliError(Form("Error retrieving file from source %s failed!", source->GetName()));
77 delete filesources;
78 return 0;
79 }
80
81 Int_t DET,SM,ROW,COL;
82 Float_t GAIN;
83 TFile *f= new TFile(filename.Data());
84 TTree *tree = (TTree*)f->Get("ic");
85 tree->SetBranchAddress("DET", &DET);
86 tree->SetBranchAddress("SM", &SM);
87 tree->SetBranchAddress("ROW", &ROW);
88 tree->SetBranchAddress("COL", &COL);
89 tree->SetBranchAddress("GAIN", &GAIN);
90 Int_t nEntries = (Int_t) tree->GetEntries();
91 for(Int_t i = 0; i < nEntries; i++)
92 {
93 tree->GetEntry(i);
94// if(DET>1 || SM>23 || ROW>95 || COL>95) {
95// printf("Error! gain[%d,%d,%d,%d] = %f\n",DET,SM,ROW,COL,GAIN);
96// continue;
97 // }
98 calibda->SetGainFact(DET,SM,ROW,COL,GAIN);
99 }
100 f->Close();
101 delete f;
102 }
103
104 //Now we have to store the final CDB file
105 AliCDBMetaData metaData;
106 metaData.SetBeamPeriod(0);
107 metaData.SetComment("test PMD preprocessor");
108
109 result = Store("Calib","Data", calibda, &metaData);
110
111 delete calibda;
112 return result;
113}
114