Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

AlgAtmosShowerList Class Reference

#include <AlgAtmosShowerList.h>

Inheritance diagram for AlgAtmosShowerList:

AlgBase List of all members.

Public Member Functions

 AlgAtmosShowerList ()
virtual ~AlgAtmosShowerList ()
virtual void RunAlg (AlgConfig &ac, CandHandle &ch, CandContext &cx)
virtual void Trace (const char *c) const
void RunTheFinder (CandSliceHandle *slice, const CandTrackListHandle *tracklist)
void FormTheHits (CandSliceHandle *slice)
void FormTheClusters ()
void IDTrkAndShwClusters ()
void FormDummyTracks (CandSliceHandle *slice, const CandTrackListHandle *tracklist)
void FindShowerLikeSegments ()
void DetermineShowerLikeShowerSegments ()
void Form2DShowers ()
void MatchShowers ()
void Form3DShowers (CandSliceHandle *slice)
void FormVertexShowers (CandSliceHandle *slice)

Private Attributes

vector< HitCamAtNu * > HitBank [500]
vector< ClusterCamAtNu * > ClusterBank [500]
vector< TrackSegmentCamAtNu * > SegmentBank [500]
vector< ShowerSegmentCamAtNu * > ShowerSegmentBank
vector< ShowerSegmentCamAtNu * > ShowerViewSegBank [2]
vector< ShowerSegmentCamAtNu * > ShowersFound [2]
vector< ShowerCamAtNu * > ShowerBank [2]
vector< TrackSegmentCamAtNu * > TempTrack [2]
vector< TrackCamAtNu * > FinalTrackBank [2]
VldContextvldc
int NumModules
int PlanesInModule
int ModuleType

Constructor & Destructor Documentation

AlgAtmosShowerList::AlgAtmosShowerList  ) 
 

Definition at line 50 of file AlgAtmosShowerList.cxx.

00051 {
00052 }

AlgAtmosShowerList::~AlgAtmosShowerList  )  [virtual]
 

Definition at line 57 of file AlgAtmosShowerList.cxx.

00058 {
00059 }


Member Function Documentation

void AlgAtmosShowerList::DetermineShowerLikeShowerSegments  ) 
 

Definition at line 687 of file AlgAtmosShowerList.cxx.

References ShowerSegmentCamAtNu::GetBegPlane(), ShowerSegmentCamAtNu::GetCluster(), ShowerSegmentCamAtNu::GetEndPlane(), ShowerSegmentCamAtNu::GetEntries(), ClusterCamAtNu::GetShwFlag(), ClusterCamAtNu::GetShwPlnFlag(), ClusterCamAtNu::GetTrkFlag(), ShowerSegmentCamAtNu::GetUID(), ShowerSegmentCamAtNu::SetUID(), and ShowerViewSegBank.

Referenced by RunTheFinder().

00688 {
00689   
00690   vector<ShowerSegmentCamAtNu*> mysegbnk2;
00691   int trkctr,shwctr,plnctr;
00692 
00693   // Initially set Segment UIDs based on Cluster Trk and Shw Flags
00695   for(unsigned int View=0;View<2;View++)
00696     {
00697       for(unsigned int i=0;i<ShowerViewSegBank[View].size();i++)
00698         {
00699           ShowerSegmentCamAtNu* seg = ShowerViewSegBank[View][i];
00700           trkctr=0; shwctr=0; plnctr=0; 
00701           for(unsigned int j=0;j<seg->GetEntries();j++)
00702             {
00703               ClusterCamAtNu* clr = seg->GetCluster(j);
00704               if(clr->GetShwFlag()>1)
00705                 { 
00706                   shwctr++; 
00707                   if(clr->GetTrkFlag()<2) trkctr++; 
00708                 }
00709               if(clr->GetShwPlnFlag()>0){ plnctr++; } 
00710             }
00711           if( plnctr>-1 )
00712             {
00713               if(trkctr>-1) seg->SetUID(1); 
00714               if(trkctr>0) seg->SetUID(2);
00715             }
00716         }
00717     }
00718 
00719   // Store overlapping U and V segments
00721   for(unsigned int i=0;i<ShowerViewSegBank[0].size();i++)
00722     {
00723       ShowerSegmentCamAtNu* segu = ShowerViewSegBank[0][i];
00724       for(unsigned int j=0;j<ShowerViewSegBank[1].size();j++)
00725         {
00726           ShowerSegmentCamAtNu* segv = ShowerViewSegBank[1][j];
00727           if( segu->GetBegPlane()-2<segv->GetEndPlane() && segu->GetEndPlane()>segv->GetBegPlane()-2 && segu->GetUID()>0 && segv->GetUID()>0 )
00728             {
00729               if(segv->GetUID()>1) mysegbnk2.push_back(segu); 
00730               if(segu->GetUID()>1) mysegbnk2.push_back(segv); 
00731             }
00732         }
00733     }
00734 
00735   // Set UIDs to 2 for stored segments
00737   for(unsigned int i=0;i<mysegbnk2.size();i++)
00738     {
00739       mysegbnk2[i]->SetUID(2);
00740     }
00741   
00742   mysegbnk2.clear();
00743   return;
00744 }

void AlgAtmosShowerList::FindShowerLikeSegments  ) 
 

Definition at line 589 of file AlgAtmosShowerList.cxx.

References ShowerSegmentCamAtNu::AddCluster(), ClusterBank, ShowerSegmentCamAtNu::GetBegPlane(), ShowerSegmentCamAtNu::GetBegTPos(), ShowerSegmentCamAtNu::GetEndPlane(), ShowerSegmentCamAtNu::GetEndTPos(), ShowerSegmentCamAtNu::GetPlaneView(), ClusterCamAtNu::GetShwFlag(), ClusterCamAtNu::GetTrkPlnFlag(), ShowerSegmentCamAtNu::IsShwLikeAssoc(), MSG, PlanesInModule, ClusterCamAtNu::SetShwFlag(), ShowerSegmentBank, and ShowerViewSegBank.

Referenced by RunTheFinder().

00590 {
00591   // Does what it says in the title
00592 
00593   int ShwAssocNum, Counter, pln0, npln, i, k0;
00594   unsigned int nclusters, nclusters1;
00595   int View;
00596 
00597   //
00599   for(int Module=0; Module<NumModules; ++Module) {
00600     for(int Plane=1; Plane<PlanesInModule+1; ++Plane) {
00601       i=Plane + Module*(PlanesInModule+1);
00602 
00603       nclusters = ClusterBank[i].size();
00604 
00605       for(unsigned int j=0; j<nclusters; ++j) {
00606         ClusterCamAtNu* Clust0 = ClusterBank[i][j];
00607 
00608         // Consider likely clusters
00609         if(Clust0->GetShwFlag()==1 && Clust0->GetTrkPlnFlag()!=2) {
00610           
00611           ShowerSegmentCamAtNu* ShwLikeSeg = new ShowerSegmentCamAtNu(0,Clust0,0);
00612           Clust0->SetShwFlag(2); Counter=1;
00613           
00614           while(Counter>0) {
00616             Counter=0;
00617             
00618             pln0 = -2 + ShwLikeSeg->GetBegPlane(); // Previous plane in view
00619             npln = 3 + (ShwLikeSeg->GetEndPlane()-ShwLikeSeg->GetBegPlane())/2; // Span of planes in view
00620             
00621             // Loop over nearby planes in view
00623             for(int k=0; k<npln; ++k) {
00624               k0=pln0+(2*k);
00625               
00626               if(k0>Module*(PlanesInModule+1) && k0<(Module+1)*(PlanesInModule+1)) {
00627                 nclusters1=ClusterBank[k0].size();
00628 
00629                 // Loop over clusters on nearby plane
00631                 for(unsigned int k1=0; k1<nclusters1; ++k1) {
00632                   ClusterCamAtNu* Clust1 = ClusterBank[k0][k1];
00633                   
00634                   if(Clust1->GetShwFlag()>0 && Clust1->GetShwFlag()<2 && Clust1->GetTrkPlnFlag()!=2) {
00635                     ShwAssocNum=ShwLikeSeg->IsShwLikeAssoc(Clust1);
00636                     
00637                     if(ShwAssocNum>0) {
00638                       ShwLikeSeg->AddCluster(Clust1);
00639                       Clust1->SetShwFlag(2); 
00640                       Counter++;
00641                     }
00642                   }
00643                 }
00645               }
00646             }
00648           } 
00650           View = ShwLikeSeg->GetPlaneView(); ShowerViewSegBank[View].push_back(ShwLikeSeg);
00651           ShowerSegmentBank.push_back(ShwLikeSeg);
00652           //delete ShwLikeSeg;
00653         }
00654       } // End loop over clusters on plane
00655     } 
00656   } 
00658   MSG("AlgAtmosShowerList", Msg::kVerbose) << " *** FindShowerSegments() *** " << endl;
00659   MSG("AlgAtmosShowerList", Msg::kVerbose) << " *** 2ND LIST OF CLUSTERS *** " << endl;
00660   for(int i=0; i<500; ++i){
00661     for(unsigned int j=0; j<ClusterBank[i].size(); ++j) {
00662       MSG("AlgAtmosShowerList", Msg::kVerbose)
00663         << " plane="    << ClusterBank[i][j]->GetPlane() 
00664         << " begtpos="  << ClusterBank[i][j]->GetBegTPos() 
00665         << " endtpos="  << ClusterBank[i][j]->GetEndTPos() 
00666         << " trkflag="  << ClusterBank[i][j]->GetTrkFlag()
00667         << " shwpln="   << ClusterBank[i][j]->GetShwPlnFlag() 
00668         << " trkpln="   << ClusterBank[i][j]->GetTrkPlnFlag()
00669         << " shwflag="  << ClusterBank[i][j]->GetShwFlag() << endl;
00670     }
00671   }
00672 
00673   MSG("AlgAtmosShowerList", Msg::kVerbose) << " *** LIST OF SHOWER SEGMENTS *** " << endl;
00674   for(unsigned int j=0;j<ShowerSegmentBank.size(); ++j) {
00675     ShowerSegmentCamAtNu* seg = ShowerSegmentBank[j];
00676     MSG("AlgAtmosShowerList", Msg::kVerbose) << "Beg(Plane,Tpos) = (" << seg->GetBegPlane() << "," << seg->GetBegTPos() << 
00677       ") -> End(Plane,Tpos) = (" << seg->GetEndPlane() << ","  << seg->GetEndTPos() << ") " << endl;
00678   }
00679 
00680 }

void AlgAtmosShowerList::Form2DShowers  ) 
 

Definition at line 751 of file AlgAtmosShowerList.cxx.

References ShowerSegmentCamAtNu::AddCluster(), ShowerSegmentCamAtNu::AddSegment(), ClusterBank, ShowerSegmentCamAtNu::GetBegPlane(), ShowerSegmentCamAtNu::GetBegStrip(), ShowerSegmentCamAtNu::GetCluster(), ShowerSegmentCamAtNu::GetEndPlane(), ShowerSegmentCamAtNu::GetEndStrip(), ShowerSegmentCamAtNu::GetEntries(), ShowerSegmentCamAtNu::GetNHits(), ClusterCamAtNu::GetPlane(), ClusterCamAtNu::GetShwFlag(), ClusterCamAtNu::GetShwPlnFlag(), ClusterCamAtNu::GetTrkFlag(), ClusterCamAtNu::GetTrkPlnFlag(), ShowerSegmentCamAtNu::GetUID(), ShowerSegmentCamAtNu::IsShwAssoc(), MSG, PlanesInModule, ClusterCamAtNu::SetShwFlag(), ShowerSegmentCamAtNu::SetUID(), and ShowerViewSegBank.

Referenced by RunTheFinder().

