00001
00002
00003
00004
00005
00006 #include <iostream.h>
00007
00008 #define EEMC 5
00009 #define EPRS 6
00010 #define ESMDU 7
00011 #define ESMDV 8
00012 #define EPSTS 9
00013
00014
00015 class St_geant_Maker;
00016
00017 TBrowser *b = 0;
00018
00019 St_geant_Maker *geant= 0;
00020
00021 const TString *detname[] = {
00022 "bemc", "bprs", "bsmde", "bsmdp",
00023 "eemc", "eprs", "esmdv", "esmdu", "epst" };
00024
00025
00026 Int_t getVolIdEemc(const Int_t ivid, Int_t §or,Int_t &eta,
00027 Int_t &sub, Int_t &detector)
00028 {
00029
00030 static Int_t emcIvid[4]={100000,1000,10,1};
00031 Int_t emcChid[4], i, ividw, lowup, phi, dep;
00032
00033 ividw = ivid;
00034
00035 for(i=0; i<4; i++){
00036 emcChid[i] = ividw/emcIvid[i];
00037 ividw = ividw%emcIvid[i];
00038 }
00039
00040 if(ividw == 0){
00041 lowup = emcChid[0];
00042 phi = emcChid[1];
00043 eta = emcChid[2];
00044 dep = emcChid[3];
00045
00046 if (dep > 4)
00047 printf(" getVolIdEemc => wrong value of section %i \n",dep);
00048 detector = EEMC;
00049 if (dep == 1) detector = EPRS;
00050 else if
00051 (dep == 4) detector = EPSTS;
00052
00053 sector=(phi-1)/5 + 1;
00054 sector=(phi-1)/5 + 1;
00055 sub = (phi-1)%5 + 1;
00056
00057
00058 }
00059 else{
00060 printf("getVolIdEemc: error decoding EEMC Geant volume Id %i; lowup=%i\n",
00061 ivid, lowup);
00062 return 1;
00063 }
00064
00065
00066 if (lowup == 1) sector = sector + 3;
00067 else {
00068 sector = sector + 9;
00069 if (sector > 12 )
00070 sector = sector - 12;
00071 }
00072
00073
00074
00075
00076 return 0;
00077 }
00078
00079
00080 Int_t getVolIdEsmd(const Int_t ivid, Int_t §or,Int_t &plane,
00081 Int_t &strip, Int_t &detector)
00082 {
00083 static Int_t smdIvid[4]={1000000,10000,1000,1};
00084 Int_t smdChid[5], i, ividw, lowup, phi;
00085
00086 ividw = ivid;
00087 for(i=0; i<4; i++){
00088 smdChid[i] = ividw/smdIvid[i];
00089 ividw = ividw%smdIvid[i];
00090 }
00091
00092 if(ividw == 0){
00093 lowup = smdChid[0];
00094 phi = smdChid[1];
00095 plane = smdChid[2];
00096 strip = smdChid[3];
00097
00098 if (phi == 1 || phi == 4) {
00099 if (plane == 3) detector = ESMDV;
00100 if (plane == 1) detector = ESMDU;
00101 }
00102 else if (phi == 2 || phi == 5) {
00103 if (plane == 1) detector = ESMDV;
00104 if (plane == 2) detector = ESMDU;
00105 }
00106 else if (phi == 3 || phi == 6) {
00107 if (plane == 2) detector = ESMDV;
00108 if (plane == 3) detector = ESMDU;
00109 }
00110 else{
00111 printf(" getVolIdEsmd -- error decoding ESMD Geant volume Id %i; lowup=%i\n",
00112 ivid, lowup);
00113 return 1;
00114 }
00115 }
00116
00117 sector = phi;
00118
00119
00120 if (lowup == 1) sector = sector + 3;
00121 else {
00122 sector = sector + 9;
00123 if (sector > 12 )
00124 sector = sector - 12;
00125 }
00126
00127
00128
00129
00130
00131 return 0;
00132 }
00133
00134
00135 void eemc(const Int_t Nevents=2,
00136 const Char_t *fzfile ="pt20y11phi50_0100.fzd")
00137 {
00138
00139 Float_t E;
00140 Int_t nhit=0, id,m,e,s, adc;
00141 Int_t ivid,sector,eta,plane,strip,sub,det;
00142 Int_t i=0;
00143
00144 gROOT->LoadMacro("bfc.C");
00145
00146 bfc(0,"fzin sim_T gen_T",fzfile);
00147
00148 for (i=1; i<=Nevents; i++ ) {
00149 chain->Clear();
00150 if (chain->Make(i)>=kStEOF) break;
00151
00152 St_g2t_emc_hit *g2t_emc_hit = (St_g2t_emc_hit *) chain->FindObject("g2t_eem_hit");
00153 if (g2t_emc_hit!=0) {
00154 Int_t nhits = g2t_emc_hit->GetNRows();
00155 g2t_emc_hit_st *hit = g2t_emc_hit->GetTable();
00156 printf("#-# Emc hits :volume_id,energy\n");
00157 for(Int_t ihit=0; ihit<nhits; ihit++,hit++) {
00158 ivid = hit->volume_id;
00159 E = hit->de;
00160 getVolIdEemc(ivid,sector,eta,sub,det);
00161 fprintf(stderr,"%2i %8i %s %8.6f \n",ihit,ivid,detname[det-1],E);
00162 }
00163 }
00164
00165 St_g2t_emc_hit *g2t_smd_hit = (St_g2t_emc_hit *) chain->FindObject("g2t_esm_hit");
00166 if (g2t_smd_hit !=0 ) {
00167 Int_t nhits = g2t_smd_hit->GetNRows();
00168 g2t_emc_hit_st *hit = g2t_smd_hit->GetTable();
00169 printf("#-# Smd hits :volume_id,energy\n");
00170 for(Int_t ihit=0; ihit<nhits; ihit++,hit++) {
00171 ivid = hit->volume_id;
00172 E = hit->de;
00173 getVolIdEsmd(ivid,sector,plane,strip,det);
00174 printf("%2i %8i %s %8.6f \n",ihit,ivid,detname[det-1],E);
00175 }
00176 }
00177 printf ("=========================================== Done with Event no. %d\n",i);
00178
00179 }
00180 }
00181