40 #include "St_DataSetIter.h"
42 #include "StIOMaker/StIOMaker.h"
44 #include "StThreeVectorF.hh"
45 #include "StThreeVectorD.hh"
46 #include "StPhysicalHelixD.hh"
48 #include "StEvent/StTrackTopologyMap.h"
49 #include "StEvent/StRunInfo.h"
51 #include "StMuDSTMaker/COMMON/StMuDstMaker.h"
52 #include "StMuDSTMaker/COMMON/StMuDst.h"
53 #include "StMuDSTMaker/COMMON/StMuEvent.h"
54 #include "StMuDSTMaker/COMMON/StMuTrack.h"
55 #include "StMuDSTMaker/COMMON/StMuEmcCollection.h"
57 #include "StEEmcUtil/EEmcGeom/EEmcGeomDefs.h"
58 #include "StEEmcUtil/EEmcGeom/EEmcGeomSimple.h"
60 #include "StEEmcUtil/StEEmcSmd/StEEmcSmdGeom.h"
62 #include "StEEmcUtil/database/StEEmcDb.h"
63 #include "StEEmcUtil/database/EEmcDbItem.h"
64 #include "StEEmcUtil/EEfeeRaw/EEname2Index.h"
66 #include "EEmcTower.h"
67 #include "EEmcTTMatch.h"
68 #include "EEmcTTMMaker.h"
71 #if !defined(ST_NO_NAMESPACES)
74 using std::ostringstream;
100 if( mMuDstMaker == NULL )
101 Fatal(
"EEmcTTMMaker",
"invalid StMuDstMaker");
110 mFileName = TString(
GetName());
112 mFileName +=
".ndst.root";
133 mTrackList =
new TList;
134 mTowerList =
new TList;
135 mMatchList =
new TList;
137 mTowerList->SetOwner();
138 mMatchList->SetOwner();
153 if( mTree !=NULL )
delete mTree;
154 if( mFile !=NULL )
delete mFile;
157 if( mMatchList!=NULL )
delete mMatchList;
158 if( mTrackList!=NULL )
delete mTrackList;
159 if( mTowerList!=NULL )
delete mTowerList;
167 mEEmcDb = (
StEEmcDb*)this->GetDataSet(
"StEEmcDb");
169 Fatal(
"EEmcTTMMaker",
"invalid StEEmcDbMaker");
173 mFile =
new TFile(mFileName,
"RECREATE");
if(!mFile)
return kStErr;
174 mTree =
new TTree(
"ttm",
"TPC track to EEmc tower matches");
if(!mTree)
return kStErr;
176 mTree->Branch(
"matches",
"TList",&mMatchList,32768,0);
178 mTree->Branch(
"info" ,
"StEventInfo" ,&mEvInfo ,32768,0);
179 mTree->Branch(
"summary" ,
"StEventSummary" ,&mEvSumm ,32768,0);
180 mTree->Branch(
"trigger" ,
"StMuTriggerIdCollection",&mEvTrig ,32768,0);
183 mFile->mkdir(
"histos");
188 hTrackNHits =
new TH1F(
"hTrankNHits",
"hits/track" ,100, 0.0,100 );
189 hTrackLen =
new TH1F(
"hTrackLen" ,
"track length [cm]" ,500, 0.0,500.0);
190 hTrackPt =
new TH1F(
"hTrackPt" ,
"p_T [GeV]" ,500, 0.0, 5.0);
191 hTrackPtot =
new TH1F(
"hTrackPtot" ,
"p_tot [GeV]" ,500, 0.0, 5.0);
193 hTrackDCA[0] =
new TH1F(
"hTrackDCAX" ,
"x_vtxdca [cm]" ,200,- 50.0, 50.0);
194 hTrackDCA[1] =
new TH1F(
"hTrackDCAY" ,
"y_vtxdca [cm]" ,200, -50.0, 50.0);
195 hTrackDCA[2] =
new TH1F(
"hTrackDCAZ" ,
"z_vtxdca [cm]" ,200, -5.0, 5.0);
201 return StMaker::Init();
220 Warning(
"Make",
"%s error, muDST maker data missing",
GetName());
224 if(mEEmcDb->valid()<=0) {
225 Warning(
"Make",
"%s: missing EEMC Db records",
GetName());
232 Warning(
"Make",
"%s: no MuEvent data for this event",
GetName());
236 if( muEvent->ctbMultiplicity() > mMaxCTBsum )
return kStOK;
241 Warning(
"Make",
"%s: no tracks for this event",
GetName());
247 Info(
"Make",
"%s: no EMC data for this event",
GetName());
251 if(emc->getNEndcapTowerADC()<=0) {
252 Info(
"Make",
"%s: no EEMC tower data for this event",
GetName());
265 TIter nextTrack(tracks);
268 while ( (track = (
StMuTrack *)nextTrack()) ) {
273 hTrackNHits->Fill(track->
nHitsFit());
275 hTrackPt ->Fill(track->
pt());
276 hTrackPtot ->Fill(p.mag());
278 hTrackDCA[0] ->Fill(dca.x());
279 hTrackDCA[1] ->Fill(dca.y());
280 hTrackDCA[2] ->Fill(dca.z());
283 mTrackList->Add(track);
287 if( mTrackList->IsEmpty() ) {
289 Info(
"Make",
"no good tracks for this event");
296 for (Int_t i=0; i< emc->getNEndcapTowerADC(); i++) {
301 emc->getEndcapTowerADC(i,adc,sec,sub,eta);
302 if (adc<=0)
continue;
305 const EEmcDbItem *dbi = mEEmcDb->getT(sec,sub+
'@',eta);
307 if(dbi==NULL)
continue;
311 adcped = float(adc) - dbi->ped;
312 edep = (dbi->gain>0.0) ? adcped/dbi->gain : 0.0;
313 if(adcped<0.0)
continue;
318 mTowerList->Add(eemcHit);
319 eemcMatch->
Add(eemcHit);
328 TIter nextTrack(mTrackList);
329 while( (track=(
StMuTrack *)nextTrack()) != NULL ) {
334 map<double,TString>::const_iterator zpos=mZ.begin();
335 for(
unsigned int k=0; zpos!=mZ.end() ; ++zpos,k++) {
336 double z = zpos->first;
340 dphi = fmod(phi0 - r.Phi(),TMath::TwoPi());
341 deta = (eta0 - r.Eta() );
342 if( !
MatchTrack(dphi,deta,phiHW,etaHW) )
break;
345 if(!matched)
continue;
346 eemcMatch->
Add(track);
350 mMatchList->Add(eemcMatch);
354 if(mTreeOut && ntrack>0) mTree->Fill();
375 if(mTreeOut && mTree!=NULL) mFile->Write();
385 if(! track->
topologyMap().trackTpcOnly() )
return kFALSE;
386 if( track->
type() != 1 )
return kFALSE;
387 if( track->
flag() <= 0 )
return kFALSE;
388 if( track->
nHitsFit() < mMinTrackHits )
return kFALSE;
389 if( track->
length() < mMinTrackLength )
return kFALSE;
390 if( track->
pt() < mMinTrackPt )
return kFALSE;
391 if( track->
eta() < mMinTrackEta )
return kFALSE;
392 if( track->
eta() > mMaxTrackEta )
return kFALSE;
411 if( mPhiFac*phihw < fabs(dphi) )
return kFALSE;
412 if( mEtaFac*etahw < fabs(deta) )
return kFALSE;
428 out <<
"<EEmcTTMMaker:Summary>\n";
429 out <<
" <Maker Name=\"" <<
GetName() <<
"\" />\n";
431 out.setf(ios_base::fixed,ios_base::floatfield);
434 out <<
" <CutsSummary>\n";
437 out <<
" max CTB sum allowed " << mMaxCTBsum <<
"\n\n";
439 out <<
" min hits/track required " << mMinTrackHits <<
"\n";
440 out <<
" min track length required " << mMinTrackLength <<
"\n";
441 out <<
" min track transverse momentum required " << mMinTrackPt <<
"\n";
442 out <<
" min track pseudorapidity at origin required " << mMinTrackEta <<
"\n";
443 out <<
" max track pseudorapidity at origin required " << mMaxTrackEta <<
"\n\n";
445 out <<
" tracks are matched at the following depths:\n";
446 map<double,TString>::const_iterator zpos;
448 for(zpos=mZ.begin(); zpos!=mZ.end() ; ++zpos)
449 out <<
" " << ++k <<
". z=" << zpos->first <<
" \"" << zpos->second <<
"\"\n";
451 out <<
" max track to tower center dist. " << mPhiFac <<
" x tower half-width (phi)\n";
452 out <<
" max track to tower center dist. " << mEtaFac <<
" x tower half-width (eta)\n";
453 out <<
" </CutsSummary>\n";
456 out <<
" <Statistics>\n";
457 out <<
" *** Statistics:\n";
458 out <<
" total # of events " << mNEvents <<
"\n";
459 out <<
" # of matched tracks " << mNMatched <<
"\n";
460 out <<
" # of matched tracks/event " << float(mNMatched)/mNEvents <<
"\n";
461 out <<
" </Statistics>\n";
463 out <<
"</EEmcTTMMaker:Summary>\n";
464 out.setf(ios_base::fmtflags(0),ios_base::floatfield);
472 ostream& operator<<(ostream &out,
const EEmcTTMMaker &ttm) {
Double_t lengthMeasured() const
Returns length of track (cm) from first to last measured point.
void ResetZPositionsArray()
clears z positions array
short type() const
Returns the track type: 0=global, 1=primary, etc (see StEvent manual for type information) ...
static const Double_t kDefDeltaPhiCut
default value for the maximum distance in phi from the tower center
Double_t pt() const
Returns pT at point of dca to primary vertex.
Double_t length() const
Returns length of track (cm) from primary vertex to last measured point.
Float_t getEtaHalfWidth(UInt_t eta) const
virtual void Clear(Option_t *option="")
User defined functions.
static const Double_t kDefMinTrackPt
default value for the minimum track pT allowed
EEmcTTMMaker(const char *self="ttmmk", class StMuDstMaker *mumaker=NULL)
Float_t getPhiMean(UInt_t sec) const
ostream & Summary(ostream &out) const
prints matching cuts and statistics summary
void ResetStats()
resets the collected statistics
void AddZPosition(const TString name, const double zpos)
UShort_t nHitsFit() const
Return total number of hits used in fit.
virtual void Clear(Option_t *option="")
short flag() const
Returns flag, (see StEvent manual for type information)
Int_t Matches()
returns number of matched tracks
static const Double_t kDefMaxTrackEta
default value for the maximum track pseudorapidity at origin allowed
const StThreeVectorF & p() const
Returns 3-momentum at dca to primary vertex.
virtual Int_t Make()
process one event
Double_t eta() const
Returns pseudo rapidity at point of dca to primary vertex.
Bool_t AcceptTrack(const StMuTrack *track)
whether accept the track or not
static TObjArray * primaryTracks()
returns pointer to a list of tracks belonging to the selected primary vertex
virtual ~EEmcTTMMaker()
the destructor
static StMuEmcCollection * muEmcCollection()
returns pointer to current StMuEmcCollection
static StMuEvent * event()
returns pointer to current StMuEvent (class holding the event wise information, e.g. event number, run number)
Float_t getPhiHalfWidth(UInt_t sec=0, UInt_t ssec=0) const
Bool_t MatchTrack(const double dphi, const double deta, const double phihw, const double etahw)
whether track matches or not
virtual const char * GetName() const
special overload
void Add(EEmcTower *t)
adds tower data
StThreeVectorF dca(Int_t vtx_id=-1) const
Returns 3D distance of closest approach to primary vertex.
EEmcTTMatch class contains results of TPC track to EEMC tower matching.
static const Int_t kDefMaxCTBsum
default value for the maximum CTB sum allowed
static const Double_t kDefDeltaEtaCut
default value for the maximum distance in eta from the tower center
static const Double_t kDefMinTrackEta
default value for the minimum track pseudorapidity at origin allowed
Collection of trigger ids as stored in MuDst.
StTrackTopologyMap topologyMap() const
Returns topology map.
EEmcTower holds information about an EEMC tower 'hit'.
static Bool_t ExtrapolateToZ(const StMuTrack *track, const double z, TVector3 &r)
given track and position z return TVector3 with a
virtual Int_t Finish()
cleans up at the end
virtual Int_t Init()
initialize maker
static const Double_t kDefMinTrackLength
default value for the minimum track length allowed
static const Int_t kDefMinTrackHits
default value for the minimum TPC hits/track allowed
Float_t getEtaMean(UInt_t eta) const