00752 {
00753 
00754   // *************************************************
00755   // * F O R M A T I O N   O F   2 D   S H O W E R S *
00756   // *************************************************
00757   vector<ShowerSegmentCamAtNu*> FirstChoiceSegments,SecondChoiceSegments;
00758   MSG("AlgAtmosShowerList", Msg::kVerbose) << " *** formation of 2D showers *** " << endl;
00759   int nshws,maxshws,showerclusters,ObjectsAdded,npln,id,pln0,k0,npts,Module,assoc;
00760   bool FoundPrimarySegment(false);
00761   double topscore,score;
00762   unsigned int ShowerSegmentsInView,clustersinsegment;
00763   if(ShowerViewSegBank[0].size()>0 && ShowerViewSegBank[1].size()>0)
00764     {//assuming we have any shower segments loop over the views
00765       for(int View=0;View<2;View++)
00766         {
00767           ShowerSegmentsInView=ShowerViewSegBank[View].size();
00768           FoundPrimarySegment=true; nshws=0; maxshws=4;
00769           // Build Showers around primary segments
00771           while(FoundPrimarySegment)
00772             {
00773               FoundPrimarySegment=false;
00774               
00775               // Select segments
00777               FirstChoiceSegments.clear(); 
00778               SecondChoiceSegments.clear();
00779               
00780               for(unsigned int i=0;i<ShowerSegmentsInView;i++)
00781                 {
00782                   ShowerSegmentCamAtNu* seg = ShowerViewSegBank[View][i];
00783                   if(seg->GetUID()>0 && seg->GetUID()<3)
00784                     {
00785                       showerclusters=0; clustersinsegment=seg->GetEntries();
00786                       for(unsigned int j=0;j<clustersinsegment;j++)
00787                         {
00788                           ClusterCamAtNu* cluster = seg->GetCluster(j);
00789                           if( cluster->GetShwPlnFlag()>0 && cluster->GetShwFlag()==2 ) { showerclusters++; }
00790                         }
00791                       if( nshws>0 && showerclusters<1 ) { seg->SetUID(0); }
00792                     }
00793                   if(seg->GetUID()==2) { FirstChoiceSegments.push_back(seg); } 
00794                   if(seg->GetUID()==1) { SecondChoiceSegments.push_back(seg); }
00795                 }
00796               
00797               // If there were no segments with UID 2 use those with UID 1
00799               if(FirstChoiceSegments.size()==0) { FirstChoiceSegments=SecondChoiceSegments; } 
00800               
00801               // Determine primary segment
00803               npln=0; id=-1; topscore=0.0;
00804               for(unsigned int i=0;i<FirstChoiceSegments.size();i++)
00805                 {
00806                   ShowerSegmentCamAtNu* seg = FirstChoiceSegments[i];
00807                   npts = 1+(seg->GetEndPlane()-seg->GetBegPlane())/2;        
00808                   if(npts>npln-3)
00809                     {
00810                       score=seg->GetNHits();
00811                       if(npts>npln || score>topscore) 
00812                         {
00813                           //which one is picked depends on the order we loop through the clusters!
00814                           //EG compare Seg1(npts=3; nhits=10;) and Seg2(npts=2; nhits=16;)
00815                           //if we loop through Seg1 then Seg2 then we pick Seg2,
00816                           //if we loop through Seg2 then Seg1 then we pick Seg1!
00817                           npln=npts; topscore=score; 
00818                           id=i;
00819                         }
00820                     }
00821                 }
00822               
00823               // Propagate the primary segment if one was found
00825               if(id>-1)
00826                 {
00827                   ShowerSegmentCamAtNu* seg0 = FirstChoiceSegments[id];
00828                   FoundPrimarySegment=true; 
00829                   nshws++; seg0->SetUID(3); 
00830                   Module=(int)((seg0->GetEndPlane())/(PlanesInModule+1));
00831                   
00832                   ObjectsAdded=1;
00833                   while(ObjectsAdded>0)
00834                     {
00835                       ObjectsAdded=0;
00836                       
00837                       // Add associated clusters 
00839                       pln0 = -4 + seg0->GetBegPlane();
00840                       npln = 5 + (seg0->GetEndPlane()-seg0->GetBegPlane())/2;
00841                       for(int k=0;k<npln;k++)
00842                         {
00843                           k0 = pln0+2*k;
00844                           if(k0>Module*(PlanesInModule+1) && k0<(Module+1)*(PlanesInModule+1))
00845                             {
00846                               for(unsigned int k1=0;k1<ClusterBank[k0].size();k1++)
00847                                 {
00848                                   ClusterCamAtNu* cluster1 = ClusterBank[k0][k1];
00849                                   if(cluster1->GetShwFlag()<2 && cluster1->GetTrkPlnFlag()!=2)
00850                                     {
00851                                       assoc=seg0->IsShwAssoc(cluster1);
00852                                       if( (assoc>0 && cluster1->GetTrkFlag()<3) || (assoc>1 && cluster1->GetPlane()-seg0->GetBegPlane()>0 && seg0->GetEndPlane()-cluster1->GetPlane()>0) )
00853                                         {
00854                                           seg0->AddCluster(cluster1); 
00855                                           cluster1->SetShwFlag(2); ObjectsAdded++;
00856                                         }
00857                                     }
00858                                 }
00859                             }
00860                         }
00861                       
00862                       // Add associated segments
00864                       for(unsigned int i=0;i<ShowerViewSegBank[View].size();i++)
00865                         {
00866                           ShowerSegmentCamAtNu* segtmp = ShowerViewSegBank[View][i];
00867                           if( segtmp->GetUID()>0 && segtmp->GetUID()<3 && (int)((segtmp->GetEndPlane())/(PlanesInModule+1))==Module )
00868                             {
00869                               assoc=seg0->IsShwAssoc(segtmp);
00870                               if(assoc>0)
00871                                 {
00872                                   seg0->AddSegment(segtmp); 
00873                                   segtmp->SetUID(-1); ObjectsAdded++;
00874                                 }
00875                             }
00876                         }
00877                     }//while(ObjectsAdded>0)
00878                   
00879                   for(unsigned int i=0;i<seg0->GetEntries();i++)
00880                     {
00881                       seg0->GetCluster(i)->SetShwFlag(3);
00882                     }
00883                   
00884                 }//if(id>-1)
00885               
00886             }//while(FoundPrimarySegment)
00887         }//end of loop over views
00888     }
00889   
00890   // Print out list of 2D showers
00891   MSG("AlgAtmosShowerList", Msg::kVerbose) << " *** LIST OF 2D SHOWERS *** " << endl;
00892   for(int View=0;View<2;View++)
00893     {
00894       MSG("AlgAtmosShowerList", Msg::kVerbose) << "view: " << View << endl;
00895       for(unsigned int i=0;i<ShowerViewSegBank[View].size();i++)
00896         {
00897           ShowerSegmentCamAtNu* segment = ShowerViewSegBank[View][i];
00898           if(segment->GetUID()>2)
00899             {
00900               MSG("AlgAtmosShowerList", Msg::kVerbose) << "  i=" << i
00901                                                     << "  begpln: " << segment->GetBegPlane()
00902                                                     << "  begstr: " << segment->GetBegStrip()
00903                                                     << "  endpln: " << segment->GetEndPlane()
00904                                                     << "  endstr: " << segment->GetEndStrip() << endl;
00905             }
00906         }
00907     }
00908   FirstChoiceSegments.clear(); SecondChoiceSegments.clear();
00909   return;
00910 }

void AlgAtmosShowerList::Form3DShowers CandSliceHandle slice  ) 
 

Definition at line 1251 of file AlgAtmosShowerList.cxx.

References ShowerCamAtNu::AddHit(), ShowerCamAtNu::GetBegPlane(), ShowerCamAtNu::GetBegStrip(), ShowerSegmentCamAtNu::GetCluster(), ShowerCamAtNu::GetEndPlane(), ShowerCamAtNu::GetEndStrip(), ClusterCamAtNu::GetEntries(), ShowerSegmentCamAtNu::GetEntries(), ClusterCamAtNu::GetHit(), ShowerCamAtNu::GetPartner(), ShowerSegmentCamAtNu::GetReseedFlag(), MSG, ShowerCamAtNu::SetPartner(), ShowerCamAtNu::SetReseedFlag(), HitCamAtNu::SetShwFlag(), ShowerBank, and ShowersFound.

Referenced by RunTheFinder().

01252 {
01253   // *************************************************
01254   // * F O R M A T I O N   O F   3 D   S H O W E R S *
01255   // *************************************************
01256   int jnflag2[2]={0,0};
01257   ShowerBank[0].clear(); ShowerBank[1].clear();
01258   // Form showers
01259   MSG("AlgAtmosShowerList", Msg::kDebug) << " *** formation of 3D showers *** " << endl;
01260   for(unsigned int i=0;i<ShowersFound[0].size();i++)
01261     {
01262       
01263       MSG("AlgAtmosShowerList", Msg::kVerbose) << " making shower " << i << endl;
01264       
01265       for(int View=0;View<2;View++)
01266         {
01267           ShowerSegmentCamAtNu* seg = ShowersFound[View][i];
01268           ShowerCamAtNu* shw = new ShowerCamAtNu(slice); 
01269           ShowerBank[View].push_back(shw);// NEWOBJCTR++;
01270           if( seg->GetReseedFlag() ) jnflag2[View]=1; 
01271           else jnflag2[View]=0;
01272           for(unsigned int j=0;j<seg->GetEntries();j++)
01273             {
01274               ClusterCamAtNu* cluster = seg->GetCluster(j);
01275               for(unsigned int k=0;k<cluster->GetEntries();k++)
01276                 {
01277                   HitCamAtNu* hit = cluster->GetHit(k);
01278                   shw->AddHit(hit); hit->SetShwFlag(2);
01279                 }
01280             }
01281         }
01282       ShowerCamAtNu* shwu = ShowerBank[0].back();
01283       ShowerCamAtNu* shwv = ShowerBank[1].back();
01284       shwu->SetPartner(shwv); shwv->SetPartner(shwu);
01285       
01286       if(jnflag2[0]>0 && jnflag2[1]>0)
01287         {
01288           shwu->SetReseedFlag(1); shwv->SetReseedFlag(1);
01289         } 
01290     }
01291   MSG("AlgAtmosShowerList", Msg::kVerbose) << " *** LIST 3D SHOWERS *** " << endl;
01292   for(int View=0;View<2;View++)
01293     {
01294       MSG("AlgAtmosShowerList", Msg::kVerbose) << "=================================================================================" << endl;
01295       MSG("AlgAtmosShowerList", Msg::kVerbose) << "view: " << View << endl;
01296       for(unsigned int i=0;i<ShowerBank[View].size();i++)
01297         {
01298           ShowerCamAtNu* shower = ShowerBank[View][i];
01299           ShowerCamAtNu* partner = shower->GetPartner();
01300           MSG("AlgAtmosShowerList", Msg::kVerbose) << "  i=" << i
01301                                                    << "  begpln: " << shower->GetBegPlane()
01302                                                    << "  begstr: " << shower->GetBegStrip()
01303                                                    << "  endpln: " << shower->GetEndPlane()
01304                                                    << "  endstr: " << shower->GetEndStrip() << endl;
01305           MSG("AlgAtmosShowerList", Msg::kVerbose) << "       begpln: " << partner->GetBegPlane()
01306                                                    << "  begstr: " << partner->GetBegStrip()
01307                                                    << "  endpln: " << partner->GetEndPlane()
01308                                                    << "  endstr: " << partner->GetEndStrip() << endl;
01309           MSG("AlgAtmosShowerList", Msg::kVerbose) << "=================================================================================" << endl;
01310         }
01311     }
01312   return;
01313 }

