5 #include "St_base/StMessMgr.h"
7 #include "StEvent/StEvent.h"
9 #include "StEvent/StFcsCluster.h"
10 #include "StEvent/StFttCollection.h"
11 #include "StEvent/StFcsCollection.h"
12 #include "StEvent/StFwdTrack.h"
13 #include "StEvent/StFwdTrackCollection.h"
15 #include "StMuDSTMaker/COMMON/StMuDstMaker.h"
16 #include "StMuDSTMaker/COMMON/StMuDst.h"
17 #include "StMuDSTMaker/COMMON/StMuFwdTrack.h"
18 #include "StMuDSTMaker/COMMON/StMuFwdTrackCollection.h"
20 #include "StFcsDbMaker/StFcsDb.h"
21 #include "StFwdTrackMaker/Common.h"
22 #include "StFwdUtils/StFwdAnalysisMaker.h"
25 StFwdAnalysisMaker::StFwdAnalysisMaker() :
StMaker(
"fwdAna"){
26 setLocalOutputFile(
"" );
30 if ( mLocalOutputFile !=
"" ){
31 auto prevDir = gDirectory;
34 TFile *fOutput =
new TFile(mLocalOutputFile,
"RECREATE");
37 nh.second->SetDirectory(gDirectory);
44 LOG_INFO <<
"Done writing StFwdAnalysisMaker output to local file : " << mLocalOutputFile << endm;
51 int StFwdAnalysisMaker::Init() {
52 LOG_DEBUG <<
"StFwdAnalysisMaker::Init" << endm;
54 AddHist(
mHists[
"fwdMultFailed"] =
new TH1F(
"fwdMultFailed",
";N_{ch}^{FWD}; counts", 100, 0, 100) );
55 AddHist(
mHists[
"fwdMultAll"] =
new TH1F(
"fwdMultAll",
";N_{ch}^{FWD}; counts", 100, 0, 100) );
56 AddHist(
mHists[
"fwdMultGood"] =
new TH1F(
"fwdMultGood",
";N_{ch}^{FWD}; counts", 100, 0, 100) );
57 AddHist(
mHists[
"fwdMultFST"] =
new TH1F(
"fwdMultFST",
";N_{ch}^{FWD}; counts", 100, 0, 100) );
58 AddHist(
mHists[
"nHitsFit"] =
new TH1F(
"nHitsFit",
";nHitsFit; counts", 10, 0, 10) );
59 AddHist(
mHists[
"fwdMultEcalMatch"] =
new TH1F(
"fwdMultEcalMatch",
";N_{ch}^{FWD}; counts", 100, 0, 100) );
60 AddHist(
mHists[
"fwdMultHcalMatch"] =
new TH1F(
"fwdMultHcalMatch",
";N_{ch}^{FWD}; counts", 100, 0, 100) );
61 AddHist(
mHists[
"fwdMultEcalClusters"] =
new TH1F(
"fwdMultEcalClusters",
";N_{Clu}^{ECAL}; counts", 100, 0, 100) );
62 AddHist(
mHists[
"fwdMultHcalClusters"] =
new TH1F(
"fwdMultHcalClusters",
";N_{Clu}^{HCAL}; counts", 100, 0, 100) );
63 AddHist(
mHists[
"eta"] =
new TH1F(
"eta",
";#eta; counts", 100, 0, 5) );
64 AddHist(
mHists[
"phi"] =
new TH1F(
"phi",
";#phi; counts", 100, -3.1415926, 3.1415926) );
65 AddHist(
mHists[
"pt"] =
new TH1F(
"pt",
"; pT; counts", 500, 0, 10) );
66 AddHist(
mHists[
"charge"] =
new TH1F(
"charge",
"; charge; counts", 4, -2, 2) );
67 AddHist(
mHists[
"ecalMatchPerTrack"] =
new TH1F(
"ecalMatchPerTrack",
";N_{match} / track; counts", 5, 0, 5) );
68 AddHist(
mHists[
"hcalMatchPerTrack"] =
new TH1F(
"hcalMatchPerTrack",
";N_{match} / track; counts", 5, 0, 5) );
69 AddHist(
mHists[
"matchedEcalEnergy"] =
new TH1F(
"matchedEcalEnergy",
";Energy; counts", 100, 0, 15) );
70 AddHist(
mHists[
"matchedHcalEnergy"] =
new TH1F(
"matchedHcalEnergy",
";Energy; counts", 100, 0, 15) );
71 AddHist(
mHists[
"ecalEnergy"] =
new TH1F(
"ecalEnergy",
";Energy; counts", 100, 0, 15) );
72 AddHist(
mHists[
"hcalEnergy"] =
new TH1F(
"hcalEnergy",
";Energy; counts", 100, 0, 15) );
73 AddHist(
mHists[
"ecalXY"] =
new TH2F(
"ecalXY",
";ecalX;ecalY", 200, -200, 200, 200, -200, 200 ) );
74 AddHist(
mHists[
"hcalXY"] =
new TH2F(
"hcalXY",
";hcalX;hcalY", 200, 0, 50, 200, 0, 50 ) );
75 AddHist(
mHists[
"ecaldX"] =
new TH1F(
"ecaldX",
";dx (trk - ecal); counts", 400, -200, 200 ) );
76 AddHist(
mHists[
"matchedEcaldX"] =
new TH1F(
"matchedEcaldX",
";dx (trk - ecal); counts", 400, -200, 200 ) );
77 AddHist(
mHists[
"ecaldY"] =
new TH1F(
"ecaldY",
";dy (trk - ecal); counts", 400, -200, 200 ) );
78 AddHist(
mHists[
"matchedEcaldY"] =
new TH1F(
"matchedEcaldY",
";dy (trk - ecal); counts", 400, -200, 200 ) );
79 AddHist(
mHists[
"ecaldR"] =
new TH1F(
"ecaldR",
";dr (trk - ecal); counts", 400, 0, 400 ) );
80 AddHist(
mHists[
"ecalMindR"] =
new TH1F(
"ecalMindR",
";dr (trk - ecal); counts", 400, 0, 400 ) );
81 AddHist(
mHists[
"matchedEcaldR"] =
new TH1F(
"matchedEcaldR",
";dr (trk - ecal); counts", 400, 0, 400 ) );
82 AddHist(
mHists[
"hcaldX"] =
new TH1F(
"hcaldX",
";dx (trk - hcal); counts", 400, -200, 200 ) );
83 AddHist(
mHists[
"hcaldXdNFit"] =
new TH2F(
"hcaldXdNFit",
";dx (trk - hcal); nFit", 400, -200, 200, 10, 0, 10 ) );
84 AddHist(
mHists[
"matchedHcaldX"] =
new TH1F(
"matchedHcaldX",
";dx (trk - hcal); counts", 400, -200, 200 ) );
85 AddHist(
mHists[
"hcaldY"] =
new TH1F(
"hcaldY",
";dy (trk - hcal); counts", 400, -200, 200 ) );
86 AddHist(
mHists[
"hcaldYdNFit"] =
new TH2F(
"hcaldYdNFit",
";dy (trk - hcal); nFit", 400, -200, 200, 10, 0, 10 ) );
87 AddHist(
mHists[
"matchedHcaldY"] =
new TH1F(
"matchedHcaldY",
";dy (trk - hcal); counts", 400, -200, 200 ) );
88 AddHist(
mHists[
"hcaldR"] =
new TH1F(
"hcaldR",
";dr (trk - hcal); counts", 400, 0, 400 ) );
89 AddHist(
mHists[
"hcalMindR"] =
new TH1F(
"hcalMindR",
";dr (trk - hcal); counts", 400, 0, 400 ) );
90 AddHist(
mHists[
"matchedHcaldR"] =
new TH1F(
"matchedHcaldR",
";dr (trk - hcal); counts", 400, 0, 400 ) );
91 AddHist(
mHists[
"trkEcalX"] =
new TH2F(
"trkEcalX",
";trkX;ecalX", 300, -150, 150, 300, -150, 150 ) );
92 AddHist(
mHists[
"trkEcalY"] =
new TH2F(
"trkEcalY",
";trkY;ecalY", 300, -150, 150, 300, -150, 150 ) );
93 AddHist(
mHists[
"trkEcalMinX"] =
new TH2F(
"trkEcalMinX",
";trkX;ecalX", 300, -150, 150, 300, -150, 150 ) );
94 AddHist(
mHists[
"trkEcalMinY"] =
new TH2F(
"trkEcalMinY",
";trkY;ecalY", 300, -150, 150, 300, -150, 150 ) );
95 AddHist(
mHists[
"trkHcalX"] =
new TH2F(
"trkHcalX",
";trkX;hcalX", 300, -150, 150, 300, -150, 150 ) );
96 AddHist(
mHists[
"trkHcalY"] =
new TH2F(
"trkHcalY",
";trkY;hcalY", 300, -150, 150, 300, -150, 150 ) );
97 AddHist(
mHists[
"trkHcalMinX"] =
new TH2F(
"trkHcalMinX",
";trkX;hcalX", 300, -150, 150, 300, -150, 150 ) );
98 AddHist(
mHists[
"trkHcalMinY"] =
new TH2F(
"trkHcalMinY",
";trkY;hcalY", 300, -150, 150, 300, -150, 150 ) );
104 LOG_DEBUG <<
"StFwdAnalysisMaker::Make" << endm;
105 long long itStart = FwdTrackerUtils::nowNanoSecond();
109 ProcessFwdMuTracks();
110 LOG_DEBUG <<
"Processing Fwd Tracks took: " << (FwdTrackerUtils::nowNanoSecond() - itStart) * 1e6 <<
" ms" << endm;
114 void StFwdAnalysisMaker::Clear(
const Option_t *opts) { LOG_DEBUG <<
"StFwdAnalysisMaker::CLEAR" << endm; }
116 void StFwdAnalysisMaker::ProcessFwdTracks( ){
118 LOG_DEBUG <<
"StFwdAnalysisMaker::ProcessFwdTracks" << endm;
126 LOG_DEBUG <<
"The Ftt Collection has " << fttCol->numberOfPoints() <<
" points" << endm;
131 LOG_DEBUG <<
"Forward Track Collection is not present" << endm;
135 LOG_DEBUG <<
"Checking FcsCollection" << endm;
141 size_t fwdMultEcalMatch = 0;
142 size_t fwdMultHcalMatch = 0;
143 size_t fwdMultFST = 0;
145 LOG_INFO <<
"FwdTrackCollection has: " << ftc->tracks().size() <<
" tracks" << endm;
147 getHist(
"fwdMultAll" )->Fill( ftc->tracks().size() );
150 size_t fwdMultEcalClusters = 0;
151 size_t fwdMultHcalClusters = 0;
152 for (
int iDet = 0; iDet < 4; iDet++ ){
153 for(
size_t i = 0; i < fcs->clusters(iDet).size(); i++){
157 fwdMultEcalClusters++;
158 getHist(
"ecalEnergy" )->Fill( clu->energy() );
159 }
else if ( iDet < 4 ){
160 fwdMultHcalClusters++;
161 getHist(
"hcalEnergy" )->Fill( clu->energy() );
166 getHist(
"fwdMultEcalClusters" )->Fill( fwdMultEcalClusters );
167 getHist(
"fwdMultHcalClusters" )->Fill( fwdMultHcalClusters );
172 for (
auto fwdTrack : ftc->tracks() ){
173 if ( !fwdTrack->didFitConvergeFully() ) {
178 LOG_DEBUG << TString::Format(
"StFwdTrack[ nProjections=%lu, nFTTSeeds=%lu, nFSTSeeds=%lu, mPt=%f ]", fwdTrack->mProjections.size(), fwdTrack->mFTTPoints.size(), fwdTrack->mFSTPoints.size(), fwdTrack->momentum().perp()) << endm;
179 LOG_DEBUG <<
"track fit momentum " << TString::Format(
"(pt=%f, eta=%f, phi=%f)", fwdTrack->momentum().perp(), fwdTrack->momentum().pseudoRapidity(), fwdTrack->momentum().phi() ) << endm;
180 LOG_DEBUG <<
"StFwdTrack has " << fwdTrack->ecalClusters().size() <<
" ecal matches" << endm;
181 LOG_DEBUG <<
"StFwdTrack has " << fwdTrack->hcalClusters().size() <<
" hcal matches" << endm;
183 getHist(
"ecalMatchPerTrack")->Fill( fwdTrack->ecalClusters().size() );
184 getHist(
"hcalMatchPerTrack")->Fill( fwdTrack->hcalClusters().size() );
186 getHist(
"nHitsFit" )->Fill( fwdTrack->numberOfFitPoints() );
188 if (fwdTrack->mFSTPoints.size() > 0){
192 getHist(
"eta")->Fill( fwdTrack->momentum().pseudoRapidity() );
193 getHist(
"phi")->Fill( fwdTrack->momentum().phi() );
194 getHist(
"pt")->Fill( fwdTrack->momentum().perp() );
196 getHist(
"charge")->Fill( fwdTrack->charge() );
199 int detId = kFcsWcalId;
205 LOG_DEBUG <<
"EcalProj z= " << ecalProj.mXYZ.z() << endm;
206 LOG_DEBUG <<
"HcalProj z= " << hcalProj.mXYZ.z() << endm;
207 LOG_DEBUG <<
"EcalProj Mom" << TString::Format(
"(pt=%f, eta=%f, phi=%f)", ecalProj.mMom.perp(), ecalProj.mMom.pseudoRapidity(), ecalProj.mMom.phi() ) << endm;
209 for (
size_t iEcal = 0; iEcal < fwdTrack->ecalClusters().size(); iEcal++ ){
211 LOG_DEBUG <<
"Ecal clu detId = " << clu->detectorId() << endm;
212 getHist(
"matchedEcalEnergy")->Fill( clu->energy() );
215 float dx = ecalProj.mXYZ.x() - xyz.x();
216 float dy = ecalProj.mXYZ.y() - xyz.y();
217 float dr = sqrt(dx*dx + dy*dy);
218 getHist(
"matchedEcaldX")->Fill( dx );
219 getHist(
"matchedEcaldY")->Fill( dy );
220 getHist(
"matchedEcaldR")->Fill( dr );
223 if (ecalProj.mXYZ.z() > 500){
226 for (
int iDet = 0; iDet < 2; iDet++ ){
227 for(
size_t i = 0; i < fcs->clusters(iDet).size(); i++){
231 getHist(
"ecalXY")->Fill( xyz.x(), xyz.y() );
233 float dx = ecalProj.mXYZ.x() - xyz.x();
234 float dy = ecalProj.mXYZ.y() - xyz.y();
235 float dr = sqrt(dx*dx + dy*dy);
238 getHist(
"ecaldX" )->Fill( dx );
240 getHist(
"ecaldY" )->Fill( dy );
241 getHist(
"ecaldR" )->Fill( dr );
247 getHist(
"trkEcalX" ) -> Fill( ecalProj.mXYZ.x(), xyz.x() );
248 getHist(
"trkEcalY" ) -> Fill( ecalProj.mXYZ.y(), xyz.y() );
252 getHist(
"ecalMindR" )->Fill( mindR );
255 getHist(
"trkEcalMinX" ) -> Fill( ecalProj.mXYZ.x(), xyz.x() );
256 getHist(
"trkEcalMinY" ) -> Fill( ecalProj.mXYZ.y(), xyz.y() );
260 if (hcalProj.mXYZ.z() > 500){
264 for (
int iDet = 2; iDet < 4; iDet++ ){
265 for(
size_t i = 0; i < fcs->clusters(iDet).size(); i++){
269 getHist(
"hcalXY")->Fill( xyz.x(), xyz.y() );
271 float dx = hcalProj.mXYZ.x() - xyz.x();
272 float dy = hcalProj.mXYZ.y() - xyz.y();
273 float dr = sqrt(dx*dx + dy*dy);
275 if ( fabs(dy) < 25 ){
276 getHist(
"hcaldX" )->Fill( dx );
277 getHist(
"hcaldXdNFit" )->Fill( dx, fwdTrack->numberOfFitPoints() );
280 if ( fabs(dx) < 25 ){
281 getHist(
"hcaldY" )->Fill( dy );
282 getHist(
"hcaldYdNFit" )->Fill( dy, fwdTrack->numberOfFitPoints() );
284 getHist(
"hcaldR" )->Fill( dr );
291 getHist(
"trkHcalX" ) -> Fill( hcalProj.mXYZ.x(), xyz.x() );
292 getHist(
"trkHcalY" ) -> Fill( hcalProj.mXYZ.y(), xyz.y() );
295 getHist(
"hcalMindR" )->Fill( mindR );
298 getHist(
"trkHcalMinX" ) -> Fill( hcalProj.mXYZ.x(), xyz.x() );
299 getHist(
"trkHcalMinY" ) -> Fill( hcalProj.mXYZ.y(), xyz.y() );
303 if (fwdTrack->ecalClusters().size() > 0)
305 if (fwdTrack->hcalClusters().size() > 0)
310 getHist(
"fwdMultGood" )->Fill( nGood );
311 getHist(
"fwdMultFailed" )->Fill( nFailed );
312 getHist(
"fwdMultFST")->Fill( fwdMultFST );
313 getHist(
"fwdMultHcalMatch")->Fill( fwdMultHcalMatch );
314 getHist(
"fwdMultEcalMatch")->Fill( fwdMultEcalMatch );
316 LOG_INFO <<
"Found " << nFailed <<
" failed track fits out of " << ftc->tracks().size() << endm;
320 void StFwdAnalysisMaker::ProcessFwdMuTracks( ){
322 LOG_DEBUG <<
"StFwdAnalysisMaker::ProcessFwdMuTracks" << endm;
325 LOG_WARN <<
" No MuDstMaker ... bye-bye" << endm;
330 LOG_WARN <<
" No MuDst ... bye-bye" << endm;
339 LOG_INFO <<
"Number of StMuFwdTracks: " << ftc->numberOfFwdTracks() << endl;
343 size_t fwdMultFST = 0;
344 size_t fwdMultEcalMatch = 0;
345 size_t fwdMultHcalMatch = 0;
347 for (
size_t iTrack = 0; iTrack < ftc->numberOfFwdTracks(); iTrack++ ){
351 LOG_DEBUG <<
"StMuFwdTrack has " << muFwdTrack->mEcalClusters.GetEntries() <<
" Ecal matched" << endm;
352 LOG_DEBUG <<
"StMuFwdTrack has " << muFwdTrack->mHcalClusters.GetEntries() <<
" Hcal matched" << endm;
354 getHist(
"eta")->Fill( muFwdTrack->momentum().Eta() );
355 getHist(
"phi")->Fill( muFwdTrack->momentum().Phi() );
357 if (muFwdTrack->mFSTPoints.size() > 0){
361 if (muFwdTrack->mEcalClusters.GetEntries() > 0)
363 if (muFwdTrack->mHcalClusters.GetEntries() > 0)
368 int detId = kFcsWcalId;
373 bool foundEcalProj = muFwdTrack->getProjectionFor( detId, ecalProj, 0 );
376 for(
size_t i = 0; i < fcs->numberOfClusters(); i++){
379 if ( clu->detectorId() > 1 )
continue;
381 if ( clu->energy() < 1 )
continue;
384 float dx = ecalProj.mXYZ.X() - xyz.x();
385 float dy = ecalProj.mXYZ.Y() - xyz.y();
386 float dr = sqrt(dx*dx + dy*dy);
388 getHist(
"ecaldX" )->Fill( dx );
389 getHist(
"ecaldY" )->Fill( dy );
390 getHist(
"ecaldR" )->Fill( dr );
392 getHist(
"trkEcalX" ) -> Fill( ecalProj.mXYZ.X(), xyz.x() );
398 for (
int i = 0; i < muFwdTrack->mEcalClusters.GetEntries(); i++ ){
401 getHist(
"ecalEnergy")->Fill( c->energy() );
403 LOG_DEBUG <<
"eCal Cluster detId = " << c->detectorId() << endm;
405 getHist(
"ecalXY")->Fill( xyz.x(), xyz.y() );
408 getHist(
"matchedEcaldX")->Fill( ecalProj.mXYZ.X() - xyz.x() );
412 getHist(
"ecalMatchPerTrack")->Fill( muFwdTrack->mEcalClusters.GetEntries() );
413 getHist(
"hcalMatchPerTrack")->Fill( muFwdTrack->mHcalClusters.GetEntries() );
415 for (
int i = 0; i < muFwdTrack->mHcalClusters.GetEntries(); i++ ){
418 getHist(
"hcalEnergy")->Fill( c->energy() );
420 getHist(
"hcalXY")->Fill( c->x(), c->y() );
424 getHist(
"fwdMult")->Fill( ftc->numberOfFwdTracks() );
425 getHist(
"fwdMultFST")->Fill( fwdMultFST );
426 getHist(
"fwdMultHcalMatch")->Fill( fwdMultHcalMatch );
427 getHist(
"fwdMultEcalMatch")->Fill( fwdMultEcalMatch );
static StMuFcsCollection * muFcsCollection()
returns pointer to current StMuFcsCollection
std::map< TString, TH1 * > mHists
Map of <name (TString), histogram>
StThreeVectorD getStarXYZfromColumnRow(int det, float col, float row, float FcsZ=-1.0) const
get the STAR frame cooridnates from other way
static StMuFwdTrackCollection * muFwdTrackCollection()
returns pointer to current StMuFwdTrackCollection
bool mAnalyzeMuDst
Control whether the analysis uses StEvent (default) or MuDst as input.
TH1 * getHist(TString n)
Get the Hist object from the map.