| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

PreElecSimSvc Namespace Reference


Namespaces

namespace  __init__

Functions

 PreElecSimSvc (const string &name, ISvcLocator *pSvcLocator)
 ~PreElecSimSvc ()
StatusCode initialize ()
StatusCode queryInterface (const InterfaceID &riid, void **ppint)
SimHitHeadergetSimHitHeader (vector< const SimHeader * > &shs, TimeStamp &hite, TimeStamp &hitl)
StatusCode fillHitsBuffer (SimHeader *sh)
StatusCode findGap ()
StatusCode createHitHeaders ()

Function Documentation

PreElecSimSvc::PreElecSimSvc ( const string &  name,
ISvcLocator pSvcLocator 
)

Definition at line 9 of file PreElecSimSvc.cc.

00010               :Service(name, pSvcLocator), m_log(msgSvc(), "PreElecSimSvc")
00011 {
00012   //MixInputSvc
00013   m_mixInputSvc = 0;
00014 
00015   //MiniTimeGap 
00016   //pre(post)TimeTolerance "ns"
00017   double mintimeGap = preTimeTolerance/CLHEP::nanosecond + postTimeTolerance/CLHEP::nanosecond;
00018   /*declareProperty("MinGapTime", m_mintimeGap = preTimeTolerance + postTimeTolerance,
00019     "Minimum width for a gap that defines a chunk of SimHits");*/
00020 
00021   /*m_log<< MSG::INFO<< "PreElecSimSvc::PreElecSimSvc(): "
00022     << " m_mintimeGap: "<< m_mintimeGap<< endreq;*/
00023 
00024   TimeStamp initime(mintimeGap/1.0e9);
00025   m_minTimeGap = initime;
00026 }

PreElecSimSvc::~PreElecSimSvc (  ) 

Definition at line 28 of file PreElecSimSvc.cc.

00029 {
00030   m_log<< MSG::INFO<< "PreElecSimSvc::~PreElecSimSvc()..."<< endreq;
00031 }

StatusCode PreElecSimSvc::initialize (  ) 

Definition at line 33 of file PreElecSimSvc.cc.

00034 {
00035   //PreElecSim initialization
00036   m_log<< MSG::INFO<< "PreElecSimSvc ininalize @"<< (void*)this<< endreq;
00037   StatusCode sc = Service::initialize();
00038   if(sc.isFailure()) 
00039   {
00040     m_log<< MSG::ERROR<< "Parent class(Service) failed to initialize!"<< endreq;
00041     return sc;
00042   }
00043   
00044   //Check the mini time gap
00045   m_log<< MSG::INFO<< "MinTimeGap: "<< m_minTimeGap.GetSec()<< "s--"
00046        << m_minTimeGap.GetNanoSec()<< "ns"<< endreq;
00047 
00048   //Initialize the MixInputSvc   
00049   IService* isvc = 0;
00050   sc = serviceLocator()->service("RootIOCnvSvc", isvc, true);
00051   if(sc.isFailure()) 
00052   {
00053     m_log<< MSG::ERROR<< "Conversion service RootIOCnvSvc could not be retrieved"<< endreq;
00054     return sc;
00055   }
00056   isvc->addRef();
00057   sc = isvc->queryInterface(IMixInputSvc::interfaceID(), (void**)&m_mixInputSvc);
00058   if(sc.isFailure()) 
00059   {
00060     m_log<< MSG::ERROR<< "Service MixInputSvc does not implement IMixInputSvc"<< endreq;
00061     return sc;
00062   }
00063 
00064   return StatusCode::SUCCESS;
00065 }

StatusCode PreElecSimSvc::queryInterface ( const InterfaceID riid,
void **  ppint 
)

Definition at line 67 of file PreElecSimSvc.cc.

00068 {
00069   if(IID_IPreElecSimSvc.versionMatch(riid)) 
00070   {
00071     m_log<< MSG::DEBUG<< "queryInterface("<< riid
00072          << ")-->(IPreElecSimSvc*)"<< (void*)this<< endreq;
00073     *ppint = (IPreElecSimSvc*)this;
00074   }
00075   else 
00076   {
00077     return Service::queryInterface(riid, ppint);
00078   }
00079   addRef();
00080   return StatusCode::SUCCESS;
00081 }