void AlgAtmosShowerList::FormDummyTracks CandSliceHandle slice,
const CandTrackListHandle tracklist
 

Definition at line 463 of file AlgAtmosShowerList.cxx.

References abs(), TrackSegmentCamAtNu::AddCluster(), ClusterBank, FinalTrackBank, CandRecoHandle::GetCandSlice(), CandHandle::GetDaughterIterator(), TrackCamAtNu::GetEntries(), TrackCamAtNu::GetHit(), CalHelpers::GetPlane(), HitCamAtNu::GetPlane(), CandStripHandle::GetPlane(), CandStripHandle::GetStrip(), CandRecoHandle::GetVtxDirCosZ(), CandRecoHandle::GetVtxPlane(), HitBank, CandHandle::IsEqual(), MSG, TrackSegmentCamAtNu::SetTrkFlag(), HitCamAtNu::SetTrkFlag(), and TempTrack.

Referenced by RunTheFinder().

00464 {
00465   MSG("AlgAtmosShowerList", Msg::kVerbose) << " *** FORM DUMMY TRACKS *** " << endl;
00466   if(!tracklist) { MSG("AlgAtmosShowerList", Msg::kVerbose) << " No tracklist so not forming any dummy tracks! " << endl; return; }
00467   //Loop over tracks
00468   unsigned int ncluster,ntrkhitsincluster;
00469   int Plane,Strp, VertexPlane;
00470   int View;
00471   double dsdz(1.0);
00472   vector<ClusterCamAtNu*> TrackClusters[2];
00473   TIter trackItr(tracklist->GetDaughterIterator());
00474   while(CandTrackHandle* track = dynamic_cast<CandTrackHandle*>(trackItr())) 
00475     {
00476       //find those in the current slice
00477       if( track->GetCandSlice()->IsEqual(slice) )// track->GetCandSlice()==slice) // for some reason these slices are always different - not sure why..
00478         {
00479           //MSG("AlgAtmosShowerList", Msg::kVerbose) << " Strips in CandTrack = " << track->GetNDaughters() << "," << endl;
00480           VertexPlane=track->GetVtxPlane();
00481           dsdz=1./fabs(track->GetVtxDirCosZ());
00482           //Now make TrackCamAtNu objects
00483           for(View=0; View<2; ++View) 
00484             {
00485               TrackCamAtNu* Trk = new TrackCamAtNu(slice);
00486               FinalTrackBank[View].push_back(Trk);
00487             }
00488           // Put the hits into the TrackCamAtNu objects
00489           TIter StripItr(track->GetDaughterIterator());
00490           while(CandStripHandle* strip = dynamic_cast<CandStripHandle*>(StripItr())) 
00491             {
00492               Plane = strip->GetPlane();
00493               Strp = strip->GetStrip();
00494               View = ( (Plane<249 && Plane%2==0) || (Plane>249 && Plane%2==1) )?0:1;
00495               for(unsigned int j=0; j<HitBank[Plane].size(); ++j)
00496                 {
00497                   if(HitBank[Plane][j]->GetStrip()==Strp) 
00498                     { 
00499                       HitBank[Plane][j]->SetTrkFlag(2);
00500                       FinalTrackBank[View].back()->AddHit(HitBank[Plane][j]); 
00501                       break; 
00502                     }
00503                 }
00504             }
00505           //MSG("AlgAtmosShowerList", Msg::kVerbose) << " Hits in Track = " << FinalTrackBank[0].back()->GetEntries()+FinalTrackBank[1].back()->GetEntries() << endl; 
00506           // Find the clusters which the HitCamAtNu objects belong to
00507           for(View=0; View<2; ++View) 
00508             {
00509               TrackCamAtNu* Trk = FinalTrackBank[View].back();
00510               for(unsigned int i=0; i<Trk->GetEntries(); ++i)
00511                 {
00512                   HitCamAtNu* hit = Trk->GetHit(i);
00513                   Plane = hit->GetPlane();
00514                   ncluster=ClusterBank[Plane].size();
00515                   for(unsigned int j=0; j<ncluster; ++j) 
00516                     {
00517                       if(ClusterBank[Plane][j]->ContainsHit(hit))
00518                         {
00519                           TrackClusters[View].push_back(ClusterBank[Plane][j]);
00520                           break;
00521                         }
00522                     }
00523                 }
00524             }
00525           //MSG("AlgAtmosShowerList", Msg::kVerbose) << " Clusters Found Containing Hits in Track (U View)= " << TrackClusters[0].size() << ", (V View) = " << TrackClusters[1].size() << endl;
00526           //check if we have found enough clusters to make the TrackSegments
00527           if(TrackClusters[0].size()>2 && TrackClusters[1].size()>2)
00528             {
00529               TrackSegmentCamAtNu* SegU = new TrackSegmentCamAtNu(TrackClusters[0][0], TrackClusters[0][1], TrackClusters[0][2]);
00530               TrackSegmentCamAtNu* SegV = new TrackSegmentCamAtNu(TrackClusters[1][0], TrackClusters[1][1], TrackClusters[1][2]);
00531               ncluster = TrackClusters[0].size();
00532               for(unsigned int j=3; j<ncluster; ++j) 
00533                 {
00534                   TrackClusters[0][j]->SetTrkFlag(2);
00535                   SegU->AddCluster(TrackClusters[0][j]);
00536                   //Also alter any other necessary properties of clusters at this point
00537                   ntrkhitsincluster=0;
00538                   if(TrackClusters[0][j]->GetCharge()/dsdz<50.0 || abs(VertexPlane-TrackClusters[0][j]->GetPlane())>5)
00539                     {
00540                       for(unsigned int k=0; k<TrackClusters[0][j]->GetEntries(); ++k)
00541                         {
00542                           if(TrackClusters[0][j]->GetHit(k)->GetTrkFlag()==2) {++ntrkhitsincluster;}
00543                         }
00544                     }
00545                   if(ntrkhitsincluster==TrackClusters[0][j]->GetEntries()) { TrackClusters[0][j]->SetTrkPlnFlag(2); }
00546                 }
00547               TempTrack[0].push_back(SegU);
00548               ncluster = TrackClusters[1].size();
00549               for(unsigned int j=3; j<ncluster; ++j) 
00550                 {
00551                   TrackClusters[1][j]->SetTrkFlag(2);
00552                   SegV->AddCluster(TrackClusters[1][j]);
00553                   //Also alter any other necessary properties of clusters at this point
00554                   ntrkhitsincluster=0;
00555                   if(TrackClusters[1][j]->GetCharge()/dsdz<50.0 || abs(VertexPlane-TrackClusters[1][j]->GetPlane())>5)
00556                     {
00557                       for(unsigned int k=0; k<TrackClusters[1][j]->GetEntries(); ++k)
00558                         {
00559                           if(TrackClusters[1][j]->GetHit(k)->GetTrkFlag()==2) {++ntrkhitsincluster;}
00560                         }
00561                     }
00562                   if(ntrkhitsincluster==TrackClusters[1][j]->GetEntries()) { TrackClusters[1][j]->SetTrkPlnFlag(2); }
00563                 }
00564               TempTrack[1].push_back(SegV);
00565               //MSG("AlgAtmosShowerList", Msg::kVerbose) <<" Clusters In TrackSegment = " << TempTrack[0].back()->GetEntries()+TempTrack[1].back()->GetEntries() << endl;
00566             }
00567           
00568         }// track is in current slice
00569     }
00570   TrackClusters[0].clear(); TrackClusters[1].clear();
00571   //MSG("AlgAtmosShowerList", Msg::kVerbose) << " From " << tracklist->GetNDaughters() << " CandTracks managed to make " << TempTrack[0].size() << " TrackSegmentCamAtNu objects in each view and " << FinalTrackBank[0].size() << " TrackCamAtNu objects in each view " << endl;
00572   return;
00573 }

void AlgAtmosShowerList::FormTheClusters  ) 
 

Definition at line 268 of file AlgAtmosShowerList.cxx.

References ClusterCamAtNu::AddHit(), ClusterBank, HitBank, ClusterCamAtNu::IsHitAssoc(), and PlanesInModule.

Referenced by RunTheFinder().

00269 {
00270   // For each plane where we stored hits, we look to form 1D clusters 
00271   // of these hits. This is controlled by the IsHitAssoc method in ClusterCamAtNu.
00272   // Pointers to the ClusterCamAtNu objects are stored in plane order in a 
00273   // clusterbank
00274 
00275 
00276   bool AddingHits;
00277   int i;
00278 
00279   for(int Module=0; Module<NumModules; ++Module) {
00280     for(int Plane=0; Plane<PlanesInModule+1; ++Plane) {
00281       i=Plane + Module*(PlanesInModule+1);
00282       
00283       // Loop over the hits on plane i
00284       for(unsigned int j=0; j<HitBank[i].size(); ++j) {
00285         
00286         // Make a cluster for the first hit on the plane
00287         if(HitBank[i][j]->GetUID()==0) {
00288           ClusterCamAtNu* Clust = new ClusterCamAtNu(HitBank[i][j]);
00289           ClusterBank[HitBank[i][j]->GetPlane()].push_back(Clust);
00290 
00291           // Change UID from 0 to 1 to show that hit has been added       
00292           HitBank[i][j]->SetUID(1); 
00293           AddingHits=true;
00294           
00295           // Loop over other hits on plane to form clusters
00296           while(AddingHits==true) {
00297             AddingHits=false;
00298             
00299             for(unsigned int k=0; k<HitBank[i].size(); ++k) {
00300               if(HitBank[i][k]->GetUID()==0 && Clust->IsHitAssoc(HitBank[i][k])) {
00301                 Clust->AddHit(HitBank[i][k]); 
00302                 HitBank[i][k]->SetUID(1);
00303                 AddingHits=true;
00304               }
00305             }
00306           }
00307 
00308         }
00309       } // End loop over hits on plane
00310     } // End loop over planes in module
00311   } // End loop over modules
00312 
00313   return;
00314 }

void AlgAtmosShowerList::FormTheHits CandSliceHandle slice  ) 
 

Definition at line 212 of file AlgAtmosShowerList.cxx.

References CandStripHandle::GetCharge(), CandHandle::GetDaughterIterator(), CandDeMuxDigitHandle::GetDeMuxDigitFlagWord(), VldContext::GetDetector(), CandStripHandle::GetPlane(), HitBank, MSG, and vldc.

Referenced by RunTheFinder().

00213 {
00214   // Create and (store pointers to) HitCamAtNu objects for all strips in slice
00215   // meeting PH and XTalk requirements. HitCamAtNu class is essentially a wrapper
00216   // for CandStripHandles
00217 
00218 
00219   bool IsXTalk;
00220   double PECut=1.;
00221 
00222   // Loop over all strips in the slice
00223   TIter SliceItr(slice->GetDaughterIterator());
00224   while(CandStripHandle* SlcStrip = dynamic_cast<CandStripHandle*>(SliceItr())) {
00225   
00226     // Default XTalk flag to false, as cannot identify ND XTalk
00227     IsXTalk=false;
00228    
00229     // Identify XTalk strips for FD
00230     if(vldc->GetDetector()==Detector::kFar) {
00231       TIter DigItr(SlcStrip->GetDaughterIterator());
00232       while(CandDeMuxDigitHandle* Digit = (CandDeMuxDigitHandle*)(DigItr())) {
00233         if( ( Digit->GetDeMuxDigitFlagWord()<8 )
00234             && (Digit->GetDeMuxDigitFlagWord() & CandDeMuxDigit::kXTalk)==(CandDeMuxDigit::kXTalk) ) {
00235           IsXTalk=true; break;
00236         }
00237       }
00238     }
00239     
00240     // Add the hits to the bank, where they are stored in plane order
00241     if(IsXTalk==false && SlcStrip->GetCharge()>PECut) {
00242       HitCamAtNu* hit = new HitCamAtNu(SlcStrip);
00243       HitBank[SlcStrip->GetPlane()].push_back(hit);
00244     }
00245   }
00246 
00247 
00248   // Print out the list of hits
00249   MSG("AlgAtmosShowerList", Msg::kVerbose) << " *** LIST OF HITS *** " << endl;
00250   for(int i=0; i<500; ++i){
00251     for(unsigned int j=0; j<HitBank[i].size(); ++j) {
00252       MSG("AlgAtmosShowerList", Msg::kVerbose)
00253         << " pln="  << HitBank[i][j]->GetPlane() 
00254         << " strp=" << HitBank[i][j]->GetStrip() 
00255         << " chg="  << HitBank[i][j]->GetCharge()
00256         << " time=" << HitBank[i][j]->GetTime() << endl;
00257     }
00258   }
00259 
00260   return;
00261 }

