1 #include "StFwdTrackMaker/StFwdQAMaker.h"
2 #include "StFwdQAMaker.h"
3 #include "St_base/StMessMgr.h"
4 #include "StBFChain/StBFChain.h"
5 #include "StFwdTrackMaker/StFwdTrackMaker.h"
7 #include "StFwdTrackMaker/include/Tracker/FwdTracker.h"
8 #include "StFwdTrackMaker/include/Tracker/ObjExporter.h"
10 #include "StEvent/StBTofCollection.h"
11 #include "StEvent/StBTofHeader.h"
12 #include "StEvent/StEvent.h"
13 #include "StEvent/StFttCluster.h"
14 #include "StEvent/StFttCollection.h"
15 #include "StEvent/StFcsCluster.h"
16 #include "StEvent/StFcsCollection.h"
17 #include "StFcsDbMaker/StFcsDb.h"
18 #include "StRoot/StEpdUtil/StEpdGeom.h"
19 #include "StEvent/StFwdTrackCollection.h"
20 #include "StEvent/StFwdTrack.h"
23 #include "StMuDSTMaker/COMMON/StMuDstMaker.h"
24 #include "StMuDSTMaker/COMMON/StMuDst.h"
25 #include "StMuDSTMaker/COMMON/StMuEvent.h"
26 #include "StMuDSTMaker/COMMON/StMuFstCollection.h"
27 #include "StMuDSTMaker/COMMON/StMuFstHit.h"
28 #include "StMuDSTMaker/COMMON/StMuPrimaryVertex.h"
29 #include "StMuDSTMaker/COMMON/StMuFwdTrack.h"
30 #include "StMuDSTMaker/COMMON/StMuFwdTrackCollection.h"
31 #include "StMuDSTMaker/COMMON/StMuFcsCollection.h"
32 #include "StMuDSTMaker/COMMON/StMuFcsCluster.h"
33 #include "StMuDSTMaker/COMMON/StMuFcsHit.h"
34 #include "StMuDSTMaker/COMMON/StMuFttCluster.h"
35 #include "StMuDSTMaker/COMMON/StMuFttPoint.h"
36 #include "StMuDSTMaker/COMMON/StMuMcTrack.h"
37 #include "StMuDSTMaker/COMMON/StMuFstHit.h"
58 if (
nullptr == clu )
return;
60 float detOffset = 0.0;
61 if ( clu->detectorId() == kFcsEcalNorthDetId || clu->detectorId() == kFcsEcalSouthDetId ){
63 }
else if ( clu->detectorId() == kFcsHcalNorthDetId || clu->detectorId() == kFcsHcalSouthDetId ){
66 mXYZ.SetXYZ( xyz.x(), xyz.y(), xyz.z() + detOffset );
71 if (
nullptr == hit )
return;
73 float detOffset = 0.0;
74 if ( hit->detectorId() == kFcsEcalNorthDetId || hit->detectorId() == kFcsEcalSouthDetId ){
76 }
else if ( hit->detectorId() == kFcsHcalNorthDetId || hit->detectorId() == kFcsHcalSouthDetId ){
78 }
else if ( hit->detectorId() == kFcsPresNorthDetId || hit->detectorId() == kFcsPresSouthDetId ){
84 epdgeo.GetCorners(100*pp+tt,&n,x,y);
85 double x0 = (x[0] + x[1] + x[2] + x[3]) / 4.0;
86 double y0 = (y[0] + y[1] + y[2] + y[3]) / 4.0;
91 mXYZ.SetXYZ( xyz.x(), xyz.y(), xyz.z() + detOffset );
95 StFwdQAMaker::StFwdQAMaker() :
StMaker(
"fwdQAMaker"), mTreeFile(nullptr), mTree(nullptr) {
99 int StFwdQAMaker::Init() {
101 mTreeFile =
new TFile(
"fwdtree.root",
"RECREATE");
102 mTree =
new TTree(
"fwd",
"fwd tracking tree");
104 mTree->Branch(
"header", &mTreeData. header, 3200, 99 );
105 mTreeData.
mcTracks.createBranch(mTree,
"mcTracks");
106 mTree->Branch(
"nSeedTracks", &mTreeData.nSeedTracks,
"nSeedTracks/I");
107 mTreeData.fstPoints.createBranch(mTree,
"fstHits");
108 mTreeData.fttPoints.createBranch(mTree,
"fttPoints");
109 mTreeData.fttClusters.createBranch(mTree,
"fttClusters");
110 mTreeData.fstPoints.createBranch(mTree,
"fstPoints");
111 mTreeData.wcal.createBranch(mTree,
"wcalClusters");
112 mTreeData.hcal.createBranch(mTree,
"hcalClusters");
114 mTreeData.wcalHits.createBranch(mTree,
"wcalHits");
115 mTreeData.hcalHits.createBranch(mTree,
"hcalHits");
116 mTreeData.epdHits.createBranch(mTree,
"epdHits");
118 mTreeData.reco.createBranch(mTree,
"reco");
119 mTreeData.seeds.createBranch(mTree,
"seeds");
124 if ( mTreeFile && mTree ){
128 LOG_DEBUG <<
"StFwdQA File written" << endm;
133 LOG_INFO <<
"FWD Report:" << endm;
134 StEvent *mStEvent =
static_cast<StEvent *
>(GetInputDS(
"StEvent"));
137 auto fwdTracks = mStEvent->fwdTrackCollection();
138 LOG_INFO <<
"Number of FwdTracks (StFwdTrackCollection): " << fwdTracks->tracks().size() << endm;
139 LOG_INFO <<
"Number of Ftt Points (StEvent)" << mStEvent->fttCollection()->points().size() << endm;
141 LOG_INFO <<
"SETUP START" << endm;
145 mMuDst = mMuDstMaker->
muDst();
148 if (mMuForwardTrackCollection){
149 LOG_DEBUG <<
"Number of StMuFwdTracks: " << mMuForwardTrackCollection->numberOfFwdTracks() << endm;
152 LOG_DEBUG <<
"No StMuDstMaker found: " << mMuDstMaker << endm;
154 mFcsDb =
static_cast<StFcsDb *
>(GetDataSet(
"fcsDb"));
157 if (!mFwdTrackMaker) {
158 LOG_WARN <<
"No StFwdTrackMaker found, skipping StFwdQAMaker" << endm;
162 mTreeData.
header.run = mMuDst->
event()->runNumber();
163 LOG_DEBUG <<
"SETUP COMPLETE" << endm;
166 if ( muFstCollection ){
167 LOG_DEBUG <<
"MuDst has #fst hits: " << muFstCollection->numberOfHits() << endm;
168 for (
size_t i = 0; i < muFstCollection->numberOfHits(); i++ ){
170 mTreeData.fstPoints.add( h );
181 void StFwdQAMaker::Clear(
const Option_t *opts) {
186 void StFwdQAMaker::FillFstPoints(){
189 LOG_WARN <<
"No StMuFstCollection ... bye-bye" << endm;
194 LOG_INFO <<
"Loading " << fst->numberOfHits() <<
" StMuFstHits" << endm;
196 for (
unsigned int index = 0; index < fst->numberOfHits(); index++){
198 mTreeData.fstPoints.add( muFstHit );
226 void StFwdQAMaker::FillTracks() {
227 mTreeData.nSeedTracks = 0;
228 if ( mMuForwardTrackCollection ){
229 LOG_DEBUG <<
"Adding " << mMuForwardTrackCollection->numberOfFwdTracks() <<
" FwdTracks (MuDst)" << endm;
230 for (
size_t iTrack = 0; iTrack < mMuForwardTrackCollection->numberOfFwdTracks(); iTrack++ ){
231 auto muTrack = mMuForwardTrackCollection->getFwdTrack(iTrack);
232 mTreeData.reco.add( muTrack );
234 for (
auto fsth : muTrack->mFSTPoints){
235 mTreeData.seeds.add( fsth );
236 mTreeData.nSeedTracks++;
238 for (
auto ftth : muTrack->mFTTPoints){
239 mTreeData.seeds.add( ftth );
240 mTreeData.nSeedTracks++;
242 if ( iTrack > 5000 ) {
243 LOG_WARN <<
"Truncating to 5000 tracks" << endm;
248 LOG_DEBUG <<
"TRACKS COMPLETE" << endm;
251 void StFwdQAMaker::FillFcsStMuDst( ) {
254 LOG_DEBUG <<
"No mMuDst found, skipping StFwdQAMaker::FillFcsStEvent" << endm;
259 LOG_DEBUG <<
"No muFcsCollection found, skipping StFwdQAMaker::FillFcsStEvent" << endm;
266 LOG_INFO <<
"MuDst has #fcs clusters: " << fcs->numberOfClusters() << endm;
267 for(
size_t i = 0; i < fcs->numberOfClusters(); i++){
270 if ( clu->detectorId() == kFcsEcalNorthDetId || clu->detectorId() == kFcsEcalSouthDetId ){
271 LOG_INFO <<
"Adding WCAL Cluster to FwdTree" << endm;
272 mTreeData.wcal.add( cluSTAR );
273 }
else if ( clu->detectorId() == kFcsHcalNorthDetId || clu->detectorId() == kFcsHcalSouthDetId ){
274 LOG_INFO <<
"Adding HCAL Cluster to FwdTree" << endm;
275 mTreeData.hcal.add( cluSTAR );
282 LOG_INFO <<
"MuDst has #fcs hits: " << fcs->numberOfHits() << endm;
283 for(
size_t i = 0; i < fcs->numberOfHits(); i++){
286 if ( hit->detectorId() == kFcsEcalNorthDetId || hit->detectorId() == kFcsEcalSouthDetId ){
287 LOG_DEBUG <<
"Adding WCAL Cluster to FwdTree" << endm;
288 mTreeData.wcalHits.add( hitSTAR );
289 }
else if ( hit->detectorId() == kFcsHcalNorthDetId || hit->detectorId() == kFcsHcalSouthDetId ){
290 LOG_DEBUG <<
"Adding HCAL Cluster to FwdTree" << endm;
291 mTreeData.hcalHits.add( hitSTAR );
292 }
else if ( hit->detectorId() == kFcsPresNorthDetId || hit->detectorId() == kFcsPresSouthDetId ){
293 LOG_DEBUG <<
"Adding PRES hit to FwdTree" << endm;
294 mTreeData.epdHits.add( hitSTAR );
302 void StFwdQAMaker::FillMcTracks(){
304 TClonesArray *mcTracks = mMuDst->mcArray(1);
305 LOG_INFO <<
"MuDst has #mc tracks: " << mcTracks->GetEntriesFast() << endm;
307 for (Int_t iVtx=0; iVtx<mcTracks->GetEntriesFast(); iVtx++) {
310 if ( !mcTrack )
continue;
318 void StFwdQAMaker::FillFttClusters(){
321 if ( muFttCollection ){
322 LOG_DEBUG <<
"MuDst has #ftt clusters: " << muFttCollection->numberOfClusters() << endm;
323 for (
size_t i = 0; i < muFttCollection->numberOfClusters(); i++ ){
325 mTreeData.fttClusters.add( c );
328 for (
size_t i = 0; i < muFttCollection->numberOfPoints(); i++ ){
330 mTreeData.fttPoints.add( c );
static StMuFcsCollection * muFcsCollection()
returns pointer to current StMuFcsCollection
static StMuFttCollection * muFttCollection()
returns pointer to current StMuFttCollection
FwdTreeHeader header
Primary event vertex.
TClonesArrayWriter< StMuMcTrack > mcTracks
MC tracks.
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
StThreeVectorD getStarXYZ(int det, float FcsX, float FcsY, float FcsZ=-1.0, float zVertex=0.0) const
get the STAR frame cooridnates from local XYZ [cm]
void getEPDfromId(int det, int id, int &pp, int &tt)
Get FCS's EPD map foom EPD mapping.
static StMuFstCollection * muFstCollection()
returns pointer to current StMuFstCollection
Store Cluster with STAR XYZ position.
static StMuEvent * event()
returns pointer to current StMuEvent (class holding the event wise information, e.g. event number, run number)
Store Hit with STAR XYZ position.