SimHitHeader* PreElecSimSvc::getSimHitHeader ( vector< const SimHeader * > &  shs,
TimeStamp hite,
TimeStamp hitl 
)

Definition at line 84 of file PreElecSimSvc.cc.

00085 {
00086   m_log<< MSG::INFO<< "Now in the getSimHeaders()...."<< endreq;
00087 
00088   TimeStamp initime(0.0);
00089   hite = initime;
00090   hitl = initime;
00091 
00092   for( ; ; )
00093   {
00094     m_log<< MSG::DEBUG<< "SimHitHeaders' buffer size = "<< m_propSimHitHeaders.size()<< endreq;
00095 
00096     //The SimHitHeader buffer is not empty
00097     if(0 != m_propSimHitHeaders.size())
00098     {
00099       m_log<< MSG::DEBUG<< "So, get one SimHitHeader and its SimHeaders directly!"<< endreq;
00100       //Output one SimHitHeader
00101       SimHitHeader* shh = m_propSimHitHeaders[0];
00102       if(!shh)
00103       {
00104         m_log<< MSG::ERROR<< "Got one wrong SimHitHeader!"<< endreq;
00105         return shh; 
00106       }
00107 
00108       hite = m_hitEarliests[0];
00109       hitl = m_hitLatests[0];
00110       
00111       shs = m_HitHeaderToHeaders[shh];
00112 
00113       //pop_front the SimHitHeader buffer(take care of memory)
00114       m_log<< MSG::DEBUG<< "Before clearing: SimHitHeader buffer size: "<< m_propSimHitHeaders.size()
00115            << " SimHitToSimHeader buffer size: "<< m_HitHeaderToHeaders.size()<< endreq;
00116 
00117       m_HitHeaderToHeaders.erase(m_propSimHitHeaders[0]);
00118       m_propSimHitHeaders.pop_front();
00119       m_hitEarliests.pop_front();
00120       m_hitLatests.pop_front();
00121 
00122       m_log<< MSG::DEBUG<< "After clearing: SimHitHeader buffer size: "<< m_propSimHitHeaders.size()
00123            << " SimHitToSimHeader buffer size: "<< m_HitHeaderToHeaders.size()<< endreq;
00124 
00125       return shh;
00126     }
00127     else //The SimHitHeader buffer is empty
00128     {
00129       m_log<< MSG::DEBUG<< "So, need to create a SimHitHeader(SimHeaders) firstly!"<< endreq;
00130 
00131       m_ifDeal = false;
00132 
00133       //Multi-events input
00134       for(; ;)
00135       {
00136         //Input one SimHeader and its GenHeader
00137         SimHeader* sh = new SimHeader();
00138         //SimHeader* sh = 0;
00139         GenHeader* gh = new GenHeader();
00140 
00141         //GenHeader* gh = 0;
00142         StatusCode sc = m_mixInputSvc->prepareStream();
00143         if(sc.isFailure())
00144         {
00145           m_log<< MSG::ERROR<< "Error when preparing input-streams from files!"<< endreq;
00146           return 0;
00147         }
00148 
00149         sc = m_mixInputSvc->getSimHeader(gh, sh);
00150         if(sc.isFailure())
00151         {
00152           m_log<< MSG::ERROR<< "Error when getting a SimHeader from file!"<< endreq;
00153           return 0;
00154         }
00155 
00156         //Delete GenHeader(temp)
00157         delete gh;
00158 
00159         //Judge if need to fill the SimHits buffer
00160         if(0 == m_hitsGap.size()) //At the very beginning
00161         {
00162           m_log<< MSG::DEBUG<< "The Hits Gap vectors: GapV(TimeStamp) size = "
00163                << m_hitsGap.size()<< endreq;
00164 
00165           sc = this->fillHitsBuffer(sh);
00166           if(sc.isFailure())
00167           {
00168             m_log<< MSG::ERROR<< "Error when filling the SimHits!"<< endreq;
00169             return 0;
00170           }
00171           continue;
00172         }
00173         else
00174         {
00175           m_log<< MSG::DEBUG<< "The Hits Gap vectors: GapV(TimeStamp) size = "
00176                << m_hitsGap.size()<< endreq;
00177 
00178           //Judge if new SimHitHeaders can be created
00179           deque<TimeStamp>::size_type ind = m_hitsGap.size();
00180           ind--;
00181           for(; ; ind--)
00182           {
00183             m_log<< MSG::DEBUG<< "Now the Gap vector's index is: "<< ind<< endreq;
00184             m_log<< MSG::DEBUG<< "Time interval: "<< (sh->earliest() - m_hitsGap[ind]).GetSec()
00185                  << "--"<< (sh->earliest() - m_hitsGap[ind]).GetNanoSec()<< endreq;
00186             
00187             if((sh->earliest() - m_hitsGap[ind]) < m_minTimeGap) 
00188             {
00189               if(0 == ind)
00190               {
00191                 m_log<< MSG::DEBUG<< "Now, there is no Gap with next SimHeader!"<< endreq;
00192                 m_ifDeal = false;
00193                 break;
00194               }
00195               else continue;
00196             }
00197             else 
00198             {
00199               m_ifDeal = true;
00200               m_dealInd = ind;
00201               m_log<< MSG::DEBUG<< "The gap is between m_hitsGap["<< ind<< "]: "
00202                    << "SimHeader's earliest()"<< endreq;
00203               break;
00204             }
00205           }//over
00206 
00207           if(false == m_ifDeal) //can not create new SimHitHeaders, just fill
00208           {
00209             m_log<< MSG::DEBUG<< "So, just fill the SimHits buffer!"<< endreq;
00210 
00211             //Fill SimHits buffer with the current SimHeader
00212             sc = this->fillHitsBuffer(sh);
00213             if(sc.isFailure())
00214             {
00215               m_log<< MSG::ERROR<< "Error when filling the SimHits!"<< endreq;
00216               return 0;
00217             }
00218             
00219             continue;
00220           }
00221           else //can create new SimHitHeaders
00222           {
00223             m_log<< MSG::DEBUG<< "So, create a new SimHitHeader firstly!"<< endreq;
00224 
00225             //Create one or more new SimHitHeaders in SimHitHeader buffer
00226             sc = this->createHitHeaders();
00227             if(sc.isFailure())
00228             {
00229               m_log<< MSG::ERROR<< "Error when creating the new SimHitHeaders!"<< endreq;
00230               return 0;
00231             }
00232             
00233             m_log<< MSG::DEBUG<< "OK, then fill the SimHits buffer!"<< endreq;
00234             //then fill SimHits buffer with the current SimHeader
00235             sc = this->fillHitsBuffer(sh);
00236             if(sc.isFailure())
00237             {
00238               m_log<< MSG::ERROR<< "Error when filling the SimHits!"<< endreq;
00239               return 0; 
00240             }
00241             
00242             break; //Quit the Multi-events input cycle
00243           }
00244         }
00245       }            //Multi-events input cycle
00246     }
00247   }                //Top for cycle
00248 }

