]>
Commit | Line | Data |
---|---|---|
cbab66dd | 1 | /************************************************************************** |
99388135 | 2 | * This file is property of and copyright by the Experimental Nuclear * |
3 | * Physics Group, Dep. of Physics * | |
4 | * University of Oslo, Norway, 2007 * | |
5 | * * | |
6 | * Author: Per Thomas Hille <perthi@fys.uio.no> for the ALICE HLT Project.* | |
cbab66dd | 7 | * Contributors are mentioned in the code where appropriate. * |
99388135 | 8 | * Please report bugs to perthi@fys.uio.no * |
cbab66dd | 9 | * * |
10 | * Permission to use, copy, modify and distribute this software and its * | |
11 | * documentation strictly for non-commercial purposes is hereby granted * | |
12 | * without fee, provided that the above copyright notice appears in all * | |
13 | * copies and that both the copyright notice and this permission notice * | |
14 | * appear in the supporting documentation. The authors make no claims * | |
15 | * about the suitability of this software for any purpose. It is * | |
16 | * provided "as is" without express or implied warranty. * | |
17 | **************************************************************************/ | |
18 | ||
2b7cf4fb | 19 | #include "AliHLTPHOSRawAnalyzer.h" |
cbab66dd | 20 | #include "AliHLTPHOSRawAnalyzerComponent.h" |
bde48b84 | 21 | #include "AliHLTPHOSRcuCellEnergyDataStruct.h" |
e086ee30 | 22 | #include "AliHLTPHOSMapper.h" |
dbd79fad | 23 | #include "AliHLTPHOSSanityInspector.h" |
24 | #include "AliHLTPHOSBaseline.h" | |
25 | #include "TFile.h" | |
26 | #include "TTree.h" | |
27 | #include "TClonesArray.h" | |
939c67e7 | 28 | #include "AliAltroDecoder.h" // decoder for altro payload |
29 | #include "AliAltroData.h" // container for altro payload | |
30 | #include "AliAltroBunch.h" // container for altro bunches | |
31 | ||
32 | ||
33 | AliHLTPHOSRawAnalyzerComponent::AliHLTPHOSRawAnalyzerComponent():AliHLTPHOSRcuProcessor(), | |
34 | fAnalyzerPtr(0), | |
35 | fSendChannelData(kFALSE), | |
36 | fOutPtr(0), | |
37 | fMapperPtr(0), | |
38 | fUseBaselineSubtraction(false), | |
39 | fDecoderPtr(0), | |
40 | fAltroDataPtr(0), | |
41 | fAltroBunchPtr(0) | |
42 | // fRawMemoryReader(0), fPHOSRawStream(0) | |
cbab66dd | 43 | { |
ab38011b | 44 | //comment |
e086ee30 | 45 | fMapperPtr = new AliHLTPHOSMapper(); |
939c67e7 | 46 | fAltroDataPtr = new AliAltroData(); |
47 | fAltroBunchPtr = new AliAltroBunch(); | |
48 | fDecoderPtr = new AliAltroDecoder(); | |
49 | fSanityInspectorPtr = new AliHLTPHOSSanityInspector(); | |
50 | } | |
51 | ||
2b7cf4fb | 52 | |
2ef3c547 | 53 | |
cbab66dd | 54 | AliHLTPHOSRawAnalyzerComponent::~AliHLTPHOSRawAnalyzerComponent() |
55 | { | |
ab38011b | 56 | //comment |
b60bd496 | 57 | delete fMapperPtr; |
cbab66dd | 58 | } |
59 | ||
2ef3c547 | 60 | |
cbab66dd | 61 | int |
d2a0b488 | 62 | AliHLTPHOSRawAnalyzerComponent::Deinit() |
cbab66dd | 63 | { |
ab38011b | 64 | //comment |
d2a0b488 | 65 | Logging(kHLTLogInfo, "HLT", "PHOS", ",AliHLTPHOSRawAnalyzerComponen Deinit"); |
d2a0b488 | 66 | return 0; |
cbab66dd | 67 | } |
68 | ||
2ef3c547 | 69 | |
9dfd64cf | 70 | const char* |
71 | AliHLTPHOSRawAnalyzerComponent::GetComponentID() | |
72 | { | |
ab38011b | 73 | //comment |
9dfd64cf | 74 | return "AliPhosTestRaw"; |
75 | } | |
ee7849e6 | 76 | |
1c1b3412 | 77 | |
cbab66dd | 78 | void |
ee7849e6 | 79 | AliHLTPHOSRawAnalyzerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) |
cbab66dd | 80 | { |
ab38011b | 81 | //comment |
146c463a | 82 | const AliHLTComponentDataType* pType=fgkInputDataTypes; |
ee7849e6 | 83 | while (pType->fID!=0) { |
84 | list.push_back(*pType); | |
85 | pType++; | |
86 | } | |
cbab66dd | 87 | } |
88 | ||
2ef3c547 | 89 | |
cbab66dd | 90 | AliHLTComponentDataType |
91 | AliHLTPHOSRawAnalyzerComponent::GetOutputDataType() | |
92 | { | |
ab38011b | 93 | //comment |
d504c864 | 94 | return AliHLTPHOSDefinitions::fgkCellEnergyDataType; |
cbab66dd | 95 | } |
96 | ||
d504c864 | 97 | |
cbab66dd | 98 | void |
9dfd64cf | 99 | AliHLTPHOSRawAnalyzerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier ) |
100 | ||
cbab66dd | 101 | { |
ab38011b | 102 | //comment |
ef408bb3 | 103 | constBase = 30; |
dbd79fad | 104 | inputMultiplier = 1.2; |
cbab66dd | 105 | } |
106 | ||
2ef3c547 | 107 | |
939c67e7 | 108 | |
d504c864 | 109 | int |
1804b020 | 110 | AliHLTPHOSRawAnalyzerComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, AliHLTComponentTriggerData& /*trigData*/, |
dbd79fad | 111 | AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks ) |
cbab66dd | 112 | { |
ab38011b | 113 | //comment |
14ff16ed | 114 | UInt_t offset = 0; |
115 | UInt_t mysize = 0; | |
116 | UInt_t tSize = 0; | |
117 | Float_t baseline = 0; | |
53740333 | 118 | AliHLTUInt8_t* outBPtr; |
53740333 | 119 | outBPtr = outputPtr; |
0a211711 | 120 | const AliHLTComponentBlockData* iter = NULL; |
121 | unsigned long ndx; | |
14ff16ed | 122 | Int_t *rawDataBufferPos = (Int_t *)outputPtr; |
afc526a2 | 123 | |
dbd79fad | 124 | for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ ) |
125 | { | |
939c67e7 | 126 | Int_t tmpChannelCnt = 0; |
0a211711 | 127 | iter = blocks+ndx; |
53740333 | 128 | mysize = 0; |
129 | offset = tSize; | |
dbd79fad | 130 | Int_t crazyness = 0; |
14ff16ed | 131 | mysize += sizeof(AliHLTPHOSRcuCellEnergyDataStruct); |
132 | ||
d504c864 | 133 | if ( iter->fDataType != AliHLTPHOSDefinitions::fgkDDLPackedRawDataType ) |
0a211711 | 134 | { |
dbd79fad | 135 | continue; |
dbd79fad | 136 | } |
dbd79fad | 137 | if( fPhosEventCount%100 == 0) |
138 | { | |
139 | cout << "event count = "<< fPhosEventCount <<endl; | |
dbd79fad | 140 | } |
dbd79fad | 141 | |
dbd79fad | 142 | fDecoderPtr->SetMemory(reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize); |
e086ee30 | 143 | fDecoderPtr->Decode(); |
e086ee30 | 144 | fOutPtr = (AliHLTPHOSRcuCellEnergyDataStruct*)outBPtr; |
0d7c9b63 | 145 | fOutPtr->fRcuX = fRcuX; |
146 | fOutPtr->fRcuZ = fRcuZ; | |
d2b84453 | 147 | fOutPtr->fModuleID =fModuleID; |
14ff16ed | 148 | rawDataBufferPos += (mysize)/sizeof(Int_t); |
149 | ||
e086ee30 | 150 | while( fDecoderPtr->NextChannel(fAltroDataPtr) == true ) |
151 | { | |
939c67e7 | 152 | if(fAltroDataPtr->GetDataSize() != (fNTotalSamples +2)) |
dbd79fad | 153 | { |
939c67e7 | 154 | cout << "Error, fDataSize = " << fAltroDataPtr->GetDataSize() << endl; |
dbd79fad | 155 | continue; |
156 | } | |
2374af72 | 157 | else |
158 | { | |
159 | // cout << "Info, fDataSize = " << fAltroDataPtr->GetDataSize() << endl; | |
160 | } | |
161 | ||
939c67e7 | 162 | crazyness = fSanityInspectorPtr->CheckInsanity(fAltroDataPtr->GetData(), fAltroDataPtr->GetDataSize() - 2); |
939c67e7 | 163 | fAnalyzerPtr->SetData(fAltroDataPtr->GetData()); |
164 | fAnalyzerPtr->Evaluate(0, fAltroDataPtr->GetDataSize() -2); | |
14ff16ed | 165 | |
af6a2273 | 166 | fOutPtr->fValidData[tmpChannelCnt].fZ = fMapperPtr->fHw2geomapPtr[fAltroDataPtr->GetHadd()].fZRow; |
167 | fOutPtr->fValidData[tmpChannelCnt].fX = fMapperPtr->fHw2geomapPtr[fAltroDataPtr->GetHadd()].fXCol; | |
168 | fOutPtr->fValidData[tmpChannelCnt].fGain = fMapperPtr->fHw2geomapPtr[fAltroDataPtr->GetHadd()].fGain; | |
939c67e7 | 169 | |
dbd79fad | 170 | if(fUseBaselineSubtraction) |
939c67e7 | 171 | { |
172 | baseline = fBaselines[fOutPtr->fValidData[tmpChannelCnt].fX][fOutPtr->fValidData[tmpChannelCnt].fZ][ fOutPtr->fValidData[tmpChannelCnt].fGain]; | |
173 | } | |
174 | ||
dbd79fad | 175 | fOutPtr->fValidData[tmpChannelCnt].fEnergy = (float)fAnalyzerPtr->GetEnergy() - baseline; |
e086ee30 | 176 | fOutPtr->fValidData[tmpChannelCnt].fTime = (float)fAnalyzerPtr->GetTiming(); |
dbd79fad | 177 | fOutPtr->fValidData[tmpChannelCnt].fCrazyness = (int)crazyness; |
14ff16ed | 178 | fOutPtr->fValidData[tmpChannelCnt].fNSamples = fNTotalSamples; |
179 | fOutPtr->fValidData[tmpChannelCnt].fData = rawDataBufferPos; | |
939c67e7 | 180 | const UInt_t *tmpData = fAltroDataPtr->GetData(); |
181 | ||
dbd79fad | 182 | for(Int_t sample = 0; sample < fNTotalSamples; sample++) |
183 | { | |
939c67e7 | 184 | (fOutPtr->fValidData[tmpChannelCnt].fData)[sample] = tmpData[sample] - (int)baseline; |
dbd79fad | 185 | } |
14ff16ed | 186 | |
187 | UInt_t tmpSize = sizeof(Int_t)*(fOutPtr->fValidData[tmpChannelCnt].fNSamples); | |
188 | mysize += sizeof(Int_t)*(fOutPtr->fValidData[tmpChannelCnt].fNSamples); | |
189 | mysize += tmpSize; | |
190 | rawDataBufferPos += tmpSize/sizeof(Int_t); | |
e086ee30 | 191 | tmpChannelCnt ++; |
e086ee30 | 192 | } |
14ff16ed | 193 | |
194 | fOutPtr->fCnt = tmpChannelCnt; | |
195 | fOutPtr->fSize = mysize; | |
03b3d247 | 196 | |
e086ee30 | 197 | AliHLTComponentBlockData bd; |
198 | FillBlockData( bd ); | |
199 | bd.fOffset = offset; | |
200 | bd.fSize = mysize; | |
939c67e7 | 201 | |
e086ee30 | 202 | bd.fDataType = AliHLTPHOSDefinitions::fgkCellEnergyDataType; |
203 | bd.fSpecification = 0xFFFFFFFF; | |
204 | outputBlocks.push_back( bd ); | |
939c67e7 | 205 | |
e086ee30 | 206 | tSize += mysize; |
207 | outBPtr += mysize; | |
208 | ||
209 | if( tSize > size ) | |
210 | { | |
6e709a0d | 211 | cout <<"kHLTLogFatal, HLT::AliHLTPHOSRawAnalyzerComponent::DoEvent Too much dataData written over allowed buffer. Amount written:" |
e086ee30 | 212 | << tSize << " allowed" << size << endl; |
213 | Logging( kHLTLogFatal, "HLT::AliHLTPHOSRawAnalyzerComponent::DoEvent", "Too much data", | |
214 | "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu." | |
215 | , tSize, size ); | |
216 | return EMSGSIZE; | |
217 | } | |
dbd79fad | 218 | |
e086ee30 | 219 | } |
e086ee30 | 220 | |
d2a0b488 | 221 | fPhosEventCount++; |
2b7cf4fb | 222 | |
223 | if(fPrintInfo == kTRUE) | |
224 | { | |
14ff16ed | 225 | if(fPhosEventCount%fPrintInfoFrequncy == 0) |
2b7cf4fb | 226 | { |
d2a0b488 | 227 | cout <<"Analyzing event " << fPhosEventCount << "for Equippment " << fkEquippmentID << endl; |
2b7cf4fb | 228 | } |
229 | } | |
e086ee30 | 230 | |
2947a32c | 231 | return 0; |
232 | }//end DoEvent | |
e086ee30 | 233 | |
0a211711 | 234 | |
14ff16ed | 235 | |
0a211711 | 236 | int |
237 | AliHLTPHOSRawAnalyzerComponent::DoInit( int argc, const char** argv ) | |
238 | { | |
939c67e7 | 239 | //See base class for documentation |
2ef3c547 | 240 | cout <<"AliHLTPHOSRawAnalyzerComponent::DoInit( int argc, const char** argv ) "<< endl; |
939c67e7 | 241 | |
2b7cf4fb | 242 | fSendChannelData = kFALSE; |
243 | fPrintInfo = kFALSE; | |
2947a32c | 244 | Reset(); |
2b7cf4fb | 245 | int iResult=0; |
246 | TString argument=""; | |
d2a0b488 | 247 | iResult = ScanArguments(argc, argv); |
2b7cf4fb | 248 | |
dbd79fad | 249 | for(int i = 0; i < argc; i++) |
250 | { | |
251 | if(!strcmp("-baselinefile", argv[i])) | |
252 | { | |
253 | cout << "Getting baselines from " << argv[i+1] << endl; | |
254 | SetBaselines(argv[i+1]); | |
255 | } | |
256 | } | |
dbd79fad | 257 | |
d2a0b488 | 258 | if(fIsSetEquippmentID == kFALSE) |
2b7cf4fb | 259 | { |
e56d0892 | 260 | cout << "The argument equippmentID is not set: set it with a component argumet like this: -equippmentID <number>" << endl; |
2b7cf4fb | 261 | Logging( kHLTLogFatal, "HLT::AliHLTPHOSRcuHistogramProducerComponent::DoInt( int argc, const char** argv )", "Missing argument", |
262 | "The argument equippmentID is not set: set it with a component argumet like this: -equippmentID <number>"); | |
e086ee30 | 263 | iResult = -3; |
2b7cf4fb | 264 | } |
d2a0b488 | 265 | else |
266 | { | |
2ef3c547 | 267 | iResult = 0; |
268 | // fRawMemoryReader->SetEquipmentID(fkEquippmentID); | |
d2a0b488 | 269 | } |
939c67e7 | 270 | |
d2a0b488 | 271 | return iResult; |
0a211711 | 272 | } |
9dfd64cf | 273 | |
9dfd64cf | 274 | |
2947a32c | 275 | void |
276 | AliHLTPHOSRawAnalyzerComponent::Reset() | |
277 | { | |
ab38011b | 278 | //comment |
1804b020 | 279 | for(unsigned int mod = 0; mod < N_MODULES; mod ++) |
9dfd64cf | 280 | { |
1804b020 | 281 | for(unsigned int row = 0; row < N_ZROWS_MOD; row ++) |
2947a32c | 282 | { |
1804b020 | 283 | for(unsigned int col = 0; col < N_XCOLUMNS_MOD; col ++) |
2947a32c | 284 | { |
1804b020 | 285 | for(unsigned int gain = 0; gain < N_GAINS; gain ++ ) |
2947a32c | 286 | { |
287 | fMaxValues[mod][row][col][gain] = 0; | |
288 | } | |
289 | } | |
290 | } | |
291 | } | |
dbd79fad | 292 | |
2b7cf4fb | 293 | ResetDataPtr(0, ALTRO_MAX_SAMPLES); |
432edd34 | 294 | |
295 | } // end Reset | |
296 | ||
e086ee30 | 297 | |
2947a32c | 298 | void |
432edd34 | 299 | AliHLTPHOSRawAnalyzerComponent::ResetDataPtr(int startindex, int sampleCnt) |
2947a32c | 300 | { |
ab38011b | 301 | //comment |
432edd34 | 302 | for(int i = startindex ; i< sampleCnt; i++) |
2947a32c | 303 | { |
304 | fTmpChannelData[i] = 0; | |
305 | } | |
cbab66dd | 306 | } |
ef408bb3 | 307 | |
14ff16ed | 308 | |
dbd79fad | 309 | void |
310 | AliHLTPHOSRawAnalyzerComponent::SetBaselines(const char* file) | |
311 | { | |
ab38011b | 312 | //comment |
dbd79fad | 313 | fUseBaselineSubtraction = true; |
314 | AliHLTPHOSBaseline *baseline = 0; | |
315 | TFile *baselineFile = TFile::Open(file); | |
316 | TTree *baselineTree = (TTree*)baselineFile->Get("baselineTree"); | |
317 | TClonesArray *baselineArray = new TClonesArray("AliHLTPHOSBaseline", 7168); | |
318 | baselineTree->SetBranchAddress("Baselines", &baselineArray); | |
319 | baselineTree->GetEntry(0); | |
320 | for(Int_t i = 0; i < baselineArray->GetEntriesFast(); i++) | |
321 | { | |
322 | baseline = (AliHLTPHOSBaseline*)baselineArray->At(i); | |
1804b020 | 323 | if((baseline->GetX() < (Int_t)((fRcuX + 1)*N_XCOLUMNS_RCU)) && (baseline->GetX() >= (Int_t)(fRcuX*N_XCOLUMNS_RCU))) |
dbd79fad | 324 | { |
1804b020 | 325 | if((baseline->GetZ() < (Int_t)((fRcuZ + 1)*N_ZROWS_RCU)) && (baseline->GetZ() >= (Int_t)(fRcuZ*N_ZROWS_RCU))) |
dbd79fad | 326 | { |
327 | fBaselines[baseline->GetX() - fRcuX*N_XCOLUMNS_RCU][baseline->GetZ() - fRcuZ*N_ZROWS_RCU][baseline->GetGain()] = baseline->GetBaseline(); | |
328 | // cout << fBaselines[baseline->GetX() - fRcuX*N_XCOLUMNS_RCU][baseline->GetZ() - fRcuZ*N_ZROWS_RCU][baseline->GetGain()] << endl; | |
329 | } | |
330 | } | |
331 | } | |
332 | baselineFile->Close(); | |
333 | delete baselineFile; | |
334 | baselineFile = 0; | |
335 | } |