]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PHOS/PHOSbase/AliPHOSTriggerRawReader.cxx
Reading muon trigger scalers with the DA of the muon trigger and transfer
[u/mrichter/AliRoot.git] / PHOS / PHOSbase / AliPHOSTriggerRawReader.cxx
CommitLineData
e1aec4f9 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 * Class for reading the Trigger Data Stream from Raw.
20 * please read documentation for AliPHOSTriggerRawReader::ReadFromStream .
21 */
22
23
24#include "AliPHOSTriggerRawReader.h"
25
26#include "AliCaloRawStreamV3.h"
27#include "AliPHOSTRURawReader.h"
28
29ClassImp(AliPHOSTriggerRawReader)
30
31
32//________________________________________________________________
33AliPHOSTriggerRawReader::AliPHOSTriggerRawReader()
34 : TObject(),
35 fTRUs()
36{
37 // default constructor.
38
39 // Initialise fTRUs
40 for(Int_t mod=0; mod<kNMods; mod++)
41 for(Int_t row=0; row<kNTRURows; ++row)
42 for(Int_t branch=0; branch<kNBranches; ++branch)
43 fTRUs[mod][row][branch] = 0;
44}
45
46
47//________________________________________________________________
48AliPHOSTriggerRawReader::~AliPHOSTriggerRawReader()
49{
50 // destructor
51
52 for(Int_t mod = 0; mod < kNMods; ++mod)
53 for(Int_t row = 0; row < kNTRURows; ++row)
54 for(Int_t branch = 0; branch < kNBranches; branch++)
55 delete fTRUs[mod][row][branch];
56}
57
58
59//________________________________________________________________
60AliPHOSTRURawReader* AliPHOSTriggerRawReader::GetTRU(Int_t mod, Int_t truRow, Int_t branch)
61{
62 // Get TRU Raw Reader.
63
aab25bc6 64 if (mod<0 || mod>=kNMods) return 0x0;
65 if (truRow<0 || truRow>=kNTRURows) return 0x0;
66 if (branch<0 || branch>=kNBranches) return 0x0;
67
e1aec4f9 68 if( ! fTRUs[mod][truRow][branch] )
69 fTRUs[mod][truRow][branch] = new AliPHOSTRURawReader();
70 return fTRUs[mod][truRow][branch];
71}
72
73
74//________________________________________________________________
75void AliPHOSTriggerRawReader::ReadFromStream(AliCaloRawStreamV3* rawStream)
76{
77 // Give a AliCaloRawStreamV3* to an instance of this class.
78 // It will read from the stream. The stream is passed to 'AliPHOSTRURawReader's
79 // which are accesible through 'AliPHOSTriggerRawReader::GetTRU'.
80 // note that @param rawStream will not be left in the same state in terms of
81 // bunch position, i.e. rawStream->NextBunch() will be called.
82 //
83 // It is up to the user to check that
84 // the is at a channel which is tru data, i.e.:
85 // while (rawStream->NextDDL()) {
86 // while (rawStream->NextChannel()) {
87 // if ( rawStream->IsTRUData() )
88 // triggerReader->ReadFromStream(rawStream);
89 // else
90 // // do something else
91 // }
92 // }
93 // . Other uses will result in undefined behaviour!
94
95 while (rawStream->NextBunch()) {
96 Int_t module = rawStream->GetModule();
97 Int_t rcuRow = rawStream->GetRow();
98 Int_t branch = 1 - rawStream->GetBranch(); // !!! Found this to be necessary, -Henrik Qvigstad <henrik.qvigstad@cern.ch>
99
aab25bc6 100 AliPHOSTRURawReader* reader = GetTRU(module, rcuRow, branch);
101 if (reader) reader->ReadFromStream(rawStream);
e1aec4f9 102 } // end while
103}
104
105//________________________________________________________________
106void AliPHOSTriggerRawReader::Reset()
107{
108 // Reset
109
110 for(Int_t mod = 0; mod < kNMods; ++mod)
111 for(Int_t truRow = 0; truRow < kNTRURows; ++truRow)
112 for(Int_t branch = 0; branch < kNBranches; branch++)
113 if( fTRUs[mod][truRow][branch] )
114 fTRUs[mod][truRow][branch]->Reset();
115}