From ced309a5ef8b644963405ff686d0879ff0b79341 Mon Sep 17 00:00:00 2001 From: martinez Date: Fri, 27 Jan 2006 17:18:52 +0000 Subject: [PATCH] Add scaler event for trigger, copy data blockwise in buffers --- MUON/AliMUON.cxx | 13 +- MUON/AliMUON.h | 9 +- MUON/AliMUONDDLTrigger.h | 2 + MUON/AliMUONRawReader.cxx | 155 ++++++++++------- MUON/AliMUONRawReader.h | 5 +- MUON/AliMUONRawWriter.cxx | 269 ++++++++++++++++++----------- MUON/AliMUONRawWriter.h | 12 +- MUON/AliMUONScalerEventTrigger.cxx | 49 +++++- MUON/AliMUONScalerEventTrigger.h | 3 + MUON/AliMUONSubEventTracker.h | 6 +- MUON/AliMUONSubEventTrigger.h | 4 +- 11 files changed, 349 insertions(+), 178 deletions(-) diff --git a/MUON/AliMUON.cxx b/MUON/AliMUON.cxx index 48ba3496431..9bac1ac898b 100644 --- a/MUON/AliMUON.cxx +++ b/MUON/AliMUON.cxx @@ -104,7 +104,8 @@ AliMUON::AliMUON() fMaxDestepGas(0.), fMaxDestepAlu(0.), fMaxIterPad(0), - fCurIterPad(0) + fCurIterPad(0), + fTriggerScalerEvent(kFALSE) { // Default Constructor // @@ -131,7 +132,8 @@ AliMUON::AliMUON(const char *name, const char *title) fMaxDestepGas(-1), // Negatives values are ignored by geant3 CONS200 fMaxDestepAlu(-1), // in the calculation of the tracking parameters fMaxIterPad(0), - fCurIterPad(0) + fCurIterPad(0), + fTriggerScalerEvent(kFALSE) { AliDebug(1,Form("ctor this=%p",this)); fIshunt = 0; @@ -427,9 +429,12 @@ void AliMUON::Hits2SDigits() void AliMUON::Digits2Raw() { // convert digits of the current event to raw data - AliMUONRawWriter* rawData; + + AliMUONRawWriter* rawData = new AliMUONRawWriter(fLoader,fMUONData); + + if(fTriggerScalerEvent == kTRUE) + rawData->SetScalerEvent(); - rawData = new AliMUONRawWriter(fLoader,fMUONData); if (!rawData->Digits2Raw()) AliInfo("pb writting raw data"); delete rawData; return; diff --git a/MUON/AliMUON.h b/MUON/AliMUON.h index 3ec582fb8be..b8aa34437c1 100644 --- a/MUON/AliMUON.h +++ b/MUON/AliMUON.h @@ -105,7 +105,10 @@ class AliMUON : public AliDetector // Set alignement option virtual void SetAlign(Bool_t align = true); virtual void SetAlign(const TString& fileName, Bool_t align = true); - + + // Set scaler event for trigger + virtual void SetTriggerScalerEvent(Bool_t scaler = true){fTriggerScalerEvent = scaler;} + // Return reference to Chamber #id virtual AliMUONChamber& Chamber(Int_t id) {return *((AliMUONChamber *) (*fChambers)[id]);} @@ -147,7 +150,9 @@ class AliMUON : public AliDetector // Pad Iterator Int_t fMaxIterPad; // Maximum pad index Int_t fCurIterPad; // Current pad index - // Background eent for event mixing + + // setting scaler for trigger + Bool_t fTriggerScalerEvent; // flag to generates scaler event ClassDef(AliMUON,9) // MUON Detector base class }; diff --git a/MUON/AliMUONDDLTrigger.h b/MUON/AliMUONDDLTrigger.h index 907b239a457..61b5b268498 100644 --- a/MUON/AliMUONDDLTrigger.h +++ b/MUON/AliMUONDDLTrigger.h @@ -40,6 +40,8 @@ public: UInt_t* GetEnhancedHeader() {return &fddlWord;} + Int_t* GetGlobalInput() {return &fGlobalInput[0];} + AliRawDataHeader GetHeader(){return fHeader;} Int_t GetHeaderSize() {return sizeof(AliRawDataHeader)/4;} // in words diff --git a/MUON/AliMUONRawReader.cxx b/MUON/AliMUONRawReader.cxx index be24d01cc5a..3b3b22b7ffd 100644 --- a/MUON/AliMUONRawReader.cxx +++ b/MUON/AliMUONRawReader.cxx @@ -15,22 +15,20 @@ //////////////////////////////////// // -// MUON Raw Data generator and reader in ALICE-MUON -// This class version 3 (further details could be found in Alice-note) +// MUON Raw Data reader in ALICE-MUON +// Class version 3 (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) // -// Digits2Raw: -// Generates raw data for MUON tracker and finally for trigger -// Using real mapping (inverse) for tracker -// For trigger there is no mapping (mapping could be found in AliMUONTriggerCircuit) -// Ch. Finck july 04 // // Raw2Digits: // Using real mapping for tracker // Indranil Das (Adapted for runloader: Ch. Finck) july 05 +// Add reader for scaler trigger events +// Use memcpy instead of assignment elt by elt +// (Ch. Finck, Jan 06) // //////////////////////////////////// @@ -53,6 +51,7 @@ #include "AliMUONData.h" #include "AliMUONSubEventTracker.h" +#include "AliMUONScalerEventTrigger.h" #include "AliMUONSubEventTrigger.h" #include "AliMUONDDLTracker.h" #include "AliMUONDDLTrigger.h" @@ -73,7 +72,8 @@ ClassImp(AliMUONRawReader) // Class implementation in ROOT context //__________________________________________________________________________ AliMUONRawReader::AliMUONRawReader(AliLoader* loader, AliMUONData* data) - : TObject() + : TObject(), + fScalerEvent(kFALSE) { // Standard Constructor @@ -102,7 +102,9 @@ AliMUONRawReader::AliMUONRawReader() fLoader(0), fSegFactory(0), fDDLTracker(0), - fDDLTrigger(0) + fDDLTrigger(0), + fBusPatchManager(0), + fScalerEvent(kFALSE) { // Default Constructor @@ -172,12 +174,12 @@ Int_t AliMUONRawReader::ReadTrackerDDL(AliRawReader* rawReader) AliMUONDigit* digit = new AliMUONDigit(); - //Read Header Size of DDL,Block,DSP and BusPatch. + //Read Header Size of DDL,Block,DSP and BusPatch (put k before constant imb'cile) - Int_t ddlHeaderSize = fDDLTracker->GetHeaderSize(); - Int_t blockHeaderSize = fDDLTracker->GetBlkHeaderLength(); - Int_t dspHeaderSize = fDDLTracker->GetDspHeaderLength(); - Int_t buspatchHeaderSize = subEventTracker->GetHeaderLength(); + Int_t kDDLHeaderSize = fDDLTracker->GetHeaderSize(); + Int_t kBlockHeaderSize = fDDLTracker->GetBlkHeaderLength(); + Int_t kDspHeaderSize = fDDLTracker->GetDspHeaderLength(); + Int_t kBusPatchHeaderSize = subEventTracker->GetHeaderLength(); Int_t totalDDLSize, totalBlockSize, totalDspSize , totalBusPatchSize, dataSize; @@ -199,12 +201,12 @@ Int_t AliMUONRawReader::ReadTrackerDDL(AliRawReader* rawReader) // Each DDL is made with 2 Blocks each of which consists of 5 DSP's at most and each of DSP has at most 5 buspatches. // This information is used to calculate the size of headers (DDL,Block and DSP) which has no interesting data. - blankDDLSize = ddlHeaderSize + 2*blockHeaderSize + 2*iDspMax*dspHeaderSize; - blankBlockSize = blockHeaderSize + iDspMax*dspHeaderSize; + blankDDLSize = kDDLHeaderSize + 2*kBlockHeaderSize + 2*iDspMax*kDspHeaderSize; + blankBlockSize = kBlockHeaderSize + iDspMax*kDspHeaderSize; for (Int_t i = 0; i < iDspMax; i++) { - blankDDLSize += 2*iBusPerDSP[i]*buspatchHeaderSize; - blankBlockSize += iBusPerDSP[i]*buspatchHeaderSize; + blankDDLSize += 2*iBusPerDSP[i]*kBusPatchHeaderSize; + blankBlockSize += iBusPerDSP[i]*kBusPatchHeaderSize; } rawReader->Select(0X9, iDDL, iDDL); //Select the DDL file to be read @@ -215,12 +217,10 @@ Int_t AliMUONRawReader::ReadTrackerDDL(AliRawReader* rawReader) if(totalDDLSize > blankDDLSize) { // Compare the DDL header with an empty DDL header size to read the file - Int_t totalDataWord = rawReader->GetDataSize()/4 ; - UInt_t *buffer = new UInt_t[totalDataWord]; - for(Int_t i = 0; i < totalDataWord; i++) { - UInt_t& temp = buffer[i]; - rawReader->ReadNextInt(temp); // takes the whole result into buffer variable for future analysis - } + Int_t totalDataWord = rawReader->GetDataSize(); // in bytes + UInt_t *buffer = new UInt_t[totalDataWord/4]; + + rawReader->ReadNext((UChar_t*)buffer, totalDataWord); // elex info Int_t buspatchId; @@ -238,34 +238,41 @@ Int_t AliMUONRawReader::ReadTrackerDDL(AliRawReader* rawReader) totalBlockSize = buffer[index]; if(totalBlockSize > blankBlockSize) { // compare block header - index += blockHeaderSize; + index += kBlockHeaderSize; for(Int_t iDsp = 0; iDsp < iDspMax ;iDsp++){ //DSP loop totalDspSize = buffer[index]; indexDsp = index; - blankDspSize = dspHeaderSize + iBusPerDSP[iDsp]*buspatchHeaderSize; // no data just header + blankDspSize = kDspHeaderSize + iBusPerDSP[iDsp]*kBusPatchHeaderSize; // no data just header if(totalDspSize > blankDspSize) { // Compare DSP Header - index += dspHeaderSize; + index += kDspHeaderSize; for(Int_t iBusPatch = 0; iBusPatch < iBusPerDSP[iDsp]; iBusPatch++) { - totalBusPatchSize = buffer[index]; - buspatchId = buffer[index+2]; + //copy buffer into header structure + memcpy(subEventTracker->GetBusPatchHeader(), &buffer[index], kBusPatchHeaderSize*4); + + totalBusPatchSize = subEventTracker->GetTotalLength(); + buspatchId = subEventTracker->GetBusPatchId(); indexBusPatch = index; + - if(totalBusPatchSize > buspatchHeaderSize) { //Check Buspatch header + if(totalBusPatchSize > kBusPatchHeaderSize) { //Check Buspatch header, not empty events - index += buspatchHeaderSize; - dataSize = totalBusPatchSize - buspatchHeaderSize; + index += kBusPatchHeaderSize; + dataSize = subEventTracker->GetLength(); if(dataSize>0) { // check data present + //copy buffer into data structure + memcpy(subEventTracker->GetData(), &buffer[index], dataSize*4); + index += dataSize; + for(Int_t iData = 0; iData < dataSize; iData++) { - subEventTracker->SetData(buffer[index++],iData); //Set to extract data // digits info parity = subEventTracker->GetParity(iData); // test later for parity manuId = subEventTracker->GetManuId(iData); @@ -342,16 +349,6 @@ Int_t AliMUONRawReader::GetMapping(Int_t busPatchId, UShort_t manuId, Int_t iCath1 = 0; Int_t iCath2 = 1; -/* - AliMpPlaneType plane; - - if (manuId > 1000) { // again tmp solution (ChF) (+1000 for Non-Bending plane - plane = kNonBendingPlane; - } else { - plane = kBendingPlane; - } -*/ - if (idDE < 500) { // should use GetDirection somehow (ChF) if ( ((idDE % 100) % 2) != 0 ) { iCath1 = 1; @@ -402,15 +399,17 @@ Int_t AliMUONRawReader::ReadTriggerDDL(AliRawReader* rawReader) // reading DDL for trigger AliMUONSubEventTrigger* subEventTrigger = new AliMUONSubEventTrigger(); + AliMUONScalerEventTrigger* scalerEvent = 0x0; + AliMUONGlobalTrigger* globalTrigger = 0x0; AliMUONLocalTrigger* localTrigger = new AliMUONLocalTrigger(); - //Int_t ddlHeaderSize = fDDLTrigger->GetHeaderSize(); + //Int_t kDDLHeaderSize = fDDLTrigger->GetHeaderSize(); // we dont need this, as size of ddl data is same for triger and no trigger - Int_t ddlEnhanceHeaderSize = fDDLTrigger->GetHeaderLength(); - Int_t regHeaderLength = subEventTrigger->GetRegHeaderLength() ; + Int_t kDDLEnhanceHeaderSize = fDDLTrigger->GetHeaderLength(); + Int_t kRegHeaderSize = subEventTrigger->GetRegHeaderLength() ; Int_t loCircuit, loStripX, loDev, loStripY, loLpt, loHpt; Char_t loDecision; @@ -418,7 +417,6 @@ Int_t AliMUONRawReader::ReadTriggerDDL(AliRawReader* rawReader) UShort_t x1Pattern, x2Pattern, x3Pattern, x4Pattern; UShort_t y1Pattern, y2Pattern, y3Pattern, y4Pattern; - // loop over the two ddl's for(Int_t iDDL = 0; iDDL < 2; iDDL++) { //DDL loop @@ -426,33 +424,51 @@ Int_t AliMUONRawReader::ReadTriggerDDL(AliRawReader* rawReader) rawReader->ReadHeader(); - Int_t totalDataWord = rawReader->GetDataSize()/4 ; - UInt_t *buffer = new UInt_t[totalDataWord]; - for(Int_t i=0;iReadNextInt(temp); // takes the whole result into buffer variable for future analysis - } + Int_t totalDataWord = rawReader->GetDataSize(); // in bytes + UInt_t *buffer = new UInt_t[totalDataWord/4]; - // rawReader->ReadNext((UChar_t*)buffer, totalDataWord); // method is protected ???? + rawReader->ReadNext((UChar_t*)buffer, totalDataWord); Int_t index = 0; + fDDLTrigger->SetDDLWord(buffer[index++]); + + if(fDDLTrigger->GetEventType() == 2) { + fScalerEvent = kTRUE; + scalerEvent = new AliMUONScalerEventTrigger(); + } else + fScalerEvent = kFALSE; + + if(fScalerEvent) { + // 6 DARC scaler words + memcpy(scalerEvent->GetDarcScalers(), &buffer[index], scalerEvent->GetDarcScalerLength()*4); + index += scalerEvent->GetDarcScalerLength(); + } + + // 4 words of global board input + Global board output + memcpy(fDDLTrigger->GetGlobalInput(), &buffer[index], (kDDLEnhanceHeaderSize-1)*4); + index += kDDLEnhanceHeaderSize - 1; // kind tricky cos scaler info in-between Darc header - // fill DDL header informations - memcpy(fDDLTrigger->GetEnhancedHeader(), &buffer[index], ddlEnhanceHeaderSize*4); + if(fScalerEvent) { + // 10 Global scaler words + memcpy(scalerEvent->GetGlobalScalers(), &buffer[index], scalerEvent->GetGlobalScalerLength()*4); + index += scalerEvent->GetGlobalScalerLength(); + } // fill global trigger information globalTrigger = GetGlobalTriggerPattern(fDDLTrigger->GetGlobalOuput()); fMUONData->AddGlobalTrigger(*globalTrigger); - - index += ddlEnhanceHeaderSize; - + // 8 regional boards for (Int_t iReg = 0; iReg < 8; iReg++) { //loop over regeonal card + memcpy(subEventTrigger->GetRegHeader(), &buffer[index], kRegHeaderSize*4); + index += kRegHeaderSize; - subEventTrigger->SetRegWord(buffer[index]); //read regional data - - index += regHeaderLength; + // 11 regional scaler word + if(fScalerEvent) { + memcpy(scalerEvent->GetRegScalers(), &buffer[index], scalerEvent->GetRegScalerLength()*4); + index += scalerEvent->GetRegScalerLength(); + } // 16 local cards per regional board for (Int_t iLoc = 0; iLoc < 16; iLoc++) { //loop over local card @@ -467,9 +483,9 @@ Int_t AliMUONRawReader::ReadTriggerDDL(AliRawReader* rawReader) if(buffer[iLocIndex] > 0) { loCircuit = (Int_t)subEventTrigger->GetLocalId(iLoc)+ 16*iReg + 128*iDDL; - loStripX = (Int_t)subEventTrigger->GetXPos(iLoc); - loStripY = (Int_t)subEventTrigger->GetYPos(iLoc); - loDev = (Int_t)subEventTrigger->GetXDev(iLoc); + loStripX = (Int_t)subEventTrigger->GetXPos(iLoc); + loStripY = (Int_t)subEventTrigger->GetYPos(iLoc); + loDev = (Int_t)subEventTrigger->GetXDev(iLoc); // fill local trigger localTrigger->SetLoCircuit(loCircuit); @@ -508,6 +524,12 @@ Int_t AliMUONRawReader::ReadTriggerDDL(AliRawReader* rawReader) localTrigger->SetY4Pattern(y4Pattern); fMUONData->AddLocalTrigger(*localTrigger); + } // if buffer[] > 0 + + // 45 regional scaler word + if(fScalerEvent) { + memcpy(scalerEvent->GetLocalScalers(), &buffer[index], scalerEvent->GetLocalScalerLength()*4); + index += scalerEvent->GetLocalScalerLength(); } } // local card loop @@ -521,6 +543,9 @@ Int_t AliMUONRawReader::ReadTriggerDDL(AliRawReader* rawReader) delete globalTrigger; delete localTrigger; + if(fScalerEvent) + delete scalerEvent; + return kTRUE; } diff --git a/MUON/AliMUONRawReader.h b/MUON/AliMUONRawReader.h index 64304e791df..af8aae58d64 100644 --- a/MUON/AliMUONRawReader.h +++ b/MUON/AliMUONRawReader.h @@ -44,6 +44,7 @@ class AliMUONRawReader : public TObject AliMUONGlobalTrigger* GetGlobalTriggerPattern(Int_t gloTrg) const; + void SetScalerEvent() {fScalerEvent = kTRUE;} protected: AliMUONRawReader(); // Default constructor @@ -62,7 +63,9 @@ class AliMUONRawReader : public TObject AliMUONDDLTracker* fDDLTracker; //! DDL tracker class pointers AliMUONDDLTrigger* fDDLTrigger; //! DDL trigger class pointers - AliMpBusPatch* fBusPatchManager; //! buspatch versus DE's & DDL + AliMpBusPatch* fBusPatchManager; //! buspatch versus DE's & DDL + + Bool_t fScalerEvent; // flag to generates scaler event ClassDef(AliMUONRawReader,1) // MUON cluster reconstructor in ALICE }; diff --git a/MUON/AliMUONRawWriter.cxx b/MUON/AliMUONRawWriter.cxx index 01476bd1cdf..0920263d9e3 100644 --- a/MUON/AliMUONRawWriter.cxx +++ b/MUON/AliMUONRawWriter.cxx @@ -15,7 +15,7 @@ //////////////////////////////////// // -// MUON Raw Data generator and reader in ALICE-MUON +// MUON Raw Data generaton in ALICE-MUON // This class version 3 (further details could be found in Alice-note) // // Implemented non-constant buspatch numbers for tracking @@ -27,10 +27,10 @@ // Using real mapping (inverse) for tracker // For trigger there is no mapping (mapping could be found in AliMUONTriggerCircuit) // Ch. Finck july 04 -// -// Raw2Digits: -// Using real mapping for tracker -// Indranil Das (Adapted for runloader: Ch. Finck) july 05 +// Use memcpy instead of assignment elt by elt +// Introducing variable DSP numbers, real manu numbers per buspatch for st12 +// Implemented scaler event for Trigger +// Ch. Finck , Jan. 06 // //////////////////////////////////// @@ -53,6 +53,7 @@ #include "AliMUONData.h" #include "AliMUONSubEventTrigger.h" +#include "AliMUONScalerEventTrigger.h" #include "AliMUONDDLTracker.h" #include "AliMUONDDLTrigger.h" @@ -68,11 +69,19 @@ #include "AliMpHelper.h" #include "AliMpPad.h" - ClassImp(AliMUONRawWriter) // Class implementation in ROOT context + +Int_t AliMUONRawWriter::fgManuPerBusSwp1B[12] = {1, 27, 53, 79, 105, 131, 157, 183, 201, 214, 224, 232}; +Int_t AliMUONRawWriter::fgManuPerBusSwp1NB[12] = {1, 27, 53, 79, 105, 131, 157, 183, 201, 214, 225, 233}; + +Int_t AliMUONRawWriter::fgManuPerBusSwp2B[12] = {1, 27, 53, 79, 105, 131, 157, 183, 201, 214, 226, 246}; +Int_t AliMUONRawWriter::fgManuPerBusSwp2NB[12] = {1, 27, 53, 79, 105, 131, 157, 183, 201, 214, 227, 245}; + + //__________________________________________________________________________ AliMUONRawWriter::AliMUONRawWriter(AliLoader* loader, AliMUONData* data) - : TObject() + : TObject(), + fScalerEvent(kFALSE) { // Standard Constructor @@ -83,7 +92,6 @@ AliMUONRawWriter::AliMUONRawWriter(AliLoader* loader, AliMUONData* data) fSegFactory = new AliMpSegFactory(); // initialize container -// fMUONData = new AliMUONData(fLoader,"MUON","MUON"); fMUONData = data; // initialize array @@ -96,7 +104,6 @@ AliMUONRawWriter::AliMUONRawWriter(AliLoader* loader, AliMUONData* data) fBusPatchManager = new AliMpBusPatch(); fBusPatchManager->ReadBusPatchFile(); - } //__________________________________________________________________________ @@ -106,7 +113,9 @@ AliMUONRawWriter::AliMUONRawWriter() fLoader(0), fSegFactory(0), fDDLTracker(0), - fDDLTrigger(0) + fDDLTrigger(0), + fBusPatchManager(0), + fScalerEvent(kFALSE) { // Default Constructor fFile[0] = fFile[1] = 0x0; @@ -412,7 +421,7 @@ Int_t AliMUONRawWriter::WriteTrackerDDL(Int_t iCh) if (busPatchId != -1) { // add bus patch structure length = temp->GetHeaderLength(); - memcpy(&buffer[index],temp->GetAddress(),length*4); + memcpy(&buffer[index],temp->GetBusPatchHeader(),length*4); index += length; for (Int_t j = 0; j < temp->GetLength(); j++) { buffer[index++] = temp->GetData(j); @@ -451,12 +460,113 @@ Int_t AliMUONRawWriter::WriteTrackerDDL(Int_t iCh) return kTRUE; } + +//____________________________________________________________________ +Int_t AliMUONRawWriter::GetInvMapping(const AliMUONDigit* digit, + Int_t &busPatchId, UShort_t &manuId, UChar_t &channelId) +{ + + // Inverse mapping for tracker + + Int_t* ptr = 0; + + // information from digits + Int_t iCath = digit->Cathode(); + Int_t idDE = digit->DetElemId(); + Int_t padX = digit->PadX(); + Int_t padY = digit->PadY(); + Int_t iCh = idDE/100; + + if (idDE >= 500) { // Since in AliMpSlat pads begin at (0,0) + padX--; // while in AliMUONSt345Seg. they begin at (1,1) + padY--; + } + + // segmentation + AliMpPlaneType plane; + AliMpPlaneType plane1 = kBendingPlane; + AliMpPlaneType plane2 = kNonBendingPlane; + + if (idDE < 500) { // should use GetDirection somehow (ChF) + if ( ((idDE % 100) % 2) != 0 ) { + plane1 = kNonBendingPlane; + plane2 = kBendingPlane; + } + } + // station 345 bending == cath0 for the moment + plane = (iCath == 0) ? plane1 : plane2; + + if (idDE < 500) { + if (iCh == 1 || iCh == 2) + if (plane == kBendingPlane) + ptr = &fgManuPerBusSwp1B[0]; + else + ptr = &fgManuPerBusSwp1NB[0]; + else + if (plane == kBendingPlane) + ptr = &fgManuPerBusSwp2B[0]; + else + ptr = &fgManuPerBusSwp2NB[0]; + } + + //AliMpVSegmentation* seg = AliMUONSegmentationManager::Segmentation(idDE, plane); + AliMpVSegmentation* seg = fSegFactory->CreateMpSegmentation(idDE, iCath); + AliMpPad pad = seg->PadByIndices(AliMpIntPair(padX,padY),kTRUE); + + if (!pad.IsValid()) { + AliWarning(Form("No elec. for idDE: %d, padx: %d pady %d, charge: %d\n", + idDE, digit->PadX(), digit->PadY(), digit->Signal())); + return kTRUE; + } + + // Getting Manu id + manuId = pad.GetLocation().GetFirst(); + manuId &= 0x7FF; // 11 bits + + // Getting channel id + channelId = pad.GetLocation().GetSecond(); + channelId &= 0x3F; // 6 bits + + // Getting buspatch id + TArrayI* vec = fBusPatchManager->GetBusfromDE(idDE); + Int_t pos = 0; + + if (idDE < 500) { // station 1 & 2 + for (Int_t i = 0; i < 12; i++) + if (manuId >= *(ptr + pos++)) + break; + // while(*(ptr + pos) <= manuId) +// pos++; +// pos--; + } else { + // offset of 100 in manuId for following bus patch + pos = manuId/100; + } + + if (pos >(Int_t) vec->GetSize()) + AliWarning(Form("pos greater %d than size %d manuId %d idDE %d \n", + pos, (Int_t)vec->GetSize(), manuId, idDE)); + busPatchId = vec->At(pos); + + if (plane == kNonBendingPlane) // for Non-Bending manuid+= 1000; + manuId += 1000; // tmp solution til one finds something better (ChF) + + AliDebug(3,Form("idDE: %d, busPatchId %d, manuId: %d, channelId:%d\n", + idDE, busPatchId, manuId, channelId)); + + AliDebug(3,Form("idDE: %d, busPatchId %d, manuId: %d, channelId: %d, padx: %d pady: %d, charge: %d\n", + idDE, busPatchId, manuId, channelId, digit->PadX(), digit->PadY(), digit->Signal())); + + return kFALSE; // no error +} + //____________________________________________________________________ Int_t AliMUONRawWriter::WriteTriggerDDL() { // DDL event one per half chamber - AliMUONSubEventTrigger* subEvent = 0x0; + AliMUONSubEventTrigger* subEvent = 0x0; + AliMUONScalerEventTrigger* scalerEvent = 0x0; // stored local id number @@ -467,7 +577,7 @@ Int_t AliMUONRawWriter::WriteTriggerDDL() // DDL header AliRawDataHeader header = fDDLTrigger->GetHeader(); Int_t headerSize = fDDLTrigger->GetHeaderSize(); - Int_t length; + TClonesArray* localTrigger; TClonesArray* globalTrigger; AliMUONGlobalTrigger* gloTrg; @@ -496,6 +606,9 @@ Int_t AliMUONRawWriter::WriteTriggerDDL() Int_t serialNb = 0xF; // serial nb of card: all bits on for the moment Int_t globalFlag = 1; // set to 2 if global info present in DDL else set to 1 + if(fScalerEvent) + eventType = 2; //set to generate scaler events + Int_t nEntries = (Int_t) (localTrigger->GetEntries());// 234 local cards // stored the local card id that's fired for (Int_t i = 0; i < nEntries; i++) { @@ -506,7 +619,17 @@ Int_t AliMUONRawWriter::WriteTriggerDDL() if (!nEntries) AliError("No Trigger information available"); - buffer = new Int_t [672]; // [16(local)*5 words + 3 words]*8(reg) + 8 words = 672 + if(fScalerEvent) + // [16(local)*50 words + 14 words]*8(reg) + 6 + 10 + 6 words scaler event 6534 words + buffer = new Int_t [6534]; + else + // [16(local)*5 words + 3 words]*8(reg) + 8 words = 672 + buffer = new Int_t [672]; + + if(fScalerEvent) { + scalerEvent = new AliMUONScalerEventTrigger(); + scalerEvent->SetNumbers(); // set some numbers for scalers + } // open DDL file, on per 1/2 chamber for (Int_t iDDL = 0; iDDL < 2; iDDL++) { @@ -524,16 +647,31 @@ Int_t AliMUONRawWriter::WriteTriggerDDL() globalFlag = 2; else globalFlag = 1; + AliBitPacking::PackWord((UInt_t)globalFlag,word,8,11); fDDLTrigger->SetDDLWord(word); + buffer[index++]= word; if (iDDL == 0) fDDLTrigger->SetGlobalOutput(gloTrigPat);// no global input for the moment.... else fDDLTrigger->SetGlobalOutput(0); - length = fDDLTrigger->GetHeaderLength(); - memcpy(&buffer[index],fDDLTrigger->GetEnhancedHeader(),length*4); - index += length; + + if (fScalerEvent) { + // 6 DARC scaler words + memcpy(&buffer[index], scalerEvent->GetDarcScalers(),scalerEvent->GetDarcScalerLength()*4); + index += scalerEvent->GetDarcScalerLength(); + } + + // 4 words of global board input + Global board output + memcpy(&buffer[index], fDDLTrigger->GetGlobalInput(), (fDDLTrigger->GetHeaderLength()-1)*4); + index += fDDLTrigger->GetHeaderLength() - 1; // kind tricky cos scaler info in-between Darc header + + if (fScalerEvent) { + // 10 Global scaler words + memcpy(scalerEvent->GetGlobalScalers(), &buffer[index], scalerEvent->GetGlobalScalerLength()*4); + index += scalerEvent->GetGlobalScalerLength(); + } // 8 regional cards per DDL for (Int_t iReg = 0; iReg < 8; iReg++) { @@ -549,10 +687,14 @@ Int_t AliMUONRawWriter::WriteTriggerDDL() AliBitPacking::PackWord((UInt_t)regOut,word,0,7); // whenever regional output will be implemented subEvent->SetRegWord(word); - memcpy(&buffer[index++],subEvent->GetAddress(),4); + memcpy(&buffer[index],subEvent->GetRegHeader(),subEvent->GetRegHeaderLength()*4); + index += subEvent->GetRegHeaderLength(); - buffer[index++] = 0;// 2 words of regional input - buffer[index++] = 0; + // 11 regional scaler word + if (fScalerEvent) { + memcpy(&buffer[index], scalerEvent->GetRegScalers(), scalerEvent->GetRegScalerLength()*4); + index += scalerEvent->GetRegScalerLength(); + } // 16 local card per regional board for (Int_t iLoc = 0; iLoc < 16; iLoc++) { @@ -604,6 +746,12 @@ Int_t AliMUONRawWriter::WriteTriggerDDL() buffer[index++] = (Int_t)word; // data word } + // 45 regional scaler word + if (fScalerEvent) { + memcpy(&buffer[index], scalerEvent->GetLocalScalers(), scalerEvent->GetLocalScalerLength()*4); + index += scalerEvent->GetLocalScalerLength(); + } + } // local card delete subEvent; @@ -622,85 +770,10 @@ Int_t AliMUONRawWriter::WriteTriggerDDL() } delete[] buffer; - return kTRUE; -} + if (fScalerEvent) + delete scalerEvent; -//____________________________________________________________________ -Int_t AliMUONRawWriter::GetInvMapping(const AliMUONDigit* digit, - Int_t &busPatchId, UShort_t &manuId, UChar_t &channelId) -{ - - // Inverse mapping for tracker - - // information from digits - Int_t iCath = digit->Cathode(); - Int_t idDE = digit->DetElemId(); - Int_t padX = digit->PadX(); - Int_t padY = digit->PadY(); - - if (idDE >= 500) { // Since in AliMpSlat pads begin at (0,0) - padX--; // while in AliMUONSt345Seg. they begin at (1,1) - padY--; - } - - // segmentation - AliMpPlaneType plane; - AliMpPlaneType plane1 = kBendingPlane; - AliMpPlaneType plane2 = kNonBendingPlane; - - if (idDE < 500) { // should use GetDirection somehow (ChF) - if ( ((idDE % 100) % 2) != 0 ) { - plane1 = kNonBendingPlane; - plane2 = kBendingPlane; - } - } - // station 345 bending == cath0 for the moment - plane = (iCath == 0) ? plane1 : plane2; - - //AliMpVSegmentation* seg = AliMUONSegmentationManager::Segmentation(idDE, plane); - AliMpVSegmentation* seg = fSegFactory->CreateMpSegmentation(idDE, iCath); - AliMpPad pad = seg->PadByIndices(AliMpIntPair(padX,padY),kTRUE); - - if(!pad.IsValid()) { - AliWarning(Form("No elec. for idDE: %d, padx: %d pady %d, charge: %d\n", - idDE, digit->PadX(), digit->PadY(), digit->Signal())); - return kTRUE; - } - - // Getting Manu id - manuId = pad.GetLocation().GetFirst(); - manuId &= 0x7FF; // 11 bits - - // Getting channel id - channelId = pad.GetLocation().GetSecond(); - channelId &= 0x3F; // 6 bits - - // Getting buspatch id - TArrayI* vec = fBusPatchManager->GetBusfromDE(idDE); - Int_t pos; - - if (idDE < 500) { // station 1 & 2 - // set 32 manus for one bus patch ? (ChF) - pos = manuId/32; - } else { - // offset of 100 in manuId for following bus patch - pos = manuId/100; - } - - // if (pos >(int_t) vec.size()) -// AliWarning("pos greater than size\n"); - busPatchId = vec->At(pos); - - if (plane == kNonBendingPlane) // for Non-Bending manuid+= 1000; - manuId += 1000; // tmp solution til one finds something better (ChF) - - AliDebug(3,Form("idDE: %d, busPatchId %d, manuId: %d, channelId:%d\n", - idDE, busPatchId, manuId, channelId)); - - AliDebug(3,Form("idDE: %d, busPatchId %d, manuId: %d, channelId: %d, padx: %d pady: %d, charge: %d\n", - idDE, busPatchId, manuId, channelId, digit->PadX(), digit->PadY(), digit->Signal())); - - return kFALSE; // no error + return kTRUE; } //____________________________________________________________________ diff --git a/MUON/AliMUONRawWriter.h b/MUON/AliMUONRawWriter.h index b69bb2c8e08..c20c73139e9 100644 --- a/MUON/AliMUONRawWriter.h +++ b/MUON/AliMUONRawWriter.h @@ -50,6 +50,8 @@ class AliMUONRawWriter : public TObject Int_t GetGlobalTriggerPattern(const AliMUONGlobalTrigger* gloTrg) const; + void SetScalerEvent() {fScalerEvent = kTRUE;} + protected: AliMUONRawWriter(); // Default constructor AliMUONRawWriter (const AliMUONRawWriter& rhs); // copy constructor @@ -70,7 +72,15 @@ class AliMUONRawWriter : public TObject AliMUONDDLTracker* fDDLTracker; //! DDL tracker class pointers AliMUONDDLTrigger* fDDLTrigger; //! DDL trigger class pointers - AliMpBusPatch* fBusPatchManager; //! buspatch versus DE's & DDL + AliMpBusPatch* fBusPatchManager; //! buspatch versus DE's & DDL + + Bool_t fScalerEvent; // flag to generates scaler event + + static Int_t fgManuPerBusSwp1B[12]; //! array containing the first manuId for each buspatch st1, Bending + static Int_t fgManuPerBusSwp1NB[12]; //! array containing the first manuId for each buspatch st1, NBending + + static Int_t fgManuPerBusSwp2B[12]; //! array containing the first manuId for each buspatch st2, Bending + static Int_t fgManuPerBusSwp2NB[12]; //! array containing the first manuId for each buspatch st2, NBending // writing raw data Int_t WriteTrackerDDL(Int_t iCh); diff --git a/MUON/AliMUONScalerEventTrigger.cxx b/MUON/AliMUONScalerEventTrigger.cxx index 1a805a2f6af..696b8fb1f5c 100644 --- a/MUON/AliMUONScalerEventTrigger.cxx +++ b/MUON/AliMUONScalerEventTrigger.cxx @@ -17,9 +17,9 @@ ClassImp(AliMUONScalerEventTrigger) const Int_t AliMUONScalerEventTrigger::fgkLocalScalerLength = 45; - const Int_t AliMUONScalerEventTrigger::fgkRegScalerLength = 11; + const Int_t AliMUONScalerEventTrigger::fgkRegScalerLength = 8; const Int_t AliMUONScalerEventTrigger::fgkGlobalScalerLength = 10; - const Int_t AliMUONScalerEventTrigger::fgkDarcScalerLength = 6; + const Int_t AliMUONScalerEventTrigger::fgkDarcScalerLength = 6; //___________________________________________ AliMUONScalerEventTrigger::AliMUONScalerEventTrigger() @@ -63,3 +63,48 @@ AliMUONScalerEventTrigger::AliMUONScalerEventTrigger() fGlobalScaler[i] = 0; } +//___________________________________________ +void AliMUONScalerEventTrigger::SetNumbers() +{ + // set crasy numbers for scaler words, while no beam is coming + + fLocalL0 = 1000; + fLocalHold = 100; + fLocalClk = 10000; + fLocalLPtNTrig = 1; + fLocalHPtNTrig = 1; + fLocalLPtRTrig = 2; + fLocalHPtRTrig = 2; + fLocalLPtLTrig = 3; + fLocalHPtLTrig = 3; + fLocalLPtSTrig = 4; + fLocalHPtSTrig = 4; + fLocalEOS = 0x2AA; + fLocalReset = 10; + + fRegL0 = 1000; + fRegClk = 10000; + fRegHold = 100; + + fGlobalL0 = 1000; + fGlobalClk = 10000; + fGlobalHold = 100; + fGlobalSpare = 1; + + fDarcL0R = 1000; + fDarcL0U = 900; + fDarcL0P = 800; + fDarcL0S = 700; + fDarcClk = 10000; + fDarcHold = 100; + + for (Int_t i = 0; i < 8*4; i++) + fLocalScaler[i] = i; + + for (Int_t i = 0; i < 8; i++) + fRegScaler[i] = i; + + for (Int_t i = 0; i < 6; i++) + fGlobalScaler[i] = i; + +} diff --git a/MUON/AliMUONScalerEventTrigger.h b/MUON/AliMUONScalerEventTrigger.h index 70cd0861199..0c72058723b 100644 --- a/MUON/AliMUONScalerEventTrigger.h +++ b/MUON/AliMUONScalerEventTrigger.h @@ -66,6 +66,9 @@ public: Int_t GetGlobalScalerLength() const {return fgkGlobalScalerLength;} Int_t GetDarcScalerLength() const {return fgkDarcScalerLength;} + // set random numbers to fill variable + void SetNumbers(); + private: // local card scalers diff --git a/MUON/AliMUONSubEventTracker.h b/MUON/AliMUONSubEventTracker.h index 912e6342af5..5b681f7bd9a 100644 --- a/MUON/AliMUONSubEventTracker.h +++ b/MUON/AliMUONSubEventTracker.h @@ -35,7 +35,7 @@ public: void SetLength(Int_t l) {fLength = l;} void SetBusPatchId(Int_t b) {fBusPatchId = b;} void SetTriggerWord(Int_t w) {fTriggerWord = w;} - void SetData(UInt_t d, Int_t n) {fData[n] = d; fLength++;} + void SetData(UInt_t d, Int_t n) {fData[n] = d;} void AddData(UInt_t d); void SetAlloc(Int_t size); @@ -43,9 +43,9 @@ public: Bool_t IsSortable() const {return kTRUE;} Int_t Compare(const TObject *obj) const; - Int_t GetHeaderLength() const {return fgkHeaderLength;} + Int_t GetHeaderLength() const {return fgkHeaderLength;} - Int_t* GetAddress() {return &fTotalLength;} + Int_t* GetBusPatchHeader() {return &fTotalLength;} private: Int_t fTotalLength; // total length of buspatch structure diff --git a/MUON/AliMUONSubEventTrigger.h b/MUON/AliMUONSubEventTrigger.h index 13e6c348726..afbda4f9776 100644 --- a/MUON/AliMUONSubEventTrigger.h +++ b/MUON/AliMUONSubEventTrigger.h @@ -49,8 +49,8 @@ public: void SetRegInput(UInt_t in, Int_t n) {fRegInput[n] = in;} void SetLocalData(UInt_t d, Int_t n) {fLocalData[n] = d;} - Int_t GetRegHeaderLength() const {return fgkRegHeaderLength;} - UInt_t* GetAddress() {return &fRegWord;} + Int_t GetRegHeaderLength() const {return fgkRegHeaderLength;} + UInt_t* GetRegHeader() {return &fRegWord;} private: -- 2.43.0