StatusCode PreElecSimSvc::fillHitsBuffer ( SimHeader sh  ) 

Definition at line 251 of file PreElecSimSvc.cc.

00252 {
00253   m_log<< MSG::INFO<< "Fill SimHits buffer..."<< endreq;
00254 
00255   //Get the SimHitHeader
00256   const SimHitHeader* shh = sh->hits();
00257   map<short int, SimHitCollection*> mshc = shh->hitCollection();
00258 
00259   m_absTime = sh->timeStamp();
00260   m_log<< MSG::DEBUG<< "The current SimHeader time: "<< m_absTime.GetSec()
00261        << "--"<< m_absTime.GetNanoSec()<< endreq;
00262  
00263   //fill the SimHits buffer
00264   if(0 == m_hitsGap.size())
00265   {
00266     m_log<< MSG::DEBUG<< "m_SimHits' size is: "<< m_SimHits.size()<< "!"<< endreq;
00267 
00268     map<short int, SimHitCollection*>::iterator mit;
00269     for(mit = mshc.begin(); mit != mshc.end(); mit++)
00270     {
00271       //Get the SimHitCollection
00272       m_log<< MSG::INFO<< "In Det: "<< mit->first<< endreq;
00273 
00274       SimHitCollection* shc = mit->second;
00275       vector<SimHit*> hits = shc->collection();
00276       if(0 == hits.size()) return StatusCode::FAILURE;
00277 
00278       //Fill the Hits buffer
00279       for(vector<SimHit*>::iterator vit = hits.begin(); vit != hits.end(); vit++) 
00280       {
00281         MixSimHit mixhit;
00282         //m_log<< MSG::DEBUG<< "SimHit time: "<< (*vit)->hitTime()<< endreq;
00283         TimeStamp temTime = m_absTime;
00284         temTime.Add(((*vit)->hitTime())/1.0e9); //hitTime() to TimeStamp, relative to absolute
00285         mixhit.hitTime     = temTime;
00286         //m_log<< MSG::DEBUG<< "SimHit time: "<< (*vit)->hitTime()<< endreq;
00287         mixhit.trivialtime = (*vit)->hitTime() - (int)((*vit)->hitTime());
00288         m_log<< MSG::DEBUG<< "SimHit Time: "<< mixhit.hitTime.GetSec()
00289            << "--"<< mixhit.hitTime.GetNanoSec()<< endreq;
00290         mixhit.setHit(*vit);
00291         m_SimHits.push_back(mixhit); //deep copy need?
00292       }
00293     }
00294 
00295     sort(m_SimHits.begin(), m_SimHits.end());
00296 
00297     m_log<< MSG::DEBUG<< "After sorting....."<< endreq;
00298     for(deque<MixSimHit>::iterator vit = m_SimHits.begin(); vit != m_SimHits.end(); vit++)
00299     {
00300       //m_log<< MSG::DEBUG<< "SimHit time: "<< vit->sht->hitTime()<< endreq;
00301       m_log<< MSG::DEBUG<< "SimHit time in m_SimHits: "<< vit->hitTime.GetSec()
00302            << "--"<< vit->hitTime.GetNanoSec()<< endreq;
00303     }
00304   }
00305   else
00306   {
00307     deque<TimeStamp>::size_type curind = m_hitsGap.size();
00308     curind--;
00309 
00310     if(sh->earliest() > m_hitsGap[curind])
00311     {
00312       //Loop over all detectors' SimHitCollections
00313       deque<MixSimHit> mixhits;
00314       map<short int, SimHitCollection*>::iterator mit;
00315       for(mit = mshc.begin(); mit != mshc.end(); mit++)
00316       {
00317         //Get the SimHitCollection
00318         m_log<< MSG::INFO<< "In Det: "<< mit->first<< endreq;
00319 
00320         SimHitCollection* shc = mit->second;
00321         vector<SimHit*> hits = shc->collection();
00322         if(0 == hits.size()) return StatusCode::FAILURE;
00323 
00324         //Fill the Hits buffer
00325         for(vector<SimHit*>::iterator vit = hits.begin(); vit != hits.end(); vit++) 
00326         {
00327           MixSimHit mixhit;
00328           //m_log<< MSG::DEBUG<< "SimHit time: "<< (*vit)->hitTime()<< endreq;
00329           TimeStamp temTime = m_absTime;
00330           temTime.Add(((*vit)->hitTime())/1.0e9); //hitTime() to TimeStamp, relative to absolute
00331           mixhit.hitTime     = temTime;
00332           mixhit.trivialtime = (*vit)->hitTime() - (int)((*vit)->hitTime());
00333           m_log<< MSG::DEBUG<< "SimHit Time: "<< mixhit.hitTime.GetSec()
00334                << "--"<< mixhit.hitTime.GetNanoSec()<< endreq;
00335           mixhit.setHit(*vit);
00336           mixhits.push_back(mixhit); //deep copy need?
00337         }
00338       }
00339 
00340       //sort the mixhits
00341       sort(mixhits.begin(), mixhits.end());
00342 
00343       m_log<< MSG::DEBUG<< "After sorting....."<< endreq;
00344       for(deque<MixSimHit>::iterator dit = mixhits.begin(); dit != mixhits.end(); dit++)
00345       {
00346         //m_log<< MSG::DEBUG<< "SimHit time in mixhits: "<< dit->sht->hitTime()<< endreq;
00347         m_log<< MSG::DEBUG<< "SimHit time in mixhits: "<< dit->hitTime.GetSec()
00348              << "--"<< dit->hitTime.GetNanoSec()<< endreq;
00349         m_SimHits.push_back(*dit);
00350       }
00351 
00352       m_log<< MSG::DEBUG<< "After merging: "<< endreq;
00353       for(deque<MixSimHit>::iterator vit = m_SimHits.begin(); vit != m_SimHits.end(); vit++)
00354       {
00355         //m_log<< MSG::DEBUG<< "SimHit time in m_SimHits: "<< vit->sht->hitTime()<< endreq;
00356         m_log<< MSG::DEBUG<< "SimHit time in m_SimHits: "<< vit->hitTime.GetSec()
00357              << "--"<< vit->hitTime.GetNanoSec()<< endreq;
00358       }
00359 
00360       mixhits.clear();
00361     }
00362     else
00363     {
00364       //Loop over all detectors' SimHitCollections
00365       deque<MixSimHit> mixhits;
00366       map<short int, SimHitCollection*>::iterator mit;
00367       for(mit = mshc.begin(); mit != mshc.end(); mit++)
00368       {
00369         //Get the SimHitCollection
00370         m_log<< MSG::INFO<< "In Det: "<< mit->first<< endreq;
00371 
00372         SimHitCollection* shc = mit->second;
00373         vector<SimHit*> hits = shc->collection();
00374         if(0 == hits.size()) return StatusCode::FAILURE;
00375 
00376         //Fill the Hits buffer
00377         for(vector<SimHit*>::iterator vit = hits.begin(); vit != hits.end(); vit++) 
00378         {
00379           MixSimHit mixhit;
00380           //m_log<< MSG::DEBUG<< "SimHit time: "<< (*vit)->hitTime()<< endreq;
00381           TimeStamp temTime = m_absTime;
00382           temTime.Add(((*vit)->hitTime())/1.0e9); //hitTime() to TimeStamp, relative to absolute
00383           mixhit.hitTime     = temTime;
00384           mixhit.trivialtime = (*vit)->hitTime() - (int)((*vit)->hitTime());
00385           m_log<< MSG::DEBUG<< "SimHit Time: "<< mixhit.hitTime.GetSec()
00386                << "--"<< mixhit.hitTime.GetNanoSec()<< endreq;
00387           mixhit.setHit(*vit);
00388           mixhits.push_back(mixhit); //deep copy need?
00389         }
00390       }
00391 
00392       //sort the mixhits
00393       sort(mixhits.begin(), mixhits.end());
00394       merge(m_SimHits.begin(), m_SimHits.end(), mixhits.begin(), mixhits.end(), back_inserter(m_tranSimHits));
00395       m_SimHits = m_tranSimHits;
00396   
00397       m_log<< MSG::DEBUG<< "After merging: "<< endreq;
00398       for(deque<MixSimHit>::iterator vit = m_SimHits.begin(); vit != m_SimHits.end(); vit++)
00399       {
00400         //m_log<< MSG::DEBUG<< "SimHit time in m_SimHits: "<< vit->sht->hitTime()<< endreq;
00401         m_log<< MSG::DEBUG<< "SimHit time in m_SimHits: "<< vit->hitTime.GetSec()
00402              << "--"<< vit->hitTime.GetNanoSec()<< endreq;
00403       }
00404 
00405       m_tranSimHits.clear(); //Clear the buffer
00406       mixhits.clear();
00407     }
00408   }
00409 
00410   //Update the gap vector
00411   StatusCode sc = this->findGap();
00412   if(sc.isFailure())
00413   {
00414     m_log<< MSG::ERROR<< "Error in findGap()!"<< endreq;
00415     return StatusCode::FAILURE;
00416   }
00417 
00418   return StatusCode::SUCCESS;
00419 }

