Mapping file put in the CDB
authorbasanta <basanta@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 23 Oct 2009 03:04:44 +0000 (03:04 +0000)
committerbasanta <basanta@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 23 Oct 2009 03:04:44 +0000 (03:04 +0000)
PMD/AliPMDMappingData.cxx [new file with mode: 0644]
PMD/AliPMDMappingData.h [new file with mode: 0644]
PMD/AliPMDReadMapping.C [new file with mode: 0644]
PMD/CreateMappingCDB.C [new file with mode: 0644]

diff --git a/PMD/AliPMDMappingData.cxx b/PMD/AliPMDMappingData.cxx
new file mode 100644 (file)
index 0000000..85dcdc5
--- /dev/null
@@ -0,0 +1,174 @@
+/***************************************************************************
+ * 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.                  *
+ **************************************************************************/
+//
+// Author : 
+//
+#include "TNamed.h"
+#include "AliCDBEntry.h"
+#include "AliPMDMappingData.h"
+
+
+ClassImp(AliPMDMappingData)
+
+AliPMDMappingData::AliPMDMappingData()
+{
+  // Default constructor
+  Reset();
+}
+// ----------------------------------------------------------------- //
+AliPMDMappingData::AliPMDMappingData(const char* name)
+{
+  //constructor
+  TString namst = "Calib_";
+  namst += name;
+  SetName(namst.Data());
+  SetTitle(namst.Data());
+  Reset();
+  
+}
+// ----------------------------------------------------------------- //
+AliPMDMappingData::AliPMDMappingData(const AliPMDMappingData& mapda) :
+  TNamed(mapda)
+{
+  // copy constructor
+  SetName(mapda.GetName());
+  SetTitle(mapda.GetName());
+  Reset();
+  for(Int_t iddl = 0; iddl < kDdl; iddl++)
+    {
+      for(Int_t ibus = 0; ibus < kBus; ibus++)
+       {
+         fModuleNo[iddl][ibus]=
+           mapda.GetModuleNo(iddl,ibus);
+       }
+    }
+
+}
+// ----------------------------------------------------------------- //
+AliPMDMappingData &AliPMDMappingData::operator =(const AliPMDMappingData& mapda)
+{
+  //asignment operator
+  SetName(mapda.GetName());
+  SetTitle(mapda.GetName());
+  Reset();
+
+  for(Int_t iddl = 0; iddl < kDdl; iddl++)
+    {
+      for(Int_t ibus = 0; ibus < kBus; ibus++)
+       {
+         fModuleNo[iddl][ibus]=
+           mapda.GetModuleNo(iddl,ibus);
+       }
+    }
+
+  return *this;
+}
+// ----------------------------------------------------------------- //
+AliPMDMappingData::~AliPMDMappingData()
+{
+  //destructor
+}
+// ----------------------------------------------------------------- //
+void AliPMDMappingData::Reset()
+{
+
+  for(Int_t iddl = 0; iddl < kDdl; iddl++)
+    {
+      for(Int_t ibus = 0; ibus < kBus; ibus++)
+       {
+         fModuleNo[iddl][ibus]    = -1;
+         fMcmperBus[iddl][ibus]   = -1;
+         fStartRowBus[iddl][ibus] = -1;
+         fEndRowBus[iddl][ibus]   = -1;
+         fStartColBus[iddl][ibus] = -1;
+         fEndColBus[iddl][ibus]   = -1;
+       }
+    }
+
+}
+// ----------------------------------------------------------------- //
+Int_t AliPMDMappingData:: GetModuleNo(Int_t iddl, Int_t ibus) const
+{
+  return fModuleNo[iddl][ibus];
+}
+// ----------------------------------------------------------------- //
+Int_t AliPMDMappingData:: GetMcmperBus(Int_t iddl, Int_t ibus) const
+{
+  return fMcmperBus[iddl][ibus];
+}
+// ----------------------------------------------------------------- //
+Int_t AliPMDMappingData:: GetStartRowBus(Int_t iddl, Int_t ibus) const
+{
+  return fStartRowBus[iddl][ibus];
+}
+// ----------------------------------------------------------------- //
+Int_t AliPMDMappingData:: GetEndRowBus(Int_t iddl, Int_t ibus) const
+{
+  return fEndRowBus[iddl][ibus];
+}
+// ----------------------------------------------------------------- //
+Int_t AliPMDMappingData:: GetStartColBus(Int_t iddl, Int_t ibus) const
+{
+  return fStartColBus[iddl][ibus];
+}
+// ----------------------------------------------------------------- //
+Int_t AliPMDMappingData:: GetEndColBus(Int_t iddl, Int_t ibus) const
+{
+  return fEndColBus[iddl][ibus];
+}
+// ----------------------------------------------------------------- //
+void AliPMDMappingData::SetModuleNo(Int_t iddl, Int_t ibus, Int_t modno)
+{
+  fModuleNo[iddl][ibus] = modno;
+}
+// ----------------------------------------------------------------- //
+void AliPMDMappingData::SetMcmperBus(Int_t iddl, Int_t ibus, Int_t totmcm)
+{
+  fMcmperBus[iddl][ibus] = totmcm;
+}
+
+// ----------------------------------------------------------------- //
+void AliPMDMappingData::SetRowBus(Int_t iddl,Int_t ibus,Int_t rows,Int_t rowe)
+{
+  fStartRowBus[iddl][ibus] = rows;
+  fEndRowBus[iddl][ibus]   = rowe;
+}
+
+// ----------------------------------------------------------------- //
+void AliPMDMappingData::SetColBus(Int_t iddl,Int_t ibus,Int_t cols,Int_t cole)
+{
+  fStartColBus[iddl][ibus] = cols;
+  fEndColBus[iddl][ibus]   = cole;
+}
+// ----------------------------------------------------------------- //
+
+void AliPMDMappingData::Print(Option_t *) const
+{
+  printf("\n ######Mapping File for each ddl and patchbus ####\n");
+
+
+  for(Int_t iddl = 0; iddl < kDdl; iddl++)
+    {
+      for(Int_t ibus = 0; ibus < kBus; ibus++)
+       {
+         printf("%d %d %d %d %d %d %d %d\n",iddl, ibus,
+                fModuleNo[iddl][ibus], fMcmperBus[iddl][ibus],
+                fStartRowBus[iddl][ibus], fEndRowBus[iddl][ibus],
+                fStartColBus[iddl][ibus], fEndColBus[iddl][ibus]);
+       }
+      printf("\n");
+    }
+
+}
diff --git a/PMD/AliPMDMappingData.h b/PMD/AliPMDMappingData.h
new file mode 100644 (file)
index 0000000..6f4771f
--- /dev/null
@@ -0,0 +1,52 @@
+#ifndef ALIPMDMAPPINGDATA_H
+#define ALIPMDMAPPINGDATA_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+
+class TNamed;
+class AliCDBEntry;
+class AliPMD;
+
+class AliPMDMappingData: public TNamed
+{
+ public:
+  AliPMDMappingData();
+  AliPMDMappingData(const char* name);
+  AliPMDMappingData(const AliPMDMappingData &mapda);
+  AliPMDMappingData& operator= (const AliPMDMappingData &mapda);
+  virtual ~AliPMDMappingData();
+  void  Reset();
+
+  Int_t GetModuleNo(Int_t iddl, Int_t ibus) const;
+  Int_t GetMcmperBus(Int_t iddl, Int_t ibus) const;
+  Int_t GetStartRowBus(Int_t iddl, Int_t ibus) const;
+  Int_t GetEndRowBus(Int_t iddl, Int_t ibus) const;
+  Int_t GetStartColBus(Int_t iddl, Int_t ibus) const;
+  Int_t GetEndColBus(Int_t iddl, Int_t ibus) const;
+
+  void  SetModuleNo(Int_t iddl, Int_t ibus, Int_t modno);
+  void  SetMcmperBus(Int_t iddl, Int_t ibus, Int_t totmcm);
+  void  SetRowBus(Int_t iddl, Int_t ibus, Int_t rows, Int_t rowe);
+  void  SetColBus(Int_t iddl, Int_t ibus, Int_t cols, Int_t cole);
+
+  virtual void Print(Option_t *) const;
+  
+ protected:
+  enum
+      {
+       kDdl = 6,     // Number of DDL
+       kBus = 51    // Modules of patch bus
+      };
+
+  Int_t fModuleNo[kDdl][kBus];
+  Int_t fMcmperBus[kDdl][kBus];
+  Int_t fStartRowBus[kDdl][kBus];
+  Int_t fEndRowBus[kDdl][kBus];
+  Int_t fStartColBus[kDdl][kBus];
+  Int_t fEndColBus[kDdl][kBus];
+
+
+  ClassDef(AliPMDMappingData,1) // calibration class for gainfactors
+};
+#endif
diff --git a/PMD/AliPMDReadMapping.C b/PMD/AliPMDReadMapping.C
new file mode 100644 (file)
index 0000000..52635ba
--- /dev/null
@@ -0,0 +1,18 @@
+void AliPMDReadMapping()
+{
+  TFile * f = TFile::Open("/Users/basanta/Misc/Public/PMD/OCDBMacro/CDB_IDEAL/PMD/Calib/Mapping/Run0_999999999_v0_s0.root");
+
+  f->ls();
+  if (!AliCDBEntry)
+    {
+      printf("Something is wrong ************ \n");
+    }
+  else if(AliCDBEntry)
+    {
+      AliCDBEntry->PrintId(); 
+      AliCDBEntry->PrintMetaData();
+      AliPMDMappingData * mapdata = 0;
+      mapdata = (AliPMDMappingData*)AliCDBEntry->GetObject();
+      mapdata->Print(); 
+    }
+}
diff --git a/PMD/CreateMappingCDB.C b/PMD/CreateMappingCDB.C
new file mode 100644 (file)
index 0000000..6a4c4f7
--- /dev/null
@@ -0,0 +1,67 @@
+void CreateMappingCDB()
+{
+
+  AliCDBManager* man = AliCDBManager::Instance();
+  man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");  
+  AliPMDMappingData *mapda = new AliPMDMappingData();
+
+
+  Int_t moduleno, totPatchBus, bPatchBus, ePatchBus;
+  Int_t ibus, totmcm, rows, rowe, cols, cole;
+  Int_t moduleDDL[6] = {12,12,0,0,12,12};
+
+  ifstream infile;
+
+
+
+  for(Int_t iddl = 0; iddl < 6; iddl++)
+    {
+      if(iddl == 0) infile.open("PMD_Mapping_ddl0.dat"); // ascii file
+      if(iddl == 1) infile.open("PMD_Mapping_ddl1.dat"); // ascii file
+      if(iddl == 2) infile.open("PMD_Mapping_ddl2.dat"); // ascii file
+      if(iddl == 3) infile.open("PMD_Mapping_ddl3.dat"); // ascii file
+      if(iddl == 4) infile.open("PMD_Mapping_ddl4.dat"); // ascii file
+      if(iddl == 5) infile.open("PMD_Mapping_ddl5.dat"); // ascii file
+      
+      if(!infile)
+       AliError("Could not read the mapping file for DDL No = 0");
+
+      Int_t modulePerDDL = moduleDDL[iddl];
+
+      for (Int_t im = 0; im < modulePerDDL; im++)
+       {
+         infile >> moduleno;
+         infile >> totPatchBus >> bPatchBus >> ePatchBus;
+         
+         if (totPatchBus == 0) continue;
+         
+         for(Int_t i=0; i<totPatchBus; i++)
+           {
+             infile >> ibus >> totmcm >> rows >> rowe >> cols >> cole;
+             
+             printf("%d %d %d %d %d %d %d %d \n",moduleno,totPatchBus,
+                    ibus,totmcm,rows,rowe,cols,cole);
+
+             mapda->SetModuleNo(iddl,ibus,moduleno);
+             mapda->SetMcmperBus(iddl,ibus,totmcm);
+             mapda->SetRowBus(iddl,ibus,rows,rowe);
+             mapda->SetColBus(iddl,ibus,cols,cole);
+
+
+           }
+         
+       }
+      
+      infile.close();
+
+    }
+
+  AliCDBMetaData *md= new AliCDBMetaData();
+  md->SetResponsible("Basanta Nandi");
+  md->SetComment("Patchbus Mapping info for PMD");
+
+  AliCDBId id("PMD/Calib/Mapping",0,AliCDBRunRange::Infinity());
+
+  man->GetDefaultStorage()->Put(mapda,id, md);
+
+}