/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/EventFilter/HltUtilities/HltAlgorithms/HltAlgorithms-01-03-01/src/EFSectorHits.cxx

Go to the documentation of this file.
00001 #include "GaudiKernel/MsgStream.h"
00002 //#include "GaudiKernel/AlgFactory.h"
00003 #include "GaudiKernel/SmartDataPtr.h"
00004 //#include "GaudiKernel/PropertyMgr.h"
00005 #include "EventModel/Event.h"
00006 #include "EventModel/EventHeader.h"
00007 #include "Identifier/Identifier.h"
00008 #include "MdcRawEvent/MdcDigi.h"
00009 #include "Identifier/MdcID.h"
00010 #include "HltAlgorithms/EFSectorHits.h"
00011 #include "HltDataTypes/CriteriaItemValue.h"
00012 
00013 using namespace Event;
00014 
00015 int EFSectorHits::idmax[43]={40,44,48,56,64,72,80,80,76,76,
00016                              88,88,100,100,112,112,128,128,140,140,
00017                              160,160,160,160,176,176,176,176,208,208,
00018                              208,208,240,240,240,240,256,256,256,256,
00019                              288,288,288};
00020 
00021 EFSectorHits::EFSectorHits(const std::string& name, ISvcLocator* pSvcLocator) :
00022   IEFAlgorithm(name, pSvcLocator) {
00023   int output= (m_output%1000)/100;
00024   //declareProperty("OutputLevel",m_output = MSG::NIL);
00025   MsgStream log(msgSvc(), name);
00026   msgSvc()->setOutputLevel(name,output);
00027   m_nsec = new CriteriaItemValue;
00028 }
00029 
00030 EFSectorHits::~EFSectorHits() {
00031   delete m_nsec;
00032 }
00033 
00034 StatusCode EFSectorHits::initialize(){
00035 
00036   MsgStream log(msgSvc(), name());
00037   log << MSG::INFO << "in initialize()" << endreq;
00038 
00039   IEFAlgorithm::initialize();
00040 
00041   StatusCode sc;
00042   sc = m_HltStoreSvc->put("nsec", m_nsec);
00043   if ( sc.isFailure() ) {
00044     log << MSG::ERROR << "m_HltStoreSvc->put(nsec) wrong" << endreq;
00045     return sc;
00046   }
00047 
00048   return StatusCode::SUCCESS;
00049 }
00050 
00051 StatusCode EFSectorHits::execute() {
00052   
00053   //reset();
00054   MsgStream log(msgSvc(), name());
00055   int32_t nshower=m_ef->getEFVec(38);
00056   if(nshower<2)  return StatusCode::SUCCESS;
00057 
00058   //DataObject*  pObject;
00059  
00060   // Part 1: Get the event header, print out event and run number
00061   SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
00062   if (!eventHeader) {
00063     log << MSG::FATAL << "Could not find Event Header" << endreq;
00064     return( StatusCode::FAILURE);
00065   }
00066   //Part 2: Retrieve Hits Collection 
00067   SmartDataPtr<MdcDigiCol> mdcDigiCol(eventSvc(),"/Event/Digi/MdcDigiCol");
00068   if (!mdcDigiCol) {
00069     log << MSG::FATAL << "EmcRec could not find Mdc digi!!" << endreq;
00070     return( StatusCode::FAILURE);
00071   }
00072   //Part 3: Get information of hits
00073   unsigned int nsec=0;
00074   Identifier id;
00075   MdcDigiCol::iterator iter=mdcDigiCol->begin();
00076 
00077   CriteriaItemValue* p1;
00078   CriteriaItemValue* p2;
00079   float              phi1,phi2;
00080   if((!m_HltStoreSvc->get("phi1", p1))||(!m_HltStoreSvc->get("phi2", p2)))return false;
00081   if((!(p1->getValue(phi1)))||(!(p2->getValue(phi2)))) return false;
00082   //phi(-pi,pi)==>(0,2pi)
00083   if(phi1<0) phi1+=6.2831852;
00084   if(phi2<0) phi2+=6.2831852;
00085   //Decide sector (phi11,phi12) and (phi21,phi22)
00086   float phi11=min(phi1,phi2);
00087   float phi22=max(phi1,phi2);
00088   float phi12=(phi11+phi22-3.1415926)*0.5;
00089   float phi21=(phi11+phi22+3.1415926)*0.5;
00090   if(phi12<0.) phi12 += 6.2831852;
00091   if(phi21>6.2831852) phi21 -= 6.2831852;
00092   for(;iter!= mdcDigiCol->end();iter++) {
00093     id=(*iter)->identify();
00094     unsigned int iphi=MdcID::wire(id);
00095     unsigned int ilayer=MdcID::layer(id);
00096     if(ilayer>=43)
00097       log << MSG::ERROR << "MDC(" << ilayer <<","<<iphi <<endreq;
00098     float phi=6.2831853*iphi/idmax[ilayer];
00099     if(WhetherSector(phi,phi11,phi12)||WhetherSector(phi,phi21,phi22)) nsec++;
00100   }
00101   log << MSG::INFO << " Number of hits in sector of MDC is " << nsec <<endreq;
00102   
00103   //Part 4: Put the criteria item(s) to HltStoreSvc here
00104   m_nsec->setValue(nsec);
00105   m_ef->setVecBit(true, 0, 3);
00106   m_ef->addToEFVec(9,37);
00107   if(m_ef->getEFVec(37)!=0) log << MSG::WARNING << "nsec(0) !=0"<< endreq;
00108   m_ef->addToEFVec(nsec,37);
00109 
00110   m_run=1;
00111 
00112   return StatusCode::SUCCESS;
00113 }
00114 
00115 StatusCode EFSectorHits::finalize() {
00116   MsgStream log(msgSvc(), name());
00117   log << MSG::INFO << "in finalize()" << endmsg;
00118   return StatusCode::SUCCESS;
00119 }
00120 
00121 void EFSectorHits::reset() {
00122 
00123   if(m_run){
00124     m_nsec->reset();
00125     m_run=0;
00126   }
00127   return;
00128 }
00129 
00130 bool EFSectorHits::WhetherSector(float ph,float ph1,float ph2){
00131   float phi1=min(ph1,ph2);
00132   float phi2=max(ph1,ph2);
00133   float delta=0.0610865; //3.5*3.1415926/180.
00134   if((phi2-phi1)<3.1415926){
00135     phi1 -=delta;
00136     phi2 +=delta;
00137     if(phi1<0.) phi1 += 6.2831852;
00138     if(phi2>6.2831852) phi2 -= 6.2831852;
00139     float tmp1=min(phi1,phi2);
00140     float tmp2=max(phi1,phi2);
00141     phi1=tmp1;
00142     phi2=tmp2;
00143   }
00144   else{
00145     phi1 +=delta;
00146     phi2 -=delta;
00147   }
00148   if((phi2-phi1)<3.1415926){
00149     if(ph<=phi2&&ph>=phi1) return true;
00150     else   return false;
00151   }
00152   else{
00153     if(ph>=phi2||ph<=phi1) return true;
00154     else   return false;
00155   }
00156 }

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