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

Public Member Functions | |
| AlgEventSRList () | |
| virtual | ~AlgEventSRList () |
| virtual void | RunAlg (AlgConfig &ac, CandHandle &ch, CandContext &cx) |
| void | BuildEventFromUnassoc (AlgConfig &ac, CandHandle &ch, CandContext &cx, CandSliceHandle *slice) |
| virtual void | Trace (const char *c) const |
| void | SetPrimaryShowers (CandHandle &ch, AlgConfig &ac) |
| void | ReConstructShowers (AlgConfig &ac, CandHandle &ch, CandContext &cx) |
| void | RemoveTracksinShowers (AlgConfig &ac, TObjArray *recolist) |
| void | FillRecoList (CandSliceHandle *, CandShowerHandleItr *, CandTrackHandleItr *, TObjArray &) |
| Bool_t | MatchOtherTracksInEvent (AlgConfig &ac, const VldContext *vldcptr, CandTrackHandle *, TObjArray *) |
| void | AddObjectToEvent (CandRecoHandle *reco, TObjArray *, TObjArray *, Bool_t) |
| void | MergeShowers (CandContext &cxx, TObjArray &eventlist, AlgConfig &ac, CandSliceHandle *slice, CandClusterListHandle *clusterlist, CandShowerListHandle *showerlist) |
| void | AddStripToEvent (CandEventHandle *ev, CandShowerHandle *shw, CandClusterListHandle *clslist, CandStripHandle *closeststrip) |
| void | CreatePrimaryShower (AlgConfig &ac, CandContext &cxx, CandEventHandle *closestevent, CandShowerListHandle *showerlist, CandClusterListHandle *clusterlist, CandStripHandle *closeststrip) |
| void | FindUnassociated (CandSliceHandleItr &sliceItr, CandEventHandleItr *, TObjArray &unassociated) |
| void | FindUnassociated (CandSliceHandleItr &sliceItr, CandShowerHandleItr *, CandTrackHandleItr *, TObjArray &unassociated) |
| void | ReFillDist2Map (AlgConfig &ac, CandStripHandle *closeststrip, CandEventHandle *closestevent, TObjArray &unassociated, std::vector< std::map< const CandEventHandle *, Double_t > > &dist2map) |
| void | FillDist2Map (AlgConfig &ac, TObjArray &unassociated, CandHandle &ch, std::vector< std::map< const CandEventHandle *, Double_t > > &dist2map) |
|
|
Definition at line 60 of file AlgEventSRList.cxx. 00061 {
00062 }
|
|
|
Definition at line 65 of file AlgEventSRList.cxx. 00066 {
00067 }
|
|
||||||||||||||||||||
|
Definition at line 1368 of file AlgEventSRList.cxx. References Registry::Clear(), and MSG. Referenced by RunAlg(). 01369 {
01370 if (!merge) {
01371 // if this is the first match we have found for this object,
01372 //add object to list
01373 // and point prevlist to this object list
01374 objectlist->Add(reco);
01375 MSG("EventSR",Msg::kVerbose) << " adding to list\n";
01376 }
01377 else {
01378 MSG("EventSR",Msg::kVerbose) << " combining lists\n";
01379 // this object matches more than one event - merge their member
01380 // objects to list prevlist, and add the new object
01381 for (Int_t ireco2=0; ireco2<=objectlist->GetLast();ireco2++)
01382 prevlist->Add(objectlist->At(ireco2));
01383 prevlist->Add(reco);
01384 objectlist->Clear();
01385 }
01386 }
|
|
||||||||||||||||||||
|
Add a strip to the event daughter list, the primary shower, and place the modified cluster on the cluster list Definition at line 482 of file AlgEventSRList.cxx. References CandShowerHandle::AddCluster(), CandHandle::AddDaughterLink(), CandClusterHandle::DupHandle(), CandClusterHandle::GetCandSlice(), CandShowerHandle::GetCluster(), CandHandle::GetDaughterIterator(), CandShowerHandle::GetLastCluster(), CandStripHandle::GetPlane(), CandStripHandle::GetPlaneView(), CandClusterHandle::GetPlaneView(), CandHandle::IsEquivalent(), MSG, CandShowerHandle::RemoveCluster(), CandHandle::RemoveDaughter(), and CandClusterHandle::SetCandSlice(). Referenced by RunAlg(). 00486 {
00487 closestevent->AddDaughterLink(*closeststrip);
00488 shower->AddDaughterLink(*closeststrip);
00489 Int_t foundcluster=0;
00490 for (Int_t icluster=0; icluster < shower->GetLastCluster()+1 &&
00491 foundcluster==0; icluster++) {
00492 CandClusterHandle *cl = const_cast<CandClusterHandle *>
00493 (shower->GetCluster(icluster));
00494 // add strip to cluster of the same view
00495 if (cl->GetPlaneView()==closeststrip->GetPlaneView()) {
00496 foundcluster=1;
00497 MSG("EventSR",Msg::kVerbose) << "adding strip to cluster "
00498 << closeststrip->GetPlane() << endl;
00499 TIter cchItr(clusterlist->GetDaughterIterator());
00500 while (CandClusterHandle *cch =
00501 dynamic_cast<CandClusterHandle*>(cchItr())) {
00502 if(cch->IsEquivalent(cl)) {
00503 shower->RemoveCluster(cl);
00504 CandClusterHandle * newcl = cch->DupHandle();
00505 newcl->SetCandSlice(cch->GetCandSlice());
00506 newcl->AddDaughterLink(*closeststrip);
00507 clusterlist->RemoveDaughter(cch);
00508 clusterlist->AddDaughterLink(*newcl);
00509 shower->AddCluster(newcl);
00510 delete newcl;
00511 break;
00512 }
00513 }
00514 }
00515 }
00516 }
|
|
||||||||||||||||||||
|
this method is called for slices in which no shower or track was previously found. We see whether there is a 3D cluster in this slice which could be an event Definition at line 789 of file AlgEventSRList.cxx. References abs(), CandHandle::AddDaughterLink(), CandShowerHandle::BelongsWithShower(), CandHandle::FindDaughter(), Registry::Get(), AlgFactory::GetAlgHandle(), CandStripHandle::GetBegTime(), CandHandle::GetCandRecord(), CandContext::GetCandRecord(), CandStripHandle::GetCharge(), CandContext::GetDataIn(), CandHandle::GetDaughterIterator(), VldContext::GetDetector(), Registry::GetDouble(), AlgFactory::GetInstance(), Registry::GetInt(), CandContext::GetMom(), CandStripHandle::GetPlane(), CandStripHandle::GetPlaneView(), CandStripHandle::GetTPos(), RecMinos::GetVldContext(), CandHandle::GetVldContext(), CandClusterHandle::IsShowerLike(), CandEvent::MakeCandidate(), CandShower::MakeCandidate(), CandCluster::MakeCandidate(), MSG, CandHandle::SetCandRecord(), CandEventHandle::SetCandSlice(), CandRecoHandle::SetCandSlice(), CandClusterHandle::SetCandSlice(), and CandEventHandle::SetPrimaryShower(). Referenced by RunAlg(). 00793 {
00794 assert(cx.GetDataIn());
00795 MSG("EventSR",Msg::kDebug) <<" Building Event - no showers or tracks "
00796 << endl;
00797 if (!(cx.GetDataIn()->InheritsFrom("TObjArray"))) {
00798 MSG("EventSR",Msg::kDebug)<<" dataIn inherits from TObjArray " << endl;
00799 return;
00800 }
00801
00802 const CandSliceListHandle *slicelist = 0;
00803 CandShowerListHandle *showerlist = 0;
00804 CandClusterListHandle *clusterlist = 0;
00805 const TObjArray *cxin = dynamic_cast<const TObjArray *>(cx.GetDataIn());
00806 for (Int_t i=0; i<=cxin->GetLast(); i++) {
00807 TObject *tobj = cxin->At(i);
00808 if (tobj->InheritsFrom("CandSliceListHandle")) {
00809 slicelist = dynamic_cast<CandSliceListHandle*>(tobj);
00810 }
00811 // Retrieve persistant modifiable CandShowerList
00812 if (tobj->InheritsFrom("CandShowerListHandle")) {
00813 showerlist = dynamic_cast<CandShowerListHandle*>(tobj);
00814 }
00815 if (tobj->InheritsFrom("CandClusterListHandle")) {
00816 clusterlist = dynamic_cast<CandClusterListHandle*>(tobj);
00817 }
00818 }
00819
00820 if (!showerlist || !slicelist) {
00821 MSG("EventSR",Msg::kDebug)<<" no showerlist " << endl;
00822 return;
00823 }
00824 Int_t detectorType = slicelist->GetVldContext()->GetDetector();
00825
00826 CandContext cxx(this,cx.GetMom());
00827 AlgFactory &af = AlgFactory::GetInstance();
00828
00829 const char *pEventAlgConfig = 0;
00830 ac.Get("EventAlgConfig",pEventAlgConfig);
00831 AlgHandle ah = af.GetAlgHandle("AlgEventSR",pEventAlgConfig);
00832
00833 Double_t pHitAssocDPlane = ac.GetInt("HitAssocDPlane");
00834 Double_t pHitAssocDTime0 = ac.GetDouble("HitAssocDTime0");
00835 Double_t pHitAssocDTime1 = ac.GetDouble("HitAssocDTime1");
00836 Double_t pHitAssocMaxDist2 = ac.GetDouble("HitAssocMaxDist2");
00837 Double_t pHitAssocZParm = ac.GetDouble("HitAssocZParm");
00838 Double_t pHitAssocPParm = ac.GetDouble("HitAssocPParm");
00839 Double_t pHitAssocTParm = ac.GetDouble("HitAssocTParm");
00840 Double_t pShwShwDtpos2 = ac.GetDouble("ShwShwDtpos2");
00841 Double_t pShwShwDz = ac.GetDouble("ShwShwDz");
00842 Double_t pShwShwDt = ac.GetDouble("ShwShwDt");
00843 Double_t pMinShwEFract = ac.GetDouble("MinShwEFract");
00844
00845 const CandRecord *candrec = cx.GetCandRecord();
00846 assert(candrec);
00847 const VldContext *vldcptr = candrec->GetVldContext();
00848 assert(vldcptr);
00849 VldContext vldc = *vldcptr;
00850 UgliGeomHandle ugh(vldc);
00851
00852 // Iterate over strips , finding sets which are 'in time', and within
00853 // a given distance of the nearest neighbor in the set, in both views.
00854 // Each of these sets is then used to construct a shower, which becomes
00855 // the primary shower of a new event. We continue until an iteration
00856 // in which no new event is created.
00857
00858 // fill array of unique unassociated strips
00859 TObjArray unassociated;
00860 TIter stripItr(slice->GetDaughterIterator());
00861 while (CandStripHandle *strip =
00862 dynamic_cast<CandStripHandle*>(stripItr())) {
00863 Bool_t found=false;
00864 for (Int_t i=0; i<=unassociated.GetLast() && !found; i++) {
00865 CandStripHandle *strip0 =
00866 dynamic_cast<CandStripHandle*>(unassociated.At(i));
00867 if (*strip == *strip0) {
00868 found = true;
00869 }
00870 }
00871 if (!found) {
00872 if(!(detectorType==Detector::kNear && strip->GetPlane()>120)){
00873 unassociated.Add(strip);
00874 }
00875 }
00876 }
00877
00878 // loop until no new matches are found in the loop over unassoc hits.
00879 Bool_t found=false;
00880 while (unassociated.GetLast()>0 && !found) {
00881 MSG("EventSR",Msg::kDebug)<< " # unassoc "
00882 << unassociated.GetLast()+1 << endl;
00883 Bool_t firstu=true;
00884 Bool_t firstv=true;
00885 TObjArray neweventu;
00886 TObjArray neweventv;
00887 Bool_t addedstrip = true;
00888 Float_t totcharge=0;
00889 while (addedstrip) {
00890 addedstrip=false;
00891 // loop over unassoc strips.
00892 for (Int_t i=0; i<=unassociated.GetLast(); i++) {
00893 CandStripHandle *strip =
00894 dynamic_cast<CandStripHandle*>(unassociated.At(i));
00895 switch (strip->GetPlaneView()) {
00896 case PlaneView::kU:
00897 // strip is in U plane
00898 // if this is the first strip, add to newevent strip list
00899 if (firstu) {
00900 // if we don't have v strips yet, just add this strip to u list
00901 // seed the event
00902 if (firstv) {
00903 neweventu.Add(strip);
00904 MSG("EventSR",Msg::kDebug)<< " add first " << endl;
00905 totcharge +=strip->GetCharge();
00906 addedstrip = true;
00907 firstu=false;
00908 }
00909 // if we already have one or more v strips check that they are
00910 // in time, and agree in Z position.
00911 else {
00912 Bool_t found2=false;
00913 for (Int_t j=0; j<=neweventv.GetLast() && !found2;
00914 j++) {
00915 CandStripHandle *estrip =
00916 dynamic_cast<CandStripHandle*>(neweventv.At(j));
00917 Double_t dtime =
00918 strip->GetBegTime()-estrip->GetBegTime();
00919 MSG("EventSR",Msg::kDebug) << " dtime " << dtime*1e9
00920 << " " <<pHitAssocDTime0*1e9
00921 << "/" << pHitAssocDTime1*1e9
00922 << " plane diff "
00923 << abs(strip->GetPlane() -
00924 estrip->GetPlane())
00925 << "/" << pHitAssocDPlane << endl;
00926 if (dtime>pHitAssocDTime0 &&
00927 dtime<pHitAssocDTime1 &&
00928 abs(strip->GetPlane()-estrip->GetPlane()) <=
00929 pHitAssocDPlane) {
00930 MSG("EventSR",Msg::kDebug)<< " add " << endl;
00931 // match is found, add this strip to array
00932 neweventu.Add(strip);
00933 totcharge +=strip->GetCharge();
00934 addedstrip = true;
00935 firstu=0;
00936 found2=true;
00937 } // if match found
00938 } // for loop over V strips in new event
00939 } // end not first V strip
00940 } // end first U strip
00941 else {
00942 // if we already have u strips, make sure that the one we
00943 // add is adjaccent, using distance criteria based
00944 // on plane, time, and transverse postion separation
00945 Bool_t found2=false;
00946 for (Int_t j=0; j<=neweventu.GetLast() && !found2; j++) {
00947 CandStripHandle *estrip =
00948 dynamic_cast<CandStripHandle*>(neweventu.At(j));
00949 Double_t dtime =
00950 strip->GetBegTime()-estrip->GetBegTime();
00951 MSG("EventSR",Msg::kDebug) << " dtime " << dtime*1e9
00952 << " " <<pHitAssocDTime0*1e9
00953 << "/" << pHitAssocDTime1*1e9
00954 << " plane diff "
00955 << abs(strip->GetPlane() -
00956 estrip->GetPlane())
00957 << " dtpos " << (strip->GetTPos() -
00958 estrip->GetTPos())
00959 << endl;
00960 if (dtime>pHitAssocDTime0 &&
00961 dtime<pHitAssocDTime1) {
00962 Double_t dplane =
00963 (Double_t)(strip->GetPlane()-estrip->GetPlane());
00964 Double_t dtpos = strip->GetTPos()-estrip->GetTPos();
00965 Double_t dist2 = (pHitAssocZParm*dplane*dplane) +
00966 (pHitAssocPParm*dtpos*dtpos) +
00967 (pHitAssocTParm*dtime*dtime);
00968 // if dist2 2 parameter meets match criteria, add strip to array
00969 if (dist2<pHitAssocMaxDist2*4) {
00970 MSG("EventSR",Msg::kDebug)<< " add " << endl;
00971 neweventu.Add(strip);
00972 totcharge +=strip->GetCharge();
00973 addedstrip = true;
00974 firstu=0;
00975 found2=true;
00976 } // if positions match
00977 } // if in time
00978 } // end loop over event u strips
00979 } // end if already have u strip
00980 break;
00981
00982 case PlaneView::kV:
00983
00984 // if this is the first strip, add to newevent strip list
00985 if (firstv) {
00986 // strip is in V plane
00987 // if this is the first strip, add to newevent strip list
00988 if (firstu) {
00989 neweventv.Add(strip);
00990 totcharge +=strip->GetCharge();
00991 MSG("EventSR",Msg::kDebug)<< " add first" << endl;
00992 addedstrip = true;
00993 firstv = 0;
00994 }
00995 else {
00996 // if we already have one or more u strips check that they are
00997 // in time, and require agreement in Z position.
00998 Bool_t found2=false;
00999 for (Int_t j=0; j<=neweventu.GetLast() && !found2;
01000 j++) {
01001 CandStripHandle *estrip =
01002 dynamic_cast<CandStripHandle*>(neweventu.At(j));
01003 Double_t dtime =
01004 strip->GetBegTime()-estrip->GetBegTime();
01005 MSG("EventSR",Msg::kDebug) << " dtime " << dtime*1e9
01006 << " " << pHitAssocDTime0*1e9
01007 << "/" << pHitAssocDTime1*1e9
01008 << " plane diff "
01009 << abs(strip->GetPlane() -
01010 estrip->GetPlane())
01011 << "/" << pHitAssocDPlane << endl;
01012 if (dtime>pHitAssocDTime0 &&
01013 dtime<pHitAssocDTime1 &&
01014 abs(strip->GetPlane()-estrip->GetPlane()) <=
01015 pHitAssocDPlane) {
01016 // if dist2 2 parameter meets match criteria,
01017 //add strip to array
01018 MSG("EventSR",Msg::kDebug)<< " add " << endl;
01019 neweventv.Add(strip);
01020 totcharge +=strip->GetCharge();
01021 addedstrip = true;
01022 firstv = false;
01023 found2 = true;
01024 }
01025 } // end loop over u strips in event
01026 } // end if already have u strips
01027 } // end if this is the first v strip
01028 else {
01029 // if we already have v strips, make sure that the one we
01030 // add is adjaccent, using same distance criteria base
01031 // on plane, time, and transverse postion separation
01032 Bool_t found2=false;
01033 for (Int_t j=0; j<=neweventv.GetLast() && !found2; j++) {
01034 CandStripHandle *estrip =
01035 dynamic_cast<CandStripHandle*>(neweventv.At(j));
01036 Double_t dtime = strip->GetBegTime() -
01037 estrip->GetBegTime();
01038 MSG("EventSR",Msg::kDebug)<< " dtime " << dtime*1e9 << " "
01039 << pHitAssocDTime0*1e9 << "/"
01040 << pHitAssocDTime1*1e9
01041 << " plane diff "
01042 << abs(strip->GetPlane() -
01043 estrip->GetPlane())
01044 << " dtpos " << (strip->GetTPos() -
01045 estrip->GetTPos())
01046 << endl;
01047 if (dtime>pHitAssocDTime0 &&
01048 dtime<pHitAssocDTime1) {
01049 Double_t dplane =
01050 (Double_t)(strip->GetPlane()-estrip->GetPlane());
01051 Double_t dtpos = strip->GetTPos()-estrip->GetTPos();
01052 Double_t dist2 = (pHitAssocZParm*dplane*dplane) +
01053 (pHitAssocPParm*dtpos*dtpos) +
01054 (pHitAssocTParm*dtime*dtime);
01055 // if dist2 2 parameter meets match criteria,
01056 // add strip to array
01057 if (dist2<pHitAssocMaxDist2*4) {
01058 MSG("EventSR",Msg::kDebug)<< " add " << endl;
01059 neweventv.Add(strip);
01060 totcharge +=strip->GetCharge();
01061 addedstrip = true;
01062 firstv = false;
01063 found2 = true;
01064 } // end if add strip
01065 } //end if in time
01066 } // end loop over v strips
01067 }
01068 break;
01069
01070 default:
01071 break;
01072 }
01073 }
01074
01075 // end of loop over hits - remove new 'associations' and compress
01076 for (Int_t i=0; i<=neweventu.GetLast(); i++) {
01077 CandStripHandle *estrip =
01078 dynamic_cast<CandStripHandle*>(neweventu.At(i));
01079 unassociated.Remove(estrip);
01080 }
01081 for (Int_t i=0; i<=neweventv.GetLast(); i++) {
01082 CandStripHandle *estrip =
01083 dynamic_cast<CandStripHandle*>(neweventv.At(i));
01084 unassociated.Remove(estrip);
01085 }
01086 unassociated.Compress();
01087 }
01088
01089 // if we have hits in both views, build an event from them
01090 // if pulse height>10 pes
01091 MSG("EventSR",Msg::kDebug)<< " considering event formation u/v: "
01092 << !firstu << "/" << !firstv << " charge "
01093 << totcharge << endl;
01094 if (!firstu && !firstv && totcharge>20.0) {
01095 found=true;
01096
01097 Bool_t newShowerOverlapsOld=false;
01098 CandHandle *shw = NULL;
01099
01100 // construct CandClusters
01101 cxx.SetDataIn(&neweventu);
01102 AlgHandle clusterah = af.GetAlgHandle("AlgClusterSR","default");
01103 CandClusterHandle uclusterhandle =
01104 CandCluster::MakeCandidate(clusterah,cxx);
01105 uclusterhandle.SetCandSlice(slice);
01106 uclusterhandle.IsShowerLike(1);
01107 clusterlist->AddDaughterLink(uclusterhandle);
01108 cxx.SetDataIn(&neweventv);
01109 CandClusterHandle vclusterhandle =
01110 CandCluster::MakeCandidate(clusterah,cxx);
01111 vclusterhandle.SetCandSlice(slice);
01112 vclusterhandle.IsShowerLike(1);
01113 clusterlist->AddDaughterLink(vclusterhandle);
01114 CandHandle *ucluster = clusterlist->FindDaughter(&uclusterhandle);
01115 CandHandle *vcluster = clusterlist->FindDaughter(&vclusterhandle);
01116
01117 //build shower
01118 TObjArray newshower;
01119 newshower.Add(ucluster);
01120 newshower.Add(vcluster);
01121 cxx.SetDataIn(&newshower);
01122
01123
01124 AlgHandle showerah = af.GetAlgHandle("AlgShowerSR",pEventAlgConfig);
01125 CandShowerHandle showerhandle =
01126 CandShower::MakeCandidate(showerah,cxx);
01127 showerhandle.SetCandSlice(slice);
01128 showerhandle.SetCandRecord(slicelist->GetCandRecord());
01129
01130 CandShowerHandleItr showerItr(showerlist->GetDaughterIterator());
01131 while (CandShowerHandle *shower =
01132 dynamic_cast<CandShowerHandle*>(showerItr())){
01133 if(showerhandle.BelongsWithShower(shower,ac,
01134 vldcptr,
01135 pShwShwDtpos2,
01136 pShwShwDz,
01137 pShwShwDt)){
01138 newShowerOverlapsOld=true;
01139 MSG("EventSR",Msg::kDebug)
01140 << " new shower overlaps with previous - don't make new event "
01141 << endl;
01142 break;
01143 }
01144 }
01145
01146 if(!newShowerOverlapsOld){
01147 MSG("EventSR",Msg::kDebug)<< " Building Event! " << endl;
01148 showerlist->AddDaughterLink(showerhandle);
01149 shw = showerlist->FindDaughter(&showerhandle);
01150 }
01151
01152 if(!newShowerOverlapsOld){
01153 // form event from shower
01154 TObjArray recolist;
01155 recolist.Add(shw);
01156 cxx.SetDataIn(&recolist);
01157 AlgHandle eventah = af.GetAlgHandle("AlgEventSR",pEventAlgConfig);
01158 CandEventHandle eventhandle =
01159 CandEvent::MakeCandidate(eventah,cxx);
01160 eventhandle.SetCandSlice(slice);
01161 eventhandle.SetPrimaryShower(pMinShwEFract,pShwShwDz);
01162 ch.AddDaughterLink(eventhandle);
01163 }
01164 }
01165 }
01166 }
|
|
||||||||||||||||||||||||||||
|
Definition at line 519 of file AlgEventSRList.cxx. References abs(), CandHandle::AddDaughterLink(), CandEventHandle::AddShower(), CandHandle::FindDaughter(), Registry::Get(), AlgFactory::GetAlgHandle(), CandRecoHandle::GetBegPlane(), CandEventHandle::GetCandSlice(), CandStripHandle::GetCharge(), CandHandle::GetDaughterIterator(), Registry::GetDouble(), AlgFactory::GetInstance(), CandStripHandle::GetPlane(), CandStripHandle::GetPlaneView(), CandEventHandle::GetPrimaryTrack(), CandClusterHandle::IsShowerLike(), CandShower::MakeCandidate(), CandCluster::MakeCandidate(), MSG, CandRecoHandle::SetCandSlice(), CandClusterHandle::SetCandSlice(), CandContext::SetDataIn(), and CandEventHandle::SetPrimaryShower(). Referenced by RunAlg(). 00524 {
00525 // need to create a shower -- include strips from first plane in each
00526 // view plus this previously unassociated hit to generate a 3D object
00527
00528 // Get singleton instance of AlgFactory
00529 const char *pEventAlgConfig = 0;
00530 ac.Get("EventAlgConfig",pEventAlgConfig);
00531
00532 //Double_t shwshwdz = ac.GetDouble("ShwShwDz");
00533 //Double_t minShwEFract = ac.GetDouble("MinShwEFract");
00534 Double_t pMinShwStripPE = ac.GetDouble("MinShwStripPE");
00535 Double_t pMaxNewShwLen = ac.GetDouble("MaxNewShwLen");
00536
00537 AlgFactory &af = AlgFactory::GetInstance();
00538
00539 CandTrackHandle *track = closestevent->GetPrimaryTrack();
00540 if (!showerlist) {
00541 MSG("EventSR",Msg::kError) <<"CandShowerListHandle missing\n" << endl;
00542 return;
00543 }
00544
00545 closestevent->AddDaughterLink(*closeststrip);
00546
00547 // create arrays of strips for each planeview to create
00548 // shower from
00549
00550 MSG("EventSR",Msg::kVerbose) << "creating shower \n";
00551 TObjArray ustriparray;
00552 TObjArray vstriparray;
00553 Int_t uplane=track->GetBegPlane(PlaneView::kU);
00554 Int_t vplane=track->GetBegPlane(PlaneView::kV);
00555 // seed this shower with strips in most upstream track hits
00556 // in each view, along with hits above a charge threshold and
00557 // within pMaxNewShwLen of the track start
00558 TIter stripItr(track->GetDaughterIterator());
00559 while (CandStripHandle *tstrip =
00560 dynamic_cast<CandStripHandle*>(stripItr())) {
00561 if ((tstrip->GetPlane() == uplane) ||
00562 (tstrip->GetPlaneView()==PlaneView::kU &&
00563 tstrip->GetCharge()>pMinShwStripPE &&
00564 abs(tstrip->GetPlane()-uplane)<pMaxNewShwLen)) {
00565 ustriparray.Add(tstrip);
00566 }
00567 if ((tstrip->GetPlane() == vplane) ||
00568 (tstrip->GetPlaneView()==PlaneView::kV &&
00569 tstrip->GetCharge()>pMinShwStripPE &&
00570 abs(tstrip->GetPlane()-vplane)<pMaxNewShwLen)) {
00571 vstriparray.Add(tstrip);
00572 }
00573 }
00574 // add unassoc strip to appropriate array
00575 switch (closeststrip->GetPlaneView()) {
00576 case PlaneView::kU:
00577 ustriparray.Add(closeststrip);
00578 break;
00579 case PlaneView::kV:
00580 vstriparray.Add(closeststrip);
00581 break;
00582 default:
00583 break;
00584 }
00585 // build shower from U/V clusters
00586 if(ustriparray.GetLast()>=0 && vstriparray.GetLast()>=0){
00587 // now construct CandClusters
00588 AlgHandle clusterah = af.GetAlgHandle("AlgClusterSR","default");
00589
00590 cxx.SetDataIn(&ustriparray);
00591 CandClusterHandle uclusterhandle =
00592 CandCluster::MakeCandidate(clusterah,cxx);
00593 uclusterhandle.SetCandSlice(closestevent->GetCandSlice());
00594 uclusterhandle.IsShowerLike(1);
00595 clusterlist->AddDaughterLink(uclusterhandle);
00596
00597 cxx.SetDataIn(&vstriparray);
00598 CandClusterHandle vclusterhandle =
00599 CandCluster::MakeCandidate(clusterah,cxx);
00600 vclusterhandle.SetCandSlice(closestevent->GetCandSlice());
00601 vclusterhandle.IsShowerLike(1);
00602 clusterlist->AddDaughterLink(vclusterhandle);
00603
00604 // build shower from U/V clusters just created
00605 TObjArray newshower;
00606 CandHandle * ucluster =
00607 clusterlist->FindDaughter(&uclusterhandle);
00608 CandHandle * vcluster =
00609 clusterlist->FindDaughter(&vclusterhandle);
00610
00611 newshower.Add(ucluster);
00612 newshower.Add(vcluster);
00613
00614 cxx.SetDataIn(&newshower);
00615 AlgHandle showerah = af.GetAlgHandle("AlgShowerSR",pEventAlgConfig);
00616 CandShowerHandle showerhandle =
00617 CandShower::MakeCandidate(showerah,cxx);
00618 showerhandle.SetCandSlice(closestevent->GetCandSlice());
00619 showerlist->AddDaughterLink(showerhandle);
00620 CandHandle *shw = showerlist->FindDaughter(&showerhandle);
00621 CandShowerHandle *shwh = dynamic_cast<CandShowerHandle*>(shw);
00622
00623 // add this new shower to this event, and make it the
00624 // primary shower
00625 closestevent->AddShower(shwh);
00626 closestevent->SetPrimaryShower(shwh);
00627 }
00628 }
|
|
||||||||||||||||||||
|
Definition at line 1602 of file AlgEventSRList.cxx. References CandRecoHandle::GetBegPlane(), CandStripHandle::GetBegTime(), CandHandle::GetDaughterIterator(), Registry::GetDouble(), CandStripHandle::GetPlane(), CandStripHandle::GetPlaneView(), CandEventHandle::GetPrimaryShower(), CandEventHandle::GetPrimaryTrack(), CandStripHandle::GetStrip(), CandStripHandle::GetTPos(), CandRecoHandle::GetVtxT(), CandRecoHandle::GetVtxZ(), and MSG. Referenced by RunAlg(). 01602 {
01603 // grab all needed algorithm parameters
01604
01605 Double_t pShwTrkDz = ac.GetDouble("ShwTrkDz");
01606 Double_t pHitAssocDTime0 = ac.GetDouble("HitAssocDTime0");
01607 Double_t pHitAssocDTime1 = ac.GetDouble("HitAssocDTime1");
01608 Double_t pHitAssocZParm = ac.GetDouble("HitAssocZParm");
01609 Double_t pHitAssocPParm = ac.GetDouble("HitAssocPParm");
01610 Double_t pHitAssocTParm = ac.GetDouble("HitAssocTParm");
01611
01612 // construct the map, first looping over strips
01613 for (Int_t i=0; i<=unassociated.GetLast(); i++) {
01614 CandStripHandle *strip =
01615 dynamic_cast<CandStripHandle*>(unassociated.At(i));
01616 TIter eventItr(ch.GetDaughterIterator());
01617 // inner loop is over events
01618 while (CandEventHandle *event =
01619 dynamic_cast<CandEventHandle*>(eventItr())) {
01620
01621 // calculate separation in space/time
01622 Double_t dtime = (strip->GetBegTime()-event->GetVtxT());
01623 Double_t bestdist2=-1.;
01624 Double_t bestdplane=-1;
01625 Double_t bestdtpos=-1;
01626 Double_t bestdtime=-1;
01627 dist2map[i][event] = 999999999.;
01628 MSG("EventSR",Msg::kVerbose) << i << " "
01629 << strip->GetPlane() << " " << strip->GetStrip() << " dtime " << dtime*1e9 << "/" << pHitAssocDTime0*1e9 << "/" << pHitAssocDTime1*1e9 << endl;
01630 // if there is a rough time match proceed
01631 if (dtime>pHitAssocDTime0 && dtime<pHitAssocDTime1) {
01632
01633 Float_t vertexsep = 0;
01634 // If event has both shower
01635 // and track calc separation between the two. If this
01636 // separation is greater
01637 // than pSHwTrkDz, we won't bother adding the strip to the
01638 // primary shower, and will instead consider whether
01639 // to create a new shower at track vertex.
01640 if (event->GetPrimaryShower() && event->GetPrimaryTrack())
01641 vertexsep = fabs(event->GetPrimaryShower()->GetVtxZ() -
01642 event->GetPrimaryTrack()->GetVtxZ());
01643
01644 // the event has a shower, and either no track, or track and
01645 // shower vertices are in agreement. In this case, we
01646 // consider adding this strip to this shower, so calc separation.
01647 if (event->GetPrimaryShower() &&
01648 (!event->GetPrimaryTrack() || vertexsep<pShwTrkDz)) {
01649
01650 // create iterator of shower daughter strips in same view
01651 // as unassoc strip
01652 CandStripHandleItr shwstripItr(
01653 event->GetPrimaryShower()->GetDaughterIterator());
01654 CandStripHandleKeyFunc *shwstripKf =
01655 shwstripItr.CreateKeyFunc();
01656 shwstripKf->SetFun(CandStripHandle::KeyFromView);
01657 shwstripItr.GetSet()->AdoptSortKeyFunc(shwstripKf);
01658 shwstripKf = 0;
01659 shwstripItr.GetSet()->Slice();
01660 shwstripItr.GetSet()->Slice(strip->GetPlaneView(),
01661 strip->GetPlaneView());
01662
01663 // iterate over the daughter list, and find minimum distane
01664 // between daughter and unassoc strip
01665 while (CandStripHandle *shwstrip =
01666 dynamic_cast<CandStripHandle*>(shwstripItr())) {
01667 Double_t dplane =
01668 (Double_t)(strip->GetPlane()-shwstrip->GetPlane());
01669 Double_t dtpos = strip->GetTPos()-shwstrip->GetTPos();
01670 Double_t dist2 = (pHitAssocZParm*dplane*dplane) +
01671 (pHitAssocPParm*dtpos*dtpos) +
01672 (pHitAssocTParm*dtime*dtime);
01673 if (bestdist2<0. || dist2<bestdist2) {
01674 bestdist2 = dist2;
01675 bestdplane=dplane;
01676 bestdtpos=dtpos;
01677 bestdtime=dtime;
01678 }
01679 }
01680 MSG("EventSR",Msg::kVerbose)
01681 << "primary shower." << " dplane:" << bestdplane <<" dtpos:"
01682 << bestdtpos <<" dtime:" << bestdtime <<" dist2:"
01683 << bestdist2<< "\n";
01684 dist2map[i][event] = bestdist2;
01685 } // end if event has shower, etc.
01686 // else if criteria above was not satisfied, consider whether
01687 // strip is near track vertex, in which case we start new shower
01688 else if (event->GetPrimaryTrack()) {
01689
01690 // calc distance to vertex
01691 Double_t dplane =
01692 (Double_t)(strip->GetPlane()-event->GetPrimaryTrack()->
01693 GetBegPlane());
01694 Double_t dtpos=0;
01695 switch (strip->GetPlaneView()) {
01696 case PlaneView::kU:
01697 dtpos=strip->GetTPos()-event->GetPrimaryTrack()->
01698 GetU(event->GetPrimaryTrack()->GetBegPlane());
01699 break;
01700 case PlaneView::kV:
01701 dtpos=strip->GetTPos()-event->GetPrimaryTrack()->
01702 GetV(event->GetPrimaryTrack()->GetBegPlane());
01703 break;
01704 default:
01705 break;
01706 }
01707 Double_t dist2 = (pHitAssocZParm*dplane*dplane) +
01708 (pHitAssocPParm*dtpos*dtpos) +
01709 (pHitAssocTParm*dtime*dtime);
01710 dist2map[i][event] = dist2;
01711 MSG("EventSR",Msg::kVerbose)
01712 << "primary track. begin:" << " dplane:" << dplane
01713 << " dtpos:" << dtpos <<" dtime:" << dtime <<" dist2:"
01714 << dist2 << "\n";
01715 } // end if primary track
01716 } // end if time match OK
01717 } // end loop over events
01718 } // end loop over unassoc strips
01719 }
|
|
||||||||||||||||||||
|
Definition at line 1298 of file AlgEventSRList.cxx. References CandRecoHandle::GetCandSlice(), CandHandle::GetNDaughters(), CandHandle::IsCloneOf(), and MSG. Referenced by RunAlg(). 01299 {
01300
01301 if (showerItr) {
01302 showerItr->Reset();
01303 while (CandShowerHandle *shower =
01304 dynamic_cast<CandShowerHandle*>((*showerItr)())) {
01305 if (shower->GetCandSlice()) {
01306 if (slice->IsCloneOf(*(shower->GetCandSlice()))) {
01307 recolist.Add(shower);
01308 }
01309 }
01310 else {
01311 MSG("EventSR", Msg::kError)
01312 << "Shower doesn't contain a slice. Not added to recolist."
01313 << endl;
01314 }
01315 }
01316 }
01317
01318 if (trackItr) {
01319 trackItr->Reset();
01320 while (CandTrackHandle *track =
01321 dynamic_cast<CandTrackHandle*>((*trackItr)())) {
01322 if (track->GetCandSlice()) {
01323 if (slice->IsCloneOf(*track->GetCandSlice())) {
01324 if(track->GetNDaughters()==0 &&
01325 track->InheritsFrom("CandFitTrackHandle") &&
01326 dynamic_cast<CandFitTrackHandle*>(track)->GetFinderTrack()){
01327 track = dynamic_cast<CandFitTrackHandle*>(track)->GetFinderTrack();
01328 MSG("EventSR", Msg::kDebug)<< "Finder Track being used " << endl;
01329 }
01330 recolist.Add(track);
01331 }
01332 }
01333 else {
01334 MSG("EventSR", Msg::kError)
01335 << "Track doesn't contain a slice. Not added to recolist."
01336 << endl;
01337 }
01338 }
01339 }
01340 }
|
|
||||||||||||||||||||
|
Definition at line 1542 of file AlgEventSRList.cxx. References CandHandle::FindDaughter(), CandRecoHandle::GetCandSlice(), CandHandle::GetDaughterIterator(), and CandHandle::IsCloneOf(). 01542 {
01543
01544 while (CandSliceHandle *slice =
01545 dynamic_cast<CandSliceHandle*>(sliceItr())) {
01546 TIter stripItr(slice->GetDaughterIterator());
01547 while (CandStripHandle *strip =
01548 dynamic_cast<CandStripHandle*>(stripItr())) {
01549 Bool_t found=false;
01550 // check for duplicates
01551
01552 for (Int_t i=0; i<=unassociated.GetLast() && !found; i++) {
01553 CandStripHandle *strip0 =
01554 dynamic_cast<CandStripHandle*>(unassociated.At(i));
01555 if (*strip == *strip0) {
01556 found = true;
01557 break;
01558 }
01559 }
01560 // if this strip not already in unnassociated list, then
01561 // loop over objects in this slice, and check against all daughter strips
01562 if (!found) {
01563 if (showerItr) {
01564 showerItr->Reset();
01565 while (CandShowerHandle *shower =
01566 dynamic_cast<CandShowerHandle*>((*showerItr)())) {
01567 if (shower->GetCandSlice()) {
01568 if (slice->IsCloneOf(*(shower->GetCandSlice()))) {
01569 if (shower->FindDaughter(strip)) {
01570 found = true;
01571 break;
01572 }
01573 }
01574 }
01575 }
01576 }
01577 if (trackItr && !found) {
01578 trackItr->Reset();
01579 while (CandTrackHandle *track =
01580 dynamic_cast<CandTrackHandle*>((*trackItr)())) {
01581 if (track->GetCandSlice()) {
01582 if (slice->IsCloneOf(*(track->GetCandSlice()))) {
01583 if (track->FindDaughter(strip)) {
01584 found = true;
01585 break;
01586 }
01587 }
01588 }
01589 }
01590 }
01591 }
01592 // this strip is not in any event, add to unassociated list
01593 if (!found) {
01594 unassociated.Add(strip);
01595 }
01596 }
01597 }
01598 }
|
|
||||||||||||||||
|
Definition at line 1496 of file AlgEventSRList.cxx. References CandHandle::FindDaughter(), CandEventHandle::GetCandSlice(), CandHandle::GetDaughterIterator(), and CandHandle::IsCloneOf(). Referenced by RunAlg(). 01496 {
01497
01498 while (CandSliceHandle *slice =
01499 dynamic_cast<CandSliceHandle*>(sliceItr())) {
01500 TIter stripItr(slice->GetDaughterIterator());
01501 while (CandStripHandle *strip =
01502 dynamic_cast<CandStripHandle*>(stripItr())) {
01503 Bool_t found=false;
01504 // check for duplicates
01505
01506 for (Int_t i=0; i<=unassociated.GetLast() && !found; i++) {
01507 CandStripHandle *strip0 =
01508 dynamic_cast<CandStripHandle*>(unassociated.At(i));
01509 if (*strip == *strip0) {
01510 found = true;
01511 break;
01512 }
01513 }
01514 // if this strip not already in unnassociated list, then
01515 // loop over objects in this slice, and check against all daughter strips
01516 if (!found) {
01517 if (eventItr) {
01518 eventItr->Reset();
01519 while (CandEventHandle *event =
01520 dynamic_cast<CandEventHandle*>((*eventItr)())) {
01521 if (event->GetCandSlice()) {
01522 if (slice->IsCloneOf(*(event->GetCandSlice()))) {
01523 if (event->FindDaughter(strip)) {
01524 found = true;
01525 break;
01526 }
01527 }
01528 }
01529 }
01530 }
01531 }
01532 // this strip is not in any event, add to unassociated list
01533 if (!found) {
01534 unassociated.Add(strip);
01535 }
01536 }
01537 }
01538 }
|
|
||||||||||||||||||||
|
Definition at line 1347 of file AlgEventSRList.cxx. References CandTrackHandle::BelongsWithTrack(), and Registry::GetDouble(). Referenced by RunAlg(). 01348 {
01349
01350 Double_t pTrkTrkDtpos2 = ac.GetDouble("TrkTrkDtpos2")*9;
01351 Double_t pTrkTrkDz = ac.GetDouble("TrkTrkDz")*3;
01352 Double_t pTrkTrkDt = ac.GetDouble("TrkTrkDt");
01353 for (Int_t ireco2=0; ireco2<=objectlist->GetLast();
01354 ireco2++) {
01355 if (objectlist->At(ireco2)->InheritsFrom("CandTrackHandle")) {
01356 CandTrackHandle *othertrack = dynamic_cast<CandTrackHandle*>
01357 (objectlist->At(ireco2));
01358 if( !track->BelongsWithTrack(othertrack,
01359 ac,
01360 vldcptr,
01361 pTrkTrkDtpos2,pTrkTrkDz,pTrkTrkDt))return false;
01362 }
01363 }
01364 return true;
01365 }
|
|
||||||||||||||||||||||||||||
|
Definition at line 1391 of file AlgEventSRList.cxx. References CandHandle::AddDaughterLink(), CandHandle::FindDaughter(), Registry::Get(), AlgFactory::GetAlgHandle(), CandHandle::GetDaughterIterator(), AlgFactory::GetInstance(), CandStripHandle::GetPlaneView(), CandHandle::GetVldContext(), CandHandle::IsEqual(), CandClusterHandle::IsShowerLike(), CandShower::MakeCandidate(), CandCluster::MakeCandidate(), MSG, CandHandle::RemoveDaughter(), CandRecoHandle::SetCandSlice(), CandClusterHandle::SetCandSlice(), and CandContext::SetDataIn(). Referenced by RunAlg(). 01395 {
01396
01397
01398 const char *pEventAlgConfig = 0;
01399 ac.Get("EventAlgConfig",pEventAlgConfig);
01400
01401 for (Int_t i=0; i<=eventlist.GetLast(); i++) {
01402 TObjArray *objectlist = dynamic_cast<TObjArray*>(eventlist.At(i));
01403 if(objectlist->GetLast()<=0)break;
01404 Bool_t foundtrack=false;
01405 for (Int_t i=0; i<=objectlist->GetLast(); i++) {
01406 if (!(objectlist->At(i)->InheritsFrom("CandShowerHandle"))) {
01407 foundtrack=true;
01408 break;
01409 }
01410 }
01411 if(foundtrack)break;
01412 MSG("EventSR",Msg::kDebug) << " merging showers\n";
01413
01414 // if we are here, we have an event with multiple showers and no tracks, so we merge into single shower.
01415
01416 // Get singleton instance of AlgFactory
01417 AlgFactory &af = AlgFactory::GetInstance();
01418
01419 // construct total U/V cluster daughter list
01420 TObjArray ustriparray;
01421 TObjArray vstriparray;
01422 for (Int_t i=0; i<=objectlist->GetLast(); i++) {
01423 CandShowerHandle * shower = dynamic_cast<CandShowerHandle *>(objectlist->At(i));
01424 TIter stripItr(shower->GetDaughterIterator());
01425 while (CandStripHandle *strip =
01426 dynamic_cast<CandStripHandle*>(stripItr())) {
01427 if(strip->GetPlaneView()==PlaneView::kU)ustriparray.Add(strip);
01428 if(strip->GetPlaneView()==PlaneView::kV)vstriparray.Add(strip);
01429 }
01430 }
01431
01432 // make U cluster
01433 cxx.SetDataIn(&ustriparray);
01434 AlgHandle clusterah = af.GetAlgHandle("AlgClusterSR","default");
01435 CandClusterHandle uclusterhandle =
01436 CandCluster::MakeCandidate(clusterah,cxx);
01437 uclusterhandle.SetCandSlice(slice);
01438 uclusterhandle.IsShowerLike(1);
01439
01440 // make V cluster
01441 cxx.SetDataIn(&vstriparray);
01442 CandClusterHandle vclusterhandle =
01443 CandCluster::MakeCandidate(clusterah,cxx);
01444 vclusterhandle.SetCandSlice(slice);
01445 vclusterhandle.IsShowerLike(1);
01446
01447 // add new clusters to cluster list
01448 clusterlist->AddDaughterLink(uclusterhandle);
01449 clusterlist->AddDaughterLink(vclusterhandle);
01450
01451 // build shower
01452 TObjArray newshower;
01453 CandHandle *ucluster =
01454 clusterlist->FindDaughter(&uclusterhandle);
01455 CandHandle *vcluster =
01456 clusterlist->FindDaughter(&vclusterhandle);
01457 newshower.Add(ucluster);
01458 newshower.Add(vcluster);
01459 cxx.SetDataIn(&newshower);
01460
01461 AlgHandle showerah = af.GetAlgHandle("AlgShowerSR",pEventAlgConfig);
01462 CandShowerHandle showerhandle =
01463 CandShower::MakeCandidate(showerah,cxx);
01464 showerhandle.SetCandSlice(slice);
01465 showerlist->AddDaughterLink(showerhandle);
01466 // need to clean up shower list
01467 for (Int_t i=0; i<=objectlist->GetLast(); i++) {
01468 CandShowerHandle * shower = dynamic_cast<CandShowerHandle *>(objectlist->At(i));
01469 TIter shiter(showerlist->GetDaughterIterator());
01470 CandShowerHandle *oldshower;
01471 Bool_t found=false;
01472 while (!found &&
01473 (oldshower = dynamic_cast<CandShowerHandle*>(shiter()))) {
01474 if (shower->IsEqual(oldshower)) {
01475 found=true;
01476 showerlist->RemoveDaughter(oldshower);
01477 }
01478 }
01479 }
01480 CandShowerHandleItr showerItr(showerlist->GetDaughterIterator());
01481 while (CandShowerHandle *shower =
01482 dynamic_cast<CandShowerHandle*>(showerItr())){
01483 MSG("EventSR",Msg::kDebug) << " new shower " << shower << " " << shower->GetVldContext() << endl;
01484 }
01485 // reset object list to contain new shower
01486 objectlist->Clear();
01487 CandShowerHandle * shower = dynamic_cast<CandShowerHandle *>(showerlist->FindDaughter(&showerhandle));
01488 assert (shower);
01489 objectlist->Add(shower);
01490 }
01491 }
|
|
||||||||||||||||
|
This method fills a cluster list for every shower in the snarl, and then reruns the shower algorithm. Following this, it tracks the primary track in each event through the primary shower, and subtracts 1 MIP for each strip passed through. Definition at line 661 of file AlgEventSRList.cxx. References CandHandle::AddDaughterLink(), CandShowerHandle::CalibrateEnergy(), CandClusterHandle::DupHandle(), Registry::Get(), AlgHandle::GetAlgConfig(), AlgFactory::GetAlgHandle(), CandEventHandle::GetCandSlice(), CandShowerHandle::GetCluster(), CandContext::GetDataIn(), CandHandle::GetDaughterIterator(), AlgFactory::GetInstance(), CandShowerHandle::GetLastCluster(), CandEventHandle::GetLastShower(), CandEventHandle::GetPrimaryTrack(), CandEventHandle::GetShowerWritable(), CandHandle::IsCloneOf(), CandHandle::IsEqual(), MSG, CandHandle::RemoveDaughter(), AlgHandle::RunAlg(), CandRecoHandle::SetCandSlice(), and CandContext::SetDataIn(). Referenced by RunAlg(). 00662 {
00663
00664 // Retrieve persistant modifiable CandShowerList
00665 CandShowerListHandle *showerlist = const_cast<CandShowerListHandle*>
00666 (dynamic_cast<const CandShowerListHandle*>(cxx.GetDataIn()));
00667
00668 // Get singleton instance of AlgFactory
00669 AlgFactory &af = AlgFactory::GetInstance();
00670
00671 // Get an AlgHandle to AlgShowerSR with default AlgConfig
00672 const char *pEventAlgConfig = 0;
00673 ac.Get("EventAlgConfig",pEventAlgConfig);
00674
00675 AlgHandle ah = af.GetAlgHandle("AlgShowerSR",pEventAlgConfig);
00676 AlgConfig acshw = ah.GetAlgConfig();
00677
00678 TIter evItr(ch.GetDaughterIterator());
00679 while (CandEventHandle *ev =
00680 dynamic_cast<CandEventHandle*>(evItr())) {
00681 for (Int_t ishower=0; ishower<ev->GetLastShower()+1; ishower++) {
00682 CandShowerHandle *shower =
00683 dynamic_cast<CandShowerHandle*>(ev->GetShowerWritable(ishower));
00684 if (shower) {
00685 TObjArray newshower;
00686 // fill array of clusters for this shower
00687 for (Int_t icluster=0; icluster<shower->GetLastCluster()+1;
00688 icluster++) {
00689 const CandClusterHandle *cl = shower->GetCluster(icluster);
00690 if (cl) {
00691 // New handle on heap
00692 CandClusterHandle *cclh = cl->DupHandle();
00693 // Add new heap-based CandHandle to TObjArray
00694 newshower.Add(cclh);
00695 }
00696 }
00697 // re-run algorithm for this shower
00698 if (newshower.GetEntriesFast() > 0) {
00699 cxx.SetDataIn(&newshower);
00700 ah.RunAlg(*shower,cxx);
00701 }
00702 else {
00703 MSG("EventSR", Msg::kError)
00704 << "Attempt to pass empty TObjArray newshower to AlgShowerSR"
00705 << " in CandContext. AlgShowerSR::RunAlg() call ignored."
00706 << endl;
00707 }
00708
00709 // Delete heap-based CandHandles in TObjArray
00710 newshower.Delete();
00711 }
00712 else {
00713 MSG("EventSR",Msg::kWarning)
00714 << "Handle is not a CandShowerHandle."
00715 << " Shower not processed in ReConstructShowers."
00716 << endl;
00717 continue;
00718 }
00719
00720 // now loop through strips in this shower, and determine whether primary
00721 // track in this event intercepts this strip. If so, subtract 1 mip
00722 // from shower energy.
00723
00724 CandTrackHandle *primaryTrack = ev->GetPrimaryTrack();
00725
00726 // if event has primary track, extrapolate through shower and subtract energy loss to recalibrate
00727 if (primaryTrack) shower->CalibrateEnergy(primaryTrack,acshw);
00728
00729 // Update modified showers in persistent modifiable CandShowerList.
00730 // CandHandle could potentially supply a ReplaceDaughter() function.
00731 // Interface of ReplaceDaughter() would be debatable.
00732 if (showerlist) {
00733 TIter shiter(showerlist->GetDaughterIterator());
00734 CandShowerHandle *target;
00735 Bool_t found = kFALSE;
00736 while (!found &&
00737 (target = dynamic_cast<CandShowerHandle*>(shiter()))) {
00738 if (shower->IsCloneOf(*target)) { // Tests clone or Cand ==
00739 found = kTRUE;
00740
00741 // Replace target only if shower is a modified version of target
00742
00743 if (!(shower->IsEqual(target))) { // CandBase inequality
00744 shower->SetCandSlice(ev->GetCandSlice());
00745 if (!showerlist->RemoveDaughter(target)) { // Failure
00746 MSG("EventSR",Msg::kError) << endl
00747 << "Failure of ShowerList daughter removal " << endl
00748 << "attempted during replacement by modified Shower."
00749 << endl << "Will result in double counted Shower."
00750 << endl;
00751 }
00752 showerlist->AddDaughterLink(*shower);
00753 }
00754 }
00755 }
00756
00757 // Add new (unfound) shower to persistent modifiable CandShowerList.
00758 if (!found){
00759 shower->SetCandSlice(ev->GetCandSlice());
00760 showerlist->AddDaughterLink(*shower);
00761 }
00762 }
00763 }
00764 }
00765 }
|
|
||||||||||||||||||||||||
|
Definition at line 631 of file AlgEventSRList.cxx. References CandStripHandle::GetBegTime(), Registry::GetDouble(), CandStripHandle::GetPlane(), CandStripHandle::GetPlaneView(), CandStripHandle::GetTPos(), and CandRecoHandle::GetVtxT(). Referenced by RunAlg(). 00634 {
00635 Double_t pHitAssocZParm = ac.GetDouble("HitAssocZParm");
00636 Double_t pHitAssocPParm = ac.GetDouble("HitAssocPParm");
00637 Double_t pHitAssocTParm = ac.GetDouble("HitAssocTParm");
00638
00639 for (Int_t i=0; i<=unassociated.GetLast(); i++) {
00640 CandStripHandle *strip =
00641 dynamic_cast<CandStripHandle*>(unassociated.At(i));
00642 if(strip->GetPlaneView()==closeststrip->GetPlaneView()){
00643 Double_t dtime = strip->GetBegTime()-closestevent->GetVtxT();
00644 Double_t dplane =
00645 (Double_t)(strip->GetPlane()-closeststrip->GetPlane());
00646 Double_t dtpos = strip->GetTPos()-closeststrip->GetTPos();
00647 Double_t dist2 = (pHitAssocZParm*dplane*dplane) +
00648 (pHitAssocPParm*dtpos*dtpos) +
00649 (pHitAssocTParm*dtime*dtime);
00650 if (dist2<dist2map[i][closestevent]) {
00651 dist2map[i][closestevent] = dist2;
00652 }
00653 }
00654 } // loop over unassoc hits
00655 }
|
|
||||||||||||
|
This method loops over tracks in a slice, and for each loops over all showers in the same slice. For each track/shower pair, the number of isolated track points is determined, by looking in each plane whether the track location is spanned by the shower. It the number of isolated track planes is below threshold, the track is removed from the object list. Definition at line 1172 of file AlgEventSRList.cxx. References CandRecoHandle::GetBegPlane(), VldContext::GetDetector(), Registry::GetDouble(), CandRecoHandle::GetEndPlane(), CandShowerHandle::GetMaxU(), CandShowerHandle::GetMaxV(), CandShowerHandle::GetMinU(), CandShowerHandle::GetMinV(), CandHandle::GetNDaughters(), CandTrackHandle::GetU(), CandTrackHandle::GetV(), CandHandle::GetVldContext(), CandTrackHandle::IsTPosValid(), and MSG. Referenced by RunAlg(). 01172 {
01173
01174
01175 Double_t pMinTrackIsolation = ac.GetDouble("MinTrackIsolation");
01176 Double_t pMinTrackIsolationDist = ac.GetDouble("MinTrackIsolationDist");
01177
01178 for (Int_t i = 0; i <= recolist->GetLast(); i++) {
01179 CandTrackHandle *track=0;
01180 Int_t nisolated = 0;
01181 Int_t nisolatedU = 0;
01182 Int_t nisolatedV = 0;
01183 Bool_t isolated = true;
01184 Int_t longestcontig = 0;
01185 Int_t longestcontigU = 0;
01186 Int_t longestcontigV = 0;
01187
01188 if (recolist->At(i)->InheritsFrom("CandTrackHandle")) {
01189 track = dynamic_cast<CandTrackHandle*>(recolist->At(i));
01190
01191 // count number of planes in each view in which
01192 // track is outside shower
01193 Int_t firstplane = TMath::Min(track->GetBegPlane(),
01194 track->GetEndPlane());
01195 Int_t lastplane = TMath::Max(track->GetBegPlane(),
01196 track->GetEndPlane());
01197 Int_t firstuplane = TMath::Min(track->GetBegPlane(PlaneView::kU),
01198 track->GetEndPlane(PlaneView::kU));
01199 Int_t firstvplane = TMath::Min(track->GetBegPlane(PlaneView::kV),
01200 track->GetEndPlane(PlaneView::kV));
01201 Int_t lastuplane = TMath::Max(track->GetBegPlane(PlaneView::kU),
01202 track->GetEndPlane(PlaneView::kU) );
01203 Int_t lastvplane = TMath::Max(track->GetBegPlane(PlaneView::kV),
01204 track->GetEndPlane(PlaneView::kV) );
01205
01206 MSG("RemoveTracksInShowers",Msg::kDebug) << " track extent " << firstplane << " " << lastplane << " " << track->GetNDaughters() << " " << track->GetBegPlane() << " " << track->GetEndPlane() << endl;
01207
01208 for(Int_t iplane = firstplane;iplane <= lastplane;iplane++){
01209 PlexPlaneId plnid(track->GetVldContext()->GetDetector(),iplane,false);
01210 // require that the plane be within the track
01211 // extent for this planeview
01212 isolated = true;
01213 if((plnid.GetPlaneView() == PlaneView::kU &&
01214 iplane >= firstuplane && iplane <= lastuplane) ||
01215 (plnid.GetPlaneView() == PlaneView::kV &&
01216 iplane >= firstvplane &&
01217 iplane<=lastvplane)){
01218
01219 for (Int_t j = 0; j<=recolist->GetLast(); j++) {
01220 if(isolated){
01221 if (recolist->At(j)->InheritsFrom("CandShowerHandle")) {
01222 CandShowerHandle * shower = dynamic_cast<CandShowerHandle*>(recolist->At(j));
01223 if(iplane >= shower->GetBegPlane() &&
01224 iplane <= shower->GetEndPlane()){
01225 // if plane within shower extent, compare track position
01226 // with shower width. If track outside shower by
01227 // a distance pMinTrackIsolationDist, or shower width
01228 // is less than this distance, inc isolated.
01229 Double_t minPE=2.0;
01230 Float_t minUshw = shower->GetMinU(iplane,minPE)+0.02;
01231 Float_t minVshw = shower->GetMinV(iplane,minPE)+0.02;
01232 Float_t maxUshw = shower->GetMaxU(iplane,minPE)-0.02;
01233 Float_t maxVshw = shower->GetMaxV(iplane,minPE)-0.02;
01234
01235 MSG("RemoveTracksInShowers",Msg::kDebug) << " shower extent Plane: " << iplane << " U " << minUshw << "/" << track->GetU(iplane) << "/" << maxUshw << " V " << minVshw << "/" << track->GetV(iplane) << "/" << maxVshw << endl;
01236
01237 if(plnid.GetPlaneView() == PlaneView::kU &&
01238 (track->GetU(iplane) >= (minUshw-pMinTrackIsolationDist) &&
01239 track->GetU(iplane) <= (maxUshw+pMinTrackIsolationDist) &&
01240 maxUshw-minUshw > (pMinTrackIsolationDist))){
01241 isolated = false;
01242 }
01243 if(plnid.GetPlaneView() == PlaneView::kV &&
01244 (track->GetV(iplane) >= (minVshw-pMinTrackIsolationDist)&&
01245 track->GetV(iplane) <= (maxVshw+pMinTrackIsolationDist)&&
01246 maxVshw-minVshw > (pMinTrackIsolationDist))){
01247 isolated = false;
01248 }
01249 if(!track->IsTPosValid(iplane))isolated = false;
01250 }
01251 }
01252 }
01253 }
01254 if(track->IsTPosValid(iplane)){
01255 nisolated++;
01256 if(plnid.GetPlaneView() == PlaneView::kU){
01257 nisolatedU++;
01258 }
01259 else{
01260 nisolatedV++;
01261 }
01262 }
01263 if(!isolated) {
01264 nisolated=0; // reset contig. isolation counter
01265 if(plnid.GetPlaneView() == PlaneView::kU){
01266 nisolatedU=0;
01267 }
01268 else{
01269 nisolatedV=0;
01270 }
01271 }
01272 if(nisolated > longestcontig)longestcontig = nisolated;
01273 if(nisolatedU > longestcontigU)longestcontigU = nisolatedU;
01274 if(nisolatedV > longestcontigV)longestcontigV = nisolatedV;
01275
01276 MSG("RemoveTracksInShowers",Msg::kDebug) << " nisolated, longest " << nisolated << " " << longestcontig << endl;
01277
01278 // if the number of contiguous isolated track planes is less than threshold
01279 // we remove this track from the event
01280 }
01281 }
01282 }
01283 MSG("RemoveTracksInShowers",Msg::kDebug) << " longest contig:" << longestcontig << " U " << longestcontigU << " V " << longestcontigV<< "/" << pMinTrackIsolation << endl;
01284 if(track && longestcontig < pMinTrackIsolation &&
01285 longestcontigU < pMinTrackIsolation &&
01286 longestcontigV < pMinTrackIsolation){
01287 MSG("RemoveTracksInShowers",Msg::kDebug) << " REMOVING TRACK" << endl;
01288 recolist->RemoveAt(i);
01289 recolist->Compress();
01290 //If you compress here then decrement i so that you
01291 //don't miss any tracks in recolist
01292 i-=1;
01293 }
01294 }
01295 }
|
|
||||||||||||||||
|
Implements AlgBase. Definition at line 70 of file AlgEventSRList.cxx. References abs(), CandHandle::AddDaughterLink(), AddObjectToEvent(), AddStripToEvent(), CandTrackHandle::BelongsWithShower(), CandShowerHandle::BelongsWithShower(), CandTrackHandle::BelongsWithTrack(), CandShowerHandle::BelongsWithTrack(), BuildEventFromUnassoc(), CreatePrimaryShower(), FillDist2Map(), FillRecoList(), FindUnassociated(), Registry::Get(), AlgFactory::GetAlgHandle(), CandRecoHandle::GetBegPlane(), CandStripHandle::GetBegTime(), CandContext::GetCandRecord(), CandContext::GetDataIn(), CandHandle::GetDaughterIterator(), Registry::GetDouble(), CandRecoHandle::GetEndPlane(), AlgFactory::GetInstance(), CandEventHandle::GetLastShower(), CandContext::GetMom(), CandHandle::GetNDaughters(), CandStripHandle::GetPlane(), CandEventHandle::GetPrimaryShower(), CandEventHandle::GetPrimaryTrack(), CandEventHandle::GetShower(), CandEventHandle::GetShowerWritable(), CandStripHandle::GetTPos(), RecMinos::GetVldContext(), CandRecoHandle::GetVtxPlane(), CandRecoHandle::GetVtxT(), CandRecoHandle::GetVtxU(), CandRecoHandle::GetVtxV(), CandRecoHandle::GetVtxZ(), CandHandle::IsCloneOf(), CandEvent::MakeCandidate(), MatchOtherTracksInEvent(), max, MergeShowers(), min, MSG, ReConstructShowers(), ReFillDist2Map(), RemoveTracksinShowers(), CandEventHandle::SetCandSlice(), and SetPrimaryShowers(). 00072 {
00073
00074 assert(cx.GetDataIn());
00075 if (!(cx.GetDataIn()->InheritsFrom("TObjArray"))) return;
00076
00077 CandContext cxx(this,cx.GetMom());
00078 AlgFactory &af = AlgFactory::GetInstance();
00079 const char *pEventAlgConfig = 0;
00080 ac.Get("EventAlgConfig",pEventAlgConfig);
00081 AlgHandle ah = af.GetAlgHandle("AlgEventSR",pEventAlgConfig);
00082 // grab all needed algorithm parameters
00083 Double_t pTrkTrkDtpos2 = ac.GetDouble("TrkTrkDtpos2");
00084 Double_t pTrkTrkDz = ac.GetDouble("TrkTrkDz");
00085 Double_t pTrkTrkDt = ac.GetDouble("TrkTrkDt");
00086 Double_t pShwTrkDtpos2 = ac.GetDouble("ShwTrkDtpos2");
00087 Double_t pShwTrkDz = ac.GetDouble("ShwTrkDz");
00088 Double_t pShwTrkDt = ac.GetDouble("ShwTrkDt");
00089 Double_t pShwShwDtpos2 = ac.GetDouble("ShwShwDtpos2");
00090 Double_t pShwShwDz = ac.GetDouble("ShwShwDz");
00091 Double_t pShwShwDt = ac.GetDouble("ShwShwDt");
00092 Double_t pMaxNewShwLen = ac.GetDouble("MaxNewShwLen");
00093 Double_t pHitAssocDTime0 = ac.GetDouble("HitAssocDTime0");
00094 Double_t pHitAssocDTime1 = ac.GetDouble("HitAssocDTime1");
00095 Double_t pHitAssocMaxDist2 = ac.GetDouble("HitAssocMaxDist2");
00096
00097 // grab all needed input lists
00098 const CandRecord *candrec = cx.GetCandRecord();
00099 assert(candrec);
00100 const VldContext *vldcptr = candrec->GetVldContext();
00101 assert(vldcptr);
00102 VldContext vldc = *vldcptr;
00103 const CandSliceListHandle *slicelist = 0;
00104 CandShowerListHandle *showerlist = 0;
00105 const CandTrackListHandle *tracklist = 0;
00106 CandClusterListHandle *clusterlist = 0;
00107 const TObjArray *cxin =
00108 dynamic_cast<const TObjArray *>(cx.GetDataIn());
00109 for (Int_t i=0; i<=cxin->GetLast(); i++) {
00110 TObject *tobj = cxin->At(i);
00111 if (tobj->InheritsFrom("CandSliceListHandle")) {
00112 slicelist = dynamic_cast<CandSliceListHandle*>(tobj);
00113 }
00114 if (tobj->InheritsFrom("CandShowerListHandle")) {
00115 showerlist = dynamic_cast<CandShowerListHandle*>(tobj);
00116 }
00117 if (tobj->InheritsFrom("CandTrackListHandle")) {
00118 tracklist = dynamic_cast<CandTrackListHandle*>(tobj);
00119 }
00120 if (tobj->InheritsFrom("CandClusterListHandle")) {
00121 clusterlist = dynamic_cast<CandClusterListHandle*>(tobj);
00122 }
00123 }
00124 if (!slicelist) {
00125 MSG("EventSR",Msg::kError) << "CandSliceListHandle missing\n";
00126 return;
00127 }
00128
00129 CandShowerHandleItr * showerItr=0;
00130 // create iterators for track, shower, and cluster lists, keying on slice
00131 if (showerlist && showerlist->GetNDaughters()>0) {
00132 showerItr = new CandShowerHandleItr(showerlist->GetDaughterIterator());
00133 CandShowerHandleKeyFunc *showerKf = showerItr->CreateKeyFunc();
00134 showerKf->SetFun(CandShowerHandle::KeyFromSlice);
00135 showerItr->GetSet()->AdoptSortKeyFunc(showerKf);
00136 showerKf = 0;
00137 }
00138
00139 CandTrackHandleItr * trackItr = 0;
00140 if (tracklist && tracklist->GetNDaughters()>0) {
00141 trackItr = new CandTrackHandleItr(tracklist->GetDaughterIterator());
00142 CandTrackHandleKeyFunc *trackKf = trackItr->CreateKeyFunc();
00143 trackKf->SetFun(CandTrackHandle::KeyFromSlice);
00144 trackItr->GetSet()->AdoptSortKeyFunc(trackKf);
00145 trackKf = 0;
00146 }
00147
00148 CandClusterHandleItr * clusterItr = 0;
00149 if (clusterlist && clusterlist->GetNDaughters()>0) {
00150 clusterItr = new CandClusterHandleItr(clusterlist->GetDaughterIterator());
00151 CandClusterHandleKeyFunc *clusterKf = clusterItr->CreateKeyFunc();
00152 clusterKf->SetFun(CandClusterHandle::KeyFromSlice);
00153 clusterItr->GetSet()->AdoptSortKeyFunc(clusterKf);
00154 clusterKf = 0;
00155 }
00156
00157 Int_t nslice=0;
00158
00159 // loop over slices
00160 CandSliceHandleItr sliceItr(slicelist->GetDaughterIterator());
00161 while (CandSliceHandle *slice =
00162 dynamic_cast<CandSliceHandle*>(sliceItr())) { //loop over slices
00163
00164 ++nslice;
00165 MSG("EventSR", Msg::kDebug)
00166 << " ****** Slice " << nslice << " *******"
00167 << endl;
00168
00169 TObjArray recolist;
00170 TObjArray eventlist;
00171
00172 //construct list of all showers and tracks in this slice
00173 FillRecoList(slice,showerItr,trackItr,recolist);
00174
00175 // remove tracks in recolist which have few/any isolated hits
00176 RemoveTracksinShowers(ac,&recolist);
00177
00178 MSG("EventSR",Msg::kVerbose)
00179 << "recolist begin " << recolist.GetLast()+1 << "\n";
00180 // loop over shower+tracklist, and find associations
00181 for (Int_t i=0; i<=recolist.GetLast(); i++) {
00182 //determine whether this entry is shower or track
00183 CandShowerHandle *shower=0;
00184 CandTrackHandle *track=0;
00185 CandRecoHandle *reco=0;
00186 if (recolist.At(i)->InheritsFrom("CandShowerHandle")) {
00187 shower = dynamic_cast<CandShowerHandle*>(recolist.At(i));
00188 reco = shower;
00189 MSG("EventSR",Msg::kVerbose) << " shower " << reco->GetVtxU()
00190 << " " << reco->GetVtxV() << " "
00191 << reco->GetVtxZ() << "\n";
00192 }
00193 if (recolist.At(i)->InheritsFrom("CandTrackHandle")) {
00194 track = dynamic_cast<CandTrackHandle*>(recolist.At(i));
00195 reco = track;
00196 MSG("EventSR",Msg::kVerbose) << " track " << reco->GetVtxU()
00197 << " " << reco->GetVtxV() << " "
00198 << reco->GetVtxZ() << "\n";
00199 }
00200
00201 // now loop over events previously created
00202 // and see whether this object should be added
00203 Bool_t merge=false;
00204 TObjArray *prevlist=0;
00205 for (Int_t ievt=0; ievt<=eventlist.GetLast(); ievt++) {
00206 Bool_t thiseventmatches=false;
00207 TObjArray *objectlist = dynamic_cast<TObjArray*>(eventlist.At(ievt));
00208 // loop over objects within this event
00209 for (Int_t ireco=0; !thiseventmatches && ireco<=objectlist->GetLast(); ireco++) {
00210 Bool_t match=false;
00211 if (objectlist->At(ireco)->InheritsFrom("CandShowerHandle")) {
00212 CandShowerHandle *target = dynamic_cast<CandShowerHandle*>
00213 (objectlist->At(ireco));
00214 if(shower) {
00215 match = target->BelongsWithShower(shower,ac,vldcptr,
00216 pShwShwDtpos2,
00217 pShwShwDz,pShwShwDt);
00218 }
00219 if(track) {
00220 match = target->BelongsWithTrack(track,ac,vldcptr,
00221 pShwTrkDtpos2,
00222 pShwTrkDz,pShwTrkDt);
00223 match = match && MatchOtherTracksInEvent(ac,vldcptr,track,objectlist);
00224 }
00225 }
00226 else if (objectlist->At(ireco)->InheritsFrom("CandTrackHandle")) {
00227 CandTrackHandle *target = dynamic_cast<CandTrackHandle*>
00228 (objectlist->At(ireco));
00229 if(shower) {
00230 match = target->BelongsWithShower(shower,ac,vldcptr,
00231 pShwTrkDtpos2,
00232 pShwTrkDz,pShwTrkDt);
00233 }
00234 if(track) {
00235 match = target->BelongsWithTrack(track,ac,vldcptr,
00236 pTrkTrkDtpos2,
00237 pTrkTrkDz,pTrkTrkDt);
00238 match = match && MatchOtherTracksInEvent(ac,vldcptr,track,objectlist);
00239 }
00240 }
00241 if(match){
00242 thiseventmatches = true;
00243 MSG("EventSR",Msg::kVerbose)
00244 << " adding object to event \n";
00245 AddObjectToEvent(reco,objectlist,prevlist,merge);
00246 if(!merge) prevlist=objectlist;
00247 merge=true;
00248 }
00249 } // end loop over objects in event
00250 } // end loop over event list
00251 // we found no matches for this object, so start a new event
00252 if (!merge) {
00253 Bool_t pass=true;
00254 if (shower) {
00255 MSG("EventSR",Msg::kVerbose)
00256 << " none found, creating event for shower\n";
00257 }
00258
00259 if (track) {
00260 MSG("EventSR",Msg::kVerbose)
00261 << " none found, creating event for track\n";
00262 }
00263
00264 if(pass){
00265 TObjArray *event = new TObjArray;
00266 event->Add(recolist.At(i));
00267 eventlist.Add(event);
00268 }
00269 }
00270 } // end loop over recolist
00271
00272 // remove all empty events from event list
00273 for (Int_t i=0; i<=eventlist.GetLast(); i++) {
00274 TObjArray *objectlist = dynamic_cast<TObjArray*>(eventlist.At(i));
00275 if (objectlist->GetLast()<0) {
00276 eventlist.Remove(objectlist);
00277 }
00278 }
00279 eventlist.Compress();
00280
00281 // merge showers in NC events
00282 MergeShowers(cxx, eventlist,ac,slice,clusterlist,showerlist);
00283
00284 // now make CandEvents for each event we have found
00285 Bool_t buildEvent=false;
00286 for (Int_t i=0; i<=eventlist.GetLast(); i++) {
00287 TObjArray *objectlist = dynamic_cast<TObjArray*>(eventlist.At(i));
00288 MSG("EventSR",Msg::kVerbose) << "making event of "
00289 << objectlist->GetLast()+1
00290 << " objects \n";
00291 cxx.SetDataIn(objectlist);
00292 buildEvent=true;
00293 CandEventHandle eventhandle = CandEvent::MakeCandidate(ah,cxx);
00294 MSG("EventSR",Msg::kVerbose) << " # of strips: "
00295 << eventhandle.GetNDaughters() << "\n";
00296 eventhandle.SetCandSlice(slice);
00297 ch.AddDaughterLink(eventhandle);
00298 delete eventlist.At(i);
00299 }
00300 if (!buildEvent) BuildEventFromUnassoc(ac,ch,cx,slice);
00301 }
00302
00303 delete trackItr;
00304 delete showerItr;
00305 delete clusterItr;
00306
00307 MSG("EventSR",Msg::kVerbose) << "starting unassociated hits assignment \n";
00308
00309 // find unassociated hits, and place them in tobjarray
00310 sliceItr.Reset();
00311 TObjArray unassociated;
00312 CandShowerHandleItr * showerItr2=0;
00313 CandTrackHandleItr * trackItr2=0;
00314 CandEventListHandle &eventlist = dynamic_cast<CandEventListHandle &>(ch);
00315 CandEventHandleItr * eventItr2=0;
00316 if (showerlist && showerlist->GetNDaughters()>0) {
00317 showerItr2 = new CandShowerHandleItr(showerlist->GetDaughterIterator());
00318 }
00319 if (tracklist && tracklist->GetNDaughters()>0) {
00320 trackItr2 = new CandTrackHandleItr(tracklist->GetDaughterIterator());
00321 }
00322 if (eventlist.GetNDaughters()>0) {
00323 eventItr2 = new CandEventHandleItr(eventlist.GetDaughterIterator());
00324 }
00325 FindUnassociated(sliceItr,eventItr2, unassociated);
00326 delete trackItr2;
00327 delete showerItr2;
00328 delete eventItr2;
00329
00330 // reset primary shower assignment for each event (is this needed?)
00331 SetPrimaryShowers(ch,ac);
00332
00333 // now loop over unnassociated hits, and check for adjacency with all
00334 // showers, and track vertices (in the case that no shower exists).
00335 // If a match is found in the former case,
00336 // add strip to shower. In the latter case, create a new shower.
00337
00338 // this map contains the separation between each event/unassociated hit
00339 vector<map<const CandEventHandle*, Double_t> > dist2map(unassociated.GetLast()+1);
00340 FillDist2Map(ac,unassociated,ch,dist2map);
00341
00342 vector<Bool_t> alreadyUsed(unassociated.GetLast()+1);
00343 for (Int_t i=0; i<=unassociated.GetLast(); i++) alreadyUsed[i] = false;
00344
00345 // loop over unnassociated hits, adding them to events.
00346 // After each loop the affected distance map entries are recalculated,
00347 // and the loop is repeated. This continues until a loop adds no strips.
00348 Bool_t found=true;
00349 Int_t n_found=0;
00350 while (found) {
00351 // found indicates whether a strip was added to an event in this loop
00352 found=false;
00353
00354 CandStripHandle *closeststrip= 0;
00355 CandEventHandle *closestevent= 0;
00356 Double_t closestdist2 = 9999999.;
00357 Int_t closesti=-1;
00358
00359 // loop over unassoc strips
00360 for (Int_t i=0; i<=unassociated.GetLast(); i++) {
00361 if(alreadyUsed[i]) continue;
00362
00363 CandStripHandle *strip =
00364 dynamic_cast<CandStripHandle*>(unassociated.At(i));
00365
00366 CandEventHandle *bestevent = 0;
00367 Double_t bestdist2 = 9999999.;
00368 // loop over events, and find event which is closest to strip
00369 // and in time
00370 TIter eventItr(ch.GetDaughterIterator());
00371 while (CandEventHandle *event =
00372 dynamic_cast<CandEventHandle*>(eventItr())) {
00373 Double_t dtime = strip->GetBegTime()-event->GetVtxT();
00374 if (dtime>pHitAssocDTime0 && dtime<pHitAssocDTime1
00375 && (!bestevent || dist2map[i][event]<bestdist2)) {
00376 bestevent = event;
00377 bestdist2 = dist2map[i][event];
00378 }
00379 }
00380 if (bestevent && (!closeststrip || bestdist2<closestdist2)) {
00381 closeststrip = strip;
00382 closesti=i;
00383 closestdist2 = bestdist2;
00384 closestevent = bestevent;
00385 }
00386 }
00387 MSG("EventSR",Msg::kVerbose)<< "closest strip " << closestdist2
00388 << "/"<<pHitAssocMaxDist2<< endl;
00389
00390 // if distance to closest event less than maximum allowable add to event
00391 if(closeststrip && closestevent && closestdist2<pHitAssocMaxDist2){
00392
00393 MSG("EventSR",Msg::kVerbose) << "closest strip "
00394 << closeststrip->GetPlane() << " "
00395 << closeststrip->GetTPos()
00396 << " " << closestdist2 << "\n";
00397
00398 alreadyUsed[closesti] = true;
00399 found=true;
00400 ++n_found;
00401
00402 // now either add this strip to existing primary shower, or
00403 // create a new shower at the track vertex if one does not exist
00404 // Get PrimaryShower CandHandle from fShowerList for modification.
00405 CandShowerHandle *shower = 0;
00406 if (CandShowerHandle *primsh = closestevent->GetPrimaryShower()) {
00407 for (Int_t ishower=0; !shower &&
00408 ishower<closestevent->GetLastShower()+1; ishower++) {
00409 const CandShowerHandle *target =
00410 closestevent->GetShower(ishower);
00411 if (primsh->IsCloneOf(*target)) // Tests clone or Cand ==
00412 shower = closestevent->GetShowerWritable(ishower);
00413 }
00414 }
00415
00416 Float_t minShwPlane=0;
00417 Float_t maxShwPlane=0;
00418 if(shower){
00419 minShwPlane=min(shower->GetVtxPlane(),shower->GetEndPlane());
00420 maxShwPlane=max(shower->GetVtxPlane(),shower->GetEndPlane());
00421 }
00422 Float_t vertexsep = 0;
00423 CandTrackHandle *track = closestevent->GetPrimaryTrack();
00424 if (shower && track) {
00425 vertexsep = abs(shower->GetBegPlane() - track->GetBegPlane());
00426 vertexsep *= PITCHINMETRES;
00427 MSG("EventSR",Msg::kVerbose) << "Found track and primary shower. \n"
00428 << "Vertex separation (limit) = "
00429 << vertexsep << "("
00430 << pShwTrkDz << ")" << " \n";
00431 }
00432 // if event has shower and either no track, or shower is close
00433 // to track vertex, add this hit to the shower which was
00434 // compared in position to this strip earler.
00435 if (shower && (!track || vertexsep<pShwTrkDz)) {
00436
00437 // NOTE: CandShowerHandle *shower, used to modify CandShower, is owned
00438 // by fShowerList.
00439 // add new strip to this shower, and the appropriate cluster
00440 if(closeststrip->GetPlane()>minShwPlane-pMaxNewShwLen &&
00441 closeststrip->GetPlane()<maxShwPlane+pMaxNewShwLen ){
00442
00443 MSG("EventSR",Msg::kVerbose) << "adding strip to shower \n";
00444 AddStripToEvent(closestevent,shower,clusterlist,closeststrip);
00445 }
00446 }
00447
00448 // no shower consistent with track vertex, and this strip
00449 // is close to vertex, so start new shower.
00450 else if (track) {
00451 CreatePrimaryShower(ac,cxx,closestevent,showerlist,
00452 clusterlist,closeststrip);
00453 }
00454
00455 // need to recalculate distances bewteen remaining
00456 // unassoc hits and this modified event, if the added strip
00457 // results in a smaller separation, replace value in dist2map
00458 ReFillDist2Map(ac,closeststrip,closestevent,unassociated,dist2map);
00459 } // if adding strip to event in form of new shower
00460 } // if found (if an unassoc hit was matched to event in last loop over them
00461
00462 // because we have added strips to previously constructed showers, their
00463 // runalg method should be run on them again. In the future, an
00464 // optimization would be to do this only on showers which have been
00465 // touched.
00466 MSG("EventSR",Msg::kVerbose) << "added " << n_found << " of "
00467 << unassociated.GetLast()+1
00468 << " unassociated hits " << endl;
00469
00470 cxx.SetDataIn(showerlist); // Pass along persistable CandShowerList
00471 ReConstructShowers(ac,ch,cxx);
00472
00473 // For each event, we set it's primary shower to that which has the
00474 // highest energy.
00475
00476 SetPrimaryShowers(ch,ac);
00477 }
|
|
||||||||||||
|
Redetermine primary shower for each event. If the largest shower is greater than shwshwdz from the track vertex, and the closest shower has energy greater than minshwEfract call the closest shower the primary, otherwise the largest shower is the primary Definition at line 770 of file AlgEventSRList.cxx. References CandHandle::GetDaughterIterator(), Registry::GetDouble(), and CandEventHandle::SetPrimaryShower(). Referenced by RunAlg(). 00771 {
00772
00773 // This method loops over events in the eventlist, finding the largest
00774 // shower and setting that to the primary shower in the event.
00775
00776 Double_t pShwShwDz = ac.GetDouble("ShwShwDz");
00777 Double_t pMinShwEFract = ac.GetDouble("MinShwEFract");
00778
00779 TIter evItr(ch.GetDaughterIterator());
00780 while (CandEventHandle *ev =
00781 dynamic_cast<CandEventHandle*>(evItr())) {
00782 ev->SetPrimaryShower(pMinShwEFract,pShwShwDz);
00783 }
00784 }
|
|
|
Reimplemented from AlgBase. Definition at line 1722 of file AlgEventSRList.cxx. 01723 {
01724 }
|
1.3.9.1