void AlgAtmosShowerList::FormVertexShowers CandSliceHandle slice  ) 
 

Definition at line 1320 of file AlgAtmosShowerList.cxx.

References ShowerCamAtNu::AddAssocTrack(), ShowerCamAtNu::AddHit(), FinalTrackBank, ShowerCamAtNu::GetBegPlane(), TrackCamAtNu::GetBegPlane(), ShowerCamAtNu::GetBegStrip(), HitCamAtNu::GetCharge(), ShowerCamAtNu::GetEndPlane(), TrackCamAtNu::GetEndPlane(), ShowerCamAtNu::GetEndStrip(), TrackCamAtNu::GetEntries(), ShowerCamAtNu::GetHit(), TrackCamAtNu::GetHit(), ShowerCamAtNu::GetNHits(), HitCamAtNu::GetPlane(), HitCamAtNu::GetPlaneView(), HitCamAtNu::GetShwFlag(), HitCamAtNu::GetStrip(), HitCamAtNu::GetTrkFlag(), HitBank, HitCamAtNu::IsDiffuseShwAssoc(), ShowerCamAtNu::IsDiffuseShwAssoc(), HitCamAtNu::IsShwAssoc(), MSG, PlanesInModule, ShowerCamAtNu::SetBegVtxFlag(), ShowerCamAtNu::SetEndVtxFlag(), ShowerCamAtNu::SetReseedFlag(), HitCamAtNu::SetShwFlag(), and ShowerBank.

Referenced by RunTheFinder().

