]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PHOS/AliPHOSTriggerRawReader.cxx
PHOS trigger information in the ESD.
[u/mrichter/AliRoot.git] / PHOS / AliPHOSTriggerRawReader.cxx
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 ClassImp(AliPHOSTriggerRawReader)
30
31
32 //________________________________________________________________
33 AliPHOSTriggerRawReader::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 //________________________________________________________________
48 AliPHOSTriggerRawReader::~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 //________________________________________________________________
60 AliPHOSTRURawReader* AliPHOSTriggerRawReader::GetTRU(Int_t mod, Int_t truRow, Int_t branch)
61 {
62   // Get TRU Raw Reader.
63
64   if( ! fTRUs[mod][truRow][branch] )
65     fTRUs[mod][truRow][branch] = new AliPHOSTRURawReader();
66   return fTRUs[mod][truRow][branch];
67 }
68  
69
70 //________________________________________________________________
71 void AliPHOSTriggerRawReader::ReadFromStream(AliCaloRawStreamV3* rawStream)
72 {
73   // Give a AliCaloRawStreamV3* to an instance of this class.
74   // It will read from the stream. The stream is passed to 'AliPHOSTRURawReader's
75   // which are accesible through 'AliPHOSTriggerRawReader::GetTRU'.
76   // note that @param rawStream will not be left in the same state in terms of
77   // bunch position, i.e. rawStream->NextBunch() will be called.
78   //
79   // It is up to the user to check that
80   // the is at a channel which is tru data, i.e.:
81   //   while (rawStream->NextDDL()) {
82   //     while (rawStream->NextChannel()) {
83   //       if ( rawStream->IsTRUData() ) 
84   //      triggerReader->ReadFromStream(rawStream);
85   //       else
86   //      // do something else
87   //     }
88   //   } 
89   // . Other uses will result in undefined behaviour!
90
91   while (rawStream->NextBunch()) {
92     Int_t module = rawStream->GetModule();
93     Int_t rcuRow = rawStream->GetRow();
94     Int_t branch = 1 - rawStream->GetBranch(); // !!! Found this to be necessary, -Henrik Qvigstad <henrik.qvigstad@cern.ch>
95     
96     GetTRU(module, rcuRow, branch)->ReadFromStream(rawStream);
97   } // end while 
98 }
99
100 //________________________________________________________________
101 void AliPHOSTriggerRawReader::Reset()
102 {
103   // Reset
104
105   for(Int_t mod = 0; mod < kNMods; ++mod)
106     for(Int_t truRow = 0; truRow < kNTRURows; ++truRow)
107       for(Int_t branch = 0; branch < kNBranches; branch++)
108         if( fTRUs[mod][truRow][branch] )
109           fTRUs[mod][truRow][branch]->Reset();
110 }