Line data Source code
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 :
29 22 : ClassImp(AliPHOSTriggerRawReader)
30 :
31 :
32 : //________________________________________________________________
33 : AliPHOSTriggerRawReader::AliPHOSTriggerRawReader()
34 4 : : TObject(),
35 4 : fTRUs()
36 20 : {
37 : // default constructor.
38 :
39 : // Initialise fTRUs
40 48 : for(Int_t mod=0; mod<kNMods; mod++)
41 200 : for(Int_t row=0; row<kNTRURows; ++row)
42 480 : for(Int_t branch=0; branch<kNBranches; ++branch)
43 160 : fTRUs[mod][row][branch] = 0;
44 8 : }
45 :
46 :
47 : //________________________________________________________________
48 : AliPHOSTriggerRawReader::~AliPHOSTriggerRawReader()
49 24 : {
50 : // destructor
51 :
52 48 : for(Int_t mod = 0; mod < kNMods; ++mod)
53 200 : for(Int_t row = 0; row < kNTRURows; ++row)
54 480 : for(Int_t branch = 0; branch < kNBranches; branch++)
55 288 : delete fTRUs[mod][row][branch];
56 12 : }
57 :
58 :
59 : //________________________________________________________________
60 : AliPHOSTRURawReader* AliPHOSTriggerRawReader::GetTRU(Int_t mod, Int_t truRow, Int_t branch)
61 : {
62 : // Get TRU Raw Reader.
63 :
64 256 : if (mod<0 || mod>=kNMods) return 0x0;
65 128 : if (truRow<0 || truRow>=kNTRURows) return 0x0;
66 128 : if (branch<0 || branch>=kNBranches) return 0x0;
67 :
68 128 : if( ! fTRUs[mod][truRow][branch] )
69 256 : fTRUs[mod][truRow][branch] = new AliPHOSTRURawReader();
70 128 : return fTRUs[mod][truRow][branch];
71 128 : }
72 :
73 :
74 : //________________________________________________________________
75 : void 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 0 : while (rawStream->NextBunch()) {
96 0 : Int_t module = rawStream->GetModule();
97 0 : Int_t rcuRow = rawStream->GetRow();
98 0 : Int_t branch = 1 - rawStream->GetBranch(); // !!! Found this to be necessary, -Henrik Qvigstad <henrik.qvigstad@cern.ch>
99 :
100 0 : AliPHOSTRURawReader* reader = GetTRU(module, rcuRow, branch);
101 0 : if (reader) reader->ReadFromStream(rawStream);
102 : } // end while
103 0 : }
104 :
105 : //________________________________________________________________
106 : void AliPHOSTriggerRawReader::Reset()
107 : {
108 : // Reset
109 :
110 52 : for(Int_t mod = 0; mod < kNMods; ++mod)
111 200 : for(Int_t truRow = 0; truRow < kNTRURows; ++truRow)
112 480 : for(Int_t branch = 0; branch < kNBranches; branch++)
113 160 : if( fTRUs[mod][truRow][branch] )
114 0 : fTRUs[mod][truRow][branch]->Reset();
115 4 : }
|