01321 {
01322   // *********************************************************
01323   // * F O R M A T I O N   O F   V E R T E X   S H O W E R S *
01324   // *********************************************************
01325   //  int fVtxFlag=1; //
01326   int View, Module, pln, id, jnflag, bpln, epln, pln0, ctr, npln, dpln, dstr; 
01327   int jnflag2[2];
01328   double score, topscore;
01329   //     if(fVtxFlag)
01330   //       {
01331   MSG("AlgAtmosShowerList", Msg::kDebug) << " *** formation of vertex showers *** " << endl;
01332   
01333   vector<HitCamAtNu*> TempHitTrack[2],HitsNearTrackBeg[2],HitsNearTrackEnd[2];
01334   vector<ShowerCamAtNu*> TempShowers[2];
01335   for(unsigned int i=0;i<FinalTrackBank[0].size();i++)
01336     {
01337         
01338       // beginning vertex shower (existing)
01339       for(View=0;View<2;View++)
01340         {   
01341           TempShowers[View].clear(); TempHitTrack[View].clear(); HitsNearTrackBeg[View].clear(); 
01342           TrackCamAtNu* trk = FinalTrackBank[View][i];
01343           for(unsigned int j=0;j<trk->GetEntries();j++)
01344             {
01345               HitCamAtNu* hit = trk->GetHit(j);
01346               if( hit->GetPlane()<trk->GetBegPlane()+9 && 2*hit->GetPlane()<trk->GetBegPlane()+trk->GetEndPlane()+1
01347                   && (int)((hit->GetPlane())/(PlanesInModule+1))==(int)((trk->GetBegPlane())/(PlanesInModule+1)) )
01348                 {
01349                   TempHitTrack[View].push_back(hit);
01350                 }
01351             }
01352         }
01353 //       MSG("AlgAtmosShowerList", Msg::kVerbose) <<" TempHitTrack[0].size() "<< TempHitTrack[0].size() << ", TempHitTrack[1].size() "<< TempHitTrack[1].size() << endl;
01354       for(unsigned int j=0;j<ShowerBank[0].size();j++)
01355         {
01356           for(View=0;View<2;View++)
01357             {
01358 //            MSG("AlgAtmosShowerList", Msg::kVerbose) << "Trying to match shower & track hits in View : "<< View<< endl;
01359               TrackCamAtNu* trk = FinalTrackBank[View][i];
01360               ShowerCamAtNu* shw = ShowerBank[View][j];
01361 //            MSG("AlgAtmosShowerList", Msg::kVerbose) << "Hits In Shower"<<endl;
01362 //            for(unsigned int l=0; l<shw->GetNHits(); ++l)
01363 //              {
01364 //                HitCamAtNu* hit = shw->GetHit(l);
01365 //                MSG("AlgAtmosShowerList", Msg::kVerbose) << "     Hit: Plane = " << hit->GetPlane() <<", Strip = " << hit->GetStrip() <<", Time = " << hit->GetTime() << endl;
01366 //              }
01367               jnflag2[View]=0;
01368               if( shw->GetBegPlane()<trk->GetBegPlane()+9
01369                   && 2*shw->GetBegPlane()<trk->GetBegPlane()+trk->GetEndPlane()+1 
01370                   && (int)((shw->GetBegPlane())/(PlanesInModule+1))==(int)((trk->GetBegPlane())/(PlanesInModule+1)) )
01371                 {
01372                   //MSG("AlgAtmosShowerList", Msg::kVerbose) << "Trying to associate shower with track"<<endl;
01373                   for(unsigned int k=0;k<TempHitTrack[View].size();k++)
01374                     {
01375 //                    HitCamAtNu* hit = TempHitTrack[View][k];
01376 //                    MSG("AlgAtmosShowerList", Msg::kVerbose) << "TrackHit: Plane = " << hit->GetPlane() <<", Strip = " << hit->GetStrip() <<", Time = " << hit->GetTime() << endl;
01377                       if(shw->IsDiffuseShwAssoc(TempHitTrack[View][k])>0) { MSG("AlgAtmosShowerList", Msg::kVerbose) << "Associated in view "<<View<<endl; jnflag2[View]=1; break; }
01378                     }
01379                 }
01380             }
01381           if(jnflag2[0]>0 || jnflag2[1]>0)
01382             {
01383               for(View=0;View<2;View++) { TempShowers[View].push_back(ShowerBank[View][j]); }
01384             }
01385         }
01386 //       MSG("AlgAtmosShowerList", Msg::kVerbose) <<" TempShowers[0].size() "<< TempShowers[0].size() << ", TempShowers[1].size() "<< TempShowers[1].size() << endl;
01387       if( TempShowers[0].size()>0 && TempShowers[1].size()>0 )
01388         {
01389           id=-1; topscore=9999.9;
01390           for(unsigned int j=0;j<TempShowers[0].size();j++)
01391             {
01392               ShowerCamAtNu* shwu = TempShowers[0][j];
01393               ShowerCamAtNu* shwv = TempShowers[1][j];
01394               score = shwu->GetBegPlane()+shwv->GetBegPlane();  
01395               if(score<topscore) { topscore=score; id=j; }
01396             }
01397           if(1+id>0)
01398             {
01399               MSG("AlgAtmosShowerList", Msg::kVerbose) << " found existing beginning vertex shower " << endl;
01400               for(View=0;View<2;View++)
01401                 {
01402                   TrackCamAtNu* trk = FinalTrackBank[View][i];
01403                   ShowerCamAtNu* shw = TempShowers[View][id];
01404                   //trk->SetBegVtxShower(shw); 
01405                   shw->AddAssocTrack(trk); shw->SetBegVtxFlag(1); 
01406                 }
01407             }
01408         }
01409 
01410       // beginning vertex shower (new)
01411       else
01412         {
01413           if( i==0 )
01414             {
01415               for(View=0;View<2;View++)
01416                 {
01417                   HitsNearTrackBeg[View].clear();
01418                   TrackCamAtNu* trk = FinalTrackBank[View][i];
01419 
01420                   Module=(int)((trk->GetBegPlane())/(PlanesInModule+1));
01421                   for(int j=-3;j<4;j++)
01422                     {
01423                       pln=trk->GetBegPlane()+2*j;
01424                       if( 2*pln<trk->GetBegPlane()+trk->GetEndPlane()+1 && pln>Module*(PlanesInModule+1) && pln<(Module+1)*(PlanesInModule+1) )
01425                         {
01426                           for(unsigned int k=0;k<HitBank[pln].size();k++)
01427                             {
01428                               HitCamAtNu* hit = HitBank[pln][k];
01429                               if( hit->GetShwFlag()<2  && ( hit->GetTrkFlag()<2 || hit->GetCharge()>50 ) )
01430                                 {
01431                                   for(unsigned int l=0;l<TempHitTrack[View].size();l++)
01432                                     {
01433                                       HitCamAtNu* hittrk = TempHitTrack[View][l];
01434                                       if( hittrk->GetPlane()<trk->GetBegPlane()+7 && hittrk->IsDiffuseShwAssoc(hit)>0 )
01435                                         {
01436                                           HitsNearTrackBeg[View].push_back(hit); hit->SetShwFlag(1); break;
01437                                         }
01438                                     }
01439                                 }
01440                             }
01441                         }
01442                     }
01443                   
01444                   if(HitsNearTrackBeg[View].size()>0)
01445                     {
01446                       bpln=trk->GetBegPlane()-6; epln=trk->GetBegPlane()+6;
01447                       ctr=1;
01448                       while(ctr>0)
01449                         {
01450                           ctr=0;
01451                           pln0=bpln-4; npln=5+(epln-bpln)/2;
01452                           for(int j=0;j<npln;j++)
01453                             {
01454                               pln=pln0+2*j;
01455                               if(pln>Module*(PlanesInModule+1) && pln<(Module+1)*(PlanesInModule+1))
01456                                 {
01457                                   for(unsigned int k=0;k<HitBank[pln].size();k++)
01458                                     {
01459                                       HitCamAtNu* hit = HitBank[pln][k];
01460                                       if(hit->GetShwFlag()<1 && hit->GetTrkFlag()<1)
01461                                         {
01462                                           for(unsigned int l=0;l<HitsNearTrackBeg[View].size();l++)
01463                                             {
01464                                               HitCamAtNu* hitshw = HitsNearTrackBeg[View][l];
01465                                               if( hitshw->IsDiffuseShwAssoc(hit)>0 )
01466                                                 {
01467                                                   HitsNearTrackBeg[View].push_back(hit); hit->SetShwFlag(1); 
01468                                                   if(hit->GetPlane()<bpln) bpln=hit->GetPlane(); 
01469                                                   if(hit->GetPlane()>epln) epln=hit->GetPlane();
01470                                                   ctr++; break;
01471                                                 }
01472                                             }
01473                                         }
01474                                     }   
01475                                 }
01476                             }
01477                         }
01478                       for(unsigned int j=0;j<HitsNearTrackBeg[View].size();j++)
01479                         {
01480                           HitCamAtNu* hit = HitsNearTrackBeg[View][j];
01481                           hit->SetShwFlag(0);
01482                         }
01483                     }
01484                 }
01485             }
01486         }
01487 
01488       // end vertex shower (existing)
01489       for(View=0;View<2;View++)
01490         {   
01491           TempShowers[View].clear();     
01492           TempHitTrack[View].clear(); HitsNearTrackEnd[View].clear(); 
01493           TrackCamAtNu* trk = FinalTrackBank[View][i];
01494           for(unsigned int j=0;j<trk->GetEntries();j++)
01495             {
01496               HitCamAtNu* hit = trk->GetHit(j);
01497               if( hit->GetPlane()>trk->GetEndPlane()-9
01498                   && 2*hit->GetPlane()>trk->GetBegPlane()+trk->GetEndPlane()-1
01499                   && (int)((hit->GetPlane())/(PlanesInModule+1))==(int)((trk->GetEndPlane())/(PlanesInModule+1)) )
01500                 {
01501                   TempHitTrack[View].push_back(hit);
01502                 }
01503             }
01504         }
01505       
01506       for(unsigned int j=0;j<ShowerBank[0].size();j++)
01507         {
01508           for(View=0;View<2;View++)
01509             {
01510               TrackCamAtNu* trk = FinalTrackBank[View][i];
01511               ShowerCamAtNu* shw = ShowerBank[View][j];
01512               jnflag2[View]=0;
01513               if( shw->GetEndPlane()>trk->GetEndPlane()-9
01514                   && 2*shw->GetEndPlane()>trk->GetBegPlane()+trk->GetEndPlane()-1 
01515                   && (int)((shw->GetEndPlane())/(PlanesInModule+1))==(int)((trk->GetEndPlane())/(PlanesInModule+1)) )
01516                 {
01517                   for(unsigned int k=0;k<TempHitTrack[View].size();k++)
01518                     {
01519                       HitCamAtNu* hit = TempHitTrack[View][k];
01520                       if(shw->IsDiffuseShwAssoc(hit)>0) { jnflag2[View]=1; break; }
01521                     }
01522                 }
01523             }
01524           if(jnflag2[0]>0 || jnflag2[1]>0)
01525             {
01526               for(View=0;View<2;View++)
01527                 {
01528                   ShowerCamAtNu* shw = ShowerBank[View][j];
01529                   TempShowers[View].push_back(shw);
01530                 }
01531             }
01532         }
01533       
01534       if( TempShowers[0].size()>0 && TempShowers[1].size()>0 )
01535         {
01536           id=-1; topscore=-9999.9;
01537           for(unsigned int j=0;j<TempShowers[0].size();j++)
01538             {
01539               ShowerCamAtNu* shwu = TempShowers[0][j];
01540               ShowerCamAtNu* shwv = TempShowers[1][j];
01541               score = shwu->GetEndPlane()+shwv->GetEndPlane();  
01542               if(score>topscore) { topscore=score; id=j; }
01543             }
01544           if(1+id>0)
01545             {
01546               MSG("AlgAtmosShowerList", Msg::kVerbose) << " found existing end vertex shower " << endl;
01547               for(View=0;View<2;View++)
01548                 {
01549                   TrackCamAtNu* trk = FinalTrackBank[View][i];
01550                   ShowerCamAtNu* shw = TempShowers[View][id];
01551                   //trk->SetEndVtxShower(shw); 
01552                   shw->AddAssocTrack(trk); shw->SetEndVtxFlag(1); 
01553                 }
01554             }
01555         }
01556       
01557       // end vertex shower (new)
01558       else
01559         {
01560           if( i==0 )
01561             {
01562               for(View=0;View<2;View++)
01563                 {
01564                   HitsNearTrackEnd[View].clear();
01565                   TrackCamAtNu* trk = FinalTrackBank[View][i];
01566 
01567                   Module=(int)((trk->GetEndPlane())/(PlanesInModule+1));
01568                   for(int j=-3;j<4;j++)
01569                     {
01570                       pln=trk->GetEndPlane()+2*j;
01571                       if( 2*pln>trk->GetBegPlane()+trk->GetEndPlane()-1 && pln>Module*(PlanesInModule+1) && pln<(Module+1)*(PlanesInModule+1) )
01572                         {
01573                           for(unsigned int k=0;k<HitBank[pln].size();k++)
01574                             {
01575                               HitCamAtNu* hit = HitBank[pln][k];
01576                               if( hit->GetShwFlag()<2 && ( hit->GetTrkFlag()<2 || hit->GetCharge()>50 ) )
01577                                 {
01578                                   for(unsigned int l=0;l<TempHitTrack[View].size();l++)
01579                                     {
01580                                       HitCamAtNu* hittrk = TempHitTrack[View][l];
01581                                       if( hittrk->GetPlane()>trk->GetEndPlane()-7 && hittrk->IsDiffuseShwAssoc(hit)>0 )
01582                                         {
01583                                           HitsNearTrackEnd[View].push_back(hit); hit->SetShwFlag(1); break;
01584                                         }
01585                                     }
01586                                 }
01587                             }
01588                         }
01589                     }
01590                   
01591                   if(HitsNearTrackEnd[View].size()>0)
01592                     {
01593                       bpln=trk->GetEndPlane()-6; epln=trk->GetEndPlane()+6;
01594                       ctr=1;
01595                       while(ctr>0)
01596                         {
01597                           ctr=0;
01598                           pln0=bpln-4; npln=5+(epln-bpln)/2;
01599                           for(int j=0;j<npln;j++)
01600                             {
01601                               pln=pln0+2*j;
01602                               if(pln>Module*(PlanesInModule+1) && pln<(Module+1)*(PlanesInModule+1))
01603                                 {
01604                                   for(unsigned int k=0;k<HitBank[pln].size();k++)
01605                                     {
01606                                       HitCamAtNu* hit = HitBank[pln][k];
01607                                       if(hit->GetShwFlag()<1 && hit->GetTrkFlag()<1)
01608                                         {
01609                                           jnflag=0;
01610                                           for(unsigned int l=0;l<HitsNearTrackEnd[View].size();l++)
01611                                             {
01612                                               HitCamAtNu* hitshw = HitsNearTrackEnd[View][l];
01613                                               if( hitshw->IsDiffuseShwAssoc(hit)>0 )
01614                                                 {
01615                                                   HitsNearTrackEnd[View].push_back(hit); hit->SetShwFlag(1); 
01616                                                   if(hit->GetPlane()<bpln) bpln=hit->GetPlane(); 
01617                                                   if(hit->GetPlane()>epln) epln=hit->GetPlane();
01618                                                   ctr++; break;
01619                                                 }
01620                                             }
01621                                         }
01622                                     }   
01623                                 }
01624                             }
01625                         }
01626                       for(unsigned int j=0;j<HitsNearTrackEnd[View].size();j++)
01627                         {
01628                           HitCamAtNu* hit = HitsNearTrackEnd[View][j];
01629                           hit->SetShwFlag(0);
01630                         }
01631                     }
01632                 }
01633             }
01634         }
01635 
01636       if( HitsNearTrackBeg[0].size()>0 && HitsNearTrackBeg[1].size()>0 )
01637         {
01638           MSG("AlgAtmosShowerList", Msg::kVerbose) << " found new vertex shower at beginning of track " << endl;
01639           for(View=0;View<2;View++)
01640             {
01641               ShowerCamAtNu* shw = new ShowerCamAtNu(slice);
01642               for(unsigned int j=0;j<HitsNearTrackBeg[View].size();j++)
01643                 {
01644                   HitCamAtNu* hit = HitsNearTrackBeg[View][j];
01645                   shw->AddHit(hit); hit->SetShwFlag(2);
01646                 }
01647               TrackCamAtNu* trk = FinalTrackBank[View][i];
01648               //trk->SetBegVtxShower(shw); 
01649               shw->AddAssocTrack(trk); shw->SetBegVtxFlag(1); shw->SetReseedFlag(1);
01650               ShowerBank[View].push_back(shw);
01651             }
01652         }
01653 
01654       if( HitsNearTrackEnd[0].size()>0 && HitsNearTrackEnd[1].size()>0 )
01655         {
01656           MSG("AlgAtmosShowerList", Msg::kVerbose) << " found new vertex shower at end of track " << endl;
01657           for(View=0;View<2;View++)
01658             {
01659               ShowerCamAtNu* shw = new ShowerCamAtNu(slice);
01660               for(unsigned int j=0;j<HitsNearTrackEnd[View].size();j++)
01661                 {
01662                   HitCamAtNu* hit = HitsNearTrackEnd[View][j];
01663                   shw->AddHit(hit); hit->SetShwFlag(2);
01664                 }
01665               TrackCamAtNu* trk = FinalTrackBank[View][i];
01666               //trk->SetEndVtxShower(shw); 
01667               shw->AddAssocTrack(trk); shw->SetEndVtxFlag(1); shw->SetReseedFlag(1);
01668               ShowerBank[View].push_back(shw);
01669             }
01670         }
01671     }
01672   //      }
01673           
01674         
01675   // *********************************************
01676   // * M O P   U P   R E M A I N I N G   H I T S *
01677   // *********************************************
01678  
01679   // Mopping up remaining hits
01680   MSG("AlgAtmosShowerList", Msg::kDebug) << " *** mop up remaining hits *** " << endl;
01681   Double_t shwwinplns,shwwinstrps;
01682   if( ShowerBank[0].size()>0 )
01683     {
01684       shwwinplns=8; shwwinstrps=12; 
01685       if(FinalTrackBank[0].size()==0) { shwwinplns=16; shwwinstrps=25; }
01686       for(Module=0;Module<NumModules;Module++)
01687         {
01688           for(pln=1;pln<PlanesInModule;pln++)
01689             {
01690               int i=pln+Module*(PlanesInModule+1);
01691               for(unsigned int j=0;j<HitBank[i].size();j++)
01692                 {
01693                   HitCamAtNu* hit = HitBank[i][j];
01694                   if(hit->GetShwFlag()<1 && hit->GetTrkFlag()<1)
01695                     { 
01696                       View = hit->GetPlaneView();
01697                       id=-1; score=shwwinplns+shwwinstrps;
01698                       for(unsigned int k=0;k<ShowerBank[View].size();k++)
01699                         {
01700                           ShowerCamAtNu* shw = ShowerBank[View][k];
01701                           if( (int)((shw->GetEndPlane())/(PlanesInModule+1)) == Module )
01702                             {
01703                               for(unsigned int l=0;l<shw->GetNHits();l++)
01704                                 {
01705                                   if(ShowerBank[View].size()>1 || id<0)
01706                                     {
01707                                       HitCamAtNu* hittmp = shw->GetHit(l);
01708                                       if( (hittmp->GetShwFlag()>1) && (hit->GetTrkFlag()<1||hittmp->IsShwAssoc(hit)>0) )
01709                                         {
01710                                           dpln=hit->GetPlane()-hittmp->GetPlane(); if(dpln<0) dpln=-dpln; 
01711                                           dstr=hit->GetStrip()-hittmp->GetStrip(); if(dstr<0) dstr=-dstr; 
01712                                           if( dpln<shwwinplns && dstr<shwwinstrps && dpln+dstr<score )
01713                                             {
01714                                               id=k; score=dpln+dstr;
01715                                             }
01716                                         }
01717                                     }
01718                                 }
01719                             }
01720                         }
01721                       if(id>-1)
01722                         {
01723                           ShowerBank[View][id]->AddHit(hit); hit->SetShwFlag(1);
01724                         }
01725                     }
01726                 }
01727             }
01728         }
01729     }
01730 
01731   // Print list of showers
01732   MSG("AlgAtmosShowerList", Msg::kVerbose) << " *** LIST OF SHOWERS *** " << endl;
01733   for(View=0;View<2;View++)
01734     {
01735       MSG("AlgAtmosShowerList", Msg::kVerbose) << "view: " << View << endl;
01736       for(unsigned int i=0;i<ShowerBank[View].size();i++)
01737         {
01738           ShowerCamAtNu* shw = ShowerBank[View][i];
01739           MSG("AlgAtmosShowerList", Msg::kVerbose)
01740             << "   i=" << i << "   " 
01741             << shw->GetBegPlane() << " " << shw->GetBegStrip() << "    "
01742             << shw->GetEndPlane() << " " << shw->GetEndStrip() << endl;
01743         }
01744       TempHitTrack[View].clear(); HitsNearTrackBeg[View].clear(); HitsNearTrackEnd[View].clear();
01745       TempShowers[View].clear();
01746     }
01747 
01748 
01749   return;
01750 }

