00001
00002
00003 #include <cassert>
00004 #include <TClonesArray.h>
00005 #include <StMessMgr.h>
00006
00007 #include "EEtwHitDst.h"
00008 #include "EEsmdHitDst.h"
00009 #include "EEsectorDst.h"
00010
00011 ClassImp(EEsectorDst)
00012
00013
00014
00015
00016 EEsectorDst::EEsectorDst(int id){
00017
00018 ID=id;
00019 Pre1Hits = new TClonesArray("EEtwHitDst",1000);
00020 Pre2Hits = new TClonesArray("EEtwHitDst",1000);
00021 TwHits = new TClonesArray("EEtwHitDst",1000);
00022 SmdUHits = new TClonesArray("EEsmdHitDst",1000);
00023 SmdVHits = new TClonesArray("EEsmdHitDst",1000);
00024 PostHits = new TClonesArray("EEtwHitDst",1000);
00025 }
00026
00027
00028
00029
00030 EEsectorDst::~EEsectorDst() {
00031 delete Pre1Hits;
00032 delete Pre2Hits;
00033 delete TwHits;
00034 delete SmdUHits;
00035 delete SmdVHits;
00036 delete PostHits;
00037 }
00038
00039
00040
00041
00042 void EEsectorDst::clear(){
00043 Pre1Hits->Clear();
00044 Pre2Hits->Clear();
00045 SmdUHits->Clear();
00046 SmdVHits->Clear();
00047 TwHits->Clear();
00048 PostHits->Clear();
00049 }
00050
00051
00052
00053
00054
00055 void EEsectorDst::print(int k){
00056
00057 LOG_INFO<<Form("EEsectorDst(ID=%d)::print() nPre1Hit=%d nPre2Hit=%d nSmdUHit=%d nSmdVHit=%d nTowerHit=%d nPostHit=%d \n",ID,Pre1Hits->GetEntries(),Pre2Hits->GetEntries(),SmdUHits->GetEntries(),SmdVHits->GetEntries(),TwHits->GetEntries(),PostHits->GetEntries())<<endm;
00058
00059 if(k<0) return;
00060
00061 LOG_INFO<<Form("EEsectorDst(Tower) nHit=%d\n",TwHits->GetEntries())<<endm;
00062 int i;
00063
00064 TClonesArray *hitA=getTwHits();
00065 for(i=0;i<hitA->GetEntries();i++){
00066 EEtwHitDst *hit=(EEtwHitDst*)hitA->At(i);
00067 hit->print();
00068 }
00069
00070 LOG_INFO<<Form ("EEsectorDst(pre/post/SMD) not implemented\n")<<endm;
00071 }
00072
00073
00074
00075
00076
00077 void EEsectorDst::addTwHit(char sub, int eta, float ener, TClonesArray *hitA) {
00078
00079 TClonesArray &hits = *hitA;
00080 int len=hits.GetEntries();
00081 EEtwHitDst *hit= new(hits[len]) EEtwHitDst;
00082 hit->set(sub,eta,ener);
00083
00084 }
00085
00086
00087
00088
00089
00090 void EEsectorDst::addSmdHit(int strip, float ener, TClonesArray *hitA) {
00091
00092 TClonesArray &hits = *hitA;
00093 int len=hits.GetEntries();
00094 EEsmdHitDst *hit= new(hits[len]) EEsmdHitDst;
00095
00096
00097 hit->set(strip,ener);
00098 }
00099
00100
00101
00102
00103 void EEsectorDst::sumRawMC(EEsectorDst *outSec, float minE) {
00104
00105
00106
00107
00108 const int mx=60;
00109 const int mx2=300;
00110 float sum1[mx];
00111 float sum2[mx];
00112 float sumU[mx2];
00113 float sumV[mx2];
00114 float sum3[mx];
00115 float sum4[mx];
00116
00117 sumRawMCtw(Pre1Hits,sum1,mx);
00118 sumRawMCtw(Pre2Hits,sum2,mx);
00119
00120 sumRawMCsmd(SmdUHits ,sumU,mx2);
00121 sumRawMCsmd(SmdVHits ,sumV,mx2);
00122 sumRawMCtw(TwHits ,sum3,mx);
00123 sumRawMCtw(PostHits,sum4,mx);
00124
00125 int j;
00126
00127
00128 float grandSum=0;
00129
00130
00131
00132
00133
00134
00135 for(j=0;j<mx;j++) {
00136 char sub='A'+j/12;
00137 int eta=1+j%12;
00138 float ener1=sum1[j];
00139 float ener2=sum2[j];
00140 float ener3=sum3[j];
00141 float ener4=sum4[j];
00142
00143 float ener14=ener1+ener2+ener3+ener4;
00144
00145 grandSum+=ener14;
00146
00147 if(ener1>minE)
00148 addTwHit(sub,eta,ener1,outSec->Pre1Hits);
00149
00150 if(ener2>minE)
00151 addTwHit(sub,eta,ener2,outSec->Pre2Hits);
00152
00153 if(ener14>minE)
00154 addTwHit(sub,eta,ener14,outSec->TwHits);
00155
00156 if(ener4>minE)
00157 addTwHit(sub,eta,ener4,outSec->PostHits);
00158
00159 }
00160
00161
00162
00163 for(j=0;j<mx2;j++) {
00164 int strip=j+1;
00165
00166 float ener=sumU[j];
00167 grandSum+=ener;
00168 if(ener>minE)
00169 addSmdHit(strip,ener,outSec->SmdUHits);
00170
00171 ener=sumV[j];
00172 grandSum+=ener;
00173 if(ener>minE)
00174 addSmdHit(strip,ener,outSec->SmdVHits);
00175
00176 }
00177
00178
00179
00180 }
00181
00182
00183
00184
00185 void EEsectorDst::sumRawMCtw(TClonesArray *inH, float* sum, int mx) {
00186
00187
00188 int j;
00189 for(j=0;j<mx;j++) sum[j]=0;
00190
00191 int nOK=0;
00192
00193 int ih;
00194 for(ih=0;ih<inH->GetEntries();ih++) {
00195 EEtwHitDst *hit=(EEtwHitDst*)inH->At(ih);
00196 char sub;
00197 int eta;
00198 float ener;
00199
00200 hit->get(sub,eta,ener);
00201
00202
00203 nOK++;
00204
00205 int index=(sub-'A')*12+ (eta-1);
00206 assert(index>=0 && index<mx);
00207 sum[index]+=ener;
00208 }
00209
00210 }
00211
00212
00213
00214
00215
00216 void EEsectorDst::sumRawMCsmd(TClonesArray *inH, float* sum, int mx) {
00217
00218 int j;
00219 for(j=0;j<mx;j++) sum[j]=0;
00220
00221 int nOK=0;
00222 int ih;
00223 for(ih=0;ih<inH->GetEntries();ih++) {
00224 EEsmdHitDst *hit=(EEsmdHitDst*)inH->At(ih);
00225 int strip;
00226 float ener;
00227
00228 hit->get(strip,ener);
00229
00230 nOK++;
00231
00232 int index=strip-1;
00233 assert(index>=0 && index<mx);
00234 sum[index]+=ener;
00235 }
00236
00237 }
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
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
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303