]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Different mapping files per module are created by WriteMapping.C
authorkharlov <kharlov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 2 Sep 2009 15:53:48 +0000 (15:53 +0000)
committerkharlov <kharlov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 2 Sep 2009 15:53:48 +0000 (15:53 +0000)
PHOS/macros/Mapping/CSP2ALTRO_new.dat [moved from PHOS/macros/Mapping/CSP2ALTRO.dat with 100% similarity]
PHOS/macros/Mapping/CSP2ALTRO_old.dat [new file with mode: 0644]
PHOS/macros/Mapping/WriteMapping.C

diff --git a/PHOS/macros/Mapping/CSP2ALTRO_old.dat b/PHOS/macros/Mapping/CSP2ALTRO_old.dat
new file mode 100644 (file)
index 0000000..30e3363
--- /dev/null
@@ -0,0 +1,39 @@
+* Geometrical mapping within one FEE card
+* x  z  CSP ALTRO  Hi Lo
+*-----------------------
+  0  1   0   2     10 11
+  1  1   1   2     14 15
+  2  1   2   2      5  4
+  3  1   3   2      1  0
+  4  1   4   3      1  0
+  5  1   5   3      5  4
+  6  1   6   3     14 15
+  7  1   7   3     10 11
+*-----------------------
+  0  0  16   2      8  9
+  1  0  17   2     12 13
+  2  0  18   2      7  6
+  3  0  19   2      3  2
+  4  0  20   3      3  2
+  5  0  21   3      7  6
+  6  0  22   3     12 13
+  7  0  23   3      8  9
+*-----------------------
+ 15  1  15   4      8  9
+ 14  1  14   4     12 13
+ 13  1  13   4      7  6
+ 12  1  12   4      3  2
+ 11  1  11   0      3  2
+ 10  1  10   0      7  6
+  9  1   9   0     12 13
+  8  1   8   0      8  9
+*-----------------------
+ 15  0  31   4     10 11
+ 14  0  30   4     14 15
+ 13  0  29   4      5  4
+ 12  0  28   4      1  0
+ 11  0  27   0      1  0
+ 10  0  26   0      5  4
+  9  0  25   0     14 15
+  8  0  24   0     10 11
+*-----------------------
index 0780d51d0a3aec8cf759d17cd129af63aee93e87..8772dbab919b69f68ae2d8cabb566d132c0f5d79 100644 (file)
@@ -20,82 +20,97 @@ WriteMapping()
 
   char string[128];
   UInt_t xcell,zcell,csp,altro,chanHG,chanLG;