void AlgAtmosShowerList::IDTrkAndShwClusters  ) 
 

Definition at line 321 of file AlgAtmosShowerList.cxx.

References ClusterBank, ClusterCamAtNu::GetBegStrip(), ClusterCamAtNu::GetCharge(), ClusterCamAtNu::GetEndStrip(), ClusterCamAtNu::GetEntries(), ClusterCamAtNu::GetPlane(), ClusterCamAtNu::GetShwFlag(), ClusterCamAtNu::GetShwPlnFlag(), ClusterCamAtNu::GetTrkFlag(), ClusterCamAtNu::GetTrkPlnFlag(), ClusterCamAtNu::IsShwAssoc(), MSG, PlanesInModule, ClusterCamAtNu::SetShwFlag(), ClusterCamAtNu::SetShwPlnFlag(), and ClusterCamAtNu::SetTrkPlnFlag().

Referenced by RunTheFinder().

00322 {
00323   // Look at the 1D clusters formed and use simple techniques to get an idea
00324   // of how track-like or shower-like each cluster is.
00325   // Then look at all clusters on the plane and see how track-like or shower-like
00326   // the plane is.
00327 
00328   int i, k0;
00329   int nclust0, nclust1, nhits0, nhits1, ShwAssocNum;
00330   vector<ClusterCamAtNu*> TempClust0;
00331   vector<ClusterCamAtNu*> TempClust1;
00332   
00333   // Identify the shower-like clusters
00335   for(int Module=0; Module<NumModules; ++Module) {
00336     for(int Plane=1; Plane<PlanesInModule+1; ++Plane) {
00337       i=Plane + Module*(PlanesInModule+1);
00338       
00339       for(unsigned int j=0; j<ClusterBank[i].size(); ++j) {
00340         ClusterCamAtNu* Clust0 = ClusterBank[i][j];
00341 
00342         nhits0=Clust0->GetEntries(); nclust0=1;
00343         nhits1=Clust0->GetEntries(); nclust1=1;
00344         TempClust0.clear(); TempClust1.clear(); 
00345         
00346         
00347         // Look for shower associations in nearby planes
00349         // Loop over nearby planes
00350         for(int k=-1; k<2; ++k) {
00351           k0=i+(2*k);
00352           
00353           // Check k0 is a valid nearby plane
00354           if(k0>Module*(PlanesInModule+1) && k0<(Module+1)*(PlanesInModule+1)) {
00355 
00356             // Loop over clusters on plane k0
00357             for(unsigned int k1=0; k1<ClusterBank[k0].size(); ++k1) {
00358               ClusterCamAtNu* Clust1 = ClusterBank[k0][k1];
00359 
00360               // Check shower-like associations
00361               if(Clust0->GetCharge()>1. && Clust1->GetCharge()>1.) {
00362                 ShwAssocNum=Clust0->IsShwAssoc(Clust1);
00363                 
00364                 // Store the association data and the clusters
00365                 if(ShwAssocNum>0) {
00366                   nhits0+=Clust1->GetEntries(); 
00367                   nclust0+=1;
00368                   TempClust0.push_back(Clust1);
00369                 }
00370                 
00371                 if(ShwAssocNum>1) {
00372                   nhits1+=Clust1->GetEntries(); 
00373                   nclust1+=1;
00374                   TempClust1.push_back(Clust1);
00375                 }
00376               }
00377             } // End loop over clusters on nearby plane
00378           }
00379         } // End loop over nearby planes
00381 
00382         // Use the above results to set the shower flags
00383         // Has important implications for finding tracks embedded in showers
00385         if(nclust1>1 && nhits1>4) {
00386           for(unsigned int k=0; k<TempClust1.size(); ++k) {
00387             TempClust1[k]->SetShwFlag(1);
00388           }
00389         }
00390 
00391         if(nclust0>4 && nhits0>5) {
00392           for(unsigned int k=0; k<TempClust0.size(); ++k) {
00393             TempClust0[k]->SetShwFlag(1);
00394           }
00395         }
00396 
00397         // Set shower flag for very high pulse height clusters
00398         if(Clust0->GetShwFlag()<1 && Clust0->GetCharge()>50.) {
00399           Clust0->SetShwFlag(1);
00400         }
00402 
00403       }
00404     }
00405   }
00407 
00408 
00409 
00410   // Identify track-like and shower-like planes
00412   double Charge;
00413 
00414   for(int Module=0; Module<NumModules; ++Module) {
00415     for(int Plane=0; Plane<PlanesInModule+1; ++Plane) {
00416       i=Plane + Module*(PlanesInModule+1);
00417       Charge=0.;
00418 
00419       // Get total charge in clusters on plane
00420       for(unsigned int j=0; j<ClusterBank[i].size(); ++j) {
00421         Charge+=ClusterBank[i][j]->GetCharge();
00422       }
00423 
00424       if(Charge>0.) {
00425         for(unsigned int j=0; j<ClusterBank[i].size(); ++j) {
00426           ClusterCamAtNu* Clust = ClusterBank[i][j];
00427 
00428           // Set the plane flags for the clusters
00429           if(Clust->GetEntries()<3 && (Clust->GetCharge()/Charge)>0.5) {Clust->SetTrkPlnFlag(1);}
00430           if(Clust->GetEntries()>1 && (Clust->GetCharge()/Charge)>0.5) {Clust->SetShwPlnFlag(1);}
00431         }
00432       }
00433     }
00434   }
00436   
00437 
00438 
00439   // Print out list of hits and 1D clusters
00440   MSG("AlgAtmosShowerList", Msg::kVerbose) << " *** LIST OF CLUSTERS *** " << endl;
00441   for(int i=0; i<500; ++i){
00442     for(unsigned int j=0; j<ClusterBank[i].size(); ++j) {
00443       MSG("AlgAtmosShowerList", Msg::kVerbose)
00444         << " plane="    << ClusterBank[i][j]->GetPlane() 
00445         << " begstrip=" << ClusterBank[i][j]->GetBegStrip() 
00446         << " endstrip=" << ClusterBank[i][j]->GetEndStrip() 
00447         << " trkflag="   << ClusterBank[i][j]->GetTrkFlag()
00448         << " trkpln="   << ClusterBank[i][j]->GetTrkPlnFlag()
00449         << " shwflag="   << ClusterBank[i][j]->GetShwFlag()
00450         << " shwpln="   << ClusterBank[i][j]->GetShwPlnFlag() << endl;
00451 
00452     }
00453   }
00454   TempClust0.clear(); TempClust1.clear();
00455   return;
00456 }

void AlgAtmosShowerList::MatchShowers  ) 
 

Definition at line 918 of file AlgAtmosShowerList.cxx.

References ShowerSegmentCamAtNu::AddCluster(), ClusterBank, ShowerSegmentCamAtNu::ContainsCluster(), ShowerSegmentCamAtNu::GetBegPlane(), ShowerSegmentCamAtNu::GetBegStrip(), ShowerSegmentCamAtNu::GetBegTime(), ClusterCamAtNu::GetCharge(), ShowerSegmentCamAtNu::GetCluster(), TrackSegmentCamAtNu::GetCluster(), ShowerSegmentCamAtNu::GetEndPlane(), ShowerSegmentCamAtNu::GetEndStrip(), ShowerSegmentCamAtNu::GetEndTime(), ClusterCamAtNu::GetEntries(), ShowerSegmentCamAtNu::GetEntries(), TrackSegmentCamAtNu::GetEntries(), ShowerSegmentCamAtNu::GetNHits(), ShowerSegmentCamAtNu::GetPartner(), ClusterCamAtNu::GetPlane(), ClusterCamAtNu::GetPlaneView(), ClusterCamAtNu::GetShwFlag(), ShowerSegmentCamAtNu::GetUID(), ShowerSegmentCamAtNu::IsDiffuseShwAssoc(), MSG, PlanesInModule, ShowerSegmentCamAtNu::SetPartner(), ClusterCamAtNu::SetShwFlag(), ShowerSegmentCamAtNu::SetUID(), ShowerSegmentBank, ShowersFound, ShowerViewSegBank, and TempTrack.

Referenced by RunTheFinder().

