30 #include "StHitFilterMaker.h"
31 #include "StMessMgr.h"
34 #include "StEventTypes.h"
36 #ifndef ST_NO_NAMESPACES
37 using std::binary_search;
48 StHitFilterMaker::
StHitFilterMaker(const
char *name, Double_t ptl, Double_t pth, Double_t eta, Double_t zvert, Double_t WestEta):
StMaker(name),mPtLowerCut(ptl),mPtUpperCut(pth), mAbsEtaCut(eta), mAbsZVertCut(zvert), mKeepWestHighEtaHits(WestEta){
61 gMessMgr->Info() <<
"StHitFilterMaker::Init(): keeping tracks between " <<
62 mPtLowerCut <<
" and " << mPtUpperCut <<
"GeV/c (negative = no cut)" << endm;
63 gMessMgr->Info() <<
"StHitFilterMaker::Init(): keeping tracks with |eta| < " <<
65 gMessMgr->Info() <<
"StHitFilterMaker::Init(): keeping tracks with |ZVert| < " <<
67 return StMaker::Init();
81 event = (
StEvent *) GetInputDS(
"StEvent");
85 gMessMgr->Info() <<
"StHitFilterMaker::Make(): not a valid StEvent: " << endm;
91 vector<StTrackNode*> keptTrackNodes;
93 StSPtrVecTrackNode& nodes =
event->trackNodes();
94 for (StSPtrVecTrackNodeIterator nodeIter = nodes.begin();
95 nodeIter != nodes.end(); ++nodeIter) {
96 bool isAcceptedTrack =
false;
99 ientry < (*nodeIter)->entries(); ++ientry) {
104 if (!(track->topologyMap().hasHitInDetector(kTpcId))) {
109 isAcceptedTrack =
true;
113 if (isAcceptedTrack) {
114 keptTrackNodes.push_back(*nodeIter);
118 sort(keptTrackNodes.begin(),keptTrackNodes.end());
119 vector<StTrackNode*>::iterator uniquePos =
120 unique(keptTrackNodes.begin(),keptTrackNodes.end());
121 keptTrackNodes.erase(uniquePos,keptTrackNodes.end());
124 gMessMgr->Info() <<
"StHitFilterMaker::Make(): keeping TPC hits on " <<
125 keptTrackNodes.size() <<
" track nodes " << endm;
126 if (! TESTBIT(
m_Mode, kTpcId))
128 if (! TESTBIT(
m_Mode, kSvtId)) {
135 bool StHitFilterMaker::accept(
StEvent *event) {
137 if( !(event->primaryVertex()))
return false;
138 if( fabs(event->primaryVertex()->position().z()) > mAbsZVertCut)
return false;
143 if (track->flag() <= 0)
return false;
144 StSPtrVecTrackPidTraits &traits = track->pidTraits();
145 unsigned int size = traits.size();
147 for (
unsigned int i = 0; i < size; i++) {
148 if (! traits[i])
continue;
149 if ( traits[i]->IsZombie())
continue;
151 if (p) {
return true;}
154 if (track->geometry()) {
155 if (mPtLowerCut > 0 && track->geometry()->momentum().perp() < mPtLowerCut )
157 if (mPtUpperCut > 0 && track->geometry()->momentum().perp() > mPtUpperCut )
159 if (mAbsEtaCut > 0 && fabs(track->geometry()->momentum().pseudoRapidity()) > mAbsEtaCut)
167 bool StHitFilterMaker::accept(
StHit *
hit) {
168 if( hit->flag() > 3)
return false;
179 vector<StTrackNode*>& keptTrackNodes)
182 Int_t removedHits1 = 0, removedHits2 = 0;
183 Int_t keep4fgt1=0, keep4fgt2=0;
185 if (event && event->tpcHitCollection()) {
188 for (
unsigned int n=0; n<theHits->numberOfSectors(); n++) {
189 for (
unsigned int m=0; m<theHits->sector(n)->numberOfPadrows(); m++) {
191 for (
unsigned int h=0; h<theHits->sector(n)->padrow(m)->hits().size(); h++) {
193 if (theHits->sector(n)->padrow(m)->hits()[h]->trackReferenceCount() == 0) {
194 if (! (theHits->sector(n)->padrow(m)->hits()[h]->isZombie())) {
195 if(mKeepWestHighEtaHits<=0.0 ||
196 checkHitTowardFgt(theHits->sector(n)->padrow(m)->hits()[h])==0 ){
197 theHits->sector(n)->padrow(m)->hits()[h]->makeZombie();
207 gMessMgr->Info() <<
"StHitFilterMaker::removeTpcHitsNotOnTracks. Total "<<totalHits<<
208 ", Removed " << removedHits1 <<
" TPC hits not on any tracks" << endm;
210 if(mKeepWestHighEtaHits>0.0) gMessMgr->Info() <<
" But keeping "<<keep4fgt1<<
" hits for fgt"<<endm;
213 StSPtrVecTrackNode& nodes =
event->trackNodes();
214 for (
unsigned int i = 0; i < nodes.size(); i++) {
216 if (!binary_search(keptTrackNodes.begin(),
217 keptTrackNodes.end(),
221 for (
unsigned int j = 0; j < node->entries(); j++) {
222 StTrack* track = node->track(j);
224 if (!(track->topologyMap().hasHitInDetector(kTpcId))) {
230 StPtrVecHit& hitList = info->hits();
231 for (
unsigned int k = 0; k < hitList.size(); k++)
232 if (hitList[k]->detector() == kTpcId &&
233 !(hitList[k]->isZombie()) ) {
234 if(mKeepWestHighEtaHits<=0.0 || checkHitTowardFgt(hitList[k])==0 ){
235 hitList[k]->makeZombie();
246 gMessMgr->Info() <<
"StHitFilterMaker::removeTpcHitsNotOnTracks. Removed " <<
247 removedHits2 <<
" TPC hits not on passed tracks" << endm;
248 if(mKeepWestHighEtaHits>0.0) gMessMgr->Info() <<
" But keeping "<<keep4fgt2<<
" hits for fgt"<<endm;
249 gMessMgr->Info() <<
"StHitFilterMaker::removeTpcHitsNotOnTracks. Saving " <<
250 (totalHits - removedHits1 - removedHits2) <<
" after filter" << endm;
263 vector<StTrackNode*>& keptTrackNodes)
265 Int_t removedHits = 0;
267 if (event && event->svtHitCollection()) {
270 for (
unsigned int l=0; l<theHits->numberOfBarrels(); l++) {
271 for (
unsigned int m=0; m<theHits->barrel(l)->numberOfLadders(); m++) {
272 for (
unsigned int n=0; n<theHits->barrel(l)->ladder(m)->numberOfWafers(); n++) {
273 for (
unsigned int h=0; h<theHits->barrel(l)->ladder(m)->wafer(n)->hits().size(); h++) {
275 if (theHits->barrel(l)->ladder(m)->wafer(n)->hits()[h]->trackReferenceCount() == 0) {
276 if (! (theHits->barrel(l)->ladder(m)->wafer(n)->hits()[h]->isZombie())) {
277 theHits->barrel(l)->ladder(m)->wafer(n)->hits()[h]->makeZombie();
286 gMessMgr->Info() <<
"StHitFilterMaker::removedSvtHitsNotOnTracks. Removed " <<
287 removedHits <<
" SVT hits not on any tracks" << endm;
291 StSPtrVecTrackNode& nodes =
event->trackNodes();
292 for (
unsigned int i = 0; i < nodes.size(); i++) {
294 if (!binary_search(keptTrackNodes.begin(),
295 keptTrackNodes.end(),
299 for (
unsigned int j = 0; j < node->entries(); j++) {
300 StTrack* track = node->track(j);
302 if (!(track->topologyMap().hasHitInDetector(kSvtId))) {
308 StPtrVecHit& hitList = info->hits();
309 for (
unsigned int k = 0; k < hitList.size(); k++)
310 if (hitList[k]->detector() == kSvtId &&
311 !(hitList[k]->isZombie()) ) {
312 hitList[k]->makeZombie();
320 gMessMgr->Info() <<
"StHitFilterMaker::removeSvtHitsNotOnTracks. Removed " <<
321 removedHits <<
" SVT hits not on passed tracks" << endm;
337 Int_t removedHits = 0;
339 if (event && event->svtHitCollection()) {
342 for (
unsigned int l=0; l<theHits->numberOfBarrels(); l++) {
343 for (
unsigned int m=0; m<theHits->barrel(l)->numberOfLadders(); m++) {
344 for (
unsigned int n=0; n<theHits->barrel(l)->ladder(m)->numberOfWafers(); n++) {
345 for (
unsigned int h=0; h<theHits->barrel(l)->ladder(m)->wafer(n)->hits().size(); h++) {
346 if (! (accept(theHits->barrel(l)->ladder(m)->wafer(n)->hits()[h])) ||
348 if (! (theHits->barrel(l)->ladder(m)->wafer(n)->hits()[h]->isZombie())) {
349 theHits->barrel(l)->ladder(m)->wafer(n)->hits()[h]->makeZombie();
358 gMessMgr->Info() <<
"StHitFilterMaker::removeBadSvtHits. Removed " <<
359 removedHits <<
" bad SVT hits" << endm;
367 Int_t StHitFilterMaker::checkHitTowardFgt(
StHit* hit){
368 if(hit->position().z() < 0)
return 0;
369 if(hit->position().pseudoRapidity()>mKeepWestHighEtaHits)
return 1;
virtual ~StHitFilterMaker()
Dummy destructor.
bool removeTpcHitsNotOnTracks(StEvent *, vector< StTrackNode * > &)
bool removeSvtHitsNotOnTracks(StEvent *, vector< StTrackNode * > &)
virtual Int_t Init()
Init - is a first method the top level StChain calls to initialize all its makers.
bool removeBadSvtHits(StEvent *)
Filters out TPC hits from StEvent on tracks that don't pass cuts. This is based on the StEventScaveng...