-  UInt_t hwAddress, maxHWAddress[4]={0,0,0,0}, nHWaddress[4]={0,0,0,0};
-  FILE *fd = fopen("CSP2ALTRO.dat","r");
-  if (fd != 0) 
-    printf("Input file CSP2ALTRO.dat is opened successfully\n");
-  else {
-    printf("Cannot open the input file CSP2ALTRO.dat\n");
-    return -1;
-  }
-
-  FILE *fRCU[4];
-
-  for (Int_t iRCU=0; iRCU<4; iRCU++) {
-    TString rcuFileName = Form("RCU%d.data.unsorted",iRCU);
-    fRCU[iRCU] = fopen(rcuFileName.Data(),"w");
-  }
-
-  while (fgets(string,128,fd)) {
-    if (string[0]=='*') {
-      continue;
+  UInt_t hwAddress, maxHWAddress[4], nHWaddress[4];
+  const char *FEEmapping[2] = {"CSP2ALTRO_new.dat", "CSP2ALTRO_old.dat"};
+  Int_t map=0;
+
+  for (Int_t module=0; module<5; module++) {
+    printf("\n\n====> Mapping file is created for the module %d\n",module);
+    if      (module <4) map=0;
+    else if (module==4) map=1;
+    FILE *fd = fopen(FEEmapping[map],"r");
+    if (fd != 0) 
+      printf("Input file %s is opened successfully\n",FEEmapping[map]);
+    else {
+      printf("Cannot open the input file %s\n",FEEmapping[map]);
+      return -1;
     }
-    sscanf(string,"%d %d %d %d %d %d",&xcell,&zcell,&csp,&altro,&chanHG,&chanLG);
+    
+    FILE *fRCU[4];
+
     for (Int_t iRCU=0; iRCU<4; iRCU++) {
-      for (Int_t iBranch=0; iBranch<2; iBranch++) {
-       for (Int_t iFEE=1; iFEE<=14; iFEE++) {
-         // High gain
-         hwAddress = chanHG | (altro<<4) | (iFEE<<7) | (iBranch<<11);
-         if (hwAddress > maxHWAddress[iRCU]) maxHWAddress[iRCU]=hwAddress;
-         nHWaddress[iRCU]++;
-         fprintf(fRCU[iRCU],"%4d %4d %4d %4d\n",
-                 hwAddress,xcell+iRCU*16,zcell+27+(2*iBranch-1)+(iFEE-1)*2*(2*iBranch-1),0);
-         // Low gain
-         hwAddress = chanLG | (altro<<4) | (iFEE<<7) | (iBranch<<11);
-         if (hwAddress > maxHWAddress[iRCU]) maxHWAddress[iRCU]=hwAddress;
-         nHWaddress[iRCU]++;
-         fprintf(fRCU[iRCU],"%4d %4d %4d %4d\n",
-                 hwAddress,xcell+iRCU*16,zcell+27+(2*iBranch-1)+(iFEE-1)*2*(2*iBranch-1),1);
+      TString rcuFileName = Form("Mod%dRCU%d.data.unsorted",module,iRCU);
+      fRCU[iRCU] = fopen(rcuFileName.Data(),"w");
+      maxHWAddress[iRCU]=0;
+      nHWaddress[iRCU]=0;
+    }
+    
+    while (fgets(string,128,fd)) {
+      if (string[0]=='*') {
+       continue;
+      }
+      sscanf(string,"%d %d %d %d %d %d",
+            &xcell,&zcell,&csp,&altro,&chanHG,&chanLG);
+      for (Int_t iRCU=0; iRCU<4; iRCU++) {
+       for (Int_t iBranch=0; iBranch<2; iBranch++) {
+         for (Int_t iFEE=1; iFEE<=14; iFEE++) {
+           // High gain
+           hwAddress = chanHG | (altro<<4) | (iFEE<<7) | (iBranch<<11);
+           if (hwAddress > maxHWAddress[iRCU]) maxHWAddress[iRCU]=hwAddress;
+           nHWaddress[iRCU]++;
+           fprintf(fRCU[iRCU],"%4d %4d %4d %4d\n",
+                   hwAddress,
+                   xcell+iRCU*16,
+                   zcell+27+(2*iBranch-1)+(iFEE-1)*2*(2*iBranch-1),0);
+           // Low gain
+           hwAddress = chanLG | (altro<<4) | (iFEE<<7) | (iBranch<<11);
+           if (hwAddress > maxHWAddress[iRCU]) maxHWAddress[iRCU]=hwAddress;
+           nHWaddress[iRCU]++;
+           fprintf(fRCU[iRCU],"%4d %4d %4d %4d\n",
+                   hwAddress,
+                   xcell+iRCU*16,
+                   zcell+27+(2*iBranch-1)+(iFEE-1)*2*(2*iBranch-1),1);
+         }
        }
       }
     }
-  }
-  printf("End of input file\n");
-  fclose(fd);
-
-  for (Int_t iRCU=0; iRCU<4; iRCU++) {
-    fclose(fRCU[iRCU]);
-  }
-
-  // Post-process the RCU mapping files
-
-  for (Int_t iRCU=0; iRCU<4; iRCU++) {
+    printf("End of input file\n");
+    fclose(fd);
 
-    // Add the number of channels and maximum HW address
-
-    TString rcuFileName = Form("RCU%d.data",iRCU);
-    fRCU[iRCU] = fopen(rcuFileName.Data(),"w");
-    fprintf(fRCU[iRCU],"%d\n%d\n",nHWaddress[iRCU]+256,maxHWAddress[iRCU]);
-
-    // TRU mapping
-
-    for (int i=0; i<128; i++) {
-      fprintf(fRCU[iRCU],"%4d %4d %4d %4d\n",i,iRCU,i,2);
+    for (Int_t iRCU=0; iRCU<4; iRCU++) {
+      fclose(fRCU[iRCU]);
     }
-    for (int i=0; i<128; i++) {
-      fprintf(fRCU[iRCU],"%4d %4d %4d %4d\n",i+2048,iRCU,i+2048,2);
+    
+    // Post-process the RCU mapping files
+    
+    for (Int_t iRCU=0; iRCU<4; iRCU++) {
+      
+      // Add the number of channels and maximum HW address
+      
+      TString rcuFileName = Form("Mod%dRCU%d.data",module,iRCU);
+      fRCU[iRCU] = fopen(rcuFileName.Data(),"w");
+      fprintf(fRCU[iRCU],"%d\n%d\n",nHWaddress[iRCU]+256,maxHWAddress[iRCU]);
+      
+      // TRU mapping
+      
+      for (int i=0; i<128; i++) {
+       fprintf(fRCU[iRCU],"%4d %4d %4d %4d\n",i,iRCU,i,2);
+      }
+      for (int i=0; i<128; i++) {
+       fprintf(fRCU[iRCU],"%4d %4d %4d %4d\n",i+2048,iRCU,i+2048,2);
+      }
+      fclose(fRCU[iRCU]);
+      
+      // Sort HW addresses
+      
+      TString cmd = Form("sort -n Mod%dRCU%d.data.unsorted >> %s", 
+                        module,iRCU,rcuFileName.Data());
+      gSystem->Exec(cmd);
+      
+      cmd = Form("rm -f Mod%dRCU%d.data.unsorted", module,iRCU);
+      gSystem->Exec(cmd);
+      
+      printf("RCU mapping file %s is created\n",rcuFileName.Data());
     }
-    fclose(fRCU[iRCU]);
-
-    // Sort HW addresses
-
-    TString cmd = Form("sort -n RCU%d.data.unsorted >> %s", iRCU,rcuFileName.Data());
-    gSystem->Exec(cmd);
-
-    cmd = Form("rm -f RCU%d.data.unsorted", iRCU);
-    gSystem->Exec(cmd);
-
-    printf("RCU mapping file %s is created\n",rcuFileName.Data());
   }
-
 }