/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Muc/MucRecEvent/MucRecEvent-00-02-52/src/MucRecHitContainer.cxx

Go to the documentation of this file.
00001 //$id$
00002 //
00003 //$log$
00004 
00005 /*
00006  *    2003/12/13   Zhengyun You     Peking University
00007  * 
00008  *    2004/09/12   Zhengyun You     Peking University
00009  *                 transplanted to Gaudi framework
00010  */
00011 
00012 #include "MucRecEvent/MucRecHitContainer.h"
00013 
00014 // Constructor.
00015 MucRecHitContainer::MucRecHitContainer()
00016 { }
00017 
00018 // Destructor.
00019 MucRecHitContainer::~MucRecHitContainer()
00020 {
00021   //Clear();
00022 }
00023 
00024 // Initializes the MucRecHitContainer.
00025 void 
00026 MucRecHitContainer::Init()
00027 {
00028   //  cout << "MucRecHitContainer::Init-I1  hello world" << endl;
00029 
00030   Clear();
00031 
00032   //cout << "*********** Hit Container Initialized! *********** " << endl;
00033 }
00034 
00035 void 
00036 MucRecHitContainer::Clear()
00037 {
00038   for (int part = 0; part < (int)MucID::getPartNum(); part++) {
00039     for (int seg = 0; seg < (int)MucID::getSegNum(part); seg++) {
00040       for (int gap = 0; gap < (int)MucID::getGapNum(part); gap++) {
00041         MucRecHitID gapID(part, seg, gap);
00042         m_GapHitCount[gapID] = 0;
00043       }
00044     }
00045   }
00046 
00047   //m_pMucRecHitCol->clear();
00048   m_pHit.clear();
00049 }
00050 
00051 int 
00052 MucRecHitContainer::GetHitCount()
00053 {
00054   int count = 0;
00055   for (int part = 0; part < (int)MucID::getPartNum(); part++) {
00056     for (int seg = 0; seg < (int)MucID::getSegNum(part); seg++) {
00057       for (int gap = 0; gap < (int)MucID::getGapNum(part); gap++) {
00058         MucRecHitID gapID(part, seg, gap);
00059         count += m_GapHitCount[gapID];
00060       }
00061     }
00062   }
00063   
00064   return count;
00065 }
00066 
00067 int 
00068 MucRecHitContainer::GetGapHitCount(const MucRecHitID gapID)
00069 {
00070   if (m_GapHitCount.count(gapID)) return m_GapHitCount[gapID];
00071   return 0;
00072 }
00073 
00074 int 
00075 MucRecHitContainer::GetGapHitCount(const int part,
00076                                    const int seg,
00077                                    const int gap)
00078 {
00079   MucRecHitID gapID(part, seg, gap);
00080   return m_GapHitCount[gapID];
00081 }
00082 
00083 MucRecHit* 
00084 MucRecHitContainer::GetHit(const MucRecHitID id)
00085 {
00086   if (m_pHit.count(id)) return m_pHit[id];
00087   else return 0;
00088 }
00089 
00090 MucRecHit* 
00091 MucRecHitContainer::GetHit(const int part,
00092                            const int seg,
00093                            const int gap,
00094                            const int hit)
00095 {
00096   MucRecHitID id(part, seg, gap, hit);
00097   return m_pHit[id];
00098 }
00099 
00100 MucRecHit* 
00101 MucRecHitContainer::GetHitByIdentifier(const Identifier id)
00102 {
00103   int part  = MucID::part(id);
00104   int seg   = MucID::seg(id);
00105   int gap   = MucID::gap(id);
00106   int strip = MucID::strip(id);
00107   
00108   return GetHitByIdentifier(part, seg, gap, strip);
00109 }
00110 
00111 MucRecHit* 
00112 MucRecHitContainer::GetHitByIdentifier(const int part,
00113                                        const int seg,
00114                                        const int gap,
00115                                        const int strip)
00116 {
00117   Identifier id = MucID::channel_id(part, seg, gap, strip);
00118   for(int i = 0; i < GetGapHitCount(part, seg, gap); i++) {
00119     MucRecHit *hit = GetHit(part, seg, gap, i);
00120     if(id == hit->GetID()) {
00121       return hit;
00122     }
00123   }
00124   
00125   return 0;
00126 }
00127 
00128 // Place a new hit object in the container.
00129 void
00130 MucRecHitContainer::AddHit(const Identifier id)
00131 {
00132   int part  = MucID::part(id);
00133   int seg   = MucID::seg(id);
00134   int gap   = MucID::gap(id);
00135   int strip = MucID::strip(id);
00136 
00137   AddHit(part, seg, gap, strip);
00138 }
00139 
00140 // Place a new hit object in the container.
00141 void
00142 MucRecHitContainer::AddHit(const int part,
00143                            const int seg,
00144                            const int gap,
00145                            const int strip)
00146 {
00147   if ( (part  >= 0) && (part  < (int)MucID::getPartNum()) &&
00148        (seg   >= 0) && (seg   < (int)MucID::getSegNum(part)) &&
00149        (gap   >= 0) && (gap   < (int)MucID::getGapNum(part)) &&
00150        (strip >= 0) && (strip < (int)MucID::getStripNum(part, seg, gap)) )
00151     {
00152       MucRecHitID gapID(part, seg, gap);
00153       //       cout << "MucRecHitContainer::AddHit-I1  " << idGap << endl;
00154       
00155       int hitCount = m_GapHitCount[gapID];
00156       MucRecHitID id(part, seg, gap, hitCount);
00157       //       cout << "MucRecHitContainer::AddHit-I2  hit id = " << id << endl;
00158       
00159       MucRecHit *pHit = new MucRecHit(part, seg, gap, strip);
00160       m_pMucRecHitCol->push_back(pHit);
00161 
00162       m_pHit[id] = pHit;
00163       if(!m_pHit[id]) {
00164         cout << "MucRecHitContainer::AddHit-F1  failed to create new MucRecHit" << endl;
00165       }
00166       else {
00167         m_GapHitCount[gapID]++;
00168       }
00169     }
00170 }
00171 
00172 void
00173 MucRecHitContainer::SetMucRecHitCol(MucRecHitCol* p)
00174 {
00175   m_pMucRecHitCol = p;
00176 
00177   MucRecHitCol::iterator imuchit;
00178   for(imuchit = p->begin();
00179       imuchit != p->end();
00180       imuchit++){
00181         int part = (*imuchit)->Part();
00182         int seg  = (*imuchit)->Seg();
00183         int gap  = (*imuchit)->Gap();
00184         int strip= (*imuchit)->Strip();
00185         
00186         MucRecHitID gapID(part, seg, gap);
00187         int hitCount = m_GapHitCount[gapID];
00188         MucRecHitID id(part, seg, gap, hitCount);
00189 
00190         m_pHit[id] = *imuchit;
00191         if(!m_pHit[id]) {
00192                 cout << "MucRecHitContainer::AddHit-F1  failed to create new MucRecHit" << endl;
00193         }
00194         else {
00195                 m_GapHitCount[gapID]++;
00196         }
00197 
00198 
00199   }
00200 
00201 }
00202 

Generated on Tue Nov 29 23:12:58 2016 for BOSS_7.0.2 by  doxygen 1.4.7