00001
00002
00003
00004
00005 #include <TFile.h>
00006 #include <TH2.h>
00007
00008 #include "StEEsmdCalMaker.h"
00009
00010 #include "StMuDSTMaker/COMMON/StMuEvent.h"
00011 #include "StMuDSTMaker/COMMON/StMuDst.h"
00012 #include "StMuDSTMaker/COMMON/StMuDstMaker.h"
00013
00014 #include <StMessMgr.h>
00015
00016 #include "StEEmcUtil/database/EEmcDbItem.h"
00017 #include "StEEmcUtil/database/StEEmcDb.h"
00018
00019
00020 ClassImp(StEEsmdCalMaker)
00021
00022
00023
00024 StEEsmdCalMaker::StEEsmdCalMaker( const char* self ,const char* muDstMakerName) : StMaker(self){
00025 mMuDstMaker = (StMuDstMaker*)GetMaker(muDstMakerName);
00026 assert(mMuDstMaker);
00027 MCflag=0;
00028
00029
00030
00031
00032
00033
00034 float maxAdc=4095;
00035 float maxEtot=60;
00036 const float feta[MaxEtaBins]= {1.95,1.855,1.765,1.675,1.59,1.51,1.435,1.365,1.3,1.235,1.17,1.115};
00037
00038 int i;
00039
00040 mfixEmTgain=new float [MaxEtaBins];
00041 for (i=0;i<MaxEtaBins;i++) {
00042 mfixEmTgain[i]=maxAdc/maxEtot/cosh(feta[i]);
00043 }
00044 mfixSMDgain=23000;
00045 mfixPgain=23000;
00046
00047 }
00048
00049
00050
00051
00052 StEEsmdCalMaker::~StEEsmdCalMaker(){
00053 }
00054
00055
00056
00057 void StEEsmdCalMaker::SetSector(int sec){
00058 setSector(sec);
00059 TString name=GetName();
00060 name+="-";
00061 name+=sec;
00062
00063 SetName(name);
00064 }
00065
00066
00067
00068
00069 Int_t StEEsmdCalMaker::Init(){
00070 eeDb = (StEEmcDb*)this->GetDataSet("StEEmcDb");
00071
00072 EEsmdCal::init();
00073 printf("%s has MCflag=%d\n",GetName(),MCflag);
00074 return StMaker::Init();
00075 }
00076
00077
00078
00079 Int_t StEEsmdCalMaker::InitRun(int runNo){
00080 if(runNo==0) {
00081 gMessMgr->Message("","W")<<GetName()<<"::InitRun("<<runNo<<") ??? changed to 555, it s OK for M-C - perhaps, JB"<<endm;
00082 runNo=555;
00083 }
00084 initRun(runNo);
00085 return kStOK;
00086 }
00087
00088
00089
00090
00091
00092 Int_t StEEsmdCalMaker::Finish(){
00093 finish(0);
00094 return kStOK;
00095 }
00096
00097
00098
00099
00100 Int_t StEEsmdCalMaker::Make(){
00101
00102 clear();
00103
00104 if(unpackMuDst()<0) return kStOK;
00105
00106 findSectorMip();
00107
00108 return kStOK;
00109 }
00110
00111
00112
00113
00114 Int_t StEEsmdCalMaker::unpackMuDst(){
00115
00116 nInpEve++;
00117 gMessMgr->Message("","D") <<GetName()<<"::::getAdc() is called "<<endm;
00118
00119
00120 StMuEmcCollection* emc = mMuDstMaker->muDst()->muEmcCollection();
00121 if (!emc) {
00122 gMessMgr->Message("","W") <<"No EMC data for this event"<<endm; return kStOK;
00123 }
00124
00125
00126 int i, n1=0,n2=0,n3=0;
00127
00128
00129 for (i=0; i< emc->getNEndcapTowerADC(); i++) {
00130 int sec,eta,sub,val;
00131
00132 emc->getEndcapTowerADC(i,val,sec,sub,eta);
00133 assert(sec>0 && sec<=MaxSectors);
00134
00135
00136 if(sec<eeDb->getFirstSector() || sec>eeDb->getLastSector()) continue;
00137
00138 const EEmcDbItem *x=eeDb->getTile(sec,'A'+sub-1,eta,'T');
00139 assert(x);
00140 if(x->fail ) continue;
00141
00142 int iphi=(x->sec-1)*MaxSubSec+(x->sub-'A');
00143 int ieta=x->eta-1;
00144 assert(iphi>=0 && iphi<MaxPhiBins);
00145 assert(ieta>=0 && ieta<MaxEtaBins);
00146
00147 float adc=-100, rawAdc=-101, ene=-102;
00148
00149 if(MCflag) {
00150 adc=val;
00151 rawAdc=adc+x->ped;
00152 ene=adc/ mfixEmTgain[ieta];
00153 } else {
00154 rawAdc=val;
00155 adc=rawAdc-x->ped;
00156 if(x->gain) ene=adc/x->gain;
00157 }
00158
00159 int iT=0;
00160
00161
00162
00163 tileAdc[iT][ieta][iphi]=adc;
00164 tileThr[iT][ieta][iphi]=rawAdc>x->thr;
00165 if(rawAdc>x->thr) n1++;
00166 if(x->gain<=0) continue;
00167 tileEne[iT][ieta][iphi]=ene;
00168
00169 }
00170
00171
00172
00173 int pNh= emc->getNEndcapPrsHits();
00174 for (i=0; i<pNh; i++) {
00175 int pre;
00176 int sec,eta,sub;
00177
00178 StMuEmcHit *hit=emc->getEndcapPrsHit(i,sec,sub,eta,pre);
00179
00180
00181 if(sec<eeDb->getFirstSector() || sec>eeDb->getLastSector()) continue;
00182
00183
00184
00185 const EEmcDbItem *x=eeDb-> getTile(sec,sub-1+'A', eta, pre-1+'P');
00186 if(x==0) continue;
00187 if(x->fail ) continue;
00188
00189
00190 int iphi=(x->sec-1)*MaxSubSec+(x->sub-'A');
00191 int ieta=x->eta-1;
00192 assert(iphi>=0 && iphi<MaxPhiBins);
00193 assert(ieta>=0 && ieta<MaxEtaBins);
00194 int iT=pre;
00195 assert(iT>0 && iT<mxTile);
00196
00197 float val=hit->getAdc();
00198 float adc=-100, rawAdc=-101, ene=-102;
00199
00200 if(MCflag) {
00201 adc=val;
00202 rawAdc=adc+x->ped;
00203 ene=val/mfixPgain;
00204 } else {
00205 rawAdc=val;
00206 adc=rawAdc-x->ped;
00207 if(x->gain) ene=adc/x->gain;
00208 }
00209 if(rawAdc>x->thr) n2++;
00210
00211
00212 tileAdc[iT][ieta][iphi]=adc;
00213 tileThr[iT][ieta][iphi]=rawAdc>x->thr;
00214
00215 if(x->gain<=0) continue;
00216 tileEne[iT][ieta][iphi]=ene;
00217
00218 }
00219
00220
00221
00222
00223 char uv='U';
00224 for(uv='U'; uv<='V'; uv++) {
00225 int sec,strip;
00226 int nh= emc->getNEndcapSmdHits(uv);
00227
00228 for (i=0; i<nh; i++) {
00229 StMuEmcHit *hit=emc->getEndcapSmdHit(uv,i,sec,strip);
00230 assert(sec>0 && sec<=MaxSectors);
00231
00232
00233 if(sec<eeDb->getFirstSector() || sec>eeDb->getLastSector()) continue;
00234
00235 const EEmcDbItem *x=eeDb->getByStrip(sec,uv,strip);
00236 assert(x);
00237 if(x->fail ) continue;
00238
00239 float val=hit->getAdc();
00240 float adc=-100, rawAdc=-101, ene=-102;
00241
00242
00243 if(MCflag) {
00244 adc=val;
00245 rawAdc=adc+x->ped;
00246 ene=val/mfixSMDgain;
00247 }else {
00248 rawAdc=val;
00249 adc=rawAdc-x->ped;
00250 if(x->gain) ene=adc/x->gain;
00251 }
00252 if(rawAdc>x->thr) n3++;
00253
00254
00255 smdAdc[x->plane-'U'][x->strip-1]=adc;
00256 if(x->gain<=0)continue;
00257 smdEne[x->plane-'U'][x->strip-1]=ene;
00258 }
00259 }
00260
00261
00262 return n1;
00263 }
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290