00001 #include <stdio.h> 00002 #include <stdlib.h> 00003 #include "StCustomFilter.h" 00004 00005 #include "StEvent.h" 00006 #include "StHit.h" 00007 #include "StTrack.h" 00008 #include "StVertex.h" 00009 #include "StTrackGeometry.h" 00010 #include "StTrackDetectorInfo.h" 00011 // For L3 filter 00012 #include "StarClassLibrary/BetheBloch.h" 00013 #include "StEvent/StDedxPidTraits.h" 00014 00015 00016 //______________________________________________________________________________ 00017 ClassImp(StCustomFilter) 00018 StCustomFilter::StCustomFilter(const char *name,bool active):StFilterABC(name,active) 00019 { 00020 // Assing a custom data-member 00021 mBB = new BetheBloch(); 00022 // Set the default values for the parameters. 00023 // Don't change this line !!! 00024 SetDefs(); 00025 00026 } 00027 //______________________________________________________________________________ 00028 StCustomFilter::~StCustomFilter() 00029 { // delete the custom data-member 00030 delete mBB; 00031 } 00032 //______________________________________________________________________________ 00033 const char **StCustomFilter::GetNams() const 00034 { 00035 // Create a "Label" list to be used with the dialog box 00036 static const char *nams[] = { 00037 " pCutHigh ", 00038 " nHitsCutHighP ", 00039 " pCutLow ", 00040 " nHitsCutLowP ", 00041 " chargeForLowP ", 00042 " dEdxMassCutHigh ", 00043 " dEdxFractionCutHigh ", 00044 " dEdxMassCutLow ", 00045 " dEdxFractionCutLow ", 00046 0 00047 }; 00048 return nams; 00049 } 00050 //______________________________________________________________________________ 00051 const float *StCustomFilter::GetDefs() const 00052 { 00053 // Create a list of the "default values" 00054 // The order of the default values must match the "label" list (see: StCustomFilter::GetNams) 00055 static const float defs[] = { 00056 /* pCutHigh */ 2.0, // high momentum cut for RICH/Upsilon candidates 00057 /* nHitsCutHighP */ 10, // nHits cut for all tracks 00058 /* pCutLow */ 0.2, // low momentum cut 00059 /* nHitsCutLowP */ 15, 00060 /* chargeForLowP */ -1, // charge for tracks with pCutLow < p < pCutHigh, set to 0 for all tracks 00061 /* dEdxMassCutHigh */ 0.939, // cut below BetheBloch(p/dEdxMassCutHigh), e.g. proton-band 00062 /* dEdxFractionCutHigh */ 0.6, // cut fraction of dEdx-band, i.e. dEdxFractionCut * BetheBloch(p/dEdxMassCut) 00063 /* dEdxMassCutLow */ 0.494, // cut above BetheBloch(p/dEdxMassCutLow), e.g. kaon-band 00064 /* dEdxFractionCutLow */ 1.1, 00065 //------------------------------------------------------------------------------------------- 00066 0 // the last valuse MUST be zero and it MUST be present 00067 //------------------------------------------------------------------------------------------- 00068 }; 00069 return defs; 00070 } 00071 00072 //______________________________________________________________________________ 00073 Int_t StCustomFilter::Accept(StPoints3DABC *pnt, Color_t&color, Size_t&size, Style_t&style) 00074 { 00075 // --- 00076 // "Accept" method is called by the StEventDisplayMaker event loop 00077 // once for each component of the StEvent. 00078 // 00079 // To see all possible combinations check: 00080 // StRoot/StEventUtilities/StEventHelper.cxx:StFilterDef::Accept() 00081 // method 00082 // 00083 // Input: pnt - the interface to the object 3D coordinate 00084 // color - the default color 00085 // size - the default size (it if the line width for trach and the dot diameter for the hits) 00086 // style - the default style (it is the line style or ROOT marker style) 00087 // 00088 // Output color - the custom color if any 00089 // size - the custom size if any 00090 // style - the custom style if any 00091 // 00092 // return : 0 the object is rejected and it will not be drawn 00093 // +n the object is accepted and will be passed to next filter if any 00094 // optionally you may change the object visual attribute 00095 // like color, style and size 00096 // If you have no intention to change the default values 00097 // you may simply ignore the parameters. 00098 // The attributes set by the filter do overwrite what other filter may have set 00099 // 00100 // If the object has passed the last filter in row it will be drawn. 00101 // --- 00102 TObject *to; 00103 StTrack *trk; 00104 to = pnt->GetObject(); 00105 if (!to) return 1; 00106 // We want to provide our own custom cut for the StTrack object only. 00107 if (!to->InheritsFrom(StTrack::Class())) return 1; 00108 00109 // The track component of StEvent was found let's apply our custom cut. 00110 trk = (StTrack*)to; 00111 return Accept(trk,color,size,style); 00112 } 00113 //______________________________________________________________________________ 00114 Int_t StCustomFilter::Accept(const StTrack* track,Color_t&color, Size_t&size, Style_t&style) 00115 { 00116 // 00117 // User provided the selection and cutom visual attribute fot the track 00118 // It is assumed this function needs the value assigned through interactive dialog 00119 // 00120 // If you don't want to change the default visual attribute you may simply ignore the input parameters 00121 // This concrete cut implementation was borrowed from StRoot/StMuDSTMaker/COMMON/StMStMuL3Filter 00122 //----- 00123 00124 00125 00126 //----- 00127 // Note: The statements below make a copy of the object data-mambers to the local variables 00128 //----- 00129 // There is no need to assign the local variable. 00130 // We do that to highlight the difference between the original "StMStMuL3Filter" 00131 //----- 00132 00133 float pCutHigh = fpCutHigh; // high momentum cut for RICH/Upsilon candidates 00134 int nHitsCutHighP = int(fnHitsCutHighP); // nHits cut for all tracks 00135 00136 // following cuts apply only for tracks with pCutLow < p <pHigh 00137 float pCutLow = fpCutLow; // low momentum cut 00138 int nHitsCutLowP = int(fnHitsCutLowP); 00139 int chargeForLowP = int(fchargeForLowP); // charge for tracks with pCutLow < p < fpCutHigh, set to 0 for all tracks 00140 float dEdxMassCutHigh = fdEdxMassCutHigh; // cut below BetheBloch(p/dEdxMassCutHigh), e.g. proton-band 00141 float dEdxFractionCutHigh = fdEdxFractionCutHigh;// cut fraction of dEdx-band, i.e. dEdxFractionCut * BetheBloch(p/dEdxMassCut) 00142 float dEdxMassCutLow = fdEdxMassCutLow; // cut above BetheBloch(p/dEdxMassCutLow), e.g. kaon-band 00143 float dEdxFractionCutLow = fdEdxFractionCutLow; 00144 // -- The copy of the all data-members have been made 00145 00146 int iret = 0; 00147 int chargeOK = 0; 00148 int dedxOK = 0; 00149 00150 float magnitude = track->geometry()->momentum().magnitude(); 00151 int nPoints = track->detectorInfo()->numberOfPoints(); 00152 00153 if ( magnitude > pCutHigh && nPoints >= nHitsCutHighP) iret = 1; 00154 else { 00155 if ( magnitude > pCutLow && nPoints >= nHitsCutLowP ) 00156 { 00157 // check charge 00158 if (chargeForLowP==0) 00159 chargeOK = 1; 00160 else if (track->geometry()->charge() == chargeForLowP) 00161 chargeOK = 1; 00162 00163 // check dEdx 00164 // if (mBB==0) mBB = new BetheBloch(); 00165 float dedxHigh = dEdxFractionCutHigh * mBB->Sirrf(magnitude/dEdxMassCutHigh); 00166 float dedxLow = dEdxFractionCutLow * mBB->Sirrf(magnitude/dEdxMassCutLow); 00167 float dedx = 0; 00168 00169 // get track dEdx 00170 const StSPtrVecTrackPidTraits& traits = track->pidTraits(); 00171 StDedxPidTraits* dedxPidTr; 00172 for (unsigned int itrait = 0; itrait < traits.size(); itrait++){ 00173 dedxPidTr = 0; 00174 if (traits[itrait]->detector() == kTpcId) { 00175 StTrackPidTraits* thisTrait = traits[itrait]; 00176 dedxPidTr = dynamic_cast<StDedxPidTraits*>(thisTrait); 00177 if (dedxPidTr && dedxPidTr->method() == kTruncatedMeanId) { 00178 // adjust L3 dE/dx by a factor of 2 to match offline 00179 dedx = 2 * dedxPidTr->mean(); 00180 } 00181 } 00182 } 00183 if (dedx > dedxHigh && dedx > dedxLow) 00184 dedxOK = 1; 00185 // final answer 00186 iret = chargeOK * dedxOK; 00187 } // if (pCutLow && nHitsCutLowP) 00188 } 00189 return iret; 00190 }
1.5.9