Adding macros for generation lookup tables and mapping files for the hit and trigger...
authorszostak <szostak@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sun, 23 Sep 2007 11:44:40 +0000 (11:44 +0000)
committerszostak <szostak@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sun, 23 Sep 2007 11:44:40 +0000 (11:44 +0000)
HLT/MUON/macros/CreateBusToDetElemFile.C [new file with mode: 0644]
HLT/MUON/macros/CreateHitRecoLookupTables.C [new file with mode: 0644]
HLT/MUON/macros/CreateRegionalToLocalCardMapping.C [new file with mode: 0644]
HLT/MUON/macros/CreateTriggerRecoLookupTables.C [new file with mode: 0644]

diff --git a/HLT/MUON/macros/CreateBusToDetElemFile.C b/HLT/MUON/macros/CreateBusToDetElemFile.C
new file mode 100644 (file)
index 0000000..6a0264d
--- /dev/null
@@ -0,0 +1,58 @@
+/**************************************************************************
+ * This file is property of and copyright by the ALICE HLT Project        * 
+ * All rights reserved.                                                   *
+ *                                                                        *
+ * Primary Authors:                                                       *
+ *   Indranil Das <indra.das@saha.ac.in>                                  *
+ *                                                                        *
+ * 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.                  *
+ **************************************************************************/
+/*********************************************
+Purpose:  A macro to generate buspatch to ddl mapping file 
+
+Created:  7/10/2005
+Modified: 22/12/2005
+Modified: 09/02/2006
+Modified: 09/04/2007
+Modified: 24/08/2007 (To adopt to AliRoot v4-06-Release)
+
+Author:   Indranil Das, HEP, SINP, Kolkata
+Email:    indra.das@saha.ac.in
+***********************************************/
+
+
+#include <TArrayI.h>
+#include <AliMpDDLStore.h>
+#include <AliMpDetElement.h>
+#include <AliMpSegmentation.h>
+
+int CreateBusToDetElemFile()
+{
+  FILE *fp = fopen("BusToDetElem.dat","w");
+
+  AliMpDetElement* fDetElement;
+  AliMpSegmentation::ReadData(); 
+  AliMpDDLStore::ReadData();
+
+  fprintf(fp,"#DE\tBusPatch\tDDL\n");
+  for(int ch=7;ch<=10;ch++){
+    fprintf(fp,"# Chamber %d\n",ch);
+    for(int i=0; i<26 ; i++){
+      fDetElement = AliMpDDLStore::Instance()->GetDetElement(ch*100 + i);
+       fprintf(fp,"%d\t%d - %d\t%d\n",ch*100 + i,fDetElement->GetBusPatchId(0),
+              fDetElement->GetBusPatchId(fDetElement->GetNofBusPatches()-1),fDetElement->GetDdlId());
+    }
+  }
+  //delete fDDLStore;
+  delete fDetElement;
+
+  fclose(fp);
+  return 0;
+}
diff --git a/HLT/MUON/macros/CreateHitRecoLookupTables.C b/HLT/MUON/macros/CreateHitRecoLookupTables.C
new file mode 100644 (file)
index 0000000..a6100eb
--- /dev/null
@@ -0,0 +1,182 @@
+/**************************************************************************
+ * This file is property of and copyright by the ALICE HLT Project        * 
+ * All rights reserved.                                                   *
+ *                                                                        *
+ * Primary Authors:                                                       *
+ *   Indranil Das <indra.das@saha.ac.in>                                  *
+ *                                                                        *
+ * 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.                  *
+ **************************************************************************/
+
+/*********************************************
+Purpose:  A macro to generate LookupTable
+          in the following form
+detElemId+manuid+channelId  buspatchId Ix  IY  X  Y  B/NB
+
+Created:  7/10/2005
+Modified: 22/12/2005
+Modified: 09/02/2006
+Modified: 09/04/2007
+Modified: 24/08/2007 (To adopt to AliRoot v4-06-Release)
+
+Run Info: To run this code copy "rootlogon.C" 
+          in the current directory from $ALICE_ROOT/MUON 
+          and specify the 
+          transformFileName as "geometry.root" of the 
+          simulation directory.Then compile and run using
+          .L generateLookupTable.C++
+
+Author:   Indranil Das, HEP, SINP, Kolkata
+Email:    indra.das@saha.ac.in
+***********************************************/
+
+#include <iostream> 
+
+//STEER 
+#include "AliCDBManager.h"
+
+//MUON
+#include "AliMUONGeometryTransformer.h"
+
+//MUON/mapping 
+#include "AliMpPad.h"
+#include "AliMpSegmentation.h"
+#include "AliMpDDLStore.h"
+#include "AliMpDEIterator.h"
+#include "AliMpVSegmentation.h"
+#include "AliMpDEManager.h"
+
+class AliMpDDLStore ;
+
+using namespace std;
+
+
+Bool_t CreateHitRecoLookupTables(TString transformFileName = "geometry.root")
+{
+  Char_t filename1[20], filename2[20];
+  Int_t chamberId;
+  
+  AliMpSegmentation *mpSegFactory = AliMpSegmentation::ReadData(); 
+
+  AliMpDDLStore* fDDLStore = AliMpDDLStore::ReadData();
+  
+  AliMUONGeometryTransformer* chamberGeometryTransformer = new AliMUONGeometryTransformer();
+  chamberGeometryTransformer->LoadGeometryData(transformFileName);
+  
+  for(Int_t iCh = 0; iCh < 4; iCh++){ // max 4
+    
+    sprintf(filename1,"Lut%d.dat",2*(6+iCh));
+    FILE *fout1 = fopen(filename1,"w");
+
+    sprintf(filename2,"Lut%d.dat",2*(6+iCh)+1);
+    FILE *fout2 = fopen(filename2,"w");
+
+    chamberId = iCh + 6;
+
+    AliMpDEIterator it;
+    for ( it.First(chamberId); ! it.IsDone(); it.Next() ) {
+    
+      Int_t detElemId = it.CurrentDEId();
+      
+      cout<<"Running for detElemId :"<<detElemId<<endl;
+      
+      for(Int_t iPlane = 0 ; iPlane <= 1 ; iPlane++){
+       
+       AliMp::CathodType cath;
+
+       if(iPlane == 0)
+         cath = AliMp::kCath0 ;
+       else
+         cath = AliMp::kCath1 ;
+       
+       AliMpVSegmentation* seg = mpSegFactory->CreateMpSegmentation(detElemId, cath);
+       
+       Int_t maxIX = seg->MaxPadIndexX();  
+       Int_t maxIY = seg->MaxPadIndexY(); 
+       Int_t idManuChannel, manuId, channelId,idetElemId;
+       Int_t busPatchId;
+       Double_t realX, realY, realZ;
+       Double_t localX, localY, localZ;
+       Double_t padSizeX, padSizeY;
+       Int_t pcbType;
+
+       //Pad Info of a segment
+       for(Int_t iX = 0; iX<= maxIX ; iX++){
+         for(Int_t iY = 0; iY<= maxIY ; iY++){
+           if(seg->HasPad(AliMpIntPair(iX,iY))){
+             AliMpPad pad = seg->PadByIndices(AliMpIntPair(iX,iY),kFALSE);
+             
+             // Getting Manu id
+             manuId = pad.GetLocation().GetFirst();
+             manuId &= 0x7FF; // 11 bits 
+             
+             busPatchId = fDDLStore->GetBusPatchId(detElemId,manuId);
+             
+             // Getting channel id
+             channelId =  pad.GetLocation().GetSecond();
+             channelId &= 0x3F; // 6 bits
+             
+             idetElemId = detElemId%100;
+             
+             idManuChannel &= 0x0;
+             idManuChannel = (idManuChannel|idetElemId)<<11;  
+             idManuChannel = (idManuChannel|manuId)<<6 ;
+             idManuChannel |= channelId ;
+             
+             localX = pad.Position().X();
+             localY = pad.Position().Y();
+             localZ = 0.0;
+
+             chamberGeometryTransformer->Local2Global(detElemId,localX,localY,localZ,
+                                                      realX,realY,realZ);
+
+             padSizeX = 2.0*pad.Dimensions().X();
+             padSizeY = 2.0*pad.Dimensions().Y();
+
+             if(iPlane == 0 ){
+               if(padSizeX==2.5)
+                 pcbType = 0;
+               else if(padSizeX==5.0)
+                 pcbType = 1;
+               else
+                 pcbType = 2;
+             }
+             else{
+               if(padSizeY==2.5)
+                 pcbType = 0;
+               else if(padSizeY==5.0)
+                 pcbType = 1;
+               else
+                 pcbType = 2;
+             }
+               
+             if(idetElemId<7 || idetElemId > 19){
+               fprintf(fout2,"%d\t%d\t%d\t%f\t%f\t%f\t%d\t%d\n",idManuChannel,iX,iY,realX,realY,realZ,pcbType,iPlane);
+             }
+             else{
+               fprintf(fout1,"%d\t%d\t%d\t%f\t%f\t%f\t%d\t%d\n",idManuChannel,iX,iY,realX,realY,realZ,pcbType,iPlane);
+             }// HasPad Condn
+             
+           }
+           else{
+             cout<<"pad not found for iX :"<<iX<<", iY:"<<iY<<endl;
+           }
+         }// iY loop
+       }// iX loop
+       
+      }// iPlane
+
+    } // detElemId loop
+
+    fclose(fout1);
+    fclose(fout2);
+  }// ichamber loop
+  
+  return kTRUE;
+}
diff --git a/HLT/MUON/macros/CreateRegionalToLocalCardMapping.C b/HLT/MUON/macros/CreateRegionalToLocalCardMapping.C
new file mode 100644 (file)
index 0000000..aeecf19
--- /dev/null
@@ -0,0 +1,92 @@
+/**************************************************************************
+ * This file is property of and copyright by the ALICE HLT Project        * 
+ * All rights reserved.                                                   *
+ *                                                                        *
+ * Primary Authors:                                                       *
+ *   Indranil Das <indra.das@saha.ac.in>                                  *
+ *                                                                        *
+ * 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.                  *
+ **************************************************************************/
+
+/**********************************************************************
+ Created on : 08/09/2007
+ Purpose    : TriggerDDL Regional to LocalBoard Mapping.
+ Author     : Indranil Das, HEP Division, SINP
+ Email      : indra.das@saha.ac.in | indra.ehep@gmail.com
+**********************************************************************/
+
+#include <iostream>
+
+#include "AliMpDDLStore.h"
+#include "AliMpSegmentation.h"
+#include "AliMpTriggerCrate.h"
+#include "AliMpLocalBoard.h"
+
+using namespace std;
+
+bool CreateRegionalToLocalCardMapping()
+{
+  AliMpSegmentation::ReadData(); 
+  AliMpDDLStore::ReadData();
+
+  FILE *fout = fopen("RegionalToLocalCard.dat","w");
+
+  for(int iTrigDDL = 0; iTrigDDL<2 ; iTrigDDL++){
+
+    for(int iReg = 0; iReg < 8 ; iReg++){
+    
+      AliMpTriggerCrate* crate = AliMpDDLStore::Instance()->GetTriggerCrate(iTrigDDL,iReg);
+      cout<<"Nof Local Board : "<<crate->GetNofLocalBoards()<<endl;
+      AliMpLocalBoard* locBoard ;
+      
+      for(int i = 0 ; i < crate->GetNofLocalBoards() ; i++){
+      locBoard = AliMpDDLStore::Instance()->GetLocalBoard(crate->GetLocalBoardId(i));
+
+      cout<<"iTrigDDL : "<<iTrigDDL<<", iReg : "<<iReg<<", iLoc : "<<i
+         <<", locID : "<<locBoard->GetId()<<", Switch : (" ;
+      fprintf(fout,"%1d\t%1d\t%-2d\t%-3d\t",iTrigDDL,iReg,i,locBoard->GetId());
+
+      int switch_packed ;
+      switch_packed &= 0x0 ;
+      for(int j = 0 ; j < locBoard->GetNofSwitches() ; j++){
+       cout<<locBoard->GetSwitch(j);
+       
+       if(j<(locBoard->GetNofSwitches()-1))
+         switch_packed = (switch_packed | locBoard->GetSwitch(j))<<1 ;
+       else
+         switch_packed |= locBoard->GetSwitch(j) ;
+      }
+
+      cout<<"), packed switched : "<<switch_packed<<", DDL : ";
+      fprintf(fout,"%-4d\t",switch_packed);
+
+      for(int j = 0 ; j < 4 ; j++){ 
+       // intensionally made 4 instead of locBoard->GetNofDEs() to give identical structure for the fake local IDs
+       if(locBoard->GetNofDEs()<4){
+         cout<<locBoard->GetDEId(0)<<", ";
+         fprintf(fout,"%-4d\t",locBoard->GetDEId(0));
+       }else{
+         cout<<locBoard->GetDEId(j)<<", ";
+         fprintf(fout,"%-4d\t",locBoard->GetDEId(j));
+       }//if detelem condn
+      }// detelem loop
+
+      cout<<endl;
+      fprintf(fout,"\n");
+
+      }// loc board loop
+      delete crate;
+      //delete locBoard;
+
+    }//iReg loop
+  }//iTrigDDL loop
+
+  fclose(fout);
+  return true;
+}
diff --git a/HLT/MUON/macros/CreateTriggerRecoLookupTables.C b/HLT/MUON/macros/CreateTriggerRecoLookupTables.C
new file mode 100644 (file)
index 0000000..9f3ec4a
--- /dev/null
@@ -0,0 +1,185 @@
+/**************************************************************************
+ * This file is property of and copyright by the ALICE HLT Project        * 
+ * All rights reserved.                                                   *
+ *                                                                        *
+ * Primary Authors:                                                       *
+ *   Indranil Das <indra.das@saha.ac.in>                                  *
+ *                                                                        *
+ * 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.                  *
+ **************************************************************************/
+
+/**********************************************
+Purpose:  A modified macro to generate MappingTable
+          in the following form
+
+detElemId+iPlane+iX+iY  Ix  IY  X  Y  B/NB pcbtype
+
+          for the trigger stations.
+
+Created:  13/05/2007
+Modified: 31/08/2007 (Adopted to AliRoot v4-06-Release)
+Modified: 08/09/2007 (To produce mapping on the basis of uniqueID as detElemId+iPlane+localCard+ibitXY )
+Author:   Indranil Das, HEP, SINP, Kolkata
+Email:    indra.das@saha.ac.in | indra.ehep@gmail.com
+***********************************************/
+
+#include <iostream> 
+
+//STEER 
+#include "AliCDBManager.h"
+
+//MUON
+#include "AliMUONGeometryTransformer.h"
+#include "AliMUONGeometryDetElement.h"
+#include "AliMUONCalibrationData.h"
+#include "AliMUONVCalibParam.h"
+
+//MUON/mapping 
+#include "AliMpPad.h"
+#include "AliMpSegmentation.h"
+#include "AliMpDEIterator.h"
+#include "AliMpVSegmentation.h"
+#include "AliMpDEManager.h"
+
+
+using namespace std;
+
+
+Bool_t CreateTriggerRecoLookupTables(TString transformFileName = "geometry.root")
+{
+
+  Char_t filename1[20], filename2[20];
+  Int_t chamberId;
+
+  Int_t runNumber = 0;
+  
+  AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT");
+  AliMUONCalibrationData cd(runNumber);
+
+  AliMpSegmentation *mpSegFactory = AliMpSegmentation::ReadData(); 
+
+  AliMUONGeometryTransformer* chamberGeometryTransformer = new AliMUONGeometryTransformer();
+  chamberGeometryTransformer->LoadGeometryData(transformFileName);
+  
+    sprintf(filename1,"Lut%d.dat",2*(10+0));
+    //ofstream fout1(filename1);
+    FILE *fout1 = fopen(filename1,"w");
+
+    sprintf(filename2,"Lut%d.dat",2*(10+0)+1);
+    //ofstream fout2(filename2);
+    FILE *fout2 = fopen(filename2,"w");
+
+  for(Int_t iCh = 0; iCh < 4; iCh++){ // max 4
+
+    chamberId = iCh + 10;
+    
+    cout<<"Running for Chamber : "<<chamberId<<endl;
+
+    AliMpDEIterator it;
+    for ( it.First(chamberId); ! it.IsDone(); it.Next() ) {
+    
+      Int_t detElemId = it.CurrentDEId();
+      
+      Double_t globPos[3] = {0.0, 0.0, 0.0};
+      Double_t locPos[3] = {0.0, 0.0, 0.0};
+
+      chamberGeometryTransformer->GetDetElement(detElemId)->Local2Global(locPos[0],locPos[1],locPos[2],globPos[0],globPos[1],globPos[2]);
+       
+      for(Int_t iPlane = 0 ; iPlane <= 1 ; iPlane++){
+       
+       AliMp::CathodType cath;
+
+       if(iPlane == 0)
+         cath = AliMp::kCath0 ;
+       else
+         cath = AliMp::kCath1 ;
+
+       AliMpVSegmentation* seg = mpSegFactory->CreateMpSegmentation(detElemId, cath);
+
+       Int_t maxIX = seg->MaxPadIndexX();  
+       Int_t maxIY = seg->MaxPadIndexY(); 
+       Int_t idManuChannel,idetElemId;
+
+       Double_t realX, realY, realZ;
+       Double_t localX, localY, localZ;
+       Double_t padSizeX, padSizeY;
+       Int_t pcbType;
+       Int_t locCard, ibitxy;
+
+       //Pad Info of a segment
+       for(Int_t iX = 0; iX<= maxIX ; iX++){
+         for(Int_t iY = 0; iY<= maxIY ; iY++){
+           if(seg->HasPad(AliMpIntPair(iX,iY))){
+             AliMpPad pad = seg->PadByIndices(AliMpIntPair(iX,iY),kFALSE);
+             
+             locCard = pad.GetLocation(0).GetFirst();
+             ibitxy = pad.GetLocation(0).GetSecond();
+
+             idetElemId = detElemId%1000;
+             idetElemId &= 0x1FF ;
+             iPlane &= 0x1 ;
+             locCard &= 0xFF ;
+             ibitxy &= 0xF ;
+             
+             idManuChannel &= 0x0;
+             idManuChannel = (idManuChannel|idetElemId)<<1;  
+             idManuChannel = (idManuChannel|iPlane)<<8;  
+             idManuChannel = (idManuChannel|locCard)<<4 ;
+             idManuChannel |= ibitxy;
+             
+             localX = pad.Position().X();
+             localY = pad.Position().Y();
+             localZ = 0.0;
+
+             chamberGeometryTransformer->Local2Global(detElemId,localX,localY,localZ,
+                                                      realX,realY,realZ);
+             padSizeX = 2.0*pad.Dimensions().X();
+             padSizeY = 2.0*pad.Dimensions().Y();
+
+             if(iPlane == 0 ){
+               if(padSizeX==17.0)
+                 pcbType = 0;
+               else if(padSizeX==34.0)
+                 pcbType = 1;
+               else
+                 pcbType = 2;
+             }
+             else{
+               if(padSizeY==51.0)
+                 pcbType = 0;
+               else
+                 pcbType = 1;
+             }
+             
+             idetElemId %= 100;
+
+             if(idetElemId<5 || idetElemId > 13){
+               fprintf(fout1,"%d\t%d\t%d\t%f\t%f\t%f\t%d\t%d\n",idManuChannel,iX,iY,realX,realY,realZ,pcbType,iPlane);
+             }
+             else{
+               fprintf(fout2,"%d\t%d\t%d\t%f\t%f\t%f\t%d\t%d\n",idManuChannel,iX,iY,realX,realY,realZ,pcbType,iPlane);
+             }// HasPad Condn
+             
+           }
+           else{
+             cout<<"pad not found for iX :"<<iX<<", iY:"<<iY<<endl;
+           }
+         }// iY loop
+       }// iX loop
+       
+      }// iPlane
+    } // detElemId loop
+
+  }// ichamber loop
+
+  fclose(fout1);
+  fclose(fout2);
+  
+  return kTRUE;
+}