StatusCode PreElecSimSvc::findGap (  ) 

Definition at line 421 of file PreElecSimSvc.cc.

00422 {
00423   m_log<< MSG::DEBUG<< "Find gap here(update the Gap Vector)..."<< endreq;
00424 
00425   //Prepare the Gap vector
00426   //m_hitsgap.clear();
00427   m_hitsGap.clear();
00428 
00429   if(m_SimHits.size() < 2) //at least two hits. Actually, now there is just one.
00430   {
00431     m_log<< MSG::WARNING<< "No enough SimHits in m_SimHits! Be carefull!"<< endreq;
00432 
00433     //m_hitsgap.push_back(m_SimHits[0].sht->hitTime());
00434     //TimeStamp gapBeginTime(m_SimHits[0].sht->hitTime());
00435     //gapBeginTime.Add(m_absTime);
00436     m_hitsGap.push_back(m_SimHits[0].hitTime);
00437 
00438     for(vector<TimeStamp>::size_type ind = 0; ind != m_hitsGap.size(); ind++)
00439     {
00440       m_log<< MSG::DEBUG<< "TimeStamp Gap: "<< m_hitsGap[ind].GetSec()<< "--"
00441            << m_hitsGap[ind].GetNanoSec()<< endreq;
00442     }
00443 
00444     return StatusCode::SUCCESS;
00445   }
00446 
00447   //The first two lines from Fifteen, the third one is mine
00448   //________hhhhhh__hh______hhhhh_h______________hhhh_h_hhh_hhhhhhh___
00449   //                  gap          gap                             Gap
00450   //The three gap should be in Gap vector( g_g_G ) 
00451   //The last G is a potential begin of a gap
00452 
00453   //Standalone test
00454   deque<MixSimHit>::iterator dit, ddit, dend;
00455   dend = m_SimHits.end();
00456   dend--;
00457   for(dit = m_SimHits.begin(); dit != dend; dit++)
00458   {
00459     ddit = dit + 1;
00460     TimeStamp timeinter = ddit->hitTime - dit->hitTime;
00461     
00462     //There is one gap. Update the gap vector
00463     if(timeinter > m_minTimeGap)
00464     {
00465       m_log<< MSG::DEBUG<< "There is one gap!"<< endreq;
00466 
00467       m_hitsGap.push_back(dit->hitTime);
00468     }
00469   }
00470 
00471   //Last "Gap"
00472   m_log<< MSG::DEBUG<< "There is the last gap!"<< endreq;
00473   m_hitsGap.push_back(dend->hitTime);
00474 
00475   for(vector<TimeStamp>::size_type ind = 0; ind != m_hitsGap.size(); ind++)
00476   {
00477     m_log<< MSG::DEBUG<< "TimeStamp Gap: "<< m_hitsGap[ind].GetSec()<< "--"
00478          << m_hitsGap[ind].GetNanoSec()<< endreq;
00479   }
00480 
00481   return StatusCode::SUCCESS;
00482 }

