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