]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG0/TPC/AliROCRawAnalysisSelector.cxx
More mods to suit ROOT head
[u/mrichter/AliRoot.git] / PWG0 / TPC / AliROCRawAnalysisSelector.cxx
CommitLineData
eb884e16 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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
16/* $Id$ */
17
18
19#include "AliROCRawAnalysisSelector.h"
20
21#include <AliLog.h>
22
c50f9dc0 23#include <AliRawEvent.h>
24#include <AliRawReaderRoot.h>
25#include <AliRawEventHeaderBase.h>
26#include <AliTPCRawStream.h>
27#include <AliTPCParamSR.h>
28
eb884e16 29#include <TFile.h>
30#include <TTree.h>
31#include <TCanvas.h>
c50f9dc0 32#include <TTimeStamp.h>
d560b581 33#include <TROOT.h>
eb884e16 34
1d7991a5 35#include <TPC/AliTPCRawHistograms.h>
36
eb884e16 37
38ClassImp(AliROCRawAnalysisSelector)
39
40AliROCRawAnalysisSelector::AliROCRawAnalysisSelector() :
c50f9dc0 41 TSelector(),
42 fRawEvent(0),
1d7991a5 43 fTree(0),
44 fParam(0)
eb884e16 45{
46 //
47 // Constructor. Initialization of pointers
48 //
1d7991a5 49
50 for (Int_t i=0; i<kTPCSectors; i++)
51 fHistograms[i] = 0;
52
53 fParam = new AliTPCParamSR;
eb884e16 54}
55
56AliROCRawAnalysisSelector::~AliROCRawAnalysisSelector()
57{
58 //
59 // Destructor
60 //
61}
62
63void AliROCRawAnalysisSelector::SlaveBegin(TTree* tree)
64{
65 //
c50f9dc0 66
67 if (tree != 0)
68 Init(tree);
eb884e16 69}
70
c50f9dc0 71void AliROCRawAnalysisSelector::Init(TTree* tree)
eb884e16 72{
73 // The Init() function is called when the selector needs to initialize
74 // a new tree or chain. Typically here the branch addresses of the tree
75 // will be set. It is normaly not necessary to make changes to the
76 // generated code, but the routine can be extended by the user if needed.
77 // Init() will be called many times when running with PROOF.
78
c50f9dc0 79 fTree = tree;
80
eb884e16 81 // Set branch address
1d7991a5 82 if (tree)
83 {
c50f9dc0 84 AliDebug(AliLog::kInfo, "INFO: Tree found");
85
86 tree->SetBranchAddress("rawevent", &fRawEvent);
87 }
eb884e16 88}
89
90Bool_t AliROCRawAnalysisSelector::Process(Long64_t entry)
91{
92 //
1d7991a5 93 //
eb884e16 94 //
95
1d7991a5 96 AliDebug(AliLog::kInfo, Form("Processing event %lld", entry));
97
dc89d87e 98 fTree->GetTree()->GetEntry(entry);
99
1d7991a5 100 if (!fRawEvent)
101 {
102 AliDebug(AliLog::kError, "fRawEvent empty");
103 return kFALSE;
104 }
105
106 AliRawReaderRoot* rawReader = new AliRawReaderRoot(fRawEvent);
eb884e16 107
1d7991a5 108 const AliRawEventHeaderBase* eventHeader = dynamic_cast<const AliRawEventHeaderBase*> (rawReader->GetEventHeader());
109 if (eventHeader)
110 {
c50f9dc0 111 eventHeader->Print();
112
113 UInt_t timeStamp = eventHeader->Get("Timestamp");
114 UInt_t eventType = eventHeader->Get("Type");
115
1d7991a5 116 AliDebug(AliLog::kInfo, Form("Time stamp: %s, event type %d", TTimeStamp(timeStamp).AsString(), eventType));
c50f9dc0 117 }
eb884e16 118
c50f9dc0 119 AliTPCRawStream* tpcRawStream = new AliTPCRawStream(rawReader);
120
c50f9dc0 121 const Int_t kNIS = fParam->GetNInnerSector();
122 const Int_t kNOS = fParam->GetNOuterSector();
123 const Int_t kNS = kNIS + kNOS;
124
1d7991a5 125 for (Int_t sector = 0; sector < kNS; sector++)
126 {
127 AliDebug(AliLog::kInfo, Form("*** Looking at sector %d ***", sector));
c50f9dc0 128
129 Int_t nRows = 0;
130 Int_t nDDLs = 0, indexDDL = 0;
131
1d7991a5 132 if (sector < kNIS)
133 {
c50f9dc0 134 nRows = fParam->GetNRowLow();
c50f9dc0 135 nDDLs = 2;
1d7991a5 136 indexDDL = sector * 2;
c50f9dc0 137 }
1d7991a5 138 else
139 {
c50f9dc0 140 nRows = fParam->GetNRowUp();
c50f9dc0 141 nDDLs = 4;
1d7991a5 142 indexDDL = (sector-kNIS) * 4 + kNIS * 2;
c50f9dc0 143 }
144
145 // Loas the raw data for corresponding DDLs
146 rawReader->Reset();
147 tpcRawStream->SetOldRCUFormat(kTRUE);
148 rawReader->Select("TPC",indexDDL,indexDDL+nDDLs-1);
c50f9dc0 149
1d7991a5 150 AliDebug(AliLog::kDebug, Form("Selected DDLs %d ... %d", indexDDL, indexDDL+nDDLs-1));
c50f9dc0 151
1d7991a5 152 Int_t count = 0;
c50f9dc0 153
1d7991a5 154 while (tpcRawStream->Next())
155 {
156 if (tpcRawStream->GetSector() != sector)
157 {
158 AliDebug(AliLog::kError, Form("Sector index mismatch ! Expected (%d), but got (%d) !",sector,tpcRawStream->GetSector()));
159 return kFALSE;
160 }
161
162 if ((count++ % 100000) == 0)
163 AliDebug(AliLog::kDebug, Form("Found %d. digit in sector %d: row %d, pad %d, time %d, signal %d", count,
164 tpcRawStream->GetSector(), tpcRawStream->GetRow(), tpcRawStream->GetPad(), tpcRawStream->GetTime(), tpcRawStream->GetSignal()));
165
166 if (!fHistograms[sector])
167 {
168 // not sure if this is still needed, should prevent creation of the histogram in the opened root file
169 gROOT->cd();
170 fHistograms[sector] = new AliTPCRawHistograms(sector);
171 }
172
173 fHistograms[sector]->FillDigit(tpcRawStream);
174 }
c50f9dc0 175 }
dc89d87e 176
177 delete fRawEvent;
178 fRawEvent = 0;
eb884e16 179
180 return kTRUE;
181}
182
183void AliROCRawAnalysisSelector::SlaveTerminate()
184{
185 //
1d7991a5 186 for (Int_t i=0; i<kTPCSectors; i++)
187 if (fHistograms[i])
188 fOutput->Add(fHistograms[i]);
eb884e16 189}
190
191void AliROCRawAnalysisSelector::Terminate()
192{
c50f9dc0 193 AliDebug(AliLog::kInfo, "Terminate....");
194
eb884e16 195 // TODO read from output list for PROOF
196
197 TFile* file = TFile::Open("rocRaw.root", "RECREATE");
198
1d7991a5 199 for (Int_t i=0; i<kTPCSectors; i++)
200 if (fHistograms[i])
201 fHistograms[i]->SaveHistograms();
eb884e16 202
203 file->Close();
1d7991a5 204
205 for (Int_t i=0; i<kTPCSectors; i++)
206 if (fHistograms[i])
207 fHistograms[i]->DrawHistograms();
eb884e16 208}