16 #include "StEEmcA2EMaker.h"
19 #include "StMuDSTMaker/COMMON/StMuEmcCollection.h"
20 #include "StMuDSTMaker/COMMON/StMuDst.h"
24 #include "StEEmcUtil/database/StEEmcDb.h"
25 #include "StEEmcUtil/database/EEmcDbItem.h"
29 #include "StEvent/StEvent.h"
30 #include "StEvent/StEmcDetector.h"
31 #include "StEvent/StEmcModule.h"
32 #include "StEvent/StEmcRawHit.h"
33 #include "StEvent/StEmcCollection.h"
35 #include "StMessMgr.h"
52 for ( Int_t layer=0; layer < 4; layer++ ) {
61 for ( Int_t i=0;i<12;i++ )
62 for ( Int_t j=0;j<6;j++ )
73 for ( Int_t layer=0; layer < 4; layer++ )
81 for ( Int_t phi=phibin-1;phi<=phibin+1;phi++ )
82 for ( Int_t eta=etabin-1;eta<=etabin+1;eta++ )
86 if ( phi==phibin && eta==etabin )
continue;
89 if ( eta<0 || eta>11)
continue;
93 if ( kphi<0 ) kphi+=60;
94 if ( kphi>59 ) kphi-=60;
96 Int_t neighbor=12*kphi+eta;
98 if ((neighbor>=0) && (neighbor<720)) {
115 for ( Int_t sec=0; sec<12; sec++ ) {
116 for ( Int_t plane=0; plane<2; plane++ ) {
142 for ( Int_t i = 0; i < 4; i++ )
mHitTowers.push_back(t);
146 std::vector< StEEmcStripVec_t > plane;
149 for ( Int_t i=0; i < 12; i++ )
mHitStrips.push_back(plane);
156 StEEmcA2EMaker::~StEEmcA2EMaker()
167 return StMaker::Init();
186 {LOG_DEBUG <<
"Reading from MuDst..." << endm;}
194 {LOG_DEBUG <<
"Reading from StEvent..." << endm;}
197 {LOG_WARN <<
"Cannot find emc in the event" << endm;}
200 {LOG_WARN <<
"Cannot find neither event or mudst" << endm;}
209 {LOG_WARN <<
"Cannot find StMuEmcCollection" << endm;}
213 LOG_DEBUG<<
GetName()<<
"::fillFromMuDst() N tower ADC = "<<emc -> getNEndcapTowerADC()<<endm;
216 for ( Int_t ihit = 0; ihit < emc -> getNEndcapTowerADC(); ihit++ ) {
218 Int_t adc, sec, sub, eta;
219 emc -> getEndcapTowerADC ( ihit, adc, sec, sub, eta );
225 if ((sec >= 0) && (sec < 12) && (sub >= 0) && (sub < 5) && (eta >= 0) && (eta < 12)) {
232 LOG_DEBUG<<
GetName()<<
"::fillFromMuDst() N pre/post ADC = "<<emc -> getNEndcapPrsHits()<<endm;
235 for ( Int_t ihit = 0; ihit < emc -> getNEndcapPrsHits(); ihit++ ) {
237 Int_t adc, sec, sub, eta, det;
238 const StMuEmcHit *
hit = emc -> getEndcapPrsHit(ihit, sec, sub, eta, det);
241 adc = hit -> getAdc();
247 if ((sec >= 0) && (sec < 12) && (sub >= 0) && (sub < 5) && (eta >= 0) && (eta < 12) && (det >= 1) && (det < 4)) {
255 Char_t cpl[] = {
'U',
'V' };
256 for ( Int_t plane = 0; plane < 2; plane++ )
257 for ( Int_t ihit = 0; ihit < emc -> getNEndcapSmdHits(cpl[plane]); ihit++ ) {
259 Int_t sec,
strip, adc;
260 const StMuEmcHit *
hit = emc -> getEndcapSmdHit( cpl[plane], ihit, sec, strip );
261 adc = hit -> getAdc();
266 if ((sec >= 0) && (sec < 12) && (strip >= 0) && (strip < 288)) {
279 if (!((sec>=0 && sec<12) && (sub>=0 && sub<5) && (eta>=0 && eta<12) && (layer>=0 && layer < 4))) {
282 Int_t
index=60*sec+12*sub+eta;
283 if (!((0<=index) && (index<720))) {
288 static const Char_t subsectors[] = {
'A',
'B',
'C',
'D',
'E' };
289 static const Char_t detectors[] = {
'T',
'P',
'Q',
'R' };
308 if ( dbitem -> fail )
return energy;
311 Float_t ped = dbitem -> ped;
312 Float_t gain = dbitem -> gain;
316 if ( adc < threshold )
return energy;
323 if ( gain <= 0. )
return energy;
325 energy = ( adc - ped + 0.5 ) / gain;
331 UInt_t s=(UInt_t)
mTowers[index][layer].sector();
332 UInt_t ss=(UInt_t)
mTowers[index][layer].subsector();
333 UInt_t eb=(UInt_t)
mTowers[index][layer].etabin();
334 TVector3 momentum=
mEEgeom -> getTowerCenter( s,ss,eb );
335 momentum=momentum.Unit();
339 if ( !
mTowers[index][layer].fail() )
359 if (!((0 <= sec) && (sec < 12) && (0 <= plane) && (plane < 2) && (0 <= strip) && (strip < 288))) {
364 static const Char_t planes[] = {
'U',
'V' };
368 if ( dbitem == 0 )
return energy;
378 if ( dbitem -> fail )
return energy;
381 Float_t ped = dbitem -> ped;
382 Float_t gain = dbitem -> gain;
386 if ( adc < threshold )
return energy;
387 mHits[sec][plane+4]++;
393 if ( gain <= 0. )
return energy;
396 energy = ( adc - ped + 0.5 ) / gain;
411 for ( Int_t layer = 0; layer < 4; layer++ )
414 for ( Int_t sector=0; sector<12; sector++ )
415 for ( Int_t plane = 0; plane < 2; plane++ )
423 for ( Int_t i = 0; i < 720; i++ )
424 for ( Int_t j = 0; j < 4; j++ )
427 for ( Int_t i = 0; i < 12; i++ )
428 for ( Int_t j = 0; j < 2; j++ )
429 for ( Int_t k = 0; k < 288; k++ )
433 for ( Int_t i = 0; i < 12; i++ )
434 for ( Int_t j = 0; j < 6; j++ ) {
446 const StEmcDetector *detector=emc->detector(kEndcapEmcTowerId);
449 Warning(
"fillFromSt",
"\n**********\nemc->detector() NULL for eemc towers. MAJOR PROBLEM, trying to procede.\n**********\n\n");
453 for ( UInt_t sec = 0; sec < detector -> numberOfModules(); sec++ )
458 const StEmcModule *sector = detector -> module( sec+1 );
462 const StSPtrVecEmcRawHit &hits = sector->hits();
465 for ( UInt_t ihit=0; ihit<hits.size(); ihit++ )
474 Int_t isector = hits[ihit]->module() - 1;
475 Int_t isubsector = hits[ihit]->sub() - 1;
476 Int_t ietabin = hits[ihit]->eta() - 1;
477 Int_t adc = hits[ihit]->adc();
478 if (!((isector >= 0) && (isector < 12) && (isubsector >= 0) && (isubsector < 5) && (ietabin >= 0) && (ietabin < 12))) {
482 Int_t iphibin = 5 * isector + isubsector;
483 Int_t
index = 12 * iphibin + ietabin;
484 if (!((iphibin >= 0) && (iphibin < 60) && (index >= 0) && (index < 720))) {
489 std::cout <<
"isector=" << isector
490 <<
" isubsector=" << isubsector
491 <<
" ietabin=" << ietabin
492 <<
" " << hits[ihit]->module()
493 <<
" " << hits[ihit]->sub()
494 <<
" " << hits[ihit]->eta()
495 <<
" " << hits[ihit]->adc()
509 hits[ihit]->setEnergy(energy);
515 for ( UInt_t ii=0; ii <
mHitTowers.size(); ii++ )
518 std::cout <<
"mHitTowers[0][" << ii <<
"] "
523 <<std::endl <<
" ====> "
534 detector=emc->detector(kEndcapEmcPreShowerId);
538 Warning(
"fillFromSt",
"\n**********\nemc->detector() NULL for eemc pre/post. MAJOR PROBLEM, trying to procede.\n**********\n\n");
540 for ( UInt_t sec = 0; sec < detector -> numberOfModules(); sec++ ) {
544 const StEmcModule *sector = detector -> module( sec+1 );
545 const StSPtrVecEmcRawHit &hits = sector->hits();
548 for ( UInt_t ihit=0; ihit<hits.size(); ihit++ )
557 Int_t isector = hits[ihit]->module() - 1;
558 Int_t isubsector = (hits[ihit]->sub() - 1) % 5;
559 Int_t ietabin = hits[ihit]->eta() - 1;
560 Int_t adc = hits[ihit]->adc();
562 Int_t ilayer = (hits[ihit]->sub() - 1) / 5 + 1;
563 if (!((ilayer >= 1) && (ilayer < 4))) {
567 Int_t iphibin = 5*isector+isubsector;
568 Int_t
index = 12*iphibin + ietabin;
574 Float_t
energy =
addTowerHit( isector, isubsector, ietabin, (Float_t)adc, ilayer );
575 hits[ihit]->setEnergy(energy);
584 StDetectorId ids[] = { kEndcapSmdUStripId, kEndcapSmdVStripId };
586 for ( Int_t iplane=0; iplane<2; iplane++ )
590 detector=emc->detector( ids[iplane] );
592 Warning(
"fillFromSt",
"\n**********\nemc->detector() NULL for esmd plane. MAJOR PROBLEM, trying to procede.\n**********\n\n");
594 for ( UInt_t sec = 0; sec < detector -> numberOfModules(); sec++ )
599 const StEmcModule *sector = detector -> module( sec+1 );
600 const StSPtrVecEmcRawHit &hits = sector->hits();
603 for ( UInt_t ihit=0; ihit<hits.size(); ihit++ )
605 Int_t isector=hits[ihit]->module()-1;
606 Int_t istrip=hits[ihit]->eta()-1;
607 Int_t adc =hits[ihit]->adc();
608 if (!((isector >= 0) && (isector < 12) && (istrip >= 0) && (istrip < 288))) {
616 hits[ihit]->setEnergy(energy);
629 for ( Int_t sector=0;sector<12;sector++ ) sum+=
energy(sector,layer);
635 Int_t sec=-1,sub=-1,eta=-1;
642 Int_t sec=-1,sub=-1,eta=-1;
StEEmcA2EMaker(const Char_t *name="mEEanalysis")
Float_t mEnergy[kEEmcNumSectors][6]
EEmc ADC –> energy maker.
void stat(unsigned s)
Set a status bit for this element.
Bool_t fillFromMuDst(const StMuEmcCollection *emc)
virtual void Clear(Option_t *opts="")
Clears the element.
Float_t addTowerHit(Int_t sec, Int_t sub, Int_t eta, Float_t adc, Int_t layer)
void layer(Int_t l)
Sets the layer, [0-4]=[TPQR].
StEEmcTower * mHighTower[4]
std::vector< StEEmcTowerVec_t > mHitTowers
Float_t addSmdHit(Int_t sec, Int_t plane, Int_t str, Float_t adc)
Int_t mHits[kEEmcNumSectors][6]
Number of hits in layer.
StEEmcStrip mStrips[kEEmcNumSectors][kEEmcNumSmdUVs][kEEmcNumStrips]
Array of 12x2x288 smd strip objects.
void neighbor(StEEmcTower *n)
add a tower to list of neighbors
StEEmcStrip & strip(Int_t sector, Int_t plane, Int_t strip)
virtual void Clear(Option_t *opts="")
Clears the tower.
virtual void Clear(Option_t *option="")
User defined functions.
const EEmcGeomSimple * mEEgeom
Int_t index(Int_t sector, Int_t subsector, Int_t etabin) const
Given tower sector, subsector, etabin, translate into index.
void raw(Float_t r)
Set the raw ADC for this element.
Bool_t fillFromSt(const StEmcCollection *emc)
If StEvent is used, we will fill additional parts of StEEmcElement.
Int_t etabin() const
Returns the etabin of this tower, pre- or postshower element.
void fail(unsigned f)
Set a fail bit for this element.
Int_t phibin(Int_t sector, Int_t subsector) const
Given tower sector, subsector, translate to phibin.
void threshold(Float_t cut, Int_t layer)
const StEEmcDb * mDbMaker
std::vector< std::vector< StEEmcStripVec_t > > mHitStrips
Float_t energy(Int_t sector, Int_t layer) const
void print() const
Print a summary of this tower.
void index(Int_t i)
Sets the index for this SMD strip, 0..287.
Base class for representing tower, preshower and postshower elements.
virtual Int_t Init()
Initialize.
static StMuEmcCollection * muEmcCollection()
returns pointer to current StMuEmcCollection
virtual const char * GetName() const
special overload
Int_t phibin() const
Returns the phibin of this tower.
void adc(Float_t a)
Set the pedestal-subtracted ADC for this element.
virtual void Clear(Option_t *opts="")
Clear the maker for next event.
StEEmcTower & tower(Int_t index, Int_t layer=0)
void stemc(StEmcRawHit *h)
Sets pointer to the StEmcRawHit when processing an StEvent file.
StEEmcTower mTowers[kEEmcNumSectors *kEEmcNumSubSectors *kEEmcNumEtas][4]
Array of 720 x 4 tower objects.
void plane(Int_t p)
Sets the plane for this SMD strip, 0=U, 1=V.
bool getTower(const TVector3 &r, int &sec, int &sub, int &etabin, Float_t &dphi, Float_t &deta) const
void sector(Int_t s)
Sets the sector for this SMD strip.
void energy(Float_t e)
Set the energy (adc-ped+0.5)/gain for this element.
virtual Int_t Make()
Read and process one event.