Updated directory names on LDC in SDD calibration plotting macro (Mario Sitta)
[u/mrichter/AliRoot.git] / ITS / macrosSDD / DecodeJTAG.C
CommitLineData
e31ff8d6 1#if !defined(__CINT__) || defined(__MAKECINT__)
2#include "AliITSDDLModuleMapSDD.h"
3#include <TSystem.h>
4#endif
5
6/* $Id$ */
7
8// Macro to extract and print the configuration parameters of SDD modules
9// from JTAG hexadecimal files
10// Origin: F. Prino, prino@to.infn.it
11
12void DecodeJTAG(Int_t nDDL, Int_t nCarlos=0, TString type="PHY"){
13
14 AliITSDDLModuleMapSDD* dmap=new AliITSDDLModuleMapSDD();
15 dmap->SetJun09Map();
16 Int_t theMod=-1;
17 if(nDDL>=0 && nDDL<23){
18 theMod=dmap->GetModuleNumber(nDDL,nCarlos);
19 }else if(nDDL>=240 && nDDL<500){
20 theMod=nDDL;
21 dmap->FindInDDLMap(theMod,nDDL,nCarlos);
22 }else{
23 printf("ERROR: wronng DDL/Module number %d\n",nDDL);
24 return;
25 }
26 TString crate;
27 if(nDDL<8) crate="TOP";
28 else if(nDDL<16) crate="MED";
29 else if(nDDL<24) crate="BOT";
30
31 Int_t numSlot=nDDL%8+1;
32 Int_t car1,car2;
33 if(nCarlos%2==0){
34 car1=nCarlos;
35 car2=nCarlos+1;
36 }else{
37 car2=nCarlos;
38 car1=nCarlos-1;
39 }
40 TString filnam=Form("%s%d/%s_jtag_carlos%02d%02d.txt",crate.Data(),numSlot,
41 type.Data(),car1,car2);
42 gSystem->Exec(Form("ls -l %s\n",filnam.Data()));
43 FILE* fil=fopen(filnam.Data(),"r");
44 UInt_t word;
45 Int_t retcode;
46
47 retcode=fscanf(fil,"%x\n",&word);
48 Int_t modNum=word&0x0000000F;
49 for(Int_t iMod=0; iMod<2; iMod++){
50 retcode=fscanf(fil,"%x\n",&word);
51 if(iMod==0 && word!=0xFFFFFF00){printf("ERROR - mod 0\n"); return;}
52 if(iMod==1 && word!=0xFFFFFF11){printf("ERROR - mod 1\n"); return;}
53 retcode=fscanf(fil,"%x\n",&word); // CarlosRX word
54 if(iMod==0){
55 Int_t maskMod=(word&0x000FFF00)>>8;
56 printf("Active modules: ");
57 for(Int_t i=0;i<12;i++){
58 if(maskMod&(1<<i)) printf(" 1 ");
59 else printf(" 0 ");
60 }
61 printf("\n");
62 }
63 // CARLOS words
64 Bool_t doPrint=kFALSE;
65 if(modNum+iMod==nCarlos)doPrint=kTRUE;
66 if(doPrint) printf("*********** Module %d DDL %d (%s%d) Carlos %d **********\n",theMod,nDDL,crate.Data(),numSlot,modNum+iMod);
67 retcode=fscanf(fil,"%x\n",&word);
68 retcode=fscanf(fil,"%x\n",&word);
69 Int_t th1=(word&0xFF000000)>>24;
70 Int_t th0=(word&0x00FF0000)>>16;
71 Int_t tl1=(word&0x0000FF00)>>8;
72 Int_t tl0=(word&0x000000FF);
73 if(doPrint) printf("High Thresholds = %d %d\n",th1,th0);
74 if(doPrint) printf("Low Thresholds = %d %d\n",tl1,tl0);
75 retcode=fscanf(fil,"%x\n",&word);
76 retcode=fscanf(fil,"%x\n",&word);
77 for(Int_t iSide=0; iSide<2; iSide++){
78 if(doPrint) printf("------------------ Hybrid %d -------------\n",iSide);
79 // AMBRA WORDS
80 for(Int_t iAmbra=0; iAmbra<4; iAmbra++){
81 for(Int_t iw=0;iw<5;iw++){
82 retcode=fscanf(fil,"%x\n",&word);
83 if(doPrint && iw==1) {
84 printf("AMBRA %d --- SOP %d",iAmbra,word&0x000000FF);
85 }
86 }
87 if(word&0x0000FF00){
88 if(doPrint) printf(" --- Baselines present");
89 for(Int_t iwb=0;iwb<16;iwb++) retcode=fscanf(fil,"%x\n",&word);
90 }else{
91 if(doPrint) printf(" --- No baseline equalization");
92 }
93 if(doPrint) printf("\n");
94 }
95 // PASCAL WORDS
96 for(Int_t iPascal=0; iPascal<4; iPascal++){
97 for(Int_t iw=0;iw<4;iw++){
98 retcode=fscanf(fil,"%x\n",&word);
99 if(doPrint && iw==2){
100 printf("PASCAL %d ",iPascal);
101 if(word&0xFF000000) printf(" --- ADC full");
102 else printf(" --- ADC 1/2");
103 if(word&0x00FF0000) printf(" --- AM full");
104 else printf(" --- AM 1/2");
105 printf("\n");
106 }
107 }
108 }
109 }
110 }
111}