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"
48 #include "AliMUONDigitMaker.h"
49 #include "AliMUONDigit.h"
51 #include "AliMUONConstants.h"
52 #include "AliMUONData.h"
54 #include "AliMUONRawStreamTracker.h"
55 #include "AliMUONDDLTracker.h"
56 #include "AliMUONDspHeader.h"
57 #include "AliMUONBlockHeader.h"
58 #include "AliMUONBusStruct.h"
60 #include "AliMUONRawStreamTrigger.h"
61 #include "AliMUONDDLTrigger.h"
62 #include "AliMUONDarcHeader.h"
63 #include "AliMUONRegHeader.h"
64 #include "AliMUONLocalStruct.h"
66 #include "AliMUONLocalTrigger.h"
67 #include "AliMUONGlobalTrigger.h"
69 #include "AliMpSegFactory.h"
70 #include "AliMpVSegmentation.h"
72 #include "AliMpDEManager.h"
74 ClassImp(AliMUONDigitMaker) // Class implementation in ROOT context
75 //__________________________________________________________________________
76 AliMUONDigitMaker::AliMUONDigitMaker(AliMUONData* data)
81 // ctor with AliMUONData as argument
87 // Standard Constructor
89 // initialize segmentation factory
90 fSegFactory = new AliMpSegFactory();
92 // initialize container
96 fBusPatchManager = new AliMpBusPatch();
97 fBusPatchManager->ReadBusPatchFile();
100 fRawStreamTracker = new AliMUONRawStreamTracker();
101 fRawStreamTrigger = new AliMUONRawStreamTrigger();
104 fDigit = new AliMUONDigit();
107 fLocalTrigger = new AliMUONLocalTrigger();
108 fGlobalTrigger = new AliMUONGlobalTrigger();
110 fTrackerTimer.Start(kTRUE); fTrackerTimer.Stop();
111 fTriggerTimer.Start(kTRUE); fTriggerTimer.Stop();
112 fMappingTimer.Start(kTRUE); fMappingTimer.Stop();
116 //__________________________________________________________________________
117 AliMUONDigitMaker::AliMUONDigitMaker()
122 fScalerEvent(kFALSE),
123 fRawStreamTracker(0),
124 fRawStreamTrigger(0),
129 // Default Constructor
132 fTrackerTimer.Start(kTRUE); fTrackerTimer.Stop();
133 fTriggerTimer.Start(kTRUE); fTriggerTimer.Stop();
134 fMappingTimer.Start(kTRUE); fMappingTimer.Stop();
138 //_______________________________________________________________________
139 AliMUONDigitMaker::AliMUONDigitMaker (const AliMUONDigitMaker& rhs)
143 // Protected copy constructor
145 AliFatal("Not implemented.");
148 //_______________________________________________________________________
150 AliMUONDigitMaker::operator=(const AliMUONDigitMaker& rhs)
153 // Protected assignement operator
155 if (this == &rhs) return *this;
157 AliFatal("Not implemented.");
162 //__________________________________________________________________________
163 AliMUONDigitMaker::~AliMUONDigitMaker(void)
167 // and time processing measure
171 delete fRawStreamTracker;
172 delete fRawStreamTrigger;
175 delete fLocalTrigger;
176 delete fGlobalTrigger;
178 delete fBusPatchManager;
180 AliInfo(Form("Execution time for MUON tracker : R:%.2fs C:%.2fs",
181 fTrackerTimer.RealTime(),fTrackerTimer.CpuTime()));
182 AliInfo(Form(" Execution time for MUON tracker (mapping calls part) "
184 fMappingTimer.RealTime(),fMappingTimer.CpuTime()));
185 AliInfo(Form("Execution time for MUON trigger : R:%.2fs C:%.2fs",
186 fTriggerTimer.RealTime(),fTriggerTimer.CpuTime()));
191 //____________________________________________________________________
192 Int_t AliMUONDigitMaker::Raw2Digits(AliRawReader* rawReader)
194 // Main method to creates digit
199 ReadTrackerDDL(rawReader);
202 ReadTriggerDDL(rawReader);
208 //____________________________________________________________________
209 Int_t AliMUONDigitMaker::ReadTrackerDDL(AliRawReader* rawReader)
212 // reading tracker DDL
213 // filling the TClonesArray in MUONData
215 fTrackerTimer.Start(kFALSE);
225 AliMUONDDLTracker* ddlTracker = 0x0;
226 AliMUONBlockHeader* blkHeader = 0x0;
227 AliMUONDspHeader* dspHeader = 0x0;
228 AliMUONBusStruct* busStruct = 0x0;
231 fRawStreamTracker->SetReader(rawReader);
233 while(fRawStreamTracker->NextDDL()) {
235 ddlTracker = fRawStreamTracker->GetDDLTracker();
237 Int_t nBlock = ddlTracker->GetBlkHeaderEntries();
238 for(Int_t iBlock = 0; iBlock < nBlock ;iBlock++){
240 blkHeader = ddlTracker->GetBlkHeaderEntry(iBlock);
242 Int_t nDsp = blkHeader->GetDspHeaderEntries();
244 for(Int_t iDsp = 0; iDsp < nDsp ;iDsp++){ //DSP loop
246 dspHeader = blkHeader->GetDspHeaderEntry(iDsp);
248 Int_t nBusPatch = dspHeader->GetBusPatchEntries();
250 for(Int_t iBusPatch = 0; iBusPatch < nBusPatch; iBusPatch++) {
252 busStruct = dspHeader->GetBusPatchEntry(iBusPatch);
254 dataSize = busStruct->GetLength();
255 buspatchId = busStruct->GetBusPatchId();
257 for (Int_t iData = 0; iData < dataSize; iData++) {
260 parity = busStruct->GetParity(iData); // test later for parity
261 manuId = busStruct->GetManuId(iData);
262 channelId = busStruct->GetChannelId(iData);
263 charge = busStruct->GetCharge(iData);
265 fDigit->SetSignal(charge);
266 fDigit->SetPhysicsSignal(charge);
267 fDigit->SetADC(charge);
269 // Get Back the hits at pads
270 Int_t error = GetMapping(buspatchId,manuId,channelId,fDigit);
274 if (AliLog::GetGlobalDebugLevel() == 3) {
275 Int_t padX = fDigit->PadX();
276 Int_t padY = fDigit->PadY();
277 Int_t iCath = fDigit->Cathode();
278 Int_t idDE = fDigit->DetElemId();
280 AliDebug(1,Form("output IdDE %d busPatchid %d PadX %d PadY %d iCath %d \n",
281 idDE, buspatchId, padX, padY, iCath));
283 AliDebug(3,Form("idDE %d Padx %d Pady %d, Cath %d, charge %d",
284 idDE, padX, padY, iCath, charge));
288 fMUONData->AddDigit(fRawStreamTracker->GetDDL()/2, *fDigit);
296 fTrackerTimer.Stop();
300 //____________________________________________________________________
301 Int_t AliMUONDigitMaker::GetMapping(Int_t busPatchId, UShort_t manuId,
302 UChar_t channelId, AliMUONDigit* digit )
305 // mapping for tracker
307 fMappingTimer.Start(kFALSE);
309 // getting DE from buspatch
310 Int_t detElemId = fBusPatchManager->GetDEfromBus(busPatchId);
311 AliDebug(3,Form("detElemId: %d busPatchId %d\n", detElemId, busPatchId));
313 AliMpVSegmentation* seg = fSegFactory->CreateMpSegmentationByElectronics(detElemId, manuId);
314 AliMpPad pad = seg->PadByLocation(AliMpIntPair(manuId,channelId),kTRUE);
318 AliWarning(Form("No pad for detElemId: %d, busPatchId %d, manuId: %d, channelId: %d\n",
319 detElemId, busPatchId, manuId, channelId));
320 fMappingTimer.Stop();
324 // Getting padX, padY and cathode number.
325 Int_t padX = pad.GetIndices().GetFirst();
326 Int_t padY = pad.GetIndices().GetSecond();
327 Int_t iCath = AliMpDEManager::GetCathod(detElemId,seg->PlaneType());
329 // storing into digits
330 digit->SetPadX(padX);
331 digit->SetPadY(padY);
332 digit->SetCathode(iCath);
333 digit->SetDetElemId(detElemId);
334 digit->SetElectronics(manuId,channelId);
336 AliDebug(3,Form("detElemId: %d, busPatchId %d, manuId: %d, channelId: %d, padx: %d pady %d\n",
337 detElemId, busPatchId, manuId, channelId, padX, padY));
338 StdoutToAliDebug(3,digit->Print(););
340 fMappingTimer.Stop();
344 //____________________________________________________________________
345 Int_t AliMUONDigitMaker::ReadTriggerDDL(AliRawReader* rawReader)
347 // reading tracker DDL
348 // filling the TClonesArray in MUONData
351 AliMUONDDLTrigger* ddlTrigger = 0x0;
352 AliMUONDarcHeader* darcHeader = 0x0;
353 AliMUONRegHeader* regHeader = 0x0;
354 AliMUONLocalStruct* localStruct = 0x0;
358 fTriggerTimer.Start(kFALSE);
360 fRawStreamTrigger->SetReader(rawReader);
362 while(fRawStreamTrigger->NextDDL()) {
364 ddlTrigger = fRawStreamTrigger->GetDDLTrigger();
365 darcHeader = ddlTrigger->GetDarcHeader();
367 // fill global trigger information
368 if (darcHeader->GetGlobalFlag() == 2) {
369 fGlobalTrigger->SetGlobalPattern(darcHeader->GetGlobalOutput());
370 fMUONData->AddGlobalTrigger(*fGlobalTrigger);
373 Int_t nReg = darcHeader->GetRegHeaderEntries();
375 for(Int_t iReg = 0; iReg < nReg ;iReg++){ //reg loop
377 regHeader = darcHeader->GetRegHeaderEntry(iReg);
379 Int_t nLocal = regHeader->GetLocalEntries();
381 for(Int_t iLocal = 0; iLocal < nLocal; iLocal++) {
383 localStruct = regHeader->GetLocalEntry(iLocal);
385 if (localStruct->GetTriggerY() == 0) {
386 loCircuit = localStruct->GetId()+ 16*regHeader->GetId()
387 + 128*fRawStreamTrigger->GetDDL();
389 // fill local trigger
390 fLocalTrigger->SetLocalStruct(loCircuit, *localStruct);
392 fMUONData->AddLocalTrigger(*fLocalTrigger);
398 fTriggerTimer.Stop();