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)
82 // ctor with AliMUONData as argument
88 // Standard Constructor
90 // initialize segmentation factory
91 fSegFactory = new AliMpSegFactory();
93 // initialize container
97 fBusPatchManager = new AliMpBusPatch();
98 fBusPatchManager->ReadBusPatchFile();
101 fRawStreamTracker = new AliMUONRawStreamTracker();
102 fRawStreamTrigger = new AliMUONRawStreamTrigger();
105 fDigit = new AliMUONDigit();
108 fLocalTrigger = new AliMUONLocalTrigger();
109 fGlobalTrigger = new AliMUONGlobalTrigger();
111 fTrackerTimer.Start(kTRUE); fTrackerTimer.Stop();
112 fTriggerTimer.Start(kTRUE); fTriggerTimer.Stop();
113 fMappingTimer.Start(kTRUE); fMappingTimer.Stop();
117 //__________________________________________________________________________
118 AliMUONDigitMaker::AliMUONDigitMaker()
123 fScalerEvent(kFALSE),
124 fRawStreamTracker(0),
125 fRawStreamTrigger(0),
130 // Default Constructor
133 fTrackerTimer.Start(kTRUE); fTrackerTimer.Stop();
134 fTriggerTimer.Start(kTRUE); fTriggerTimer.Stop();
135 fMappingTimer.Start(kTRUE); fMappingTimer.Stop();
139 //_______________________________________________________________________
140 AliMUONDigitMaker::AliMUONDigitMaker (const AliMUONDigitMaker& rhs)
144 // Protected copy constructor
146 AliFatal("Not implemented.");
149 //_______________________________________________________________________
151 AliMUONDigitMaker::operator=(const AliMUONDigitMaker& rhs)
154 // Protected assignement operator
156 if (this == &rhs) return *this;
158 AliFatal("Not implemented.");
163 //__________________________________________________________________________
164 AliMUONDigitMaker::~AliMUONDigitMaker(void)
168 // and time processing measure
172 delete fRawStreamTracker;
173 delete fRawStreamTrigger;
176 delete fLocalTrigger;
177 delete fGlobalTrigger;
179 delete fBusPatchManager;
181 AliInfo(Form("Execution time for MUON tracker : R:%.2fs C:%.2fs",
182 fTrackerTimer.RealTime(),fTrackerTimer.CpuTime()));
183 AliInfo(Form(" Execution time for MUON tracker (mapping calls part) "
185 fMappingTimer.RealTime(),fMappingTimer.CpuTime()));
186 AliInfo(Form("Execution time for MUON trigger : R:%.2fs C:%.2fs",
187 fTriggerTimer.RealTime(),fTriggerTimer.CpuTime()));
192 //____________________________________________________________________
193 Int_t AliMUONDigitMaker::Raw2Digits(AliRawReader* rawReader)
195 // Main method to creates digit
200 ReadTrackerDDL(rawReader);
203 ReadTriggerDDL(rawReader);
209 //____________________________________________________________________
210 Int_t AliMUONDigitMaker::ReadTrackerDDL(AliRawReader* rawReader)
213 // reading tracker DDL
214 // filling the TClonesArray in MUONData
216 fTrackerTimer.Start(kFALSE);
226 AliMUONDDLTracker* ddlTracker = 0x0;
227 AliMUONBlockHeader* blkHeader = 0x0;
228 AliMUONDspHeader* dspHeader = 0x0;
229 AliMUONBusStruct* busStruct = 0x0;
232 fRawStreamTracker->SetReader(rawReader);
234 while(fRawStreamTracker->NextDDL()) {
236 ddlTracker = fRawStreamTracker->GetDDLTracker();
238 Int_t nBlock = ddlTracker->GetBlkHeaderEntries();
239 for(Int_t iBlock = 0; iBlock < nBlock ;iBlock++){
241 blkHeader = ddlTracker->GetBlkHeaderEntry(iBlock);
243 Int_t nDsp = blkHeader->GetDspHeaderEntries();
245 for(Int_t iDsp = 0; iDsp < nDsp ;iDsp++){ //DSP loop
247 dspHeader = blkHeader->GetDspHeaderEntry(iDsp);
249 Int_t nBusPatch = dspHeader->GetBusPatchEntries();
251 for(Int_t iBusPatch = 0; iBusPatch < nBusPatch; iBusPatch++) {
253 busStruct = dspHeader->GetBusPatchEntry(iBusPatch);
255 dataSize = busStruct->GetLength();
256 buspatchId = busStruct->GetBusPatchId();
258 for (Int_t iData = 0; iData < dataSize; iData++) {
261 parity = busStruct->GetParity(iData); // test later for parity
262 manuId = busStruct->GetManuId(iData);
263 channelId = busStruct->GetChannelId(iData);
264 charge = busStruct->GetCharge(iData);
266 fDigit->SetSignal(charge);
267 fDigit->SetPhysicsSignal(charge);
268 fDigit->SetADC(charge);
270 // Get Back the hits at pads
271 Int_t error = GetMapping(buspatchId,manuId,channelId,fDigit);
273 printf("Mapping Error\n");
277 if (AliLog::GetGlobalDebugLevel() == 3) {
278 Int_t padX = fDigit->PadX();
279 Int_t padY = fDigit->PadY();
280 Int_t iCath = fDigit->Cathode();
281 Int_t idDE = fDigit->DetElemId();
283 AliDebug(1,Form("output IdDE %d busPatchid %d PadX %d PadY %d iCath %d \n",
284 idDE, buspatchId, padX, padY, iCath));
286 AliDebug(3,Form("idDE %d Padx %d Pady %d, Cath %d, charge %d",
287 idDE, padX, padY, iCath, charge));
291 fMUONData->AddDigit(fRawStreamTracker->GetDDL()/2, *fDigit);
299 fTrackerTimer.Stop();
303 //____________________________________________________________________
304 Int_t AliMUONDigitMaker::GetMapping(Int_t busPatchId, UShort_t manuId,
305 UChar_t channelId, AliMUONDigit* digit )
308 // mapping for tracker
310 fMappingTimer.Start(kFALSE);
312 // getting DE from buspatch
313 Int_t detElemId = fBusPatchManager->GetDEfromBus(busPatchId);
314 AliDebug(3,Form("detElemId: %d busPatchId %d\n", detElemId, busPatchId));
316 AliMpVSegmentation* seg = fSegFactory->CreateMpSegmentationByElectronics(detElemId, manuId);
317 AliMpPad pad = seg->PadByLocation(AliMpIntPair(manuId,channelId),kTRUE);
321 AliWarning(Form("No pad for detElemId: %d, busPatchId %d, manuId: %d, channelId: %d\n",
322 detElemId, busPatchId, manuId, channelId));
323 fMappingTimer.Stop();
327 // Getting padX, padY and cathode number.
328 Int_t padX = pad.GetIndices().GetFirst();
329 Int_t padY = pad.GetIndices().GetSecond();
330 Int_t iCath = AliMpDEManager::GetCathod(detElemId,seg->PlaneType());
332 // storing into digits
333 digit->SetPadX(padX);
334 digit->SetPadY(padY);
335 digit->SetCathode(iCath);
336 digit->SetDetElemId(detElemId);
337 digit->SetElectronics(manuId,channelId);
339 AliDebug(3,Form("detElemId: %d, busPatchId %d, manuId: %d, channelId: %d, padx: %d pady %d\n",
340 detElemId, busPatchId, manuId, channelId, padX, padY));
341 StdoutToAliDebug(3,digit->Print(););
343 fMappingTimer.Stop();
347 //____________________________________________________________________
348 Int_t AliMUONDigitMaker::ReadTriggerDDL(AliRawReader* rawReader)
350 // reading tracker DDL
351 // filling the TClonesArray in MUONData
354 AliMUONDDLTrigger* ddlTrigger = 0x0;
355 AliMUONDarcHeader* darcHeader = 0x0;
356 AliMUONRegHeader* regHeader = 0x0;
357 AliMUONLocalStruct* localStruct = 0x0;
361 fTriggerTimer.Start(kFALSE);
363 fRawStreamTrigger->SetReader(rawReader);
365 while(fRawStreamTrigger->NextDDL()) {
367 ddlTrigger = fRawStreamTrigger->GetDDLTrigger();
368 darcHeader = ddlTrigger->GetDarcHeader();
370 // fill global trigger information
371 if (darcHeader->GetGlobalFlag() == 2) {
372 fGlobalTrigger->SetGlobalPattern(darcHeader->GetGlobalOutput());
373 fMUONData->AddGlobalTrigger(*fGlobalTrigger);
376 Int_t nReg = darcHeader->GetRegHeaderEntries();
378 for(Int_t iReg = 0; iReg < nReg ;iReg++){ //reg loop
380 regHeader = darcHeader->GetRegHeaderEntry(iReg);
382 Int_t nLocal = regHeader->GetLocalEntries();
384 for(Int_t iLocal = 0; iLocal < nLocal; iLocal++) {
386 localStruct = regHeader->GetLocalEntry(iLocal);
388 if (localStruct->GetTriggerY() == 0) {
389 loCircuit = localStruct->GetId()+ 16*regHeader->GetId()
390 + 128*fRawStreamTrigger->GetDDL();
392 // fill local trigger
393 fLocalTrigger->SetLocalStruct(loCircuit, *localStruct);
395 fMUONData->AddLocalTrigger(*fLocalTrigger);
401 fTriggerTimer.Stop();