]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/PHOS/AliHLTPHOSDigitMakerComponent.cxx
Updated DA for mapping - MON
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSDigitMakerComponent.cxx
1  /**************************************************************************
2  * This file is property of and copyright by the ALICE HLT Project        *
3  * All rights reserved.                                                   *
4  *                                                                        *
5  * Primary Authors: Oystein Djuvsland                                     *
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 #include "AliHLTPHOSDigitMakerComponent.h"
17 #include "AliHLTPHOSDigitMaker.h"
18 #include "TTree.h"
19 #include "AliHLTPHOSProcessor.h"
20 #include "AliHLTPHOSRcuCellEnergyDataStruct.h"
21 #include "AliHLTPHOSDigitContainerDataStruct.h"
22 #include "AliHLTPHOSChannelDataHeaderStruct.h"
23 #include "TClonesArray.h"
24 #include "TFile.h"
25 #include <sys/stat.h>
26 #include <sys/types.h>
27
28
29 /** 
30  * @file   AliHLTPHOSDigitMakerComponent.cxx
31  * @author Oystein Djuvsland
32  * @date   
33  * @brief  A digit maker component for PHOS HLT
34 */
35
36 // see below for class documentation
37 // or
38 // refer to README to build package
39 // or
40 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
41
42
43 const AliHLTComponentDataType AliHLTPHOSDigitMakerComponent::fgkInputDataTypes[]={kAliHLTVoidDataType,{0,"",""}};
44
45 AliHLTPHOSDigitMakerComponent gAliHLTPHOSDigitMakerComponent;
46
47 AliHLTPHOSDigitMakerComponent::AliHLTPHOSDigitMakerComponent() :
48   AliHLTPHOSProcessor(),
49   fDigitMakerPtr(0),
50   fDigitContainerPtr(0)
51   //  fEvtCnt(0)
52 {
53   //see header file for documentation
54 }
55
56 AliHLTPHOSDigitMakerComponent::~AliHLTPHOSDigitMakerComponent()
57 {
58   //see header file for documentation
59 }
60
61 int 
62 AliHLTPHOSDigitMakerComponent::Deinit()
63
64   //see header file for documentation
65   if(fDigitMakerPtr)
66     {
67       delete fDigitMakerPtr;
68       fDigitMakerPtr = 0;
69     }
70   return 0;
71 }
72
73 const char*
74 AliHLTPHOSDigitMakerComponent::GetComponentID()
75 {
76   //see header file for documentation
77   return "PhosDigitMaker";
78 }
79
80
81 void
82 AliHLTPHOSDigitMakerComponent::GetInputDataTypes(vector<AliHLTComponentDataType>& list)
83
84   //see header file for documentation
85   list.clear();
86   list.push_back(AliHLTPHOSDefinitions::fgkChannelDataType);
87
88 //   const AliHLTComponentDataType* pType=fgkInputDataTypes;
89 //   while (pType->fID!=0) {
90 //     list.push_back(*pType); 
91 //     pType++;
92 //   }
93 }
94
95 AliHLTComponentDataType 
96 AliHLTPHOSDigitMakerComponent::GetOutputDataType()
97 {
98   //see header file for documentation
99   return AliHLTPHOSDefinitions::fgkDigitDataType;
100 }
101
102
103 void 
104 AliHLTPHOSDigitMakerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
105 {
106   //see header file for documentation
107   constBase = sizeof(AliHLTPHOSDigitContainerDataStruct);
108   inputMultiplier = 1;
109 }
110
111 int 
112 AliHLTPHOSDigitMakerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
113                                         AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
114                                         std::vector<AliHLTComponentBlockData>& outputBlocks)
115 {
116   //see header file for documentation
117   UInt_t tSize            = 0;
118   UInt_t offset           = 0; 
119   UInt_t mysize           = 0;
120   Int_t digitCount = 0;
121
122   AliHLTUInt8_t* outBPtr;
123   outBPtr = outputPtr;
124   const AliHLTComponentBlockData* iter = 0; 
125   unsigned long ndx; 
126
127   UInt_t specification = 0;
128   AliHLTPHOSChannelDataHeaderStruct* tmpChannelData = 0;
129   
130   fDigitMakerPtr->SetDigitContainerStruct(reinterpret_cast<AliHLTPHOSDigitContainerDataStruct*>(outputPtr));
131
132   for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
133     {
134       iter = blocks+ndx;
135       
136       if(iter->fDataType != AliHLTPHOSDefinitions::fgkChannelDataType)
137         {
138           HLTDebug("Data block is not of type fgkChannelDataType");
139           continue;
140         }
141       if(iter == 0) continue;
142       if((reinterpret_cast<AliHLTPHOSChannelDataHeaderStruct*>(iter->fPtr))->fNChannels == 0) continue;
143       specification = specification|iter->fSpecification;
144       tmpChannelData = reinterpret_cast<AliHLTPHOSChannelDataHeaderStruct*>(iter->fPtr);
145     
146       digitCount += fDigitMakerPtr->MakeDigits(tmpChannelData);
147     }
148   
149   //  mysize = 0;
150   //offset = tSize;
151       
152   mysize += sizeof(AliHLTPHOSDigitContainerDataStruct);
153   (reinterpret_cast<AliHLTPHOSDigitContainerDataStruct*>(outputPtr))->fNDigits = digitCount;
154   AliHLTComponentBlockData bd;
155   FillBlockData( bd );
156   bd.fOffset = offset;
157   bd.fSize = mysize;
158   bd.fDataType = AliHLTPHOSDefinitions::fgkDigitDataType;
159   bd.fSpecification = specification;
160   outputBlocks.push_back(bd);
161        
162 //   tSize += mysize;
163 //   outputPtr += mysize;
164
165   if( tSize > size )
166     {
167       Logging( kHLTLogFatal, "HLT::AliHLTPHOSDigitMakerComponent::DoEvent", "Too much data", "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu.", tSize, size );
168       return EMSGSIZE;
169     }
170
171   fDigitMakerPtr->Reset();
172
173   size = mysize; 
174
175   return 0;
176 }
177
178
179 int
180 AliHLTPHOSDigitMakerComponent::DoInit(int argc, const char** argv )
181 {
182   //see header file for documentation
183
184   fDigitMakerPtr = new AliHLTPHOSDigitMaker();
185   
186   for(int i = 0; i < argc; i++)
187     {
188       if(!strcmp("-rmsfilepath", argv[i]))
189         {
190           fDigitMakerPtr->SetDigitThresholds(argv[i+1], 3);
191         }
192       if(!strcmp("-lowgainfactor", argv[i]))
193         {
194           fDigitMakerPtr->SetGlobalLowGainFactor(atof(argv[i+1]));
195         }
196       if(!strcmp("-highgainfactor", argv[i]))
197         {
198           fDigitMakerPtr->SetGlobalHighGainFactor(atof(argv[i+1]));
199         }
200       if(!strcmp("-digitthresholds", argv[i]))
201         {
202           fDigitMakerPtr->SetDigitThresholds(atof(argv[i+1]), atof(argv[i+2]));
203         }
204     }
205  
206   //fDigitMakerPtr->SetDigitThreshold(2);
207
208   return 0;
209 }
210
211 AliHLTComponent*
212 AliHLTPHOSDigitMakerComponent::Spawn()
213 {
214   //see header file for documentation
215   return new AliHLTPHOSDigitMakerComponent();
216 }