]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
New class for managing buspatch<>DDL<>DE maps separated from
authorivana <ivana@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 19 Dec 2005 09:12:50 +0000 (09:12 +0000)
committerivana <ivana@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 19 Dec 2005 09:12:50 +0000 (09:12 +0000)
AliMUONRawData
(Christian)

MUON/mapping/AliMpBusPatch.cxx [new file with mode: 0644]
MUON/mapping/AliMpBusPatch.h [new file with mode: 0644]

diff --git a/MUON/mapping/AliMpBusPatch.cxx b/MUON/mapping/AliMpBusPatch.cxx
new file mode 100644 (file)
index 0000000..2f1c8d9
--- /dev/null
@@ -0,0 +1,199 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+// $Id$
+// $MpId: $
+// Category: basic
+//
+// Class AliMpBusPatch
+// ---------------
+// Class that manages the maps buspatch<>DDL<>DE 
+// for the mapping
+// Calculates also the maximum DSP and buspatch numbers for a given DE
+//
+// Author: Ch. Finck; Subatech Nantes
+
+#include "AliMpBusPatch.h"
+#include "AliMpFiles.h"
+#include "AliMpHelper.h"
+
+#include "AliLog.h"
+
+#include <Riostream.h>
+
+ClassImp(AliMpBusPatch)
+
+//////////////////////////////////////////////////////////
+//
+// This class contains the informations about buspatch vs (DE-DDL)
+//
+//////////////////////////////////////////////////////////
+
+
+//_____________________________________________________________________________
+AliMpBusPatch::AliMpBusPatch()
+  : TObject(),
+    fDetElemIdToBusPatch(300),
+    fBusPatchToDetElem(300),
+    fBusPatchToDDL(300)
+{
+/// Default constructor
+
+  for (Int_t i = 0; i < 10; i++)
+    fMaxBusPerCh[i] = 0;
+
+}
+
+
+//_____________________________________________________________________________
+AliMpBusPatch::AliMpBusPatch(const AliMpBusPatch& rhs)
+  : TObject(rhs)
+{
+/// Copy constructor
+
+ *this = rhs;
+}
+
+//_____________________________________________________________________________
+AliMpBusPatch::~AliMpBusPatch() 
+{
+/// Destructor
+
+  fDetElemIdToBusPatch.Delete();
+  fBusPatchToDetElem.Delete();
+  fBusPatchToDDL.Delete();
+}
+
+//_____________________________________________________________________________
+AliMpBusPatch& AliMpBusPatch::operator = (const AliMpBusPatch& /*rhs*/) 
+{
+/// Assignment operator
+  AliFatal("= operator not implemented");
+
+  return *this;
+}
+
+//____________________________________________________________________
+Int_t AliMpBusPatch::GetDEfromBus(Int_t busPatchId)
+{
+ /// getting DE id from bus patch
+  Long_t it = fBusPatchToDetElem.GetValue(busPatchId);
+
+ if ( it ) 
+   return (Int_t)it;
+ else 
+   return -1;
+}
+
+//____________________________________________________________________
+TArrayI*  AliMpBusPatch::GetBusfromDE(Int_t idDE)
+{
+/// getting bus patch from DE id 
+
+  return (TArrayI*)fDetElemIdToBusPatch.GetValue(idDE);
+}
+//____________________________________________________________________
+Int_t AliMpBusPatch::GetDDLfromBus(Int_t busPatchId)
+{
+/// getting DE id from bus patch
+  Long_t it = fBusPatchToDDL.GetValue(busPatchId);
+
+ if ( it ) 
+   return (Int_t)it;
+ else 
+   return -1;
+}
+
+//____________________________________________________________________
+void AliMpBusPatch::GetDspInfo(Int_t iCh, Int_t& iDspMax, Int_t* iBusPerDSP)
+{
+/// calculates the number of DSP & buspatch per block
+
+  Int_t iBusPerBlk = fMaxBusPerCh[iCh]/4; //per half chamber; per block
+
+  iDspMax =  iBusPerBlk/5; //number max of DSP per block
+  if (iBusPerBlk % 5 != 0)
+    iDspMax += 1;
+  
+  for (Int_t i = 0; i < iDspMax; i++) {
+    if ((iBusPerBlk -= 5) > 0) 
+      iBusPerDSP[i] = 5;
+    else 
+      iBusPerDSP[i] = iBusPerBlk + 5;
+  }
+  
+}
+//____________________________________________________________________
+void AliMpBusPatch::ReadBusPatchFile()
+{
+/// idDE <> buspatch <> iDDL map's
+  
+   TString infile = AliMpFiles::BusPatchFilePath();
+
+   ifstream in(infile, ios::in);
+   if (!in) AliError("DetElemIdToBusPatch.dat not found.");
+       
+   char line[80];
+
+   Int_t iChprev = 1;
+   Int_t maxBusPatch = 0;
+
+   while ( in.getline(line,80) ) {
+
+      if ( line[0] == '#' ) continue;
+
+      TString tmp(AliMpHelper::Normalize(line));
+
+      Int_t blankPos  = tmp.First(' ');
+      Int_t blankPos1 = tmp.Last(' ');
+
+      TString sDE(tmp(0, blankPos));
+
+      Int_t idDE = atoi(sDE.Data());
+      
+      if (idDE/100 != iChprev) {
+       fMaxBusPerCh[iChprev-1] = maxBusPatch-iChprev*100+1;
+       iChprev = idDE/100;
+      }
+
+      TString sDDL(tmp(blankPos1 + 1, tmp.Length()-blankPos1));
+
+      Int_t iDDL = atoi(sDDL.Data());
+
+      TString busPatch(tmp(blankPos + 1,blankPos1-blankPos-1));
+      AliDebug(3,Form("idDE %d buspatch %s iDDL %d\n", idDE, busPatch.Data(), iDDL));
+
+      TArrayI busPatchList;
+      // decoding range of buspatch
+      AliMpHelper::DecodeName(busPatch,';',busPatchList);
+      
+      // filling buspatch -> idDE
+      for (Int_t i = 0; i < busPatchList.GetSize(); i++) {
+       fBusPatchToDetElem.Add((Long_t)busPatchList[i],(Long_t)idDE);
+       fBusPatchToDDL.Add((Long_t)busPatchList[i],(Long_t)iDDL);
+       maxBusPatch = busPatchList[i];
+      }
+   
+      // filling idDE -> buspatch list (vector)
+      fDetElemIdToBusPatch.Add((Long_t)idDE, (Long_t)(new TArrayI(busPatchList))); 
+
+    }
+   
+   fMaxBusPerCh[iChprev-1] = maxBusPatch-iChprev*100+1;
+
+  in.close();
+
+}
diff --git a/MUON/mapping/AliMpBusPatch.h b/MUON/mapping/AliMpBusPatch.h
new file mode 100644 (file)
index 0000000..c81ae26
--- /dev/null
@@ -0,0 +1,54 @@
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+// $Id$
+// $MpId: $
+
+/// \ingroup basic
+/// \class AliMpBusPatch
+/// \brief Class that manages the maps buspatch<>DDL<>DE 
+///
+/// Calculates also the maximum DSP and buspatch numbers for a given DE
+///
+/// Author: Ch. Finck; Subatech Nantes
+
+#ifndef ALI_MP_BUSPATCH_H
+#define ALI_MP_BUSPATCH_H
+
+#include <TArrayI.h>
+#include <TExMap.h>
+#include <TObject.h>
+
+class AliMpBusPatch : public TObject
+{
+
+ public:
+
+  AliMpBusPatch();
+  AliMpBusPatch(const AliMpBusPatch& src);
+  virtual ~AliMpBusPatch();
+
+  // operators  
+  AliMpBusPatch& operator = (const AliMpBusPatch& src) ;
+  
+  // methods
+  void ReadBusPatchFile();
+  void GetDspInfo(Int_t iCh, Int_t& iDspMax, Int_t* iBusPerDSP);
+
+  Int_t    GetDEfromBus(Int_t busPatchId);
+  TArrayI* GetBusfromDE(Int_t idDE);
+  Int_t    GetDDLfromBus(Int_t busPatchId);
+
+ private:
+
+  TExMap fDetElemIdToBusPatch;       //! Map from idDE to BusPatch   
+  TExMap fBusPatchToDetElem;         //! Map from BusPatch to idDE
+  TExMap fBusPatchToDDL;             //! Map from BusPatch to iDDL
+
+  Int_t fMaxBusPerCh[10];            //! max buspatch number per chamber
+
+  ClassDef(AliMpBusPatch,1) //utility class for the motif type
+};
+
+
+#endif //ALI_MP_BUSPATCH_H