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

Public Member Functions | |
| AlgEventSR () | |
| virtual | ~AlgEventSR () |
| virtual void | RunAlg (AlgConfig &ac, CandHandle &ch, CandContext &cx) |
| virtual void | Trace (const char *c) const |
|
|
Definition at line 48 of file AlgEventSR.cxx. 00049 {
00050 }
|
|
|
Definition at line 53 of file AlgEventSR.cxx. 00054 {
00055 }
|
|
||||||||||||||||
|
Implements AlgBase. Definition at line 58 of file AlgEventSR.cxx. References CandHandle::AddDaughterLink(), CandEventHandle::AddShower(), CandEventHandle::AddTrack(), AlgReco::Calibrate(), PlaneOutline::DistanceToEdge(), VertexFinder::FindVertex(), CandContext::GetDataIn(), CandHandle::GetDaughterIterator(), VldContext::GetDetector(), Registry::GetDouble(), CandRecoHandle::GetEndT(), CandRecoHandle::GetEndU(), CandRecoHandle::GetEndV(), CandRecoHandle::GetEndZ(), CandShowerHandle::GetEnergy(), MomNavigator::GetFragment(), Registry::GetInt(), CandContext::GetMom(), CandTrackHandle::GetMomentum(), CandFitTrackHandle::GetMomentumCurve(), CandStripHandle::GetPlane(), CandEventHandle::GetPrimaryShower(), CandEventHandle::GetPrimaryTrack(), CandTrackHandle::GetScore(), CandRecoHandle::GetTermPlane(), CandStripHandle::GetTPos(), CandTrackHandle::GetU(), CandTrackHandle::GetV(), RecMinos::GetVldContext(), CandRecoHandle::GetVtxPlane(), CandRecoHandle::GetVtxT(), CandRecoHandle::GetVtxU(), CandRecoHandle::GetVtxV(), CandRecoHandle::GetVtxZ(), UgliGeomHandle::GetZExtent(), CandStripHandle::GetZPos(), CandEventHandle::IsContained(), PlaneOutline::IsInside(), MSG, CandEventHandle::SetContained(), CandRecoHandle::SetEndPlane(), CandRecoHandle::SetEndT(), CandRecoHandle::SetEndU(), CandRecoHandle::SetEndV(), CandRecoHandle::SetEndZ(), CandEventHandle::SetEnergy(), CandEventHandle::SetPrimaryShower(), CandEventHandle::SetPrimaryTrack(), CandRecoHandle::SetVtxPlane(), CandRecoHandle::SetVtxT(), CandRecoHandle::SetVtxU(), CandRecoHandle::SetVtxV(), CandRecoHandle::SetVtxZ(), v, VertexFinder::VtxPlane(), VertexFinder::VtxU(), VertexFinder::VtxV(), and VertexFinder::VtxZ(). 00059 {
00060
00061
00062 // get alg parameters
00063 Double_t shwshwdz = ac.GetDouble("ShwShwDz");
00064 Double_t minShwEFract = ac.GetDouble("MinShwEFract");
00065 Double_t containDisttoEdge = ac.GetDouble("ContainDisttoEdge");
00066 Double_t isCosmic = ac.GetInt("IsCosmic");
00067
00068 // check that all is well with inputs
00069
00070 const CandRecord* candrec = dynamic_cast<CandRecord*>
00071 (cx.GetMom()->GetFragment("CandRecord", "PrimaryCandidateRecord"));
00072 if (candrec==0) {
00073 MSG("EventSR", Msg::kWarning)
00074 << "No PrimaryCandidateRecord in MOM." << endl;
00075 }
00076 assert(candrec);
00077 const VldContext *vldcptr = candrec->GetVldContext();
00078 assert(vldcptr);
00079 assert(ch.InheritsFrom("CandEventHandle"));
00080 CandEventHandle &ceh = dynamic_cast<CandEventHandle &>(ch);
00081 assert(cx.GetDataIn());
00082 assert(cx.GetDataIn()->InheritsFrom("TObjArray"));
00083 const TObjArray *tary =
00084 dynamic_cast<const TObjArray*>(cx.GetDataIn());
00085 assert(tary->GetLast()>=0);
00086
00087
00088 // loop over tracks, and find track with highest score. This we call the primary
00089 map<const CandTrackHandle*, Double_t> trackscore;
00090 CandTrackHandle *besttrack=0;
00091 for (Int_t itrk=0; itrk<=tary->GetLast(); itrk++) {
00092 TObject *tobj = tary->At(itrk);
00093 assert(tobj->InheritsFrom("CandRecoHandle"));
00094 if (tobj->InheritsFrom("CandTrackHandle")) {
00095 CandTrackHandle *trackhandle =
00096 dynamic_cast<CandTrackHandle*>(tobj);
00097 trackscore[trackhandle] = trackhandle->GetScore();
00098 if (!besttrack || trackscore[trackhandle]>trackscore[besttrack]) {
00099 besttrack = trackhandle;
00100 }
00101 }
00102 }
00103
00104 // find the shower closest to the track vertex, and the shower with highest energy
00105 CandShowerHandle *bestshower=0;
00106 CandShowerHandle *closestshower=0;
00107 CandShowerHandle *largestshower=0;
00108 Float_t largestenergy=-1;
00109 Float_t closestenergy=-1;
00110 Float_t dzlargest=0;
00111 Float_t dzclosest=1e6;
00112 for (Int_t itrk=0; itrk<=tary->GetLast(); itrk++) {
00113 TObject *tobj = tary->At(itrk);
00114 assert(tobj->InheritsFrom("CandRecoHandle"));
00115 if (tobj->InheritsFrom("CandShowerHandle")) {
00116 CandShowerHandle *showerhandle =
00117 dynamic_cast<CandShowerHandle*>(tobj);
00118 if (!largestshower || showerhandle->GetEnergy()>largestenergy) {
00119 largestenergy = showerhandle->GetEnergy();
00120 largestshower = showerhandle;
00121 if(besttrack)dzlargest=fabs(showerhandle->GetVtxZ()-besttrack->GetVtxZ());
00122 }
00123 if(besttrack){
00124 if(fabs(showerhandle->GetVtxZ()-besttrack->GetVtxZ())<dzclosest){
00125 dzclosest=fabs(showerhandle->GetVtxZ()-besttrack->GetVtxZ());
00126 closestshower=showerhandle;
00127 closestenergy=showerhandle->GetEnergy();
00128 }
00129 }
00130 }
00131 }
00132
00133 // if the largest shower is greater than shwshwdz from the track vertex,
00134 // and the closest shower has energy greater than minshwEfract
00135 // call the closest shower the primary
00136
00137 if(closestshower && (dzlargest-dzclosest)>shwshwdz && closestenergy/largestenergy>minShwEFract){
00138 bestshower=closestshower;
00139 }
00140 //largest shower is the primary if there is no track
00141 else{
00142 bestshower=largestshower;
00143 }
00144
00145 // construct daughter strip list, and track and shower lists
00146 for (Int_t i=0; i<=tary->GetLast(); i++) {
00147 TObject *tobj = tary->At(i);
00148 assert(tobj->InheritsFrom("CandRecoHandle"));
00149 CandRecoHandle *recohandle = dynamic_cast<CandRecoHandle*>(tobj);
00150 CandStripHandleItr stripItr(recohandle->GetDaughterIterator());
00151 while (CandStripHandle *strip = stripItr()) {
00152 ceh.AddDaughterLink(*strip);
00153 }
00154 if (tobj->InheritsFrom("CandShowerHandle")) {
00155 CandShowerHandle *showerhandle = dynamic_cast<CandShowerHandle*>(tobj);
00156 ceh.AddShower(showerhandle);
00157 }
00158 if (tobj->InheritsFrom("CandTrackHandle")) {
00159 CandTrackHandle *trackhandle = dynamic_cast<CandTrackHandle*>(tobj);
00160 ceh.AddTrack(trackhandle);
00161 }
00162 }
00163
00164 // set primary track and shower
00165 if (besttrack) {
00166 ceh.SetPrimaryTrack(besttrack);
00167 }
00168 if (bestshower) {
00169 ceh.SetPrimaryShower(bestshower);
00170 }
00171
00172 // Use Boehm vertex finder - this is the default vertex for non-cosmic events
00173 VertexFinder Vfinder(&ceh,vldcptr);
00174 Int_t result = Vfinder.FindVertex();
00175
00176 // if vertex finder above failed, use track vertex if it exists, and as last resort shower vertex
00177 if (besttrack) {
00178 ceh.SetVtxU(besttrack->GetVtxU());
00179 ceh.SetVtxV(besttrack->GetVtxV());
00180 ceh.SetVtxZ(besttrack->GetVtxZ());
00181 ceh.SetVtxT(besttrack->GetVtxT());
00182 ceh.SetVtxPlane(besttrack->GetVtxPlane());
00183 ceh.SetEndU(besttrack->GetEndU());
00184 ceh.SetEndV(besttrack->GetEndV());
00185 ceh.SetEndZ(besttrack->GetEndZ());
00186 ceh.SetEndT(besttrack->GetEndT());
00187 ceh.SetEndPlane(besttrack->GetTermPlane());
00188 }
00189 else if (bestshower) {
00190 ceh.SetVtxU(bestshower->GetVtxU());
00191 ceh.SetVtxV(bestshower->GetVtxV());
00192 ceh.SetVtxZ(bestshower->GetVtxZ());
00193 ceh.SetVtxT(bestshower->GetVtxT());
00194 ceh.SetVtxPlane(bestshower->GetVtxPlane());
00195 ceh.SetEndU(bestshower->GetEndU());
00196 ceh.SetEndV(bestshower->GetEndV());
00197 ceh.SetEndZ(bestshower->GetEndZ());
00198 ceh.SetEndT(bestshower->GetEndT());
00199 ceh.SetEndPlane(bestshower->GetTermPlane());
00200 }
00201 if(result==1 && !isCosmic){
00202 ceh.SetVtxU(Vfinder.VtxU());
00203 ceh.SetVtxV(Vfinder.VtxV());
00204 ceh.SetVtxZ(Vfinder.VtxZ());
00205 ceh.SetVtxPlane(Vfinder.VtxPlane());
00206 }
00207 Calibrate(&ceh);
00208
00209 // determine whether event is contained.
00210 Bool_t contained =true;
00211 UgliGeomHandle ugh(*vldcptr);
00212 PlaneOutline pl;
00213 float detzmin=0;
00214 float detzmax=999;
00215 ugh.GetZExtent(detzmin,detzmax,-1);
00216 float u,v;
00217 float xedge,yedge,dist;
00218
00219 for (Int_t i=0; i<=tary->GetLast(); i++) {
00220 if(contained){
00221 TObject *tobj = tary->At(i);
00222 assert(tobj->InheritsFrom("CandRecoHandle"));
00223 if (tobj->InheritsFrom("CandTrackHandle")) {
00224 CandTrackHandle *trackhandle =
00225 dynamic_cast<CandTrackHandle*>(tobj);
00226 CandStripHandleItr sItr(trackhandle->GetDaughterIterator());
00227 while(CandStripHandle * strip = sItr()){
00228 float z = strip->GetZPos();
00229 if(z<detzmin+containDisttoEdge ||
00230 z>detzmax-containDisttoEdge*4) contained=false;
00231 PlexPlaneId plnid(vldcptr->GetDetector(),strip->GetPlane(),false);
00232 if(plnid.GetPlaneView()==PlaneView::kV){
00233 v=strip->GetTPos();
00234 u=trackhandle->GetU(strip->GetPlane());
00235 }
00236 else if(plnid.GetPlaneView()==PlaneView::kU){
00237 u=strip->GetTPos();
00238 v=trackhandle->GetV(strip->GetPlane());
00239 }
00240 float x = 0.707*(u-v);
00241 float y = 0.707*(u+v);
00242
00243 pl.DistanceToEdge(x, y,
00244 plnid.GetPlaneView(),
00245 plnid.GetPlaneCoverage(),
00246 dist, xedge, yedge);
00247 Bool_t isInside = pl.IsInside( x, y,
00248 plnid.GetPlaneView(),
00249 plnid.GetPlaneCoverage());
00250
00251 isInside &= dist>containDisttoEdge;
00252 if(!isInside) {
00253 contained=false;
00254 break;
00255 }
00256 }
00257 }
00258 }
00259 }
00260 ceh.SetContained(contained);
00261
00262 // set energy
00263 Float_t energy=0;
00264 CandFitTrackHandle * fittrack=0;
00265 if(ceh.GetPrimaryTrack()){
00266 if(ceh.GetPrimaryTrack()->InheritsFrom("CandFitTrackHandle"))
00267 fittrack= dynamic_cast<CandFitTrackHandle *>(ceh.GetPrimaryTrack());
00268 if(ceh.IsContained() || fittrack==0){
00269 energy+=ceh.GetPrimaryTrack()->GetMomentum();
00270 }
00271 else if (fittrack){
00272 energy+=fittrack->GetMomentumCurve();
00273 }
00274 }
00275 if(ceh.GetPrimaryShower())
00276 energy+=ceh.GetPrimaryShower()->GetEnergy();
00277
00278 ceh.SetEnergy(energy);
00279 }
|
|
|
Reimplemented from AlgBase. Definition at line 284 of file AlgEventSR.cxx. 00285 {
00286 }
|
1.3.9.1