00001 #include "StMyClusterMaker.h"
00002
00003 #include "StEEmcPool/StEEmcA2EMaker/StEEmcA2EMaker.h"
00004
00005 #include <algorithm>
00006
00007 #include "StMuDSTMaker/COMMON/StMuTrack.h"
00008
00009 #include "StMcEvent/StMcEvent.hh"
00010 #include "StMcEvent/StMcTrack.hh"
00011 #include "StMcEvent/StMcVertex.hh"
00012
00013 #include "StMessMgr.h"
00014
00015 ClassImp(StMyClusterMaker);
00016
00017
00018 StMyClusterMaker::StMyClusterMaker(const Char_t *name, const StEEmcA2EMaker *a2e, StMuDstMaker * )
00019 : StEEmcGenericClusterMaker(name,a2e), StMyClusterParams()
00020 {
00021 mSmdSeedEnergy = 4.0 / 1000.0;
00022 mSmdMinEnergy = 0.5 / 1000.0;
00023
00024 mMaxExtent = 40;
00025 mTruncateRatio = 1.2;
00026 mMinStrips = 3;
00027
00028 mSeedEnergy[0]=0.8; mMinEnergy[0]=0.1;
00029 mSeedEnergy[1]=1.0/1000.0; mMinEnergy[1]=0.1/1000.0;
00030 mSeedEnergy[2]=1.0/1000.0; mMinEnergy[2]=0.1/1000.0;
00031 mSeedEnergy[3]=1.0/1000.0; mMinEnergy[3]=0.1/1000.0;
00032
00033 mEtaCut = 999;
00034 mPhiCut = 999;
00035
00036
00037
00038
00039 setDoBreakInflection(0);
00040 setDoBreakTruncation(0);
00041 setDoBreakSize(0);
00042
00043 mUseFloor=false;
00044 mFloorParams[0]=0.;mFloorParams[1]=0.;
00045
00046 }
00047
00048
00049 Int_t StMyClusterMaker::Make()
00050 {
00051
00052 buildTowerClusters();
00053 buildPreshowerClusters();
00054 buildSmdClusters();
00055 buildPostshowerClusters();
00056 Int_t result = StEEmcGenericClusterMaker::Make();
00057 return result;
00058
00059 }
00060
00061
00062 Int_t StMyClusterMaker::buildLayer(Int_t layer )
00063 {
00064
00065 const Char_t *clayers[]={"T","P","Q","R","U","V"};
00066
00067 LOG_DEBUG << " build clusters for layer=" << clayers[layer] << endm;
00068
00069
00070 StEEmcTowerVec_t hits=mEEanalysis->towers(layer);
00071
00072
00073 std::sort( hits.begin(), hits.end());
00074
00075 std::reverse( hits.begin(), hits.end());
00076
00077 LOG_DEBUG<<"searching for seeds in layer "<<clayers[layer]<<endm;
00078
00079
00080 StEEmcTowerVec_t seeds;
00081 for ( UInt_t i=0;i<hits.size();i++ )
00082 {
00083
00084 if ( hits[i].fail() ) continue;
00085
00086 if ( hits[i].energy() > mSeedEnergy[layer] )
00087 seeds.push_back(hits[i]);
00088 else
00089 break;
00090
00091 LOG_DEBUG<<"+ "<<hits[i].name()<<" "<<hits[i].energy()<<endm;
00092
00093 }
00094
00095 LOG_DEBUG<<"clustering"<<endm;
00096
00097
00098
00099 Bool_t used[720];
00100 for ( Int_t i=0;i<720;i++ ) used[i]=false;
00101 for ( UInt_t i=0;i<seeds.size();i++ )
00102 {
00103
00104 const StEEmcTower &tow=seeds[i];
00105 if ( tow.fail() ) continue;
00106 if ( used[tow.index()] ) continue;
00107
00108 Int_t etabin_seed = tow.etabin();
00109 Int_t phibin_seed = tow.phibin();
00110
00111 StEEmcCluster c;
00112 c.add(tow);
00113 used[tow.index()]=true;
00114
00115
00116
00117
00118
00119 CLUSTERING:
00120 Int_t size_old = c.numberOfTowers();
00121 for ( UInt_t j=0;j<hits.size();j++ )
00122 {
00123 const StEEmcTower &tow=hits[j];
00124
00125 if ( used[ tow.index() ] ) continue;
00126 if ( tow.fail() ) continue;
00127
00128 if ( tow.energy() < mMinEnergy[layer] ) break;
00129
00130 Int_t deta=TMath::Abs(etabin_seed - tow.etabin());
00131 if ( deta > mEtaCut ) continue;
00132
00133 Int_t phi1=TMath::Max(phibin_seed,tow.phibin());
00134 Int_t phi2=TMath::Min(phibin_seed,tow.phibin());
00135 Int_t diff1 = phi1-phi2;
00136 Int_t diff2 = phi2-phi1+60;
00137 Int_t dphi=TMath::Min(diff1,diff2);
00138 if ( dphi > mPhiCut ) continue;
00139
00140 if ( c.isNeighbor( tow ) ) {
00141 c.add(tow);
00142 used[tow.index()]=true;
00143 }
00144
00145 }
00146 if ( c.numberOfTowers() > size_old ) goto CLUSTERING;
00147
00148 add(c);
00149 LOG_DEBUG<<"+ key="<<c.key()<<" seed="<<c.tower(0).name()<<" energy="<<c.energy()<<endm;
00150
00151 }
00152
00153 return kStOk;
00154
00155 }
00156
00157
00158 Int_t StMyClusterMaker::buildTowerClusters()
00159 {
00160 buildLayer(0);
00161 return kStOK;
00162 }
00163
00164
00165 Int_t StMyClusterMaker::buildPreshowerClusters()
00166 {
00167 buildLayer(1);
00168 buildLayer(2);
00169 return kStOK;
00170 }
00171
00172
00173 Int_t StMyClusterMaker::buildPostshowerClusters()
00174 {
00175 buildLayer(3);
00176 return kStOK;
00177 }
00178
00179
00180 Int_t StMyClusterMaker::buildSmdClusters()
00181 {
00182
00183 LOG_DEBUG << " building SMD clusters" << endm;
00184
00185 for ( Int_t sector=0;sector<12;sector++ ) {
00186
00187 Float_t etmax = 0.;
00188 for ( UInt_t ii=0;ii<mTowerClusters[sector][0].size();ii++ )
00189 {
00190 const StEEmcCluster &c = mTowerClusters[sector][0][ii];
00191 if ( c.momentum().Perp() > etmax ) etmax = c.momentum().Perp();
00192 }
00193
00194
00195 if ( etmax >= 4.5 ) {
00196 mSmdSeedEnergy = ( seed_threshold + seed_slope * (etmax-4.5) ) / 1000.0;
00197 mSmdMinEnergy = 0.1 * mSmdSeedEnergy;
00198 }
00199 else {
00200 mSmdSeedEnergy = seed_threshold / 1000.0;
00201 mSmdMinEnergy = 0.1 * mSmdSeedEnergy;
00202 }
00203
00204 LOG_DEBUG<<GetName()<<" sector="<<sector<<" seed energy="<<mSmdSeedEnergy<<endm;
00205
00206 for ( Int_t plane=0;plane<2;plane++ )
00207 {
00208
00209
00210
00211 Int_t nstrips = (Int_t)mESmdGeom -> getEEmcSector( plane, sector ).stripPtrVec.size();
00212
00213
00214 Bool_t used[288]; for (Int_t i=0;i<288;i++ ) used[i]=false;
00215
00216
00217 Float_t floor[288]; for ( Int_t i=0;i<288;i++ ) floor[i]=0.;
00218
00219
00220 StEEmcStripVec_t strips=mEEanalysis->strips(sector,plane);
00221
00222 std::sort(strips.begin(),strips.end());
00223
00224 std::reverse(strips.begin(),strips.end());
00225
00226
00227 LOG_DEBUG << " sector=" << sector
00228 << " plane=" << plane
00229 << " nhit strips=" << strips.size()
00230 << endm;
00231
00232 StEEmcStripVec_t seeds;
00233
00234 Float_t emax_strip = 0.;
00235 for ( UInt_t i=0;i<strips.size();i++ )
00236 {
00237
00238
00239 Int_t myindex = strips[i].index();
00240
00241
00242 if ( strips[i].energy() < mSmdSeedEnergy ) break;
00243
00244
00245 if ( myindex < 4 || myindex > nstrips-4 ) continue;
00246
00247
00248 if ( strips[i].fail() ) continue;
00249
00250
00251 const StEEmcStrip *stripL = &mEEanalysis->strip(sector,plane,myindex-1);
00252 const StEEmcStrip *stripR = &mEEanalysis->strip(sector,plane,myindex+1);
00253 if ( stripL->fail() ) stripL = &mEEanalysis->strip(sector,plane,myindex-2);
00254 if ( stripR->fail() ) stripR = &mEEanalysis->strip(sector,plane,myindex+2);
00255 if ( stripL->energy() < mSmdMinEnergy ||
00256 stripR->energy() < mSmdMinEnergy ) continue;
00257
00258
00259 seeds.push_back( strips[i] );
00260
00261 if ( strips[i].energy() > emax_strip )
00262 {
00263 emax_strip = strips[i].energy();
00264 }
00265
00266 }
00267
00268
00269
00270 LOG_DEBUG << " sector=" << sector
00271 << " plane=" << plane
00272 << " n seed strips=" << seeds.size()
00273 << endm;
00274
00275
00276
00277 StEEmcSmdClusterVec_t clusters;
00278
00279
00280 for ( UInt_t i=0;i<seeds.size(); i++ )
00281 {
00282
00283
00284 const StEEmcStrip &seed=seeds[i];
00285 Int_t myindex=seed.index();
00286
00287
00288
00289
00290 if ( used[myindex] ) continue;
00291 used[myindex]=true;
00292
00293
00294 if ( seed.energy() < mSmdSeedEnergy + floor[myindex] ) continue;
00295
00296 StEEmcSmdCluster cluster;
00297 cluster.add( seed );
00298
00299 Int_t break_inflection = 0;
00300
00301 Int_t break_energy = 0;
00302
00303
00304 for ( Int_t j=1;j<=mMaxExtent;j++ )
00305 {
00306
00307 Float_t ecluster = cluster.energy();
00308 Int_t fail_count = 0;
00309
00310 Int_t istrip;
00311
00312
00313
00314 istrip = myindex+j;
00315 if ( istrip < nstrips ) {
00316
00317 if ( used[istrip] ) break;
00318
00319 const StEEmcStrip &strip=mEEanalysis->strip(sector,plane,istrip);
00320 Float_t energy=strip.energy();
00321
00322
00323 if ( istrip > 1 && istrip < nstrips-1 ) {
00324 const StEEmcStrip &strip_left=mEEanalysis->strip(sector,plane,istrip-1);
00325 const StEEmcStrip &strip_right=mEEanalysis->strip(sector,plane,istrip+1);
00326 if ( strip_right.energy() > strip_left.energy() ) break_inflection++;
00327 }
00328
00329 if ( energy > mSmdMinEnergy )
00330 {
00331 if ( !strip.fail() ) {
00332 used[istrip]++;
00333 cluster.add(strip);
00334 }
00335 else
00336 fail_count++;
00337 }
00338 else
00339 break_energy++;
00340
00341
00342 }
00343
00344
00345
00346
00347
00348 istrip = myindex-j;
00349 if ( istrip >=0 ) {
00350
00351 if ( used[istrip] ) break;
00352
00353 const StEEmcStrip &strip=mEEanalysis->strip(sector,plane,istrip);
00354 Float_t energy=strip.energy();
00355
00356
00357 if ( istrip > 1 && istrip < nstrips-1 ) {
00358 const StEEmcStrip &strip_left=mEEanalysis->strip(sector,plane,istrip-1);
00359 const StEEmcStrip &strip_right=mEEanalysis->strip(sector,plane,istrip+1);
00360
00361 if ( strip_right.energy() < strip_left.energy() ) break_inflection++;
00362
00363 }
00364
00365 if ( energy > mSmdMinEnergy )
00366 {
00367 if ( !strip.fail() ) {
00368 used[istrip]++;
00369 cluster.add(strip);
00370 }
00371 else
00372 fail_count++;
00373 }
00374 else
00375 break_energy++;
00376
00377
00378 }
00379
00380 if ( break_energy ) break;
00381
00382
00383
00384
00385
00386 Float_t etruncate = ecluster;
00387 etruncate *= ( mTruncateRatio - ( mTruncateRatio-1.0 ) * ( fail_count ) );
00388 if ( cluster.energy() < etruncate && mBreakTruncation ) break;
00389
00390
00391
00392
00393 if ( mBreakInflection && break_inflection ) break;
00394
00395 }
00396
00397
00398
00399 if ( cluster.size() >= mMinStrips ) {
00400 add(cluster);
00401 LOG_DEBUG << " adding " << cluster << endm;
00402 Int_t index=seed.index();
00403
00404 for ( Int_t ii=index-3;ii<=index+3; ii++ )
00405 if ( ii>=0 && ii<288 ) used[ii]=1;
00406
00407
00408
00409 if ( mUseFloor )
00410 for ( Int_t ii=0;ii<288;ii++ )
00411 {
00412 Float_t f = mFloorParams[0] * cluster.energy() * TMath::Gaus( seed.index()-ii, 0., mFloorParams[1] * cluster.sigma(), true );
00413 floor[ii]+=f;
00414 }
00415
00416
00417 }
00418
00419 }
00420
00421
00422 }
00423 }
00424
00425
00426 return kStOK;
00427 }
00428
00429
00430
00431