00919 {
00920   double fTimeWin = 100.0;
00921   int View, Module, cont, id, Plane, npts, dpln1, dpln2, nshws, k0, ctr, pln0, npln;
00922   double topscore=0., score=0.;
00923   vector<ShowerSegmentCamAtNu*> PossibleShowerSegments[2];
00924   int OverlappingSegments[2];
00925 
00926   // Store all showers with matches in the other view and UID>2 in a temporary vector
00928   for(unsigned int i=0;i<ShowerViewSegBank[0].size();i++)
00929     {
00930       ShowerSegmentCamAtNu* segu = ShowerViewSegBank[0][i];
00931       if(segu->GetUID()>2)
00932         {
00933           for(unsigned int j=0;j<ShowerViewSegBank[1].size();j++)
00934             {
00935               ShowerSegmentCamAtNu* segv = ShowerViewSegBank[1][j];
00936               if(segv->GetUID()>2)
00937                 {
00938                   if( ( segu->GetEndPlane()-segv->GetBegPlane()>-2 && segv->GetEndPlane()-segu->GetBegPlane()>-2)
00939                       && ( segu->GetEndTime()-segv->GetBegTime()>-fTimeWin && segv->GetEndTime()-segu->GetBegTime()>-fTimeWin ) )
00940                     {
00941                       PossibleShowerSegments[0].push_back(segu); PossibleShowerSegments[1].push_back(segv);
00942                     }  
00943                 }
00944             }
00945         }
00946     }
00947 
00948   // Match showers that intersect tracks
00950   vector<ClusterCamAtNu*> ShowerClustersInTracks[2];   //?tmpclr = ShowerClustersInTracks
00951   vector<ShowerSegmentCamAtNu*> ShowerSegmentsAroundTracks[2];
00952 
00953   if(TempTrack[0].size()>0)
00954     {
00955       for(unsigned int i=0;i<TempTrack[0].size();i++)
00956         {
00957           // Find Shower-like clusters from tracks
00959           for(View=0;View<2;View++)
00960             {
00961               ShowerClustersInTracks[View].clear(); ShowerSegmentsAroundTracks[View].clear();
00962               TrackSegmentCamAtNu* segtrk = TempTrack[View][i];
00963               for(unsigned int j=0;j<segtrk->GetEntries();++j)
00964                 {
00965                   ClusterCamAtNu* cluster = segtrk->GetCluster(j);
00966                   if(cluster->GetShwFlag()>2) ShowerClustersInTracks[View].push_back(cluster);  
00967                 }
00968             }
00969 
00970           // Use the tracks to match showers in U and V
00972           if(ShowerClustersInTracks[0].size()>0 && ShowerClustersInTracks[1].size()>0)
00973             {
00974               //Find ShowerSegments containing the Shower-like clusters from tracks
00976               for(unsigned int j=0;j<PossibleShowerSegments[0].size();j++)
00977                 {
00978                   for(View=0;View<2;View++)
00979                     {
00980                       OverlappingSegments[View]=0;
00981                       ShowerSegmentCamAtNu* Segment = PossibleShowerSegments[View][j];
00982                       if(Segment->GetPartner()==0)
00983                         {
00984                           for(unsigned int k=0;k<ShowerClustersInTracks[View].size();k++)
00985                             {
00986                               if(Segment->ContainsCluster(ShowerClustersInTracks[View][k])) OverlappingSegments[View]=1;
00987                             }
00988                         }
00989                     }
00990 
00991                   if(OverlappingSegments[0]>0 && OverlappingSegments[1]>0)
00992                     {
00993                       for(View=0;View<2;View++)
00994                         {
00995                           ShowerSegmentsAroundTracks[View].push_back(PossibleShowerSegments[View][j]);
00996                         }
00997                     }
00998                 }// end of loop over possible shower segments
00999             }
01000             
01001           // Decide whether any of the matches found are good enough to use
01003           if(ShowerSegmentsAroundTracks[0].size()>0 && ShowerSegmentsAroundTracks[1].size()>0)
01004             {
01005               cont=1;
01006               while(cont)
01007                 {
01008                   cont=0;
01009                   id=-1; topscore=0.0;
01010                   for(unsigned int j=0;j<ShowerSegmentsAroundTracks[0].size();j++)
01011                     {
01012                       ShowerSegmentCamAtNu* segshwu = ShowerSegmentsAroundTracks[0][j];
01013                       ShowerSegmentCamAtNu* segshwv = ShowerSegmentsAroundTracks[1][j];
01014                       if( segshwu->GetPartner()==0 && segshwv->GetPartner()==0 && segshwu->GetUID()>2 && segshwv->GetUID()>2 )
01015                         {
01016                           dpln1=segshwu->GetEndPlane()-segshwv->GetBegPlane(); 
01017                           dpln2=segshwv->GetEndPlane()-segshwu->GetBegPlane();
01018                           if(dpln1<=dpln2) score=dpln1; 
01019                           if(dpln2<=dpln1) score=dpln2;
01020                           if(score>topscore) { id=j; score=topscore; }
01021                         }
01022                     }
01023                   if(1+id>0)
01024                     {
01025                       ShowerSegmentCamAtNu* segshwu = ShowerSegmentsAroundTracks[0][id];
01026                       ShowerSegmentCamAtNu* segshwv = ShowerSegmentsAroundTracks[1][id];
01027                       segshwu->SetPartner(segshwv); segshwv->SetPartner(segshwu);
01028                       cont=1;
01029                     }         
01030                 }
01031             }
01032         }
01033     }//if(TempTrack[0].size()>0)
01034     
01035   // Determine other best matched showers
01037   while(1)
01038     {
01039       id=-1; topscore=0.0;
01040       for(unsigned int i=0;i<PossibleShowerSegments[1].size();i++)
01041         {
01042           ShowerSegmentCamAtNu* segu = PossibleShowerSegments[0][i];
01043           ShowerSegmentCamAtNu* segv = PossibleShowerSegments[1][i];
01044           if( segu->GetPartner()==segv && segv->GetPartner()==segu && segu->GetUID()<4 && segv->GetUID()<4 )
01045             {
01046               ShowersFound[0].push_back(segu); segu->SetUID(4);
01047               ShowersFound[1].push_back(segv); segv->SetUID(4);
01048             }
01049           else
01050             {
01051               if( segu->GetPartner()==0 && segv->GetPartner()==0 && segu->GetUID()>2 && segv->GetUID()>2 )
01052                 {
01053                   dpln1 = segu->GetEndPlane()-segv->GetBegPlane();
01054                   dpln2 = segv->GetEndPlane()-segu->GetBegPlane();
01055                   if(dpln1<=dpln2) score=dpln1; 
01056                   else /* if(dpln2<=dpln1)*/ score=dpln2;
01057                   if(score>topscore) { topscore=score; id=i; }
01058                 }
01059             }
01060         }
01061       if(id>-1)
01062         {
01063           ShowerSegmentCamAtNu* segu = PossibleShowerSegments[0][id];
01064           ShowerSegmentCamAtNu* segv = PossibleShowerSegments[1][id];
01065           segu->SetPartner(segv); segv->SetPartner(segu);
01066         }
01067       else { break; }
01068     }
01069 
01070   nshws=(int)ShowersFound[0].size();
01071   for(View=0;View<2;View++)
01072     {
01073       for(unsigned int i=0;i<ShowersFound[View].size();i++)
01074         {
01075           ShowerSegmentCamAtNu* seg = ShowersFound[View][i];
01076           for(unsigned int j=0;j<seg->GetEntries();j++)
01077             {
01078               seg->GetCluster(j)->SetShwFlag(4);
01079             }
01080         }
01081     }
01082 
01083   //MSG("AlgAtmosShowerList", Msg::kVerbose)
01084   MSG("AlgAtmosShowerList", Msg::kVerbose) << " *** LIST OF MATCHED SHOWER SEGMENTS *** " << endl;
01085   for(int View=0;View<2;View++)
01086     {
01087       MSG("AlgAtmosShowerList", Msg::kVerbose) << "==================================================================================" << endl;
01088       MSG("AlgAtmosShowerList", Msg::kVerbose) << "view: " << View << endl;
01089       for(unsigned int i=0;i<ShowersFound[View].size();i++)
01090         {
01091           ShowerSegmentCamAtNu* segment = ShowersFound[View][i];
01092           ShowerSegmentCamAtNu* partner = segment->GetPartner();
01093           if(segment->GetUID()>2)
01094             {
01095               MSG("AlgAtmosShowerList", Msg::kVerbose) << "  i=" << i
01096                                                        << "  begpln: " << segment->GetBegPlane()
01097                                                        << "  begstr: " << segment->GetBegStrip()
01098                                                        << "  endpln: " << segment->GetEndPlane()
01099                                                        << "  endstr: " << segment->GetEndStrip() << endl;
01100               MSG("AlgAtmosShowerList", Msg::kVerbose) << "       begpln: " << partner->GetBegPlane()
01101                                                        << "  begstr: " << partner->GetBegStrip()
01102                                                        << "  endpln: " << partner->GetEndPlane()
01103                                                        << "  endstr: " << partner->GetEndStrip() << endl;
01104               MSG("AlgAtmosShowerList", Msg::kVerbose) << "==================================================================================" << endl;
01105             }
01106         }
01107     }
01108 
01109   // *************************************
01110   // * R E S E E D I N G   S H O W E R S *
01111   // *************************************
01112   
01113   if( ShowersFound[0].size()==0 && ShowersFound[1].size()==0 && TempTrack[0].size()==0 && TempTrack[1].size()==0 )
01114     {
01115       // low-multiplicity showers
01116       MSG("AlgAtmosShowerList",Msg::kDebug) << " reseeding low muliplicity showers " << endl;
01117       vector<ShowerSegmentCamAtNu*> tmpseg[2];
01118       for(View=0;View<2;View++)
01119         {
01120           ShowerClustersInTracks[View].clear(); tmpseg[View].clear(); PossibleShowerSegments[View].clear();
01121         }
01122       int ActualPlane;
01123       // reseed clusters
01124       for(Module=0;Module<NumModules;Module++)
01125         {
01126           for(Plane=1;Plane<1+PlanesInModule;Plane++)
01127             {
01128               ActualPlane=Plane+Module*(PlanesInModule+1);
01129               for(unsigned int j=0;j<ClusterBank[ActualPlane].size();j++)
01130                 {
01131                   ClusterCamAtNu* cluster0 = ClusterBank[ActualPlane][j];
01132                   cluster0->SetShwFlag(0); 
01133                   npts=0;
01134                   for(int k=-4;k<5;k++)
01135                     {
01136                       k0=ActualPlane+k;
01137                       if(k0>Module*(PlanesInModule+1) && k0<(Module+1)*(PlanesInModule+1))
01138                         {
01139                           for(unsigned int k1=0;k1<ClusterBank[k0].size();k1++)
01140                             {
01141                               ClusterCamAtNu* cluster1 = ClusterBank[k0][k1];
01142                               if(cluster0->GetCharge()>1.0 && cluster1->GetCharge()>1.0) { npts+=(int)cluster1->GetEntries(); }
01143                             }
01144                         }
01145                     }
01146                   if(npts>3)
01147                     {
01148                       View=cluster0->GetPlaneView(); ShowerClustersInTracks[View].push_back(cluster0); cluster0->SetShwFlag(1);
01149                     }
01150                 }
01151             }
01152         }
01153         
01154       // reseed 2D showers
01155       if(ShowerClustersInTracks[0].size()>0 && ShowerClustersInTracks[1].size()>0)
01156         {    
01157           for(View=0;View<2;View++)
01158             {
01159               for(unsigned int i=0;i<ShowerClustersInTracks[View].size();i++)
01160                 {
01161                   ClusterCamAtNu* cluster0 = ShowerClustersInTracks[View][i];
01162                   if(cluster0->GetShwFlag()>0 && cluster0->GetShwFlag()<2)
01163                     {
01164                       ShowerSegmentCamAtNu* seg0 = new ShowerSegmentCamAtNu(0, cluster0, 0);
01165                       tmpseg[View].push_back(seg0); ShowerSegmentBank.push_back(seg0); 
01166                       seg0->SetUID(2); //seg0->SetReseedFlag(1); 
01167                       Module=(Int_t)((cluster0->GetPlane())/(PlanesInModule+1)); cluster0->SetShwFlag(2); 
01168                       ctr=1;
01169                       while(ctr>0)
01170                         {
01171                           ctr=0; 
01172                           pln0=-6+seg0->GetBegPlane();
01173                           npln=7+(seg0->GetEndPlane()-seg0->GetBegPlane())/2;
01174                           for(int k=0;k<npln;k++)
01175                             {
01176                               k0=pln0+2*k;
01177                               if(k0>Module*(PlanesInModule+1) && k0<(Module+1)*(PlanesInModule+1))
01178                                 {
01179                                   for(unsigned int k1=0;k1<ClusterBank[k0].size();k1++)
01180                                     {
01181                                       ClusterCamAtNu* cluster1 = ClusterBank[k0][k1];
01182                                       if( cluster1->GetShwFlag()>0 && cluster1->GetShwFlag()<2 && seg0->IsDiffuseShwAssoc(cluster1)>0 )
01183                                         {
01184                                           seg0->AddCluster(cluster1); 
01185                                           cluster1->SetShwFlag(2); ctr++;
01186                                         }
01187                                     }
01188                                 }
01189                             }
01190                         }
01191                     }
01192                 }
01193             }
01194         }
01195         
01196       MSG("AlgAtmosShowerList",Msg::kVerbose) << " low multiplicity 2D showers - U=" << tmpseg[0].size() << " V=" << tmpseg[1].size() << endl; 
01197         
01198       // reseed 3D showers
01199       if( tmpseg[0].size()>0 && tmpseg[1].size()>0 )
01200         {
01201 
01202           for(unsigned int i=0;i<tmpseg[0].size();i++)
01203             {
01204               ShowerSegmentCamAtNu* segu = tmpseg[0][i];
01205               for(unsigned int j=0;j<tmpseg[1].size();j++)
01206                 {
01207                   ShowerSegmentCamAtNu* segv = tmpseg[1][j];
01208                   if( segu->GetNHits()>2 || segv->GetNHits()>2 && segu->GetEndPlane()-segv->GetBegPlane()>-4 && segv->GetEndPlane()-segu->GetBegPlane()>-4 )
01209                     {
01210                       PossibleShowerSegments[0].push_back(segu); PossibleShowerSegments[1].push_back(segv);     
01211                     }
01212                 }
01213             }
01214 
01215           id=-1; topscore=0.0;
01216           for(unsigned int i=0;i<PossibleShowerSegments[0].size();i++)
01217             {
01218               ShowerSegmentCamAtNu* segu = PossibleShowerSegments[0][i];
01219               ShowerSegmentCamAtNu* segv = PossibleShowerSegments[1][i];
01220               score= segu->GetNHits() + segv->GetNHits();
01221               if(score>topscore)
01222                 {
01223                   topscore=score; id=i;
01224                 }
01225             }
01226             
01227           if(id>-1)
01228             {
01229               ShowerSegmentCamAtNu* segu = PossibleShowerSegments[0][id];
01230               ShowerSegmentCamAtNu* segv = PossibleShowerSegments[1][id];
01231               ShowersFound[0].push_back(segu); segu->SetPartner(segv); segu->SetUID(4);
01232               ShowersFound[1].push_back(segv); segv->SetPartner(segu); segv->SetUID(4);
01233             }
01234         }
01235       tmpseg[0].clear(); tmpseg[1].clear();
01236     }
01237   for(int i=0; i<2; ++i)
01238     {
01239       PossibleShowerSegments[i].clear();
01240       ShowerClustersInTracks[i].clear();
01241       ShowerSegmentsAroundTracks[i].clear();
01242     }
01243   return;
01244 }