StatusCode PreElecSimSvc::createHitHeaders (  ) 

Definition at line 484 of file PreElecSimSvc.cc.

00485 {
00486   //Create SimHitHeader
00487   //Bookkeeping the SimHitHeader and SimHeaders
00488   m_log<< MSG::INFO<< "Create new SimHitHeaders........"<< endreq;
00489 
00490   //Loop over the Gap vector
00491   deque<TimeStamp>::size_type iind;
00492   for(iind = 0; iind <= m_dealInd; iind++)
00493   {
00494     //One SimHitHeader each Gap
00495     m_log<< MSG::DEBUG<< "Create one SimHitHeader before SimHit("
00496          << m_hitsGap[0].GetSec()<< "--"<< m_hitsGap[0].GetNanoSec()<< ")"<< endreq;
00497 
00498     //Bookkeeping the SimHitHeader's time range
00499     m_hitEarliests.push_back(m_SimHits[0].hitTime);
00500     m_hitLatests.push_back(m_hitsGap[0]);
00501 
00502     SimHitHeader* shh = new SimHitHeader();
00503 
00504     if(0 == shh)
00505     {
00506       m_log<< MSG::ERROR<< "Can not create a new SimHitHeader!"<< endreq;
00507       return StatusCode::FAILURE;
00508     }
00509     m_log<< MSG::INFO<< "Create a new SimHitHeader: "<< shh<< endreq;
00510 
00511     //InputHeaders
00512     vector<const SimHeader*> inputHeaders;
00513 
00514     //mshc(reference)
00515     map<short int, SimHitCollection*>& mshc = shh->hitCollection();
00516     
00517     //Loop over the SimHits buffer
00518     for( ; ; )
00519     {
00520       m_log<< MSG::DEBUG<< "The SimHit buffer size is: "<< m_SimHits.size()<< endreq;
00521 
00522       deque<MixSimHit>::iterator dit = m_SimHits.begin();
00523       if(dit == m_SimHits.end())
00524       {
00525         m_log<< MSG::INFO<< "The SimHits Buffer is empty!"<< endreq;
00526         break;
00527       }
00528         
00529       if(dit->hitTime <= m_hitsGap[0])
00530       {
00531         Detector Det                   = dit->sht->hc()->detector();
00532         short int det                  = Det.siteDetPackedData();
00533         const SimHeader* currentHeader = dit->sht->hc()->header()->header();
00534         
00535         m_log<< MSG::DEBUG<< "This hit is from detector: "<< AsString(Det.detectorId())<< endreq;
00536 
00537         //There is a new detector!
00538         if(0 == mshc.size() || mshc.find(det) == mshc.end())
00539         {
00540           m_log<< MSG::DEBUG<< "map<short int, SimHitCollection*> size: "
00541                << mshc.size()<< " new detectorId: "<< AsString(Det.detectorId())<< endreq;
00542 
00543           //Create a new SimHitCollection
00544           SimHitCollection* shc = new SimHitCollection();
00545           shc->setHeader(shh);
00546           shc->setDetector(Det);
00547           //shts(reference)
00548           vector<SimHit*>& shts = shc->collection();
00549           shts.push_back(dit->sht);
00550           mshc[det] = shc;
00551           
00552           m_log<< MSG::DEBUG<< "Now the map size is: "<< mshc.size()<< endreq;
00553 
00554           //Deal with the InputHeaders
00555           vector<const SimHeader*>::iterator vit = inputHeaders.begin();
00556           if(0 == inputHeaders.size()) 
00557           {
00558             m_log<< MSG::DEBUG<< "New SimHeader: "<< currentHeader<< endreq;
00559             inputHeaders.push_back(currentHeader);
00560           }
00561           else
00562           {
00563             bool found = false;
00564             for( ; vit != inputHeaders.end(); vit++)
00565             {
00566               if(currentHeader == (*vit))
00567               {
00568                 found = true;
00569                 m_log<< MSG::DEBUG<< "SimHeader: "<< currentHeader<< " already in InputHeaders!"<< endreq;
00570                 break;
00571               }
00572             }
00573             if(false == found) 
00574             {
00575               m_log<< MSG::DEBUG<< "SimHeader: "<< currentHeader<< " should be added into InputHeaders!"<< endreq;
00576               inputHeaders.push_back(currentHeader);
00577             }       
00578           }
00579           
00580           m_SimHits.pop_front();
00581           continue;
00582         }
00583         else
00584         {
00585           m_log<< MSG::DEBUG<< "map<short int, SimHitCollection*> size: "
00586                << mshc.size()<< "  detectorId: "<< AsString(Det.detectorId())<< endreq;
00587           //shts(reference)
00588           vector<SimHit*>& shts = mshc[det]->collection();
00589           shts.push_back(dit->sht);
00590           
00591           //Deal with the InputHeaders
00592           vector<const SimHeader*>::iterator vit = inputHeaders.begin();
00593           if(0 == inputHeaders.size())
00594           {
00595             m_log<< MSG::DEBUG<< "New SimHeader: "<< currentHeader<< endreq;
00596             inputHeaders.push_back(currentHeader);
00597           }
00598           else
00599           {
00600             bool found = false;
00601             for( ; vit != inputHeaders.end(); vit++)
00602             {
00603               if(currentHeader == (*vit))
00604               {
00605                 found = true;
00606                 m_log<< MSG::DEBUG<< "SimHeader: "<< currentHeader<< " already in InputHeaders!"<< endreq;
00607                 break;
00608               }
00609             }
00610             if(false == found)
00611             {
00612               m_log<< MSG::DEBUG<< "SimHeader: "<< currentHeader<< " should be added into InputHeaders!"<< endreq;
00613               inputHeaders.push_back(currentHeader);
00614             }       
00615           }
00616 
00617           m_SimHits.pop_front();
00618           continue;
00619         }
00620       }
00621       else 
00622       {
00623         m_log<< MSG::DEBUG<< "Now create next SimHitHeader!"<< endreq;
00624         break;
00625       }
00626     }
00627     
00628     m_log<< MSG::INFO<< "Get one SimHitHeader: "<< shh<< " with "<< shh->hitCollection().size()<< endreq;
00629     m_propSimHitHeaders.push_back(shh);
00630     m_HitHeaderToHeaders[shh] = inputHeaders;
00631     m_log<< MSG::DEBUG<< "Now prepare the SimHitHeader: "<< shh<< " and "
00632          << m_HitHeaderToHeaders.size()<< " SimHeaders!"<< endreq;
00633     m_hitsGap.pop_front();
00634   } //Top for cycle
00635 
00636   return StatusCode::SUCCESS;
00637 }

| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 20:45:04 2011 for PreElecSimSvc by doxygen 1.4.7