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 "AliMUONTriggerCrateStore.h"
68 #include "AliMUONTriggerCrate.h"
69 #include "AliMUONLocalTriggerBoard.h"
70 #include "AliMUONLocalTrigger.h"
71 #include "AliMUONGlobalTrigger.h"
73 #include "AliMpSegFactory.h"
74 #include "AliMpVSegmentation.h"
76 #include "AliMpDEManager.h"
78 ClassImp(AliMUONDigitMaker) // Class implementation in ROOT context
79 //__________________________________________________________________________
80 AliMUONDigitMaker::AliMUONDigitMaker(AliMUONData* data)
83 fSegFactory(new AliMpSegFactory()),
84 fBusPatchManager(new AliMpBusPatch()),
86 fRawStreamTracker(new AliMUONRawStreamTracker()),
87 fRawStreamTrigger(new AliMUONRawStreamTrigger()),
88 fDigit(new AliMUONDigit()),
89 fLocalTrigger(new AliMUONLocalTrigger()),
90 fGlobalTrigger(new AliMUONGlobalTrigger()),
91 fCrateManager(new AliMUONTriggerCrateStore()),
97 // ctor with AliMUONData as argument
103 // Standard Constructor
106 fBusPatchManager->ReadBusPatchFile();
109 fCrateManager->ReadFromFile();
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),
135 // Default Constructor
138 fTrackerTimer.Start(kTRUE); fTrackerTimer.Stop();
139 fTriggerTimer.Start(kTRUE); fTriggerTimer.Stop();
140 fMappingTimer.Start(kTRUE); fMappingTimer.Stop();
144 //__________________________________________________________________________
145 AliMUONDigitMaker::~AliMUONDigitMaker()
149 // and time processing measure
153 delete fRawStreamTracker;
154 delete fRawStreamTrigger;
157 delete fLocalTrigger;
158 delete fGlobalTrigger;
160 delete fCrateManager;
162 delete fBusPatchManager;
164 AliInfo(Form("Execution time for MUON tracker : R:%.2fs C:%.2fs",
165 fTrackerTimer.RealTime(),fTrackerTimer.CpuTime()));
166 AliInfo(Form(" Execution time for MUON tracker (mapping calls part) "
168 fMappingTimer.RealTime(),fMappingTimer.CpuTime()));
169 AliInfo(Form("Execution time for MUON trigger : R:%.2fs C:%.2fs",
170 fTriggerTimer.RealTime(),fTriggerTimer.CpuTime()));
175 //____________________________________________________________________
176 Int_t AliMUONDigitMaker::Raw2Digits(AliRawReader* rawReader)
178 // Main method to creates digit
183 ReadTrackerDDL(rawReader);
186 ReadTriggerDDL(rawReader);
192 //____________________________________________________________________
193 Int_t AliMUONDigitMaker::ReadTrackerDDL(AliRawReader* rawReader)
196 // reading tracker DDL
197 // filling the TClonesArray in MUONData
199 fTrackerTimer.Start(kFALSE);
211 AliMUONDDLTracker* ddlTracker = 0x0;
212 AliMUONBlockHeader* blkHeader = 0x0;
213 AliMUONDspHeader* dspHeader = 0x0;
214 AliMUONBusStruct* busStruct = 0x0;
217 fRawStreamTracker->SetReader(rawReader);
219 while(fRawStreamTracker->NextDDL()) {
221 ddlTracker = fRawStreamTracker->GetDDLTracker();
223 Int_t nBlock = ddlTracker->GetBlkHeaderEntries();
224 for(Int_t iBlock = 0; iBlock < nBlock ;iBlock++){
226 blkHeader = ddlTracker->GetBlkHeaderEntry(iBlock);
228 Int_t nDsp = blkHeader->GetDspHeaderEntries();
230 for(Int_t iDsp = 0; iDsp < nDsp ;iDsp++){ //DSP loop
232 dspHeader = blkHeader->GetDspHeaderEntry(iDsp);
234 Int_t nBusPatch = dspHeader->GetBusPatchEntries();
236 for(Int_t iBusPatch = 0; iBusPatch < nBusPatch; iBusPatch++) {
238 busStruct = dspHeader->GetBusPatchEntry(iBusPatch);
240 dataSize = busStruct->GetLength();
241 buspatchId = busStruct->GetBusPatchId();
243 for (Int_t iData = 0; iData < dataSize; iData++) {
246 parity = busStruct->GetParity(iData); // test later for parity
247 manuId = busStruct->GetManuId(iData);
248 channelId = busStruct->GetChannelId(iData);
249 charge = busStruct->GetCharge(iData);
251 fDigit->SetSignal(charge);
252 fDigit->SetPhysicsSignal(charge);
253 fDigit->SetADC(charge);
255 // Get Back the hits at pads
256 Int_t error = GetMapping(buspatchId,manuId,channelId,fDigit);
258 AliWarning("Mapping Error\n");
262 if (AliLog::GetGlobalDebugLevel() == 3) {
263 Int_t padX = fDigit->PadX();
264 Int_t padY = fDigit->PadY();
265 Int_t iCath = fDigit->Cathode();
266 Int_t idDE = fDigit->DetElemId();
268 AliDebug(1,Form("output IdDE %d busPatchid %d PadX %d PadY %d iCath %d \n",
269 idDE, buspatchId, padX, padY, iCath));
271 AliDebug(3,Form("idDE %d Padx %d Pady %d, Cath %d, charge %d",
272 idDE, padX, padY, iCath, charge));
276 iChamber = fDigit->DetElemId()/100 - 1;
277 fMUONData->AddDigit(iChamber, *fDigit);
285 fTrackerTimer.Stop();
289 //____________________________________________________________________
290 Int_t AliMUONDigitMaker::GetMapping(Int_t busPatchId, UShort_t manuId,
291 UChar_t channelId, AliMUONDigit* digit )
294 // mapping for tracker
296 fMappingTimer.Start(kFALSE);
298 // getting DE from buspatch
299 Int_t detElemId = fBusPatchManager->GetDEfromBus(busPatchId);
300 AliDebug(3,Form("detElemId: %d busPatchId %d\n", detElemId, busPatchId));
302 AliMpVSegmentation* seg = fSegFactory->CreateMpSegmentationByElectronics(detElemId, manuId);
303 AliMpPad pad = seg->PadByLocation(AliMpIntPair(manuId,channelId),kTRUE);
307 AliWarning(Form("No pad for detElemId: %d, busPatchId %d, manuId: %d, channelId: %d\n",
308 detElemId, busPatchId, manuId, channelId));
309 fMappingTimer.Stop();
313 // Getting padX, padY and cathode number.
314 Int_t padX = pad.GetIndices().GetFirst();
315 Int_t padY = pad.GetIndices().GetSecond();
316 Int_t iCath = AliMpDEManager::GetCathod(detElemId,seg->PlaneType());
318 // storing into digits
319 digit->SetPadX(padX);
320 digit->SetPadY(padY);
321 digit->SetCathode(iCath);
322 digit->SetDetElemId(detElemId);
323 digit->SetElectronics(manuId,channelId);
325 AliDebug(3,Form("detElemId: %d, busPatchId %d, manuId: %d, channelId: %d, padx: %d pady %d\n",
326 detElemId, busPatchId, manuId, channelId, padX, padY));
327 StdoutToAliDebug(3,digit->Print(););
329 fMappingTimer.Stop();
333 //____________________________________________________________________
334 Int_t AliMUONDigitMaker::ReadTriggerDDL(AliRawReader* rawReader)
336 // reading tracker DDL
337 // filling the TClonesArray in MUONData
340 AliMUONDDLTrigger* ddlTrigger = 0x0;
341 AliMUONDarcHeader* darcHeader = 0x0;
342 AliMUONRegHeader* regHeader = 0x0;
343 AliMUONLocalStruct* localStruct = 0x0;
347 fTriggerTimer.Start(kFALSE);
349 fRawStreamTrigger->SetReader(rawReader);
351 while(fRawStreamTrigger->NextDDL()) {
353 ddlTrigger = fRawStreamTrigger->GetDDLTrigger();
354 darcHeader = ddlTrigger->GetDarcHeader();
356 // fill global trigger information
357 if (darcHeader->GetGlobalFlag()) {
358 fGlobalTrigger->SetGlobalPattern(darcHeader->GetGlobalOutput());
359 fMUONData->AddGlobalTrigger(*fGlobalTrigger);
362 Int_t nReg = darcHeader->GetRegHeaderEntries();
364 for(Int_t iReg = 0; iReg < nReg ;iReg++){ //reg loop
367 Char_t crateName[10];
368 GetCrateName(crateName, fRawStreamTrigger->GetDDL(), iReg);
370 AliMUONTriggerCrate* crate = fCrateManager->Crate(crateName);
373 AliWarning(Form("Missing crate number %d in DDL %d\n", iReg, fRawStreamTrigger->GetDDL()));
375 TObjArray *boards = crate->Boards();
378 regHeader = darcHeader->GetRegHeaderEntry(iReg);
380 Int_t nLocal = regHeader->GetLocalEntries();
382 for(Int_t iLocal = 0; iLocal < nLocal; iLocal++) {
384 localStruct = regHeader->GetLocalEntry(iLocal);
386 // if card has triggered
387 if (localStruct->GetTriggerY() == 0) {
389 AliMUONLocalTriggerBoard* localBoard =
390 (AliMUONLocalTriggerBoard*)boards->At(localStruct->GetId()+1);
392 loCircuit = localBoard->GetNumber();
394 // fill local trigger
395 fLocalTrigger->SetLocalStruct(loCircuit, *localStruct);
397 fMUONData->AddLocalTrigger(*fLocalTrigger);
403 fTriggerTimer.Stop();
409 //____________________________________________________________________
410 void AliMUONDigitMaker::GetCrateName(Char_t* name, Int_t iDDL, Int_t iReg)
412 // set crate name from DDL & reg number
413 // method same as in RawWriter, not so nice
414 // should be put in AliMUONTriggerCrateStore
419 sprintf(name,"%d", iReg+1);
429 sprintf(name,"%d", iReg);
433 // crate Right for first DDL