]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/MUON/AliHLTMUONProcessor.h
Fixing some documentation and comments.
[u/mrichter/AliRoot.git] / HLT / MUON / AliHLTMUONProcessor.h
1 #ifndef ALIHLTMUONPROCESSOR_H
2 #define ALIHLTMUONPROCESSOR_H
3 /* This file is property of and copyright by the ALICE HLT Project        *
4  * ALICE Experiment at CERN, All rights reserved.                         *
5  * See cxx source for full Copyright notice                               */
6
7 /* $Id: $ */
8
9 ///
10 /// @file   AliHLTMUONProcessor.h
11 /// @author Artur Szostak <artursz@iafrica.com>
12 /// @date   2007-12-12
13 /// @brief  Declaration of a common processor component abstract interface for dHLT components.
14 ///
15
16 #include "AliHLTProcessor.h"
17 #include "AliHLTMUONDataBlockReader.h"
18 #include "AliHLTMUONUtils.h"
19
20 /**
21  * @class AliHLTMUONProcessor
22  * This component class is an abstract base class for dHLT components.
23  * Some common methods useful to all dHLT specific components are implemented
24  * by this class.
25  */
26 class AliHLTMUONProcessor : public AliHLTProcessor
27 {
28 public:
29         /// Default constructor.
30         AliHLTMUONProcessor() : AliHLTProcessor() {}
31         /// Default destructor.
32         virtual ~AliHLTMUONProcessor() {}
33
34 protected:
35
36         /**
37          * Method to check the block structure and log appropriate error messages.
38          * If a problem is found with the data block then an appropriate HLT error
39          * message is logged and the method returns false.
40          * \param block  The lightweight block reader whose data block should be checked.
41          * \param name  A string containing a descriptive name of the data block
42          *          type. This name is used in the logged error messages.
43          * \returns  true if the structure of the block looks OK and false otherwise.
44          * \note  The BlockType should be a class deriving from AliHLTMUONDataBlockReader.
45          */
46         template <class BlockType>
47         bool BlockStructureOk(const BlockType& block, const char* name) const;
48         
49         /// Checks the structure of a trigger records data block.
50         bool BlockStructureOk(const AliHLTMUONTriggerRecordsBlockReader& block) const
51         {
52                 return BlockStructureOk(block, "trigger records");
53         }
54         
55         /// Checks the structure of a trigger records debug information data block.
56         bool BlockStructureOk(const AliHLTMUONTrigRecsDebugBlockReader& block) const
57         {
58                 return BlockStructureOk(block, "trigger records debug information");
59         }
60
61         /// Checks the structure of a reconstructed hits data block.
62         bool BlockStructureOk(const AliHLTMUONRecHitsBlockReader& block) const
63         {
64                 return BlockStructureOk(block, "reconstructed hits");
65         }
66         
67         /// Checks the structure of a clusters data block.
68         bool BlockStructureOk(const AliHLTMUONClustersBlockReader& block) const
69         {
70                 return BlockStructureOk(block, "clusters");
71         }
72         
73         /// Checks the structure of a ADC channels data block.
74         bool BlockStructureOk(const AliHLTMUONChannelsBlockReader& block) const
75         {
76                 return BlockStructureOk(block, "channels");
77         }
78
79         /// Checks the structure of a Manso tracks data block.
80         bool BlockStructureOk(const AliHLTMUONMansoTracksBlockReader& block) const
81         {
82                 return BlockStructureOk(block, "Manso tracks");
83         }
84         
85         /// Checks the structure of a Manso track candidates data block.
86         bool BlockStructureOk(const AliHLTMUONMansoCandidatesBlockReader& block) const
87         {
88                 return BlockStructureOk(block, "Manso track candidates");
89         }
90
91         /// Checks the structure of a single track trigger decision data block.
92         bool BlockStructureOk(const AliHLTMUONSinglesDecisionBlockReader& block) const
93         {
94                 return BlockStructureOk(block, "singles decision");
95         }
96
97         /// Checks the structure of a track pairs trigger decision data block.
98         bool BlockStructureOk(const AliHLTMUONPairsDecisionBlockReader& block) const
99         {
100                 return BlockStructureOk(block, "pairs decision");
101         }
102         
103 private:
104
105         // Do not allow copying of this class.
106         AliHLTMUONProcessor(const AliHLTMUONProcessor& /*obj*/);
107         AliHLTMUONProcessor& operator = (const AliHLTMUONProcessor& /*obj*/);
108         
109         ClassDef(AliHLTMUONProcessor, 0)  // Abstract base class for dHLT specific components.
110 };
111
112 //______________________________________________________________________________
113
114 template <class BlockType>
115 bool AliHLTMUONProcessor::BlockStructureOk(const BlockType& block, const char* name) const
116 {
117         /// Performs basic checks to see if the input data block structure is OK,
118         /// that it is not corrupt, too short etc...
119         
120         if (not block.BufferSizeOk())
121         {
122                 size_t headerSize = sizeof(typename BlockType::HeaderType);
123                 if (block.BufferSize() < headerSize)
124                 {
125                         HLTError("Received a %s data block with a size of %d bytes,"
126                                 " which is smaller than the minimum valid header size of %d bytes."
127                                 " The block must be corrupt.",
128                                 name, block.BufferSize(), headerSize
129                         );
130                         return false;
131                 }
132                 
133                 size_t expectedWidth = sizeof(typename BlockType::ElementType);
134                 if (block.CommonBlockHeader().fRecordWidth != expectedWidth)
135                 {
136                         HLTError("Received a %s data block with a record"
137                                 " width of %d bytes, but the expected value is %d bytes."
138                                 " The block might be corrupt.",
139                                 name,
140                                 block.CommonBlockHeader().fRecordWidth,
141                                 expectedWidth
142                         );
143                         return false;
144                 }
145                 
146                 HLTError("Received a %s data block with a size of %d bytes,"
147                         " but the block header claims the block should be %d bytes."
148                         " The block might be corrupt.",
149                         name, block.BufferSize(), block.BytesUsed()
150                 );
151                 return false;
152         }
153         
154         AliHLTMUONUtils::WhyNotValid reason;
155         if (not AliHLTMUONUtils::HeaderOk(block.BlockHeader(), &reason))
156         {
157                 HLTError("Received a %s data block which might be corrupt. %s",
158                         name, AliHLTMUONUtils::FailureReasonToMessage(reason)
159                 );
160                 return false;
161         }
162         
163         return true;
164 }
165
166 #endif // ALIHLTMUONPROCESSOR_H