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

AlgShieldPlankList.cxx

Go to the documentation of this file.
00001 
00002 //
00003 // $Id: AlgShieldPlankList.cxx,v 1.3 2007/02/04 05:26:51 rhatcher Exp $ 
00004 //
00005 // AlgShieldPlankList
00006 //
00007 // Package: ShieldPlank
00008 //
00009 // Super class for shield strips
00010 //
00011 // Contact: Caius Howcroft<howcroft@hep.phy.cam.ac.uk>
00012 //
00013 //
00015 
00016 #include <cmath>
00017 #include <cassert>
00018 
00019 #include "Algorithm/AlgFactory.h"
00020 #include "Algorithm/AlgHandle.h"
00021 #include "Algorithm/AlgConfig.h"
00022 #include "Candidate/CandContext.h"
00023 #include "CandDigit/CandDigitHandle.h"
00024 #include "CandDigit/CandDigitListHandle.h"
00025 
00026 #include "ShieldPlank/AlgShieldPlankList.h"
00027 #include "ShieldPlank/CandShieldPlankList.h"
00028 #include "ShieldPlank/CandShieldPlankListHandle.h"
00029 
00030 #include "ShieldPlank/CandShieldPlank.h"
00031 #include "ShieldPlank/CandShieldPlankList.h"
00032 
00033 #include "Conventions/Mphysical.h"
00034 #include "Conventions/Munits.h"
00035 #include "Conventions/PlaneView.h"
00036 #include "MessageService/MsgService.h"
00037 #include "MinosObjectMap/MomNavigator.h"
00038 #include "Navigation/NavKey.h"
00039 #include "Navigation/NavSet.h"
00040 #include "UgliGeometry/UgliGeomHandle.h"
00041 #include "Validity/VldContext.h"
00042 
00043 static NavKey StripSRKeyFromPSEId(const CandDigitHandle *);
00044  
00045 CVSID("$Id: AlgShieldPlankList.cxx,v 1.3 2007/02/04 05:26:51 rhatcher Exp $");
00046 //______________________________________________________________________
00047 AlgShieldPlankList::AlgShieldPlankList()
00048 {
00049 }
00050 
00051 //______________________________________________________________________
00052 AlgShieldPlankList::~AlgShieldPlankList()
00053 {
00054 }
00055 
00056 //______________________________________________________________________
00057 void AlgShieldPlankList::RunAlg(AlgConfig& /* ac */, 
00058                                 CandHandle& ch, CandContext& cx)
00059 {
00060 
00061   MSG("ShieldPlank",Msg::kDebug) << "Start ALGSHIELDSTRIPLIST"<<endl;
00062   assert(cx.GetDataIn());
00063 
00064   if (!(cx.GetDataIn()->InheritsFrom("CandDigitListHandle"))) {
00065     MSG("ShieldPlank",Msg::kError) << "AlgShieldPlankList wasnt passed a CandDigitList"<<endl;
00066     return;
00067   }
00068 
00069   //======================================================
00070   //Set up all pointer junk
00071   //
00072   CandShieldPlankListHandle& csslh = (CandShieldPlankListHandle&) ch;
00073   CandRecord *candrec = cx.GetCandRecord();
00074   assert(candrec);
00075   const VldContext *vldcptr = candrec->GetVldContext();
00076   assert(vldcptr);
00077   VldContext vldc = *vldcptr;
00078   
00079 
00080   CandContext cxx(this,cx.GetMom());
00081   cxx.SetCandRecord(candrec);
00082 
00083   AlgFactory &af = AlgFactory::GetInstance();
00084   AlgHandle ah = af.GetAlgHandle("AlgShieldPlank","default");
00085   
00086   
00087   const CandDigitListHandle *cdlh =
00088     dynamic_cast<const CandDigitListHandle*>(cx.GetDataIn());
00089      
00090 
00091 
00092   //=====================================================
00093   // Sort by Plane and Strip
00094   //
00095   MSG("ShieldPlank",Msg::kDebug) << "Sort by strip and plane:"<<cdlh->GetNDaughters()<<endl;
00096   CandDigitHandleItr cdhItr(cdlh->GetDaughterIterator());
00097   CandDigitHandleKeyFunc *cdhKf = cdhItr.CreateKeyFunc();
00098   cdhKf->SetFun(StripSRKeyFromPSEId);
00099   cdhItr.GetSet()->AdoptSortKeyFunc(cdhKf);
00100   cdhKf = 0;
00101   MSG("ShieldPlank",Msg::kDebug) << "Done sort"<<endl;
00102   
00103   
00104   //=====================================================
00105   //
00106   //
00107   CandDigitHandle *prev = 0;
00108   CandDigitHandle *first = 0;
00109   TObjArray cdhAr;
00110   cdhAr.Clear();
00111   while (CandDigitHandle *curr = cdhItr()) {
00112     PlexSEIdAltL pseid = curr->GetPlexSEIdAltL();
00113 
00114     if(!pseid.IsVetoShield())continue;
00115     MSG("ShieldPlank",Msg::kDebug) << "considering digit, plane " << pseid.GetPlane() << " plexsize " << pseid.GetSize() << endl;
00116     if (prev) {
00117       bool issameplank = 0;
00118       const PlexSEIdAltL& pSEIdAltL = prev->GetPlexSEIdAltL();
00119       const PlexSEIdAltL& cSEIdAltL = curr->GetPlexSEIdAltL();
00120       for(PlexSEIdAltL::const_iterator iterp = pSEIdAltL.begin();
00121           iterp!=pSEIdAltL.end(); ++iterp)
00122         {
00123            for(PlexSEIdAltL::const_iterator iterc = cSEIdAltL.begin();
00124                iterc!=cSEIdAltL.end(); ++iterc)
00125              {
00126                if((*iterp).GetSEId().IsSameStrip( (*iterc).GetSEId() ))
00127                  {
00128                    //found match
00129                    MSG("ShieldPlank",Msg::kDebug) << "MATCH " <<(*iterp).GetSEId().GetPlane() << "=="<<(*iterc).GetSEId().GetPlane()<< " Strip:"<<  (*iterp).GetSEId().GetStrip()<<" == "<<(*iterc).GetSEId().GetStrip()<<endl;            
00130                    issameplank = 1;
00131                    break;
00132                  }
00133              }
00134            if(issameplank) break;
00135         }
00136 
00137       
00138       if (issameplank) {
00139         cdhAr.Add(curr);
00140       } else {
00141         MSG("ShieldPlank",Msg::kDebug) << "Making shield strip from "<< cdhAr.GetLast()<<" digits"<<endl; 
00142         cxx.SetDataIn(&cdhAr);
00143 
00144         CandShieldPlankHandle csh = CandShieldPlank::MakeCandidate(ah,cxx);
00145         csslh.AddDaughterLink(csh);
00146         cdhAr.Clear();
00147         cdhAr.Add(curr);
00148         first = curr;
00149       }
00150     } else {
00151       cdhAr.Add(curr);
00152       first = curr;
00153     }
00154     prev = curr;
00155   }
00156   
00157   if (prev) {
00158     cxx.SetDataIn(&cdhAr);
00159     MSG("ShieldPlank",Msg::kDebug) << "Making shield strip from "<< cdhAr.GetLast()<<" digits"<<endl; 
00160     CandShieldPlankHandle csh = CandShieldPlank::MakeCandidate(ah,cxx);
00161     csslh.AddDaughterLink(csh);
00162   }
00163 
00164   //
00165   //Set the Abs time of shield plank list to the abs time of the digit list
00166   //
00167   double abstime(cdlh->GetAbsTime());
00168   if(!finite(abstime)) abstime = -99e99;
00169   csslh.SetAbsTime(abstime);
00170   
00171 }
00172 
00173 NavKey StripSRKeyFromPSEId(const CandDigitHandle *cdh)
00174 {
00175   //junk function stolen from roy
00176   return const_cast<CandDigitHandle *>(cdh)->GetPlexSEIdAltL().GetBestSEId().GetEncoded();
00177 }
00178 
00179 //______________________________________________________________________
00180 void AlgShieldPlankList::Trace(const char* /*c*/) const
00181 {
00182   //I have no idea what this does! more pointless code?
00183 }
00184 
00185 ClassImp(AlgShieldPlankList)
00186 
00187 
00188 

Generated on Mon Feb 15 11:06:19 2010 for loon by  doxygen 1.3.9.1