00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00031 #include <Stiostream.h>
00032 #include "StPeCTrigger.h"
00033 #include "StPeCMaker.h"
00034 #include "StEventTypes.h"
00035 #include "Stypes.h"
00036 #include "StMessMgr.h"
00037 #include "StPeCCtbSlat.h"
00038
00039
00040
00041 ClassImp(StPeCTrigger)
00042
00043 StPeCTrigger::StPeCTrigger() {
00044
00045
00046
00047 l0_2000 = new StPeCL0 ();
00048 l0_2000->setYear1Input ();
00049 l0_2000->setP4SLuts ();
00050
00051
00052
00053 l0_2000Corrected = new StPeCL0 ();
00054 l0_2000Corrected->setYear1Input ();
00055 l0_2000Corrected->setP4PLuts ();
00056
00057
00058
00059 l0Offline2001 = new StPeCL0 ();
00060 l0Offline2001->setYear2Input ();
00061 l0Offline2001->setCountingLuts ();
00062
00063 ctbSlats = new TClonesArray ("StPeCCtbSlat", 10);
00064
00065 }
00066 StPeCTrigger::~StPeCTrigger() {
00067 ctbSlats->Clear();
00068 delete ctbSlats ;
00069 }
00070
00071 void StPeCTrigger::clear() {
00072 ctbSlats->Clear();
00073 }
00074
00075 Int_t StPeCTrigger::process(StEvent *event)
00076 {
00077 unsigned int i,j;
00078
00079
00080 tw = event->l0Trigger()->triggerWord();
00081
00082
00083 l0_2000->setInfoLevel ( infoLevel );
00084
00085
00086 StL0Trigger* l0Data = event->l0Trigger();
00087 StTriggerDetectorCollection* trg = event->triggerDetectorCollection();
00088 if ( !trg ) {
00089 printf ( "StPeCTrigger::StPeCTrigger: No trigger information \n" ) ;
00090 return 1 ;
00091 }
00092 StCtbTriggerDetector& ctb = trg->ctb();
00093 StMwcTriggerDetector& mwc = trg->mwc();
00094 StZdcTriggerDetector& zdc = trg->zdc();
00095 StBbcTriggerDetector& bbc = trg->bbc();
00096
00097 if ( l0Data && infoLevel > 0 ){
00098 cout << "L0 mwcCtbMultiplicity = " << l0Data->mwcCtbMultiplicity() << endl;
00099 }
00100 if(&zdc){
00101 if ( infoLevel > 1 ) {
00102 cout << "ZDC sum " << zdc.adcSum() << endl;
00103 cout << "ZDC sum west " << zdc.adcSum(west) << endl;
00104 cout << "ZDC sum east " << zdc.adcSum(east) << endl;
00105 }
00106
00107 zdcWest = zdc.adcSum(west) ;
00108 zdcEast = zdc.adcSum(east) ;
00109 zdcSum = zdc.adcSum() ;
00110
00111 zdcWestUA = zdc.adc(0) ;
00112 zdcEastUA = zdc.adc(4) ;
00113 zdcSumUA = zdcEastUA+zdcWestUA ;
00114 }
00115 else {
00116 zdcWestUA = 0 ;
00117 zdcEastUA = 0 ;
00118 zdcSumUA = 0 ;
00119
00120 zdcWest = 0 ;
00121 zdcEast = 0 ;
00122 zdcSum = 0 ;
00123 }
00124
00125
00126
00127 float mwcsum = 0.0;
00128
00129 float mwcThres = 2. ;
00130 nMwcHits = 0 ;
00131 mwcSW = 0 ;
00132 mwcNW = 0 ;
00133 mwcTW = 0 ;
00134 mwcBW = 0 ;
00135 mwcSE = 0 ;
00136 mwcNE = 0 ;
00137 mwcTE = 0 ;
00138 mwcBE = 0 ;
00139 if(&mwc){
00140 for(i=0; i<mwc.numberOfSectors(); i++){
00141 for(j=0; j<mwc.numberOfSubSectors(); j++){
00142 mwcsum += mwc.mips(i,j,0);
00143 if ( mwc.mips(i,j,0) > mwcThres ) {
00144 nMwcHits++ ;
00145 if ( i == 1 || i == 2 || i == 3 ) mwcSW++ ;
00146 else if ( i == 4 || i == 5 || i == 6 ) mwcBW++ ;
00147 else if ( i == 7 || i == 8 || i == 9 ) mwcNW++ ;
00148 else if ( i == 10 || i == 11 || i == 0 ) mwcTW++ ;
00149 else if ( i == 13 || i == 14 || i == 15 ) mwcNE++ ;
00150 else if ( i == 16 || i == 17 || i == 18 ) mwcBE++ ;
00151 else if ( i == 19 || i == 20 || i == 21 ) mwcSE++ ;
00152 else if ( i == 22 || i == 23 || i == 12 ) mwcTE++ ;
00153 }
00154 }
00155 }
00156 if ( infoLevel > 1 )
00157 cout << "mwc mips " << mwcsum << endl;
00158 }
00159
00160
00161
00162 float ctbsum=0.0;
00163 ctbSW = 0 ;
00164 ctbNW = 0 ;
00165 ctbTW = 0 ;
00166 ctbBW = 0 ;
00167 ctbSE = 0 ;
00168 ctbNE = 0 ;
00169 ctbTE = 0 ;
00170 ctbBE = 0 ;
00171 nCtbHits = 0 ;
00172 float ctbThres = 2. ;
00173 if(&ctb){
00174 TClonesArray &pCtbSlats = *ctbSlats;
00175 for(i=0; i<120; i++){
00176 for(j=0; j<2; j++){
00177 ctbsum += ctb.mips(i,j,0);
00178 if ( ctb.mips(i,j,0) > 0 ) {
00179 Byte_t i_eta = (Byte_t)(j+1);
00180 Byte_t i_phi = (Byte_t)(i+1);
00181 Int_t adc = (Int_t)ctb.mips(i,j,0) ;
00182 new(pCtbSlats[nCtbHits++]) StPeCCtbSlat(i_phi,i_eta,adc) ;
00183 }
00184
00185 if ( ctb.mips(i,j,0) > ctbThres ) {
00186 if ( i >= 5 && i < 20 ) ctbSW++ ;
00187 else if ( i >= 20 && i < 35 ) ctbBW++ ;
00188 else if ( i >= 35 && i < 50 ) ctbNW++ ;
00189 else if ( i >= 50 && i < 60 ) ctbTW++ ;
00190 else if ( i < 5 ) ctbTW++ ;
00191 else if ( i >= 65 && i < 80 ) ctbNE++ ;
00192 else if ( i >= 80 && i < 95 ) ctbBE++ ;
00193 else if ( i >= 95 && i < 110 ) ctbSE++ ;
00194 else if ( i >= 110 ) ctbTE++ ;
00195 else if ( i >= 60 && i < 65 ) ctbTE++ ;
00196 }
00197 }
00198 }
00199 if ( infoLevel > 1 )
00200 cout << "CTB MIP total sum = " << ctbsum << endl;
00201 }
00202 ctbSum = ctbsum ;
00203 mwcSum = mwcsum ;
00204
00205
00206
00207
00208 if(&bbc){
00209
00210 bbcAdcSumEastSm=bbc.adcSumEast();
00211 bbcAdcSumWestSm=bbc.adcSumWest();
00212 bbcAdcSumEastLg=bbc.adcSumEastLarge();;
00213 bbcAdcSumWestLg=bbc.adcSumWestLarge();;
00214
00215 bbcNHitEastSm=bbc.nHitEast();
00216 bbcNHitWestSm=bbc.nHitWest();
00217 bbcNHitEastLg=bbc.nHitEastLarge();;
00218 bbcNHitWestLg=bbc.nHitWestLarge();;
00219
00220 bbcTacEast=bbc.tdcEarliestEast();
00221 bbcTacWest=bbc.tdcEarliestWest();
00222
00223 } else {
00224 bbcAdcSumEastSm=0;
00225 bbcAdcSumWestSm=0;
00226 bbcAdcSumEastLg=0;
00227 bbcAdcSumWestLg=0;
00228
00229 bbcNHitEastSm=0;
00230 bbcNHitWestSm=0;
00231 bbcNHitEastLg=0;
00232 bbcNHitWestLg=0;
00233
00234 bbcTacEast=0;
00235 bbcTacWest=0;
00236 }
00237
00238
00239
00240
00241 p4 = l0_2000->process ( event ) ;
00242 p4c = l0_2000Corrected->process ( event ) ;
00243 p5 = l0Offline2001->process ( event ) ;
00244
00245
00246
00247
00248 Bool_t trgOut[40];
00249 {for ( int i = 0 ; i < 40 ; i++ ) trgOut[i] = 0 ;}
00250
00251 if ( infoLevel > 2 ) {
00252 printf ( "trgBits : " ) ;
00253 for ( int i = 0 ; i < 24 ; i++ ) {
00254 printf ( "%d ", trgOut[i] ) ;
00255 }
00256 printf ( "\n" ) ;
00257 }
00258
00259
00260
00261 StFtpcHitCollection* ftpHitC = 0 ;
00262 StFtpcPlaneHitCollection* plane;
00263 StFtpcSectorHitCollection* sector;
00264
00265 ftpW = 0 ;
00266 ftpE = 0 ;
00267
00268 ftpHitC = event->ftpcHitCollection();
00269 int nFtpcPlanes = 20 ;
00270 if ( ftpHitC ) {
00271 printf ( "there is a hit collection \n" ) ;
00272 for ( int iPlane = 0 ; iPlane < nFtpcPlanes ; iPlane++ ) {
00273 plane = 0 ;
00274 plane = ftpHitC->plane(iPlane);
00275 if ( !plane ) continue ;
00276 for ( int iSector = 0 ; iSector < 6 ; iSector++ ) {
00277 sector = 0 ;
00278 sector = plane->sector(iSector);
00279 if ( !sector ) continue ;
00280 StSPtrVecFtpcHit& hits = sector->hits();
00281 for ( unsigned int iHit = 0 ; iHit < hits.size() ; iHit++ ) {
00282
00283
00284 if ( iPlane < 10 ) ftpW++ ;
00285 else ftpE++ ;
00286
00287 }
00288 }
00289 }
00290
00291 }
00292
00293 return 0 ;
00294 }
00295
00296
00297 Int_t StPeCTrigger::process(StMuDst* mudst)
00298 {
00299 unsigned int i,j;
00300
00301
00302 tw = mudst->event()->l0Trigger().triggerWord();
00303
00304
00305 vector<unsigned int> triggerIds;
00306 StMuTriggerIdCollection tt=mudst->event()->triggerIdCollection();
00307 if(&tt) {
00308 StTriggerId ttid= tt.nominal();
00309 if(&ttid) {
00310 cout << "Got IDS " << endl;
00311
00312 triggerIds= ttid.triggerIds();
00313 std::vector<unsigned int>::iterator iiter;
00314 for(iiter=triggerIds.begin(); iiter!=triggerIds.end(); iiter++) {
00315 cout << "TiD " << *iiter << endl;
00316 }
00317
00318 trg_3000 =ttid.isTrigger(3000);
00319 trg_3001 =ttid.isTrigger(3001);
00320 trg_2001 =ttid.isTrigger(2001);
00321 trg_2004 =ttid.isTrigger(2004);
00322
00323 printf("upc %1d, upc_zdc %1d, minb1 %1d, minb2 %1d\n", trg_3000, trg_3001, trg_2001, trg_2004 );
00324 }
00325 }
00326
00327 l0_2000->setInfoLevel ( infoLevel );
00328
00329
00330 StL0Trigger* l0Data = &mudst->event()->l0Trigger();
00331
00332
00333
00334
00335
00336 StCtbTriggerDetector& ctb = mudst->event()->ctbTriggerDetector();
00337
00338 StZdcTriggerDetector& zdc = mudst->event()->zdcTriggerDetector();
00339 StBbcTriggerDetector& bbc = mudst->event()->bbcTriggerDetector();
00340
00341 if ( l0Data && infoLevel > 0 ){
00342 cout << "L0 mwcCtbMultiplicity = " << l0Data->mwcCtbMultiplicity() << endl;
00343 }
00344 if(&zdc){
00345 if ( infoLevel > 1 ) {
00346 cout << "ZDC sum " << zdc.adcSum() << endl;
00347 cout << "ZDC sum west " << zdc.adcSum(west) << endl;
00348 cout << "ZDC sum east " << zdc.adcSum(east) << endl;
00349 }
00350
00351 zdcWest = zdc.adcSum(west) ;
00352 zdcEast = zdc.adcSum(east) ;
00353 zdcSum = zdc.adcSum() ;
00354
00355 zdcWestUA = zdc.adc(0) ;
00356 zdcEastUA = zdc.adc(4) ;
00357 zdcSumUA = zdcEastUA+zdcWestUA ;
00358 }
00359 else {
00360 zdcWestUA = 0 ;
00361 zdcEastUA = 0 ;
00362 zdcSumUA = 0 ;
00363
00364 zdcWest = 0 ;
00365 zdcEast = 0 ;
00366 zdcSum = 0 ;
00367 }
00368
00369
00370
00371 float ctbsum=0.0;
00372 ctbSW = 0 ;
00373 ctbNW = 0 ;
00374 ctbTW = 0 ;
00375 ctbBW = 0 ;
00376 ctbSE = 0 ;
00377 ctbNE = 0 ;
00378 ctbTE = 0 ;
00379 ctbBE = 0 ;
00380 nCtbHits = 0 ;
00381 float ctbThres = 2. ;
00382 if(&ctb){
00383 TClonesArray &pCtbSlats = *ctbSlats;
00384 for(i=0; i<120; i++){
00385 for(j=0; j<2; j++){
00386 ctbsum += ctb.mips(i,j,0);
00387 if ( ctb.mips(i,j,0) > 0 ) {
00388 Byte_t i_eta = (Byte_t)(j+1);
00389 Byte_t i_phi = (Byte_t)(i+1);
00390 Int_t adc = (Int_t)ctb.mips(i,j,0) ;
00391 new(pCtbSlats[nCtbHits++]) StPeCCtbSlat(i_phi,i_eta,adc) ;
00392 }
00393
00394 if ( ctb.mips(i,j,0) > ctbThres ) {
00395 if ( i >= 5 && i < 20 ) ctbSW++ ;
00396 else if ( i >= 20 && i < 35 ) ctbBW++ ;
00397 else if ( i >= 35 && i < 50 ) ctbNW++ ;
00398 else if ( i >= 50 && i < 60 ) ctbTW++ ;
00399 else if ( i < 5 ) ctbTW++ ;
00400 else if ( i >= 65 && i < 80 ) ctbNE++ ;
00401 else if ( i >= 80 && i < 95 ) ctbBE++ ;
00402 else if ( i >= 95 && i < 110 ) ctbSE++ ;
00403 else if ( i >= 110 ) ctbTE++ ;
00404 else if ( i >= 60 && i < 65 ) ctbTE++ ;
00405 }
00406 }
00407 }
00408 if ( infoLevel > 1 )
00409 cout << "CTB MIP total sum = " << ctbsum << endl;
00410 }
00411 ctbSum = ctbsum ;
00412 mwcSum = 0 ;
00413
00414
00415 if(&bbc){
00416
00417 bbcAdcSumEastSm=bbc.adcSumEast();
00418 bbcAdcSumWestSm=bbc.adcSumWest();
00419 bbcAdcSumEastLg=bbc.adcSumEastLarge();;
00420 bbcAdcSumWestLg=bbc.adcSumWestLarge();;
00421
00422 bbcNHitEastSm=bbc.nHitEast();
00423 bbcNHitWestSm=bbc.nHitWest();
00424 bbcNHitEastLg=bbc.nHitEastLarge();;
00425 bbcNHitWestLg=bbc.nHitWestLarge();;
00426
00427 bbcTacEast=bbc.tdcEarliestEast();
00428 bbcTacWest=bbc.tdcEarliestWest();
00429
00430 } else {
00431 bbcAdcSumEastSm=0;
00432 bbcAdcSumWestSm=0;
00433 bbcAdcSumEastLg=0;
00434 bbcAdcSumWestLg=0;
00435
00436 bbcNHitEastSm=0;
00437 bbcNHitWestSm=0;
00438 bbcNHitEastLg=0;
00439 bbcNHitWestLg=0;
00440
00441 bbcTacEast=0;
00442 bbcTacWest=0;
00443 }
00444
00445
00446
00447 p4 = l0_2000->process(mudst);
00448 p4c = l0_2000Corrected->process(mudst);
00449 p5 = l0Offline2001->process(mudst);
00450
00451
00452
00453
00454 Bool_t trgOut[40];
00455 {for ( int i = 0 ; i < 40 ; i++ ) trgOut[i] = 0 ;}
00456
00457 if ( infoLevel > 2 ) {
00458 printf ( "trgBits : " ) ;
00459 for ( int i = 0 ; i < 24 ; i++ ) {
00460 printf ( "%d ", trgOut[i] ) ;
00461 }
00462 printf ( "\n" ) ;
00463 }
00464 return 0 ;
00465 }