X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=MUON%2FAliMUONDigitMaker.cxx;h=c8de1ccf91928732548f40efc2cb8f1ccf1bcd28;hb=1ef5468a4a5a18589fd05f331d4d5e81b8546b2e;hp=1fa1223b9cb10d0a4b13c7a642e01e6560417be8;hpb=d53fb0de8936bc836be15de06556a66bf9cd9f1d;p=u%2Fmrichter%2FAliRoot.git diff --git a/MUON/AliMUONDigitMaker.cxx b/MUON/AliMUONDigitMaker.cxx index 1fa1223b9cb..c8de1ccf919 100644 --- a/MUON/AliMUONDigitMaker.cxx +++ b/MUON/AliMUONDigitMaker.cxx @@ -13,330 +13,227 @@ * provided "as is" without express or implied warranty. * **************************************************************************/ -//////////////////////////////////// -/// -/// MUON Digit maker from rawdata in ALICE-MUON -/// Using new interface with AliMUONRawStreamTracker(Trigger) -/// (New interface of AliMUONRawReader class) -/// Class version 1 (further details could be found in Alice-note) -/// -/// Implemented non-constant buspatch numbers for tracking -/// with correct DDL id (first guess) -/// (Ch. Finck, dec 2005) -/// +// $Id$ + +//----------------------------------------------------------------------------- +/// \class AliMUONDigitMaker +/// MUON Digit maker from rawdata. /// /// Raw2Digits: /// Using real mapping for tracker /// Indranil Das (Adapted for runloader: Ch. Finck) july 05 +/// +/// Implemented non-constant buspatch numbers for tracking +/// with correct DDL id. +/// (Ch. Finck, dec 05) +/// /// Add reader for scaler trigger events /// Use memcpy instead of assignment elt by elt /// (Ch. Finck, Jan 06) -/// -//////////////////////////////////// - -#include -#include - -#include - -#include "AliRawReader.h" -#include "AliRawDataHeader.h" -#include "AliLog.h" -#include "AliRun.h" +/// +/// Using new interface with AliMUONRawStreamTracker(Trigger) +/// (New interface of AliMUONRawReader class) +/// (further details could be found in Alice-note) +/// (Ch. Finck, March 06) +/// +/// Add (S)Digit maker tracker (for free) +/// and for trigger. Create trigger inverse mapping. +/// +/// \author Ch. Finck, oct 06 +//----------------------------------------------------------------------------- -#include "AliMpBusPatch.h" -#include "AliMUON.h" #include "AliMUONDigitMaker.h" -#include "AliMUONDigit.h" -#include "AliMUONConstants.h" -#include "AliMUONData.h" - -#include "AliMUONRawStreamTracker.h" -#include "AliMUONDDLTracker.h" -#include "AliMUONDspHeader.h" -#include "AliMUONBlockHeader.h" -#include "AliMUONBusStruct.h" - -#include "AliMUONRawStreamTrigger.h" +#include "AliLog.h" #include "AliMUONDDLTrigger.h" #include "AliMUONDarcHeader.h" -#include "AliMUONRegHeader.h" +#include "AliMUONVDigit.h" +#include "AliMUONVDigitStore.h" +#include "AliMUONGlobalTrigger.h" #include "AliMUONLocalStruct.h" - -#include "AliMUONTriggerCrateStore.h" -#include "AliMUONTriggerCrate.h" -#include "AliMUONLocalTriggerBoard.h" #include "AliMUONLocalTrigger.h" -#include "AliMUONGlobalTrigger.h" - -#include "AliMpSegFactory.h" -#include "AliMpVSegmentation.h" -#include "AliMpPad.h" +#include "AliMUONRawStreamTracker.h" +#include "AliMUONRawStreamTrigger.h" +#include "AliMUONRegHeader.h" +#include "AliMUONTriggerCircuit.h" +#include "AliMpTriggerCrate.h" +#include "AliMpLocalBoard.h" +#include "AliMUONVTriggerStore.h" +#include "AliMpCathodType.h" +#include "AliMpDDLStore.h" #include "AliMpDEManager.h" +#include "AliMpPad.h" +#include "AliMpSegmentation.h" +#include "AliMpVSegmentation.h" +#include "AliRawReader.h" +#include +/// \cond CLASSIMP ClassImp(AliMUONDigitMaker) // Class implementation in ROOT context +/// \endcond + //__________________________________________________________________________ -AliMUONDigitMaker::AliMUONDigitMaker(AliMUONData* data) +AliMUONDigitMaker::AliMUONDigitMaker(Bool_t enableErrorLogger) : TObject(), - fMUONData(data), - fSegFactory(new AliMpSegFactory()), - fBusPatchManager(new AliMpBusPatch()), fScalerEvent(kFALSE), + fMakeTriggerDigits(kFALSE), fRawStreamTracker(new AliMUONRawStreamTracker()), fRawStreamTrigger(new AliMUONRawStreamTrigger()), - fDigit(new AliMUONDigit()), - fLocalTrigger(new AliMUONLocalTrigger()), - fGlobalTrigger(new AliMUONGlobalTrigger()), - fCrateManager(new AliMUONTriggerCrateStore()), fTrackerTimer(), fTriggerTimer(), - fMappingTimer() + fMappingTimer(), + fDigitStore(0x0), + fTriggerStore(0x0) { - // - // ctor with AliMUONData as argument - // for reconstruction - // + /// ctor AliDebug(1,""); // Standard Constructor + if (enableErrorLogger) { + fRawStreamTracker->EnabbleErrorLogger(); + fRawStreamTrigger->EnabbleErrorLogger(); + } - // bus patch - fBusPatchManager->ReadBusPatchFile(); - - // Crate manager - fCrateManager->ReadFromFile(); - - fTrackerTimer.Start(kTRUE); fTrackerTimer.Stop(); - fTriggerTimer.Start(kTRUE); fTriggerTimer.Stop(); - fMappingTimer.Start(kTRUE); fMappingTimer.Stop(); - -} - -//__________________________________________________________________________ -AliMUONDigitMaker::AliMUONDigitMaker() - : TObject(), - fMUONData(0), - fSegFactory(0), - fBusPatchManager(0), - fScalerEvent(kFALSE), - fRawStreamTracker(0), - fRawStreamTrigger(0), - fDigit(0), - fLocalTrigger(0), - fGlobalTrigger(0), - fCrateManager(0), - fTrackerTimer(), - fTriggerTimer(), - fMappingTimer() -{ - // - // Default Constructor - // - AliDebug(1,""); fTrackerTimer.Start(kTRUE); fTrackerTimer.Stop(); fTriggerTimer.Start(kTRUE); fTriggerTimer.Stop(); fMappingTimer.Start(kTRUE); fMappingTimer.Stop(); + SetMakeTriggerDigits(); + } //__________________________________________________________________________ AliMUONDigitMaker::~AliMUONDigitMaker() { - // - // clean up - // and time processing measure - // - delete fSegFactory; + /// clean up + /// and time processing measure delete fRawStreamTracker; delete fRawStreamTrigger; - delete fDigit; - delete fLocalTrigger; - delete fGlobalTrigger; - - delete fCrateManager; - - delete fBusPatchManager; - - AliInfo(Form("Execution time for MUON tracker : R:%.2fs C:%.2fs", + AliDebug(1, Form("Execution time for MUON tracker : R:%.2fs C:%.2fs", fTrackerTimer.RealTime(),fTrackerTimer.CpuTime())); - AliInfo(Form(" Execution time for MUON tracker (mapping calls part) " + AliDebug(1, Form(" Execution time for MUON tracker (mapping calls part) " ": R:%.2fs C:%.2fs", fMappingTimer.RealTime(),fMappingTimer.CpuTime())); - AliInfo(Form("Execution time for MUON trigger : R:%.2fs C:%.2fs", + AliDebug(1, Form("Execution time for MUON trigger : R:%.2fs C:%.2fs", fTriggerTimer.RealTime(),fTriggerTimer.CpuTime())); - return; } //____________________________________________________________________ -Int_t AliMUONDigitMaker::Raw2Digits(AliRawReader* rawReader) +Int_t AliMUONDigitMaker::Raw2Digits(AliRawReader* rawReader, + AliMUONVDigitStore* digitStore, + AliMUONVTriggerStore* triggerStore) { - // Main method to creates digit - // for tracker - // and trigger - - // generate digits - ReadTrackerDDL(rawReader); - - // generate trigger - ReadTriggerDDL(rawReader); + /// Main method to creates digit + /// for tracker + /// and trigger + AliDebug(1,Form("rawReader=%p digitStore=%p triggerStore=%p", + rawReader,digitStore,triggerStore)); + + fDigitStore = digitStore; + fTriggerStore = triggerStore; + + if (!fDigitStore && !fTriggerStore) + { + AliError("No digit or trigger store given. Nothing to do..."); + return kFALSE; + } + + if ( fDigitStore ) + { + fDigitStore->Clear(); // insure we start with an empty container + ReadTrackerDDL(rawReader); + } + + if ( fTriggerStore || fMakeTriggerDigits ) + { + if ( fTriggerStore ) fTriggerStore->Clear(); + if ( fMakeTriggerDigits && !fDigitStore ) + { + AliError("Asking for trigger digits but digitStore is null"); + } + else + { + ReadTriggerDDL(rawReader); + } + } + return kTRUE; - } //____________________________________________________________________ Int_t AliMUONDigitMaker::ReadTrackerDDL(AliRawReader* rawReader) { + /// Reading tracker DDL + /// filling the fDigitStore container, which must not be null - // reading tracker DDL - // filling the TClonesArray in MUONData - // + AliDebug(1,""); + fTrackerTimer.Start(kFALSE); // elex info Int_t buspatchId; UChar_t channelId; UShort_t manuId; - Char_t parity; UShort_t charge; - Int_t dataSize; - - Int_t iChamber; - - AliMUONDDLTracker* ddlTracker = 0x0; - AliMUONBlockHeader* blkHeader = 0x0; - AliMUONDspHeader* dspHeader = 0x0; - AliMUONBusStruct* busStruct = 0x0; - fRawStreamTracker->SetReader(rawReader); + fRawStreamTracker->First(); + + while ( fRawStreamTracker->Next(buspatchId,manuId,channelId,charge) ) + { + // getting DE from buspatch + Int_t detElemId = AliMpDDLStore::Instance()->GetDEfromBus(buspatchId); + + const AliMpVSegmentation* seg + = AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(detElemId, + manuId); + + AliMp::CathodType cathodeType = AliMpDEManager::GetCathod(detElemId, + seg->PlaneType()); + + AliMpPad pad = seg->PadByLocation(AliMpIntPair(manuId,channelId),kFALSE); + + if (!pad.IsValid()) + { + AliError(Form("No pad for detElemId: %d, manuId: %d, channelId: %d", + detElemId, manuId, channelId)); + continue; + } + + AliMUONVDigit* digit = fDigitStore->Add(detElemId,manuId,channelId,cathodeType, + AliMUONVDigitStore::kDeny); + if (!digit) + { + AliError(Form("Digit DE %04d Manu %04d Channel %02d could not be added", + detElemId, manuId, channelId)); + continue; + } + + digit->SetPadXY(pad.GetIndices().GetFirst(), + pad.GetIndices().GetSecond()); + + digit->SetADC(charge); - while(fRawStreamTracker->NextDDL()) { - - ddlTracker = fRawStreamTracker->GetDDLTracker(); - - Int_t nBlock = ddlTracker->GetBlkHeaderEntries(); - for(Int_t iBlock = 0; iBlock < nBlock ;iBlock++){ - - blkHeader = ddlTracker->GetBlkHeaderEntry(iBlock); - - Int_t nDsp = blkHeader->GetDspHeaderEntries(); - - for(Int_t iDsp = 0; iDsp < nDsp ;iDsp++){ //DSP loop - - dspHeader = blkHeader->GetDspHeaderEntry(iDsp); - - Int_t nBusPatch = dspHeader->GetBusPatchEntries(); - - for(Int_t iBusPatch = 0; iBusPatch < nBusPatch; iBusPatch++) { - - busStruct = dspHeader->GetBusPatchEntry(iBusPatch); - - dataSize = busStruct->GetLength(); - buspatchId = busStruct->GetBusPatchId(); - - for (Int_t iData = 0; iData < dataSize; iData++) { - - // digits info - parity = busStruct->GetParity(iData); // test later for parity - manuId = busStruct->GetManuId(iData); - channelId = busStruct->GetChannelId(iData); - charge = busStruct->GetCharge(iData); - // set charge - fDigit->SetSignal(charge); - fDigit->SetPhysicsSignal(charge); - fDigit->SetADC(charge); - - // Get Back the hits at pads - Int_t error = GetMapping(buspatchId,manuId,channelId,fDigit); - if (error) { - AliWarning("Mapping Error\n"); - continue; - } - // debugging - if (AliLog::GetGlobalDebugLevel() == 3) { - Int_t padX = fDigit->PadX(); - Int_t padY = fDigit->PadY(); - Int_t iCath = fDigit->Cathode(); - Int_t idDE = fDigit->DetElemId(); - - AliDebug(1,Form("output IdDE %d busPatchid %d PadX %d PadY %d iCath %d \n", - idDE, buspatchId, padX, padY, iCath)); - - AliDebug(3,Form("idDE %d Padx %d Pady %d, Cath %d, charge %d", - idDE, padX, padY, iCath, charge)); - } - - // fill digits - iChamber = fDigit->DetElemId()/100 - 1; - fMUONData->AddDigit(iChamber, *fDigit); - - } // iData - } // iBusPatch - } // iDsp - } // iBlock - } // NextDDL - + } + fTrackerTimer.Stop(); return kTRUE; } -//____________________________________________________________________ -Int_t AliMUONDigitMaker::GetMapping(Int_t busPatchId, UShort_t manuId, - UChar_t channelId, AliMUONDigit* digit ) -{ - // - // mapping for tracker - // - fMappingTimer.Start(kFALSE); - - // getting DE from buspatch - Int_t detElemId = fBusPatchManager->GetDEfromBus(busPatchId); - AliDebug(3,Form("detElemId: %d busPatchId %d\n", detElemId, busPatchId)); - - AliMpVSegmentation* seg = fSegFactory->CreateMpSegmentationByElectronics(detElemId, manuId); - AliMpPad pad = seg->PadByLocation(AliMpIntPair(manuId,channelId),kTRUE); - - if (!pad.IsValid()) - { - AliWarning(Form("No pad for detElemId: %d, busPatchId %d, manuId: %d, channelId: %d\n", - detElemId, busPatchId, manuId, channelId)); - fMappingTimer.Stop(); - return kTRUE; - } // return error - - // Getting padX, padY and cathode number. - Int_t padX = pad.GetIndices().GetFirst(); - Int_t padY = pad.GetIndices().GetSecond(); - Int_t iCath = AliMpDEManager::GetCathod(detElemId,seg->PlaneType()); - - // storing into digits - digit->SetPadX(padX); - digit->SetPadY(padY); - digit->SetCathode(iCath); - digit->SetDetElemId(detElemId); - digit->SetElectronics(manuId,channelId); - - AliDebug(3,Form("detElemId: %d, busPatchId %d, manuId: %d, channelId: %d, padx: %d pady %d\n", - detElemId, busPatchId, manuId, channelId, padX, padY)); - StdoutToAliDebug(3,digit->Print();); - - fMappingTimer.Stop(); - return kFALSE; -} //____________________________________________________________________ Int_t AliMUONDigitMaker::ReadTriggerDDL(AliRawReader* rawReader) { - // reading tracker DDL - // filling the TClonesArray in MUONData - // + /// reading tracker DDL + /// filling the fTriggerStore container, which must not be null + AliDebug(1,""); + AliMUONDDLTrigger* ddlTrigger = 0x0; AliMUONDarcHeader* darcHeader = 0x0; AliMUONRegHeader* regHeader = 0x0; @@ -348,58 +245,80 @@ Int_t AliMUONDigitMaker::ReadTriggerDDL(AliRawReader* rawReader) fRawStreamTrigger->SetReader(rawReader); - while(fRawStreamTrigger->NextDDL()) { - + while (fRawStreamTrigger->NextDDL()) + { ddlTrigger = fRawStreamTrigger->GetDDLTrigger(); darcHeader = ddlTrigger->GetDarcHeader(); - + // fill global trigger information - if (darcHeader->GetGlobalFlag()) { - fGlobalTrigger->SetGlobalPattern(darcHeader->GetGlobalOutput()); - fMUONData->AddGlobalTrigger(*fGlobalTrigger); + if (fTriggerStore) + { + if (darcHeader->GetGlobalFlag()) + { + AliMUONGlobalTrigger globalTrigger; + globalTrigger.SetFromGlobalResponse(darcHeader->GetGlobalOutput()); + fTriggerStore->SetGlobal(globalTrigger); + } } - + Int_t nReg = darcHeader->GetRegHeaderEntries(); - - for(Int_t iReg = 0; iReg < nReg ;iReg++){ //reg loop - - // crate info - Char_t crateName[10]; - GetCrateName(crateName, fRawStreamTrigger->GetDDL(), iReg); - - AliMUONTriggerCrate* crate = fCrateManager->Crate(crateName); - + + for(Int_t iReg = 0; iReg < nReg ;iReg++) + { //reg loop + + + // crate info + AliMpTriggerCrate* crate = AliMpDDLStore::Instance()-> + GetTriggerCrate(fRawStreamTrigger->GetDDL(), iReg); + if (!crate) - AliWarning(Form("Missing crate number %d in DDL %d\n", iReg, fRawStreamTrigger->GetDDL())); - - TObjArray *boards = crate->Boards(); - - + AliWarning(Form("Missing crate number %d in DDL %d\n", iReg, fRawStreamTrigger->GetDDL())); + + regHeader = darcHeader->GetRegHeaderEntry(iReg); - + Int_t nLocal = regHeader->GetLocalEntries(); - - for(Int_t iLocal = 0; iLocal < nLocal; iLocal++) { - - localStruct = regHeader->GetLocalEntry(iLocal); - - // if card has triggered - if (localStruct->GetTriggerY() == 0) { - - AliMUONLocalTriggerBoard* localBoard = - (AliMUONLocalTriggerBoard*)boards->At(localStruct->GetId()+1); - - loCircuit = localBoard->GetNumber(); - - // fill local trigger - fLocalTrigger->SetLocalStruct(loCircuit, *localStruct); - - fMUONData->AddLocalTrigger(*fLocalTrigger); - } // if triggerY + for(Int_t iLocal = 0; iLocal < nLocal; iLocal++) + { + + localStruct = regHeader->GetLocalEntry(iLocal); + + // if card exist + if (localStruct) { + + loCircuit = crate->GetLocalBoardId(localStruct->GetId()); + + if ( !loCircuit ) continue; // empty slot + + AliMpLocalBoard* localBoard = AliMpDDLStore::Instance()->GetLocalBoard(loCircuit, false); + + // skip copy cards + if( !localBoard->IsNotified()) + continue; + + if (fTriggerStore) + { + // fill local trigger + AliMUONLocalTrigger localTrigger; + localTrigger.SetLocalStruct(loCircuit, *localStruct); + fTriggerStore->Add(localTrigger); + } + + if ( fMakeTriggerDigits ) + { + //FIXEME should find something better than a TArray + TArrayS xyPattern[2]; + + localStruct->GetXPattern(xyPattern[0]); + localStruct->GetYPattern(xyPattern[1]); + + TriggerDigits(loCircuit, xyPattern, *fDigitStore); + } + } // if triggerY } // iLocal } // iReg } // NextDDL - + fTriggerTimer.Stop(); return kTRUE; @@ -407,32 +326,76 @@ Int_t AliMUONDigitMaker::ReadTriggerDDL(AliRawReader* rawReader) } //____________________________________________________________________ -void AliMUONDigitMaker::GetCrateName(Char_t* name, Int_t iDDL, Int_t iReg) +Int_t AliMUONDigitMaker::TriggerDigits(Int_t nBoard, + TArrayS* xyPattern, + AliMUONVDigitStore& digitStore) const { - // set crate name from DDL & reg number - // method same as in RawWriter, not so nice - // should be put in AliMUONTriggerCrateStore - - switch(iReg) { - case 0: - case 1: - sprintf(name,"%d", iReg+1); - break; - case 2: - strcpy(name, "2-3"); - break; - case 3: - case 4: - case 5: - case 6: - case 7: - sprintf(name,"%d", iReg); - break; - } + /// make digits for trigger from pattern, and add them to digitStore - // crate Right for first DDL - if (iDDL == 0) - strcat(name, "R"); - else - strcat(name, "L"); -} + Int_t detElemId; + + AliMpLocalBoard* localBoard = AliMpDDLStore::Instance()->GetLocalBoard(nBoard); + + Int_t n,b; + + // loop over x1-4 and y1-4 + for (Int_t iChamber = 0; iChamber < 4; ++iChamber) + { + for (Int_t iCath = 0; iCath < 2; ++iCath) + { + Int_t pattern = (Int_t)xyPattern[iCath].At(iChamber); + if (!pattern) continue; + + // get detElemId + detElemId = AliMpDDLStore::Instance()->GetDEfromLocalBoard(nBoard, iChamber); + + const AliMpVSegmentation* seg + = AliMpSegmentation::Instance() + ->GetMpSegmentation(detElemId, AliMp::GetCathodType(iCath)); + + // loop over the 16 bits of pattern + for (Int_t ibitxy = 0; ibitxy < 16; ++ibitxy) + { + if ((pattern >> ibitxy) & 0x1) + { + // not quite sure about this + Int_t offset = 0; + if (iCath && localBoard->GetSwitch(6)) offset = -8; + + AliMpPad pad = seg->PadByLocation(AliMpIntPair(nBoard,ibitxy+offset),kTRUE); + + if (!pad.IsValid()) + { + AliWarning(Form("No pad for detElemId: %d, nboard %d, ibitxy: %d\n", + detElemId, nBoard, ibitxy)); + continue; + } + + n = pad.GetLocation(0).GetFirst(); // always take first location so that digits are not inserted several times + b = pad.GetLocation(0).GetSecond(); + + AliDebug(1,Form("Using localBoard %d ixy %d instead of %d,%d", + n,b,nBoard,ibitxy)); + + AliMUONVDigit* digit = digitStore.Add(detElemId,n,b,iCath,AliMUONVDigitStore::kDeny); + + if (!digit) + { + AliDebug(1, Form("Digit DE %04d LocalBoard %03d ibitxy %02d cath %d already in store", + detElemId,nBoard,ibitxy,iCath)); + continue; + } + + Int_t padX = pad.GetIndices().GetFirst(); + Int_t padY = pad.GetIndices().GetSecond(); + + // fill digit + digit->SetPadXY(padX,padY); + digit->SetCharge(1.); + }// xyPattern + }// ibitxy + }// cath + } // ichamber + + return kTRUE; +}