1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 ////////////////////////////////////
18 /// MUON Digit maker from rawdata in ALICE-MUON
19 /// Using new interface with AliMUONRawStreamTracker(Trigger)
20 /// (New interface of AliMUONRawReader class)
21 /// Class version 1 (further details could be found in Alice-note)
23 /// Implemented non-constant buspatch numbers for tracking
24 /// with correct DDL id (first guess)
25 /// (Ch. Finck, dec 2005)
29 /// Using real mapping for tracker
30 /// Indranil Das (Adapted for runloader: Ch. Finck) july 05
31 /// Add reader for scaler trigger events
32 /// Use memcpy instead of assignment elt by elt
33 /// (Ch. Finck, Jan 06)
35 ////////////////////////////////////
40 #include <TClonesArray.h>
42 #include "AliRawReader.h"
43 #include "AliRawDataHeader.h"
47 #include "AliMpBusPatch.h"
49 #include "AliMUONDigitMaker.h"
50 #include "AliMUONDigit.h"
52 #include "AliMUONConstants.h"
53 #include "AliMUONData.h"
55 #include "AliMUONRawStreamTracker.h"
56 #include "AliMUONDDLTracker.h"
57 #include "AliMUONDspHeader.h"
58 #include "AliMUONBlockHeader.h"
59 #include "AliMUONBusStruct.h"
61 #include "AliMUONRawStreamTrigger.h"
62 #include "AliMUONDDLTrigger.h"
63 #include "AliMUONDarcHeader.h"
64 #include "AliMUONRegHeader.h"
65 #include "AliMUONLocalStruct.h"
67 #include "AliMUONLocalTrigger.h"
68 #include "AliMUONGlobalTrigger.h"
70 #include "AliMpSegFactory.h"
71 #include "AliMpVSegmentation.h"
73 #include "AliMpDEManager.h"
75 ClassImp(AliMUONDigitMaker) // Class implementation in ROOT context
76 //__________________________________________________________________________
77 AliMUONDigitMaker::AliMUONDigitMaker(AliMUONData* data)
80 fSegFactory(new AliMpSegFactory()),
81 fBusPatchManager(new AliMpBusPatch()),
83 fRawStreamTracker(new AliMUONRawStreamTracker()),
84 fRawStreamTrigger(new AliMUONRawStreamTrigger()),
85 fDigit(new AliMUONDigit()),
86 fLocalTrigger(new AliMUONLocalTrigger()),
87 fGlobalTrigger(new AliMUONGlobalTrigger()),
93 // ctor with AliMUONData as argument
99 // Standard Constructor
102 fBusPatchManager->ReadBusPatchFile();
105 fTrackerTimer.Start(kTRUE); fTrackerTimer.Stop();
106 fTriggerTimer.Start(kTRUE); fTriggerTimer.Stop();
107 fMappingTimer.Start(kTRUE); fMappingTimer.Stop();
111 //__________________________________________________________________________
112 AliMUONDigitMaker::AliMUONDigitMaker()
117 fScalerEvent(kFALSE),
118 fRawStreamTracker(0),
119 fRawStreamTrigger(0),
128 // Default Constructor
131 fTrackerTimer.Start(kTRUE); fTrackerTimer.Stop();
132 fTriggerTimer.Start(kTRUE); fTriggerTimer.Stop();
133 fMappingTimer.Start(kTRUE); fMappingTimer.Stop();
137 //__________________________________________________________________________
138 AliMUONDigitMaker::~AliMUONDigitMaker()
142 // and time processing measure
146 delete fRawStreamTracker;
147 delete fRawStreamTrigger;
150 delete fLocalTrigger;
151 delete fGlobalTrigger;
153 delete fBusPatchManager;
155 AliInfo(Form("Execution time for MUON tracker : R:%.2fs C:%.2fs",
156 fTrackerTimer.RealTime(),fTrackerTimer.CpuTime()));
157 AliInfo(Form(" Execution time for MUON tracker (mapping calls part) "
159 fMappingTimer.RealTime(),fMappingTimer.CpuTime()));
160 AliInfo(Form("Execution time for MUON trigger : R:%.2fs C:%.2fs",
161 fTriggerTimer.RealTime(),fTriggerTimer.CpuTime()));
166 //____________________________________________________________________
167 Int_t AliMUONDigitMaker::Raw2Digits(AliRawReader* rawReader)
169 // Main method to creates digit
174 ReadTrackerDDL(rawReader);
177 ReadTriggerDDL(rawReader);
183 //____________________________________________________________________
184 Int_t AliMUONDigitMaker::ReadTrackerDDL(AliRawReader* rawReader)
187 // reading tracker DDL
188 // filling the TClonesArray in MUONData
190 fTrackerTimer.Start(kFALSE);
200 AliMUONDDLTracker* ddlTracker = 0x0;
201 AliMUONBlockHeader* blkHeader = 0x0;
202 AliMUONDspHeader* dspHeader = 0x0;
203 AliMUONBusStruct* busStruct = 0x0;
206 fRawStreamTracker->SetReader(rawReader);
208 while(fRawStreamTracker->NextDDL()) {
210 ddlTracker = fRawStreamTracker->GetDDLTracker();
212 Int_t nBlock = ddlTracker->GetBlkHeaderEntries();
213 for(Int_t iBlock = 0; iBlock < nBlock ;iBlock++){
215 blkHeader = ddlTracker->GetBlkHeaderEntry(iBlock);
217 Int_t nDsp = blkHeader->GetDspHeaderEntries();
219 for(Int_t iDsp = 0; iDsp < nDsp ;iDsp++){ //DSP loop
221 dspHeader = blkHeader->GetDspHeaderEntry(iDsp);
223 Int_t nBusPatch = dspHeader->GetBusPatchEntries();
225 for(Int_t iBusPatch = 0; iBusPatch < nBusPatch; iBusPatch++) {
227 busStruct = dspHeader->GetBusPatchEntry(iBusPatch);
229 dataSize = busStruct->GetLength();
230 buspatchId = busStruct->GetBusPatchId();
232 for (Int_t iData = 0; iData < dataSize; iData++) {
235 parity = busStruct->GetParity(iData); // test later for parity
236 manuId = busStruct->GetManuId(iData);
237 channelId = busStruct->GetChannelId(iData);
238 charge = busStruct->GetCharge(iData);
240 fDigit->SetSignal(charge);
241 fDigit->SetPhysicsSignal(charge);
242 fDigit->SetADC(charge);
244 // Get Back the hits at pads
245 Int_t error = GetMapping(buspatchId,manuId,channelId,fDigit);
247 printf("Mapping Error\n");
251 if (AliLog::GetGlobalDebugLevel() == 3) {
252 Int_t padX = fDigit->PadX();
253 Int_t padY = fDigit->PadY();
254 Int_t iCath = fDigit->Cathode();
255 Int_t idDE = fDigit->DetElemId();
257 AliDebug(1,Form("output IdDE %d busPatchid %d PadX %d PadY %d iCath %d \n",
258 idDE, buspatchId, padX, padY, iCath));
260 AliDebug(3,Form("idDE %d Padx %d Pady %d, Cath %d, charge %d",
261 idDE, padX, padY, iCath, charge));
265 fMUONData->AddDigit(fRawStreamTracker->GetDDL()/2, *fDigit);
273 fTrackerTimer.Stop();
277 //____________________________________________________________________
278 Int_t AliMUONDigitMaker::GetMapping(Int_t busPatchId, UShort_t manuId,
279 UChar_t channelId, AliMUONDigit* digit )
282 // mapping for tracker
284 fMappingTimer.Start(kFALSE);
286 // getting DE from buspatch
287 Int_t detElemId = fBusPatchManager->GetDEfromBus(busPatchId);
288 AliDebug(3,Form("detElemId: %d busPatchId %d\n", detElemId, busPatchId));
290 AliMpVSegmentation* seg = fSegFactory->CreateMpSegmentationByElectronics(detElemId, manuId);
291 AliMpPad pad = seg->PadByLocation(AliMpIntPair(manuId,channelId),kTRUE);
295 AliWarning(Form("No pad for detElemId: %d, busPatchId %d, manuId: %d, channelId: %d\n",
296 detElemId, busPatchId, manuId, channelId));
297 fMappingTimer.Stop();
301 // Getting padX, padY and cathode number.
302 Int_t padX = pad.GetIndices().GetFirst();
303 Int_t padY = pad.GetIndices().GetSecond();
304 Int_t iCath = AliMpDEManager::GetCathod(detElemId,seg->PlaneType());
306 // storing into digits
307 digit->SetPadX(padX);
308 digit->SetPadY(padY);
309 digit->SetCathode(iCath);
310 digit->SetDetElemId(detElemId);
311 digit->SetElectronics(manuId,channelId);
313 AliDebug(3,Form("detElemId: %d, busPatchId %d, manuId: %d, channelId: %d, padx: %d pady %d\n",
314 detElemId, busPatchId, manuId, channelId, padX, padY));
315 StdoutToAliDebug(3,digit->Print(););
317 fMappingTimer.Stop();
321 //____________________________________________________________________
322 Int_t AliMUONDigitMaker::ReadTriggerDDL(AliRawReader* rawReader)
324 // reading tracker DDL
325 // filling the TClonesArray in MUONData
328 AliMUONDDLTrigger* ddlTrigger = 0x0;
329 AliMUONDarcHeader* darcHeader = 0x0;
330 AliMUONRegHeader* regHeader = 0x0;
331 AliMUONLocalStruct* localStruct = 0x0;
335 fTriggerTimer.Start(kFALSE);
337 fRawStreamTrigger->SetReader(rawReader);
339 while(fRawStreamTrigger->NextDDL()) {
341 ddlTrigger = fRawStreamTrigger->GetDDLTrigger();
342 darcHeader = ddlTrigger->GetDarcHeader();
344 // fill global trigger information
345 if (darcHeader->GetGlobalFlag()) {
346 fGlobalTrigger->SetGlobalPattern(darcHeader->GetGlobalOutput());
347 fMUONData->AddGlobalTrigger(*fGlobalTrigger);
350 Int_t nReg = darcHeader->GetRegHeaderEntries();
352 for(Int_t iReg = 0; iReg < nReg ;iReg++){ //reg loop
354 regHeader = darcHeader->GetRegHeaderEntry(iReg);
356 Int_t nLocal = regHeader->GetLocalEntries();
358 for(Int_t iLocal = 0; iLocal < nLocal; iLocal++) {
360 localStruct = regHeader->GetLocalEntry(iLocal);
362 if (localStruct->GetTriggerY() == 0) {
363 loCircuit = localStruct->GetId()+ 16*regHeader->GetId()
364 + 128*fRawStreamTrigger->GetDDL();
366 // fill local trigger
367 fLocalTrigger->SetLocalStruct(loCircuit, *localStruct);
369 fMUONData->AddLocalTrigger(*fLocalTrigger);
375 fTriggerTimer.Stop();