00001
00002
00003
00004
00005 #include "StRFEmcTrigMaker.h"
00006 #include "StChain.h"
00007 #include "StMuDSTMaker/COMMON/StMuEvent.h"
00008 #include "StMuDSTMaker/COMMON/StMuDst.h"
00009 #include "StMuDSTMaker/COMMON/StMuDstMaker.h"
00010 #include "StMuDSTMaker/COMMON/StMuEmcCollection.h"
00011 #include "StMuDSTMaker/COMMON/StMuTrack.h"
00012 #include "StMuDSTMaker/COMMON/StMuEmcPoint.h"
00013 #include "StMuDSTMaker/COMMON/StMuTrack.h"
00014 #include "StEmcUtil/geometry/StEmcGeom.h"
00015 #include "TH1F.h"
00016 #include "TH2F.h"
00017 #include "StEvent.h"
00018 #include "StEventMaker/StEventMaker.h"
00019 #include "StEvent/StEmcDetector.h"
00020 #include "StEvent/StEmcCollection.h"
00021 #include "StEventTypes.h"
00022 #include "StEvent/StBbcTriggerDetector.h"
00023 #include "TClonesArray.h"
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 ClassImp(StRFEmcTrigMaker)
00046
00047 StRFEmcTrigMaker::StRFEmcTrigMaker(const char *name):StMaker(name){
00048 activeBBC=false;
00049 emcGeom =0;
00050 }
00051
00052 StRFEmcTrigMaker::~StRFEmcTrigMaker(){
00053 }
00054
00055
00056
00057
00058 Int_t StRFEmcTrigMaker::Init(){
00059 if (!DataMode) {
00060 cout << "You are loading StMuDst" << endl;
00061 } else {
00062 cout << "You are loading StEvent!" << endl;
00063 }
00064
00065 emcGeom = StEmcGeom::getEmcGeom("bemc");
00066 initHisto();
00067
00068 return StMaker::Init();
00069 }
00070
00071
00072
00073 void StRFEmcTrigMaker::Sum(int *sum,int *sumadd){
00074
00075 (*sum)=(*sumadd)+(*sum);
00076 }
00077
00078 void StRFEmcTrigMaker::Max(int *max,int *maxcomp){
00079 if ((*max) < (*maxcomp))
00080 (*max)=(*maxcomp);
00081 }
00082
00083
00084
00085 Int_t StRFEmcTrigMaker::getBBCtrig(){
00086 return bbcTrig;
00087 }
00088
00089 Int_t StRFEmcTrigMaker::getBEMCtrigHT(int thres){
00090
00091 int test=0;
00092 if (BHTmaxt>thres) test=1;
00093 if (BHTmaxt<=thres) test=0;
00094 return test;
00095 }
00096
00097 Int_t StRFEmcTrigMaker::getBEMCtrigJP(int thres){
00098
00099 int test=0;
00100 if (BJPmaxt>thres) test = 1;
00101 if (BJPmaxt<=thres) test = 0;
00102 return test;
00103 }
00104
00105 Int_t StRFEmcTrigMaker::getBEMCtrigTOT(int thres){
00106
00107
00108 int test=0;
00109 if (BJPsumt>thres) test = 1;
00110 if (BJPsumt<=thres) test = 0;
00111 return test;
00112 }
00113
00114 Int_t StRFEmcTrigMaker::getEEMCtrigHT(int thres){
00115
00116 int test=0;
00117 if (EHTmaxt>thres) test=1;
00118 if (EHTmaxt<=thres) test=0;
00119 return test;
00120
00121 }
00122
00123 Int_t StRFEmcTrigMaker::getEEMCtrigJP(int thres ){
00124
00125
00126 int test=0;
00127 if (EJPmaxt>thres) test = 1;
00128 if (EJPmaxt<=thres) test = 0;
00129 return test;
00130 }
00131
00132 Int_t StRFEmcTrigMaker::getEEMCtrigTOT(int thres ){
00133
00134 int test=0;
00135 if (EJPsumt>thres) test = 1;
00136 if (EJPsumt<=thres) test = 0;
00137 return test;
00138 }
00139
00140
00141 Int_t StRFEmcTrigMaker::getEEMC_HT_ADC(){
00142
00143 return EHTmaxt;
00144
00145 }
00146
00147
00148 Int_t StRFEmcTrigMaker::getEEMC_JP_ADC(){
00149
00150 return EJPmaxt;
00151
00152 }
00153
00154
00155 Int_t StRFEmcTrigMaker::getEEMC_TOT_ADC(){
00156 return EJPsumt;
00157
00158 }
00159
00160
00161 Int_t StRFEmcTrigMaker::getBEMC_HT_ADC(){
00162
00163 return BHTmaxt;
00164
00165 }
00166
00167
00168 Int_t StRFEmcTrigMaker::getBEMC_JP_ADC(){
00169
00170 return BJPmaxt;
00171
00172 }
00173
00174
00175 Int_t StRFEmcTrigMaker::getBEMC_TOT_ADC(){
00176
00177 return BJPsumt;
00178
00179 }
00180
00181
00182
00183 void StRFEmcTrigMaker:: Clear(const char *opt){
00184
00185
00186 bbcTrig=0;
00187
00188
00189 memset(jpBsum,0,sizeof(jpBsum));
00190 memset(jpBmax,0,sizeof(jpBmax));
00191 memset(jpB_hit_num,0,sizeof(jpB_hit_num));
00192 memset(tpBsum,0,sizeof(tpBsum));
00193 memset(tpBmax,0,sizeof(tpBmax));
00194
00195
00196
00197 memset(jpEsum,0,sizeof(jpEsum));
00198 memset(jpEmax,0,sizeof(jpEmax));
00199 memset(jpE_hit_num,0,sizeof(jpE_hit_num));
00200 memset(tpEsum,0,sizeof(tpEsum));
00201 memset(tpEmax,0,sizeof(tpEmax));
00202
00203 BHTmaxt=0;
00204 BJPmaxt=0;
00205 BJPsumt=0;
00206 EHTmaxt=0;
00207 EJPmaxt=0;
00208 EJPsumt=0;
00209
00210
00211 bbcCol=0;
00212 muEmcCol=0;
00213 stEmcCol=0;
00214 }
00215
00216
00217
00218 Int_t StRFEmcTrigMaker::Make(){
00219
00220
00221
00222 switch( DataMode) {
00223 case 0: {
00224 StMuDstMaker *muDstMaker = (StMuDstMaker*)GetMaker("MuDst");
00225 if(!muDstMaker) {
00226 gMessMgr->Warning() <<GetName()<<" no muDstMaker !!! Game Over!"<< endm;
00227 return kStErr;
00228 }
00229 muEvent=muDstMaker->muDst()->event();
00230 bbcCol=&(muEvent->bbcTriggerDetector());
00231 muEmcCol=muDstMaker->muDst()->muEmcCollection();
00232 unpackEmcFromMu();
00233 } break;
00234 case 1: {
00235 stEvent = (StEvent *) GetInputDS("StEvent");
00236 if(!stEvent) {
00237 gMessMgr->Warning() <<GetName()<<" no StEvent !!! Game Over!"<< endm;
00238 return kStErr;
00239 }
00240 StTriggerDetectorCollection *TrigDet=stEvent->triggerDetectorCollection();
00241 bbcCol=&(TrigDet->bbc());
00242 stEmcCol =(StEmcCollection*)stEvent->emcCollection();
00243 unpackEmcFromSt();
00244 } break;
00245 default:
00246 gMessMgr->Error() <<GetName()<<" Logic error 1, kill chain"<< endm;
00247 return kStFatal;
00248 }
00249
00250
00251 unpackBBC();
00252
00253 if(activeBBC && !getBBCtrig()) return kStErr;
00254
00255
00256 fillHisto();
00257 return kStOK;
00258 }
00259
00260
00261
00262
00263 void StRFEmcTrigMaker::unpackEmcFromMu(){
00264 if(!muEmcCol) {
00265 gMessMgr->Warning() <<GetName()<<" no muEmcCollection"<< endm;
00266 return;
00267 }
00268
00269
00270
00271
00272
00273
00274
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 det=1;
00303 for (int n=1; n<=BemcTow; n++){
00304 emcGeom->getBin(n,Bmod,Beta,Bsub);
00305 BTowADC = muEmcCol->getTowerADC(n,det);
00306 if (BTowADC>0) {
00307
00308
00309 int jpBindex=(Bmod+Bsub+5)/10;
00310 if (((Bmod+Bsub+5)>=60)&&((Bmod+Bsub+5)<=66)) {
00311 jpBindex=0;
00312 }
00313 if ((Bmod == 60)&&(Bsub==2)) jpBindex=0;
00314
00315 int tpBindex=((Bmod+Bsub-3)/2) + 30*((Beta-1)/4);
00316 if ((Bmod==1)&&(Bsub==1)) {
00317 tpBindex=(29 + 30*((Beta-1)/4));
00318 }
00319 if (Bmod>60){
00320 tpBindex=150 + ((Bmod+Bsub-3)/2) + 30*((Beta-1)/4);
00321 if ((Bmod==61)&&(Bsub==1)) {
00322 tpBindex=150 + (59 + 30*((Beta+-1)/4));
00323 }
00324 }
00325 Sum(&jpBsum[jpBindex],&BTowADC);
00326 Max(&jpBmax[jpBindex],&BTowADC);
00327 Sum(&tpBsum[tpBindex],&BTowADC);
00328 Max(&tpBmax[tpBindex],&BTowADC);
00329 jpB_hit_num[jpBindex]++;
00330
00331
00332 }
00333 }
00334 for (int q=0; q < 6; q++){
00335 Sum(&BJPsumt,&jpBsum[q]);
00336 Max(&BHTmaxt,&jpBmax[q]);
00337 Max(&BJPmaxt,&jpBsum[q]);
00338 }
00339
00340
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360 NumETow=muEmcCol->getNEndcapTowerADC();
00361 for (int m=0; m<NumETow; m++){
00362 muEmcCol->getEndcapTowerADC(m,ETowADC,Esec,Esub,Eeta);
00363 int Eid = m+84;
00364 if (ETowADC){
00365
00366 if (Eid > 719) Eid=Eid-720;
00367 int jpEindex=Eid/120;
00368 int tpEindex=Eid/24;
00369 if (Eeta>7) {
00370 tpEindex+=60;
00371 }
00372 if ((Eeta>3)&&(Eeta<8)) {
00373 tpEindex+=30;
00374 }
00375
00376 Sum(&jpEsum[jpEindex],&ETowADC);
00377 Max(&jpEmax[jpEindex],&ETowADC);
00378 Sum(&tpEsum[tpEindex],&ETowADC);
00379 Max(&tpEmax[tpEindex],&ETowADC);
00380 jpE_hit_num[jpEindex]++;
00381
00382
00383
00384
00385 }
00386 }
00387
00388
00389 for (int q=0; q < 6; q++){
00390
00391 Sum(&EJPsumt,&jpEsum[q]);
00392 Max(&EHTmaxt,&jpEmax[q]);
00393 Max(&EJPmaxt,&jpEsum[q]);
00394
00395 }
00396
00397 printf("EJPsum=%d ,EHTmax=%d,EJPmax=%d\n",EJPsumt,EHTmaxt,EJPmaxt);
00398 printf("BJPsum=%d ,BHTmax=%d,BJPmax=%d\n",BJPsumt,BHTmaxt,BJPmaxt);
00399 }
00400
00401
00402
00403
00404
00405 void StRFEmcTrigMaker::unpackEmcFromSt(){
00406 if(!stEmcCol) {
00407 gMessMgr->Warning() <<GetName()<<" no stEmcCollection"<< endm;
00408 return;
00409 }
00410
00411
00412
00413
00414
00415
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445 StDetectorId BemcId=StDetectorId(kBarrelEmcTowerId);
00446 StEmcDetector *EmcDet = stEmcCol->detector(BemcId);
00447 if(EmcDet) {
00448 for (UInt_t mod=1;mod<=EmcDet->numberOfModules();mod++){
00449 StEmcModule* module=EmcDet->module(mod);
00450 StSPtrVecEmcRawHit& hit=module->hits();
00451 for(UInt_t ih=0;ih<hit.size();ih++){
00452 StEmcRawHit *x=hit[ih];
00453 Bmod=x->module();
00454 Bsub=x->sub();
00455 Beta=x->eta();
00456 BTowADC=x->adc();
00457
00458 if (BTowADC>0) {
00459
00460 int jpBindex=(Bmod+Bsub+5)/10;
00461 if (((Bmod+Bsub+5)>=60)&&((Bmod+Bsub+5)<=66)) {
00462 jpBindex=0;
00463 }
00464 if ((Bmod == 60)&&(Bsub==2)) jpBindex=0;
00465
00466 int tpBindex=((Bmod+Bsub-3)/2) + 30*((Beta-1)/4);
00467 if ((Bmod==1)&&(Bsub==1)) {
00468 tpBindex=(29 + 30*((Beta-1)/4));
00469 }
00470 if (Bmod>60){
00471 tpBindex=150 + ((Bmod+Bsub-3)/2) + 30*((Beta-1)/4);
00472 if ((Bmod==61)&&(Bsub==1)) {
00473 tpBindex=150 + (59 + 30*((Beta+-1)/4));
00474 }
00475 }
00476 Sum(&jpBsum[jpBindex],&BTowADC);
00477 Max(&jpBmax[jpBindex],&BTowADC);
00478 Sum(&tpBsum[tpBindex],&BTowADC);
00479 Max(&tpBmax[tpBindex],&BTowADC);
00480 jpB_hit_num[jpBindex]++;
00481
00482
00483 }
00484 }
00485 }
00486
00487 for (int q=0; q < 6; q++){
00488 Sum(&BJPsumt,&jpBsum[q]);
00489 Max(&BHTmaxt,&jpBmax[q]);
00490 Max(&BJPmaxt,&jpBsum[q]);
00491 }
00492 }
00493
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510 StDetectorId EemcId=StDetectorId(kEndcapEmcTowerId);
00511 EmcDet = stEmcCol->detector(EemcId);
00512 if(EmcDet) {
00513 for (UInt_t mod=1;mod<=EmcDet->numberOfModules();mod++){
00514 StEmcModule* module=EmcDet->module(mod);
00515 StSPtrVecEmcRawHit& hit=module->hits();
00516 for(UInt_t ih=0;ih<hit.size();ih++){
00517 StEmcRawHit *x=hit[ih];
00518 Esec=x->module();
00519 Esub=x->sub();
00520 Eeta=x->eta();
00521 ETowADC=x->adc();
00522
00523 int m =60*(Esec-1) + 12*(Esub-1) + (Eeta-1);
00524 int Eid = m+84;
00525 if (ETowADC){
00526
00527 if (Eid > 719) Eid=Eid-720;
00528 int jpEindex=Eid/120;
00529 int tpEindex=Eid/24;
00530 if (Eeta>7) {
00531 tpEindex+=60;
00532 }
00533 if ((Eeta>3)&&(Eeta<8)) {
00534 tpEindex+=30;
00535 }
00536
00537 Sum(&jpEsum[jpEindex],&ETowADC);
00538 Max(&jpEmax[jpEindex],&ETowADC);
00539 Sum(&tpEsum[tpEindex],&ETowADC);
00540 Max(&tpEmax[tpEindex],&ETowADC);
00541 jpE_hit_num[jpEindex]++;
00542
00543
00544
00545
00546 }
00547 }
00548 }
00549 for (int q=0; q < 6; q++){
00550
00551 Sum(&EJPsumt,&jpEsum[q]);
00552 Max(&EHTmaxt,&jpEmax[q]);
00553 Max(&EJPmaxt,&jpEsum[q]);
00554
00555 }
00556 printf("EJPsum=%d ,EHTmax=%d,EJPmax=%d\n",EJPsumt,EHTmaxt,EJPmaxt);
00557 printf("BJPsum=%d ,BHTmax=%d,BJPmax=%d\n",BJPsumt,BHTmaxt,BJPmaxt);
00558 }
00559 }
00560
00561
00562
00563
00564
00565 void StRFEmcTrigMaker::unpackBBC(){
00566 if(!bbcCol) {
00567 gMessMgr->Warning() <<GetName()<<" no BBC Collection"<< endm;
00568 return;
00569 }
00570 int Npmt=bbcCol->numberOfPMTs();
00571
00572
00573 int Wbbc=0;
00574 int Ebbc=0;
00575 for (int pmt=0;pmt<Npmt;pmt++){
00576 BBCadc[pmt]=bbcCol->adc(pmt);
00577 int bbcadc=bbcCol->adc(pmt);
00578 if (bbcadc>5) {
00579 if (pmt<16) {
00580
00581 Ebbc=1;
00582 }
00583 if (23<pmt && pmt<40) {
00584
00585 Wbbc=1;
00586 }
00587 }
00588 }
00589
00590 if ((Ebbc==1)&&(Wbbc==1)){
00591 bbcTrig=1;
00592 }
00593
00594 gMessMgr->Info() <<GetName()<<" BBCtrig="<<getBBCtrig()<<endm;
00595
00596 }
00597
00598
00599
00600 void StRFEmcTrigMaker::initHisto() {
00601 int mxAdc=300;
00602 int nAdc=mxAdc/4;
00603 ha[0]=new TH1F("bHT","BEMC HT ADC",nAdc,-.5, mxAdc-.5);
00604 ha[1]=new TH1F("bJP","BEMC JP ADC",nAdc,-.5, mxAdc-.5);
00605 ha[2]=new TH1F("bTot","BEMC Tot ADC",nAdc,-.5, mxAdc-.5);
00606 ha[3]=new TH1F("eHT","EEMC HT ADC",nAdc,-.5, mxAdc-.5);
00607 ha[4]=new TH1F("eJP","EEMC JP ADC",nAdc,-.5, mxAdc-.5);
00608 ha[5]=new TH1F("eTot","EEMC Tot ADC",nAdc,-.5, mxAdc-.5);
00609 }
00610
00611
00612
00613 void StRFEmcTrigMaker::fillHisto() {
00614
00615 ha[0]->Fill(getBEMC_HT_ADC());
00616 ha[1]->Fill(getBEMC_JP_ADC());
00617 ha[2]->Fill(getBEMC_TOT_ADC());
00618 ha[3]->Fill(getEEMC_HT_ADC());
00619 ha[4]->Fill(getEEMC_JP_ADC());
00620 ha[5]->Fill(getEEMC_TOT_ADC());
00621 }
00622
00623
00624
00625
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636