#include <AlgMuonRemoval.h>
Inheritance diagram for AlgMuonRemoval:

Public Member Functions | |
| AlgMuonRemoval () | |
| virtual | ~AlgMuonRemoval () |
| virtual void | RunAlg (AlgConfig &ac, CandHandle &ch, CandContext &cx) |
| virtual void | Trace (const char *c) const |
Private Member Functions | |
| void | Reset () |
| void | FillTrkInfo (const CandEventHandle *event, const CandTrackHandle *track) |
Private Attributes | |
| Int_t | cMaxTrackLikePlane |
| Float_t | fTrkQ [500] |
| Float_t | fPlnQ [500] |
| Float_t | fTrkMIPDcosz [500] |
| bool | fTrkMIPCalibOkay |
| Int_t | fNTrackLikePlanes |
| Int_t | fMaxTrackLikePlane |
|
|
Definition at line 38 of file AlgMuonRemoval.cxx. 00039 {
00040 Reset();
00041 cMaxTrackLikePlane = 6;
00042 }
|
|
|
Definition at line 45 of file AlgMuonRemoval.cxx. 00046 {
00047 }
|
|
||||||||||||
|
Definition at line 254 of file AlgMuonRemoval.cxx. References cMaxTrackLikePlane, fMaxTrackLikePlane, fPlnQ, fTrkMIPCalibOkay, fTrkMIPDcosz, fTrkQ, CandStripHandle::GetCharge(), CandHandle::GetDaughterIterator(), CandRecoHandle::GetEndDirCosZ(), CandRecoHandle::GetEndPlane(), GetMaxTrackLikePlane(), CandStripHandle::GetPlane(), CandRecoHandle::GetPlaneCharge(), CandRecoHandle::GetStripCharge(), CandTrackHandle::GetU(), CandTrackHandle::GetV(), CandRecoHandle::GetVtxDirCosZ(), CandRecoHandle::GetVtxPlane(), CandTrackHandle::GetZ(), CandTrackHandle::IsTPosValid(), and MSG. Referenced by RunAlg(). 00255 {
00256 //
00257 //fill info about track direction at each plane
00258 //
00259 const double nplanes = track->GetEndPlane() - track->GetVtxPlane() + 1;
00260 const int vtxplane = track->GetVtxPlane();
00261 const int endplane = track->GetEndPlane();
00262
00263 for(int ipln = vtxplane; ipln<=endplane; ++ipln){
00264 double dcosz = track->GetVtxDirCosZ() + ((ipln - vtxplane)/nplanes)*(track->GetEndDirCosZ() - track->GetVtxDirCosZ() );
00265 int ip1 =-1;
00266 int ip2 =-1;
00267 if(track->IsTPosValid(ipln-1) && track->IsTPosValid(ipln+1)){
00268 ip2 = ipln+1; ip1 = ipln-1;
00269 }else if(track->IsTPosValid(ipln) && track->IsTPosValid(ipln+1)){
00270 ip2 = ipln+1; ip1 = ipln;
00271 }else if(track->IsTPosValid(ipln) && track->IsTPosValid(ipln-1)){
00272 ip2 = ipln; ip1 = ipln-1;
00273 }
00274 if(ip1!=-1 && ip2!=-1){
00275 const double l = sqrt( (track->GetU(ip2) - track->GetU(ip1)) *
00276 (track->GetU(ip2) - track->GetU(ip1))
00277 + (track->GetV(ip2) - track->GetV(ip1)) *
00278 (track->GetV(ip2) - track->GetV(ip1))
00279 + (track->GetZ(ip2) - track->GetZ(ip1)) *
00280 (track->GetZ(ip2) - track->GetZ(ip1)) );
00281 if(l!=0) dcosz = fabs( track->GetZ(ip2) - track->GetZ(ip1) ) / l;
00282 else dcosz = 1;
00283 }
00284 fTrkMIPDcosz[ipln] = track->GetPlaneCharge(ipln, CalStripType::kMIP)*dcosz;
00285 if(track->GetPlaneCharge(ipln, CalStripType::kMIP)==0){
00286 fTrkMIPDcosz[ipln] =1.;
00287 }
00288 }
00289
00290 TIter trkstpIter(track->GetDaughterIterator());
00291 int ntrkcalibstps = 0;
00292 while(const CandStripHandle* strip = dynamic_cast<const CandStripHandle*>(trkstpIter())){
00293 fTrkQ[strip->GetPlane()]+=strip->GetCharge(CalDigitType::kPE);
00294 if(track->GetStripCharge(strip, CalStripType::kMIP)!=0) ntrkcalibstps++;
00295 }
00296 fTrkMIPCalibOkay = (ntrkcalibstps>4);
00297
00298 //
00299 //Find where the track like planes stop
00300 //
00301 fMaxTrackLikePlane = GetMaxTrackLikePlane(event,track,cMaxTrackLikePlane);
00302 MSG("RmMu", Msg::kDebug) << " Max track like plane " << fMaxTrackLikePlane<< endl;
00303
00304 /*
00305 const int minplane = (track->GetVtxPlane()<track->GetEndPlane())?track->GetVtxPlane():track->GetEndPlane();
00306 const int maxplane = (track->GetVtxPlane()>track->GetEndPlane())?track->GetVtxPlane():track->GetEndPlane();
00307 fNTrackLikePlanes = 0;
00308 fMaxTrackLikePlane = 0;
00309 for(int ipln = minplane; ipln<=maxplane && fNTrackLikePlanes<cMaxTrackLikePlane; ipln++){
00310 if(fTrkQ[ipln]>0){
00311 MSG("RmMu", Msg::kDebug) << "Track: " << fTrkQ[ipln] << " Plane: " << fPlnQ[ipln] << " Frac: " << fTrkQ[ipln]/fPlnQ[ipln] << endl;
00312 if(fTrkQ[ipln]/fPlnQ[ipln]>.8 && fTrkQ[ipln]>3.0){
00313 fNTrackLikePlanes++;
00314 fMaxTrackLikePlane = ipln;
00315 }
00316 }
00317 }
00318 if(fNTrackLikePlanes!=cMaxTrackLikePlane) fMaxTrackLikePlane = 9999;
00319 */
00320
00321 TIter stpIter(event->GetDaughterIterator());
00322 while(const CandStripHandle* strip =
00323 dynamic_cast<const CandStripHandle*>(stpIter())){
00324 const int plane = strip->GetPlane();
00325 if(plane>0 && plane<500) fPlnQ[plane]+=strip->GetCharge(CalDigitType::kPE);
00326 }
00327 }
|
|
|
Definition at line 49 of file AlgMuonRemoval.cxx. References fPlnQ, fTrkMIPCalibOkay, fTrkMIPDcosz, and fTrkQ. Referenced by RunAlg(). 00050 {
00051 for(int ipln=0; ipln<500; ++ipln){
00052 fTrkQ[ipln] = 0;
00053 fPlnQ[ipln] = 0;
00054 fTrkMIPDcosz[ipln] = 0;
00055
00056 }
00057 fTrkMIPCalibOkay = false;
00058
00059
00060
00061 }
|
|
||||||||||||||||
|
Implements AlgBase. Definition at line 63 of file AlgMuonRemoval.cxx. References CandHandle::AddDaughterLink(), cMaxTrackLikePlane, digit(), FillTrkInfo(), CandRecord::FindCandHandle(), CandHandle::FindDaughter(), fMaxTrackLikePlane, fPlnQ, fTrkMIPCalibOkay, fTrkMIPDcosz, fTrkQ, Registry::Get(), CandDigitListHandle::GetAbsTime(), AlgHandle::GetAlgConfig(), AlgFactory::GetAlgHandle(), CandContext::GetCandRecord(), CandStripHandle::GetCharge(), CandContext::GetDataIn(), CandHandle::GetDaughterIterator(), RecMinos::GetHeader(), AlgFactory::GetInstance(), CandDigitListHandle::GetIsSparse(), CandContext::GetMom(), CandStripHandle::GetPlane(), CandDigitHandle::GetRawDigitIndex(), GetRemovableTrack(), CandHeader::GetRun(), CandHeader::GetSnarl(), CandStripHandle::GetStrip(), Registry::LockKeys(), Registry::LockValues(), CandDigit::MakeCandidate(), MSG, Reset(), SelectEvent(), Registry::Set(), CandDigitListHandle::SetAbsTime(), CandDigitListHandle::SetIsSparse(), Registry::UnLockKeys(), and Registry::UnLockValues(). 00064 {
00065 //
00066 //set up the sub-algs
00067 //
00068 //const VldContext &vldc = *(cx.GetCandRecord()->GetVldContext());
00069 AlgFactory &algfactory = AlgFactory::GetInstance();
00070 const char *tmpcs = 0;
00071 Int_t tmpi = 6;
00072 const char *pass_algorithm = 0;
00073 const char *pass_algconfig = 0;
00074
00075 if (ac.Get("PassThruAlgorithm", tmpcs)) pass_algorithm = tmpcs;
00076 if (ac.Get("PassThruAlgConfig", tmpcs)) pass_algconfig = tmpcs;
00077 if (ac.Get("MaxTrackLikePlanes", tmpi)) cMaxTrackLikePlane = tmpi;
00078
00079 AlgHandle pass_alg = algfactory.GetAlgHandle(pass_algorithm, pass_algconfig);
00080 CandContext cxx(this, cx.GetMom());
00081 cxx.SetCandRecord(cx.GetCandRecord());
00082
00083 MSG("RmMu",Msg::kDebug) << " AlgMuonRemoval::RunAlg() " <<endl;
00084 // MSG("RmMu",Msg::kDebug) << " SubAlg : " <<pass_algorithm<<endl;
00085 // MSG("RmMu",Msg::kDebug) << " SubAlg Config : " <<pass_algconfig<<endl;
00086
00087 //
00088 //Do event setup
00089 //
00090 Reset();
00091
00092 TObjArray *input = (TObjArray *)(cx.GetDataIn());
00093 const CandRecord* record = dynamic_cast<const CandRecord*>(input->At(0));
00094 assert(record);
00095 const CandHeader* header = dynamic_cast<const CandHeader*>(record->GetHeader());
00096 if(header){
00097 MSG("RmMu",Msg::kDebug) << " Snarl: " << header->GetRun() << " / "<< header->GetSnarl() <<endl;
00098 }
00099
00100 const CandEventListHandle * eventlist = dynamic_cast<CandEventListHandle*>(record->FindCandHandle("CandEventListHandle"));
00101 const CandDigitListHandle* digitlist = dynamic_cast<const CandDigitListHandle*>(record->FindCandHandle("CandDigitListHandle"));
00102
00103 if(eventlist==NULL || digitlist==NULL){
00104 MSG("RmMu",Msg::kError) << " Bailing out of Event eventlist = " << eventlist<< " digitlist = " << digitlist <<endl;
00105 return; //bail out
00106 }
00107
00108
00109 //
00110 //A list of digits to chuck/modify
00111 //
00112 std::vector<int> digitidx;
00113 std::vector<float> digitweight;
00114 long ntrackdigits = 0;
00115
00116 TIter event_iter(eventlist->GetDaughterIterator());
00117 while( const CandEventHandle* event = dynamic_cast<const CandEventHandle*>(event_iter()) ){
00118 MSG("RmMu",Msg::kDebug) << " New event " <<endl;
00119 if(SelectEvent(event)){
00120 MSG("RmMu",Msg::kDebug) << " Event is selected for muon removal " <<endl;
00121 Reset();
00122 const CandTrackHandle* track = GetRemovableTrack(event);
00123 if(!track){
00124 MSG("RmMu",Msg::kError) << " NO removalable track! "<<endl;
00125 }
00126 //
00127 //Fill some local info
00128 //
00129 FillTrkInfo(event,track);
00130
00131 MSG("RmMu",Msg::kDebug) << " fTrkMIPCalibOkay: "<< fTrkMIPCalibOkay <<endl
00132 << " fMaxTrackLikePlane : " << fMaxTrackLikePlane <<endl;
00133
00134
00135
00136 TIter stpIter(event->GetDaughterIterator());
00137 while(const CandStripHandle* strip = dynamic_cast<const CandStripHandle*>(stpIter())){
00138 const int planeno = strip->GetPlane();
00139 const int stripno = strip->GetStrip();
00140 const bool isintrack =(track->FindDaughter(strip)!=NULL);
00141 const bool ismuon = ((fTrkMIPDcosz[planeno]>0.3 && fTrkMIPDcosz[planeno]<1.2) || (fTrkMIPDcosz[planeno]>=1.2 && (fTrkQ[planeno]/fPlnQ[planeno]) > 0.8));
00142 bool doscale = planeno< fMaxTrackLikePlane && isintrack && fTrkMIPCalibOkay && fTrkMIPDcosz[planeno]>=1.2;
00143
00144 const double scale = ((fTrkMIPDcosz[planeno]!=0)? (fTrkMIPDcosz[planeno] - 1.)/fTrkMIPDcosz[planeno] : 1.);
00145 int modifydigit = 0;
00146 if(!isintrack || stripno<0 || (isintrack && !ismuon && fTrkMIPCalibOkay)){ // we are going to keep this digit.
00147 if(doscale) modifydigit = 1;
00148 }else{
00149
00150 modifydigit = 2;
00151 }
00152
00153 if(planeno>=fMaxTrackLikePlane) modifydigit = 2;
00154
00155 if(modifydigit==0){
00156 MSG("RmMu",Msg::kVerbose) << " KEEP : " << planeno << "/"<< stripno
00157 << " Q: " << strip->GetCharge()
00158 << " TrkMIP: " << fTrkMIPDcosz[planeno]
00159 << " TrkQ: " << fTrkQ[planeno]
00160 << " PlnQ: " << fPlnQ[planeno]
00161 << " intrk: " << isintrack
00162 << " ismuon: " << ismuon
00163 << " doscale: " << doscale
00164 << " scale: " << scale <<endl;
00165 }else if(modifydigit==1){
00166 MSG("RmMu",Msg::kVerbose) << " SCALE : " << planeno << "/"<< stripno
00167 << " Q: " << strip->GetCharge()
00168 << " TrkMIP: " << fTrkMIPDcosz[planeno]
00169 << " TrkQ: " << fTrkQ[planeno]
00170 << " PlnQ: " << fPlnQ[planeno]
00171 << " intrk: " << isintrack
00172 << " ismuon: " << ismuon
00173 << " doscale: " << doscale
00174 << " scale: " << scale <<endl;
00175
00176 }else if(modifydigit==2){
00177 MSG("RmMu",Msg::kVerbose) << " REJECT : " << planeno << "/"<< stripno
00178 << " Q: " << strip->GetCharge()
00179 << " TrkMIP: " << fTrkMIPDcosz[planeno]
00180 << " TrkQ: " << fTrkQ[planeno]
00181 << " PlnQ: " << fPlnQ[planeno]
00182 << " intrk: " << isintrack
00183 << " ismuon: " << ismuon
00184 << " doscale: " << doscale
00185 << " scale: " << scale <<endl;
00186
00187 }
00188
00189 if(modifydigit || isintrack){ //
00190 TIter digitIter(strip->GetDaughterIterator());
00191 while( CandDigitHandle* digit = dynamic_cast<CandDigitHandle*>(digitIter()) ) {
00192 if(modifydigit){
00193 digitidx.push_back(digit->GetRawDigitIndex());
00194 if(modifydigit==1) digitweight.push_back(scale);
00195 else digitweight.push_back(-1.);
00196 }
00197 if(isintrack) ntrackdigits++;
00198 }
00199 }
00200 }
00201 }
00202 }
00203
00204 MSG("RmMu",Msg::kDebug) << " There are " << digitidx.size()<< " digits to be modified and " << ntrackdigits <<" track digits" <<endl;
00205
00206 //iterate over base digits and do modifications
00207 TIter digitIter(digitlist->GetDaughterIterator());
00208 const unsigned int nmoddigit = digitidx.size();
00209 while( CandDigitHandle* digit = dynamic_cast<CandDigitHandle*>(digitIter()) ) {
00210 const int thisidx = digit->GetRawDigitIndex();
00211 bool ditch = 0;
00212 bool scale = 0;
00213 float scale_factor = 0;
00214 for(unsigned int idig = 0; idig<nmoddigit; ++idig){
00215 if(digitidx[idig] == thisidx ){
00216 if(digitweight[idig]>0){
00217 scale = 1;
00218 scale_factor = digitweight[idig];
00219 }else{
00220 ditch = 1;
00221 }
00222 digitidx[idig] = -1;
00223 }
00224 }
00225 if(!ditch){
00226 AlgConfig& algconfig = pass_alg.GetAlgConfig();
00227 algconfig.UnLockKeys();
00228 algconfig.UnLockValues();
00229 if(scale){
00230 algconfig.Set("doscale", 1);
00231 algconfig.Set("scalefactor", scale_factor);
00232 }else{
00233 algconfig.Set("doscale", 0);
00234 algconfig.Set("scalefactor", 1.);
00235 }
00236 algconfig.LockKeys();
00237 algconfig.LockValues();
00238 TObjArray digitalg_input;
00239 digitalg_input.Add(digit);
00240 cxx.SetDataIn(&digitalg_input);
00241 CandDigitHandle cdh = CandDigit::MakeCandidate(pass_alg, cxx);
00242 ch.AddDaughterLink(cdh, kFALSE);
00243 }
00244 }
00245
00246 //
00247 //global list stuff
00248 //
00249 CandDigitListHandle &cdlh = dynamic_cast<CandDigitListHandle &>(ch);
00250 cdlh.SetAbsTime(digitlist->GetAbsTime());
00251 cdlh.SetIsSparse(digitlist->GetIsSparse());
00252 }
|
|
|
Reimplemented from AlgBase. Definition at line 329 of file AlgMuonRemoval.cxx. 00329 {
00330 }
|
|
|
Definition at line 21 of file AlgMuonRemoval.h. Referenced by FillTrkInfo(), and RunAlg(). |
|
|
Definition at line 29 of file AlgMuonRemoval.h. Referenced by FillTrkInfo(), and RunAlg(). |
|
|
Definition at line 28 of file AlgMuonRemoval.h. |
|
|
Definition at line 25 of file AlgMuonRemoval.h. Referenced by FillTrkInfo(), Reset(), and RunAlg(). |
|
|
Definition at line 27 of file AlgMuonRemoval.h. Referenced by FillTrkInfo(), Reset(), and RunAlg(). |
|
|
Definition at line 26 of file AlgMuonRemoval.h. Referenced by FillTrkInfo(), Reset(), and RunAlg(). |
|
|
Definition at line 24 of file AlgMuonRemoval.h. Referenced by FillTrkInfo(), Reset(), and RunAlg(). |
1.3.9.1