void AlgAtmosShowerList::RunAlg AlgConfig ac,
CandHandle ch,
CandContext cx
[virtual]
 

Implements AlgBase.

Definition at line 64 of file AlgAtmosShowerList.cxx.

References CandHandle::AddDaughterLink(), ClusterBank, FinalTrackBank, AlgFactory::GetAlgHandle(), CandContext::GetCandRecord(), CandContext::GetDataIn(), CandHandle::GetDaughterIterator(), AlgFactory::GetInstance(), CandContext::GetMom(), CandHandle::GetName(), CandHandle::GetNDaughters(), RecMinos::GetVldContext(), HitBank, CandShowerAtNu::MakeCandidate(), MSG, RunTheFinder(), CandHandle::SetName(), CandHandle::SetTitle(), ShowerBank, ShowerSegmentBank, ShowersFound, ShowerViewSegBank, TempTrack, and vldc.

00066 {
00067   assert(cx.GetDataIn());
00068   const TObjArray *arr = dynamic_cast<const TObjArray*>(cx.GetDataIn());
00069   // Check for CandSliceListHandle input
00070   if(arr->At(0)->InheritsFrom("CandSliceListHandle")) 
00071     {
00072       const CandSliceListHandle *cslh = dynamic_cast<const CandSliceListHandle*>(arr->At(0));
00073       if( !cslh || cslh->GetNDaughters()<1 ) {
00074         // Require number of CandSlices to be non-zero to do anything more
00075         MSG("AlgAtmosShowerList", Msg::kWarning) << " !cslh || cslh->GetNDaughters()<1 " << endl;
00076         return;
00077       }
00078 
00079       CandRecord* candrec = (CandRecord*)(cx.GetCandRecord());
00080       assert(candrec);
00081       
00082       vldc = (VldContext*)(candrec->GetVldContext());
00083       
00084       // Create the new tracklist
00085       bool havetracks = (arr->GetLast() && arr->At(1)->InheritsFrom("CandTrackListHandle"));
00086       const CandTrackListHandle* tracklist =(havetracks)?dynamic_cast<const CandTrackListHandle*>(arr->At(1)):0;
00087 
00088 
00089       CandShowerAtNuListHandle& showerlist= dynamic_cast<CandShowerAtNuListHandle&>(ch);
00090       
00092       
00093       // Iterate over the slices
00094       TIter sliceItr(cslh->GetDaughterIterator());
00095       AlgFactory &af = AlgFactory::GetInstance();      
00096       while (CandSliceHandle *slice = dynamic_cast<CandSliceHandle*>(sliceItr())) {
00097 
00098         // Find showers in slice
00100         RunTheFinder(slice, tracklist);
00101         
00102         // Now make the shower candidates
00104         TObjArray shwcxt;
00105         AlgHandle ah_shw = af.GetAlgHandle("AlgShowerCam", "default");
00106         MSG("AlgAtmosShowerList", Msg::kDebug) << "*** CREATE CandShowerHandles *** " << endl;
00107         for(unsigned int itr=0;itr<ShowerBank[0].size();itr++)
00108           {
00109             shwcxt.Clear();
00110             
00111             shwcxt.Add(ShowerBank[0][itr]);
00112             shwcxt.Add(ShowerBank[1][itr]);
00113             CandContext cx_shw(this, cx.GetMom());
00114             cx_shw.SetCandRecord(cx.GetCandRecord());
00115             cx_shw.SetDataIn(&shwcxt);
00116             CandShowerAtNuHandle shw = CandShowerAtNu::MakeCandidate(ah_shw, cx_shw);
00117             shw.SetName(TString("CandShowerAtNuHandle")); //hardcoded names are bad
00118             shw.SetTitle(TString("Created by CamFindModule from ").Append(cslh->GetName())); 
00119             showerlist.AddDaughterLink(shw);
00120           }
00121         
00123 
00124         // Clear up
00126         unsigned int i,j;
00127         for(i=0; i<2; ++i)
00128           {
00129             // delete all TrackSegmentCamAtNu objects
00130             for(j=0; j<TempTrack[i].size(); ++j)
00131               {
00132                 if(TempTrack[i][j]) delete TempTrack[i][j];
00133               }
00134             TempTrack[i].clear(); 
00135             // delete all TrackCamAtNu objects
00136             for(j=0; j<FinalTrackBank[i].size(); ++j)
00137               {
00138                 if(FinalTrackBank[i][j]) delete FinalTrackBank[i][j];
00139               }
00140             FinalTrackBank[i].clear();
00141             // delete all ShowerCamAtNu objects
00142             for(j=0; j<ShowerBank[i].size(); ++j)
00143               {
00144                 if(ShowerBank[i][j]) delete ShowerBank[i][j];
00145               }
00146             ShowerBank[i].clear(); 
00147 
00148             ShowerViewSegBank[i].clear();//new
00149             ShowersFound[i].clear();//new       
00150           }
00151 
00152         // delete all ShowerSegmentCamAtNu objects
00153         for(j=0; j<ShowerSegmentBank.size(); ++j) {if(ShowerSegmentBank[j]) delete ShowerSegmentBank[j];}
00154         ShowerSegmentBank.clear();//new
00155 
00156         for (i=0; i<500; ++i) {
00157           for(j=0; j<HitBank[i].size(); ++j) {if(HitBank[i][j]) delete HitBank[i][j];}
00158           HitBank[i].clear();
00159           
00160           for(j=0; j<ClusterBank[i].size(); ++j) {if(ClusterBank[i][j]) delete ClusterBank[i][j];}
00161           ClusterBank[i].clear();
00162           
00163         }
00165         
00166       } // End loop over slices
00167 
00168   } // End if inherits from CandSliceListHandle
00169   
00170 }

void AlgAtmosShowerList::RunTheFinder CandSliceHandle slice,
const CandTrackListHandle tracklist
 

Definition at line 177 of file AlgAtmosShowerList.cxx.

References DetermineShowerLikeShowerSegments(), FindShowerLikeSegments(), Form2DShowers(), Form3DShowers(), FormDummyTracks(), FormTheClusters(), FormTheHits(), FormVertexShowers(), VldContext::GetDetector(), IDTrkAndShwClusters(), MatchShowers(), ModuleType, NumModules, PlanesInModule, and vldc.

Referenced by RunAlg().

00178 {
00179   // Configure algorithm for the relevant detector
00180   // For ND, initial algorithm is applied only to calorimeter,
00181   // spectrometer is treated separately
00182 
00183   switch(vldc->GetDetector()){
00184   case Detector::kFar:
00185     ModuleType=1; NumModules=2; PlanesInModule=248; break;
00186   case Detector::kNear:
00187     ModuleType=2; NumModules=1; PlanesInModule=121; break;
00188   default:
00189     ModuleType=-1; NumModules=0; PlanesInModule=0; break;
00190   }
00191 
00192   // Run the methods
00193   FormTheHits(slice);
00194   FormTheClusters(); 
00195   IDTrkAndShwClusters(); 
00196   FormDummyTracks(slice, tracklist); // edit this one to make 2 track segments (one in each view) from the candtrack
00197   FindShowerLikeSegments();//new
00198   DetermineShowerLikeShowerSegments();
00199   Form2DShowers();//new
00200   MatchShowers();//new
00201   Form3DShowers(slice);//new
00202   FormVertexShowers(slice);//new
00203 
00204   return;
00205 }

void AlgAtmosShowerList::Trace const char *  c  )  const [virtual]
 

Reimplemented from AlgBase.

Definition at line 580 of file AlgAtmosShowerList.cxx.

00581 {
00582 }


Member Data Documentation

vector<ClusterCamAtNu*> AlgAtmosShowerList::ClusterBank[500] [private]
 

Definition at line 51 of file AlgAtmosShowerList.h.

Referenced by FindShowerLikeSegments(), Form2DShowers(), FormDummyTracks(), FormTheClusters(), IDTrkAndShwClusters(), MatchShowers(), and RunAlg().

vector<TrackCamAtNu*> AlgAtmosShowerList::FinalTrackBank[2] [private]
 

Definition at line 62 of file AlgAtmosShowerList.h.

Referenced by FormDummyTracks(), FormVertexShowers(), and RunAlg().

vector<HitCamAtNu*> AlgAtmosShowerList::HitBank[500] [private]
 

Definition at line 50 of file AlgAtmosShowerList.h.

Referenced by FormDummyTracks(), FormTheClusters(), FormTheHits(), FormVertexShowers(), and RunAlg().

int AlgAtmosShowerList::ModuleType [private]
 

Definition at line 67 of file AlgAtmosShowerList.h.

Referenced by RunTheFinder().

int AlgAtmosShowerList::NumModules [private]
 

Definition at line 65 of file AlgAtmosShowerList.h.

Referenced by RunTheFinder().

int AlgAtmosShowerList::PlanesInModule [private]
 

Definition at line 66 of file AlgAtmosShowerList.h.

Referenced by FindShowerLikeSegments(), Form2DShowers(), FormTheClusters(), FormVertexShowers(), IDTrkAndShwClusters(), MatchShowers(), and RunTheFinder().

vector<TrackSegmentCamAtNu*> AlgAtmosShowerList::SegmentBank[500] [private]
 

Definition at line 52 of file AlgAtmosShowerList.h.

vector<ShowerCamAtNu*> AlgAtmosShowerList::ShowerBank[2] [private]
 

Definition at line 57 of file AlgAtmosShowerList.h.

Referenced by Form3DShowers(), FormVertexShowers(), and RunAlg().

vector<ShowerSegmentCamAtNu*> AlgAtmosShowerList::ShowerSegmentBank [private]
 

Definition at line 54 of file AlgAtmosShowerList.h.

Referenced by FindShowerLikeSegments(), MatchShowers(), and RunAlg().

vector<ShowerSegmentCamAtNu*> AlgAtmosShowerList::ShowersFound[2] [private]
 

Definition at line 56 of file AlgAtmosShowerList.h.

Referenced by Form3DShowers(), MatchShowers(), and RunAlg().

vector<ShowerSegmentCamAtNu*> AlgAtmosShowerList::ShowerViewSegBank[2] [private]
 

Definition at line 55 of file AlgAtmosShowerList.h.

Referenced by DetermineShowerLikeShowerSegments(), FindShowerLikeSegments(), Form2DShowers(), MatchShowers(), and RunAlg().

vector<TrackSegmentCamAtNu*> AlgAtmosShowerList::TempTrack[2] [private]
 

Definition at line 60 of file AlgAtmosShowerList.h.

Referenced by FormDummyTracks(), MatchShowers(), and RunAlg().

VldContext* AlgAtmosShowerList::vldc [private]
 

Definition at line 64 of file AlgAtmosShowerList.h.

Referenced by FormTheHits(), RunAlg(), and RunTheFinder().


The documentation for this class was generated from the following files:
Generated on Sat Nov 21 22:49:11 2009 for loon by  doxygen 1.3.9.1