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

EmcMCfethe Class Reference

#include <EmcMCfethe.h>

List of all members.

Public Types

enum  { m_oneProng = 1, m_twoProng = 2 }
enum  { m_oneProng = 1, m_twoProng = 2 }

Public Member Functions

void CollectBhabha ()
void CollectBhabha ()
double Ecorr (double En, double costhe)
double Ecorr (double En, double costhe)
 EmcMCfethe (const std::string &name, ISvcLocator *pSvcLocator)
 EmcMCfethe (const std::string &name, ISvcLocator *pSvcLocator)
StatusCode execute ()
StatusCode execute ()
StatusCode finalize ()
StatusCode finalize ()
double findPhiDiff (double phi1, double phi2)
double findPhiDiff (double phi1, double phi2)
int index (int theta, int phi) const
int index (int theta, int phi) const
void initGeom ()
void initGeom ()
StatusCode initialize ()
StatusCode initialize ()
bool passed ()
bool passed ()
void RetreiveShowerList ()
void RetreiveShowerList ()
void SelectBhabha ()
void SelectBhabha ()
void setPassed (bool passed)
void setPassed (bool passed)
 ~EmcMCfethe ()
 ~EmcMCfethe ()

Private Attributes

NTuple::Item< float > En
NTuple::Item< float > En
NTuple::Item< float > EnA
NTuple::Item< float > EnA
NTuple::Item< float > EnB
NTuple::Item< float > EnB
double m_CalibConst [6240]
int m_digiRangeCut
IEmcCalibConstSvcm_emcCalibConstSvc
IEmcCalibConstSvcm_emcCalibConstSvc
double m_eNormCut
int m_event
long int m_events
std::string m_fileDir
std::string m_fileExt
IEmcRecGeoSvcm_iGeoSvc
IEmcRecGeoSvcm_iGeoSvc
int ** m_index
int ** m_index
double m_inputConst [6240]
double m_LATCut
int m_maxNrXtalsShowerCut
double m_minAngCut
int m_minNrXtalsShowerCut
int m_MsgFlag
int m_nrShThreshCut
int m_nXtals
int m_oneProngsSelelected
bool m_passed
double m_phiDiffMaxCut
double m_phiDiffMinCut
long int m_rejected
int m_run
bool m_setAlwaysPassed
double m_ShEneLeptonCut
double m_ShEneThreshCut
list< EmcShowerm_showerList
list< EmcShowerm_showerList
long m_showersAccepted
long int m_taken
double m_thetaBackwardCut
double m_thetaDiffCut
double m_thetaForwardMinAngCut
double m_thetaIndexForwardCut
NTuple::Tuple * m_tuple1
NTuple::Tuple * m_tuple1
int m_twoProngsSelected
bool m_writeMVToFile
EmcBhabhaEventmyBhaEvt
EmcBhabhaEventmyBhaEvt
EmcBhaCalibDatamyCalibData
EmcBhaCalibDatamyCalibData
NTuple::Item< float > Phi
NTuple::Item< float > Phi
NTuple::Item< float > PhiInd
NTuple::Item< float > PhiInd
NTuple::Item< float > Seed
NTuple::Item< float > Seed
NTuple::Item< float > The
NTuple::Item< float > The
NTuple::Item< float > TheInd
NTuple::Item< float > TheInd


Member Enumeration Documentation

anonymous enum
 

Enumeration values:
m_oneProng 
m_twoProng 
00057 {m_oneProng=1, m_twoProng=2};

anonymous enum
 

Enumeration values:
m_oneProng 
m_twoProng 
00057 {m_oneProng=1, m_twoProng=2};


Constructor & Destructor Documentation

EmcMCfethe::EmcMCfethe const std::string &  name,
ISvcLocator *  pSvcLocator
 

00100   :Algorithm(name, pSvcLocator),  
00101    m_digiRangeCut(6),
00102    m_ShEneThreshCut(0.02),
00103    m_ShEneLeptonCut(1.),
00104    m_minNrXtalsShowerCut(10),
00105    m_maxNrXtalsShowerCut(70),
00106    m_phiDiffMinCut(0.05),
00107    m_phiDiffMaxCut(0.2), 
00108    m_nrShThreshCut(20),
00109    m_thetaIndexForwardCut(0.),
00110    m_eNormCut(0.5),
00111    m_thetaDiffCut(0.04),
00112    m_LATCut(0.8),
00113    m_thetaForwardMinAngCut(0.35),
00114    m_minAngCut(0.3),
00115    m_thetaBackwardCut(2.3),   
00116    m_showersAccepted(0),
00117    m_setAlwaysPassed(false),
00118    //--------------------
00119    m_writeMVToFile(true),
00120    m_fileExt(""),
00121    m_fileDir("/ihepbatch/besdata/public/liucx/Calib/"),
00122    m_nXtals(6240),
00123    m_MsgFlag(0)
00124 
00125 {
00126 
00127   
00128   // Declare the properties  
00129   
00130   declareProperty("digiRangeCut", m_digiRangeCut);
00131   declareProperty("ShEneThreshCut",  m_ShEneThreshCut);
00132   declareProperty("ShEneLeptonCut",  m_ShEneLeptonCut);
00133   declareProperty("minNrXtalsShowerCut",  m_minNrXtalsShowerCut);
00134   declareProperty("maxNrXtalsShowerCut",  m_maxNrXtalsShowerCut);
00135   declareProperty("phiDiffMinCut",  m_phiDiffMinCut);
00136   declareProperty("phiDiffMaxCut",  m_phiDiffMaxCut);
00137   
00138   declareProperty("nrShThreshCut",  m_nrShThreshCut);
00139   declareProperty("thetaIndexForwardCut", m_thetaIndexForwardCut);
00140   declareProperty("eNormCut",  m_eNormCut);
00141   declareProperty("thetaDiffCut", m_thetaDiffCut);
00142   declareProperty("LATCut",  m_LATCut);
00143   declareProperty("thetaForwardMinAngCut", m_thetaForwardMinAngCut);
00144   declareProperty("minAngCut",  m_minAngCut);
00145   declareProperty("thetaBackCut",  m_thetaBackwardCut);
00146   
00147   declareProperty("setAlwaysPassed", m_setAlwaysPassed);
00148   //--------------------
00149   declareProperty("writeMVToFile", m_writeMVToFile);
00150   declareProperty("fileExt", m_fileExt);
00151   declareProperty("fileDir", m_fileDir);
00152   declareProperty("MsgFlag", m_MsgFlag);
00153 
00154   
00155   int j = 0;
00156   m_index = new int*[56];
00157   for (j=0;j<56;j++ ) {
00158     m_index[j] = new int[120];
00159     for ( int k=0; k<120; k++) {
00160       m_index[j][k]=-1;
00161     }
00162   }
00163    
00164   m_iGeoSvc=0;
00165 
00166   for (int i=0; i<6240;i++)
00167     {
00168       m_inputConst[i] = 1.0;
00169     }
00170 
00171 }

EmcMCfethe::~EmcMCfethe  ) 
 

00176                         {
00177   
00178   if ( m_index != 0 ) {
00179     for (int i =0; i<56; i++ )
00180       delete[] m_index[i];
00181     delete[] m_index;
00182     m_index = 0;
00183   }
00184   
00185   
00186 }

EmcMCfethe::EmcMCfethe const std::string &  name,
ISvcLocator *  pSvcLocator
 

EmcMCfethe::~EmcMCfethe  ) 
 


Member Function Documentation

void EmcMCfethe::CollectBhabha  ) 
 

void EmcMCfethe::CollectBhabha  ) 
 

00740                          {
00741   
00742   MsgStream log(msgSvc(), name());
00743 
00744   //check if the Bhabhas were found
00745   if ( 0 != myBhaEvt->positron()->found() ||
00746        0 != myBhaEvt->electron()->found() ) {
00747     
00748     m_taken++;
00749 
00750     //------------- electron found --------------------------------------
00751     if (myBhaEvt->electron()->found() ) {
00753       En=myBhaEvt->electron()->shower().energy();
00754       Seed=myBhaEvt->electron()->shower().maxima().energy();
00755       TheInd= myBhaEvt->electron()->thetaIndex();
00756       PhiInd= myBhaEvt->electron()->phiIndex();
00757       The= myBhaEvt->electron()->theta();
00758       Phi= myBhaEvt->electron()->phi();
00759 
00761       EmcShower _theShower=EmcShower::EmcShower();
00762 
00763       _theShower = myBhaEvt->electron()->shower();
00764 
00765       list<EmcShDigi> _DigiList=_theShower.digiList();
00766       
00767       list<EmcShDigi>::const_iterator _Digi;
00768       
00769       //------------------------------------------------------
00770       //---- double loop over the digis to fill the matrix ---
00771       
00772       //first loop over Digis 
00773       double enCalibBefore=0;
00774       double enCalibAfter=0; 
00775       for (_Digi = _DigiList.begin(); 
00776            _Digi != _DigiList.end();  _Digi++) {
00777         
00778         //get Xtal index 
00779         
00780         //The thetaIndex is defined by Endcap_east(0-5),Barrel(6-49),Endcap_west(50-55)
00781         //in Emc Bhabha Calibration
00782         unsigned int newThetaInd;
00783         if (_Digi->module()==0) newThetaInd = _Digi->thetaIndex();
00784         if (_Digi->module()==1) newThetaInd = _Digi->thetaIndex() + 6;
00785         if (_Digi->module()==2) newThetaInd = 55 - _Digi->thetaIndex();   
00786        
00787         int DigiIndex = index(newThetaInd,_Digi->phiIndex());
00788         enCalibBefore += (static_cast<double>(_Digi->energy())) * m_inputConst[DigiIndex];
00789         
00790         enCalibAfter +=(static_cast<double>(_Digi->energy())) * m_inputConst[DigiIndex]
00791           *m_CalibConst[DigiIndex];
00792 
00793 
00794 
00795       }
00796 
00797       EnB = enCalibBefore;
00798       EnA = enCalibAfter;
00799       m_tuple1->write();    
00801       
00802     } else
00803       log << MSG::WARNING << " Did not find MC deposited cluster energy "
00804           <<" for this cluster:  thetaInd: " 
00805           << myBhaEvt->electron()->thetaIndex()
00806           << "  phiInd: " 
00807           << myBhaEvt->electron()->phiIndex()
00808           << endl
00809           << "Will not use this cluster for the Emc "
00810           << "Bhabha calibration !"
00811           << endreq;
00812     
00813     
00814     //---------------- positron found ----------------------------------
00815     if (myBhaEvt->positron()->found() ) {
00816       
00817       En=myBhaEvt->positron()->shower().energy();
00818       Seed=myBhaEvt->positron()->shower().maxima().energy();
00819       TheInd= myBhaEvt->positron()->thetaIndex();
00820       PhiInd= myBhaEvt->positron()->phiIndex();
00821       The= myBhaEvt->positron()->theta();
00822       Phi= myBhaEvt->positron()->phi();
00824       EmcShower _theShower=EmcShower::EmcShower();
00825 
00826       _theShower = myBhaEvt->positron()->shower();
00827 
00828       list<EmcShDigi> _DigiList=_theShower.digiList();
00829       
00830       list<EmcShDigi>::const_iterator _Digi;
00831       
00832       //------------------------------------------------------
00833       //---- double loop over the digis to fill the matrix ---
00834       
00835       //first loop over Digis 
00836       double enCalibBefore=0;
00837       double enCalibAfter=0; 
00838       for (_Digi = _DigiList.begin(); 
00839            _Digi != _DigiList.end();  _Digi++) {
00840         
00841         //get Xtal index 
00842         
00843         //The thetaIndex is defined by Endcap_east(0-5),Barrel(6-49),Endcap_west(50-55)
00844         //in Emc Bhabha Calibration
00845         unsigned int newThetaInd;
00846         if (_Digi->module()==0) newThetaInd = _Digi->thetaIndex();
00847         if (_Digi->module()==1) newThetaInd = _Digi->thetaIndex() + 6;
00848         if (_Digi->module()==2) newThetaInd = 55 - _Digi->thetaIndex();   
00849        
00850         int DigiIndex = index(newThetaInd,_Digi->phiIndex());
00851         enCalibBefore += (static_cast<double>(_Digi->energy())) * m_inputConst[DigiIndex];
00852         
00853         enCalibAfter +=(static_cast<double>(_Digi->energy())) * m_inputConst[DigiIndex]
00854           *m_CalibConst[DigiIndex];
00855 
00856       }
00857 
00858       EnB = enCalibBefore;
00859       EnA = enCalibAfter;
00860 
00861 
00862       m_tuple1->write();   
00863       
00864       
00865     } else 
00866       log << MSG::WARNING << " Did not find MC deposited cluster energy "
00867           << "for this cluster:  thetaInd: " 
00868           << myBhaEvt->positron()->thetaIndex()
00869           << "  phiInd: " 
00870           << myBhaEvt->positron()->phiIndex()
00871           << endl
00872           << "Will not use this cluster for the Emc "
00873           << "Bhabha calibration !"
00874           << endreq;
00875     
00876     
00877     
00878   } else {
00879     log << MSG::WARNING << " No Bhabha data for calibration found in event !" 
00880         << endreq;
00881     m_rejected++;
00882   }
00883   
00884 }

double EmcMCfethe::Ecorr double  En,
double  costhe
 

double EmcMCfethe::Ecorr double  En,
double  costhe
 

00947                                                 {
00948 
00949  
00950   /* double par[6]={0.0443492,
00951                  -0.0104957,
00952                  -0.0284476,
00953                  -0.00817278,
00954                  -6.48242e-06,
00955                  0.0480414};
00956   */
00957 double par[6]={
00958   0.047828,
00959   0.0090778,
00960   -0.00254,
00961   -0.000847,
00962   -0.0001967,
00963   0.044144
00964 };
00965   double ecor,lne;
00966 
00967   lne=log(En);
00968 
00969   ecor = En* exp(par[0] +par[1]*lne +par[2]*lne*lne +par[3]*lne*lne*lne
00970              +par[4]*costhe +par[5]*costhe*costhe);
00971 
00972   return ecor;
00973 
00974 }

StatusCode EmcMCfethe::execute  ) 
 

StatusCode EmcMCfethe::execute  ) 
 

00277                                {
00278   
00279   MsgStream log(msgSvc(), name());
00280   log << MSG::DEBUG << "in execute()" << endreq;   
00281   
00282   //create the object that store the needed data of the Bhabha event  
00283  
00284   int event, run;
00285   
00286   SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
00287   if (!eventHeader) {
00288     log << MSG::FATAL << "Could not find Event Header" << endreq;
00289     return( StatusCode::FAILURE);
00290   }
00291   run=eventHeader->runNumber();
00292   event=eventHeader->eventNumber();
00293   cout<<"---------"<<event<<"---------"<<run<<endl;
00294   m_event = event;
00295   m_run = run;
00296   
00297   myBhaEvt = new EmcBhabhaEvent();
00298   
00299   //retreive shower list of event
00300   RetreiveShowerList();
00301   //select bhabha event 
00302   SelectBhabha();
00303   //collect bhabha event for digi-calibration of EMC 
00304   //and fill matrix and vector of system of linear equations
00305   CollectBhabha();
00306   
00307   delete myBhaEvt;
00308   myBhaEvt=0;
00309   
00310   return StatusCode::SUCCESS;
00311 }

StatusCode EmcMCfethe::finalize  ) 
 

StatusCode EmcMCfethe::finalize  ) 
 

00314                                 {
00315   
00316   MsgStream log(msgSvc(), name());
00317   
00318   log << MSG::INFO << "in finalize()" << endreq;
00319 
00320   if ( m_writeMVToFile ) {
00321     delete myCalibData;
00322     myCalibData = 0;
00323   }
00324 
00325   cout<<"Event="<<m_events<<endl;
00326   cout<<"m_taken="<<m_taken<<endl;
00327   cout<<"m_rejected="<<m_rejected<<endl;
00328   return StatusCode::SUCCESS;
00329 }

double EmcMCfethe::findPhiDiff double  phi1,
double  phi2
 

double EmcMCfethe::findPhiDiff double  phi1,
double  phi2
 

00936 {
00937   double diff;
00938   diff = phi1 - phi2;  //rad
00939 
00940   while( diff>  pi  ) diff -= twopi;
00941   while( diff< -pi  ) diff += twopi;
00942   
00943   return diff;
00944 }

int EmcMCfethe::index int  theta,
int  phi
const [inline]
 

00078                                       {
00079     int val = ((m_index)[theta][phi]);
00080     return (val); }

int EmcMCfethe::index int  theta,
int  phi
const [inline]
 

00078                                       {
00079     int val = ((m_index)[theta][phi]);
00080     return (val); }

void EmcMCfethe::initGeom  ) 
 

void EmcMCfethe::initGeom  ) 
 

00887                      {
00888   
00889   MsgStream log(msgSvc(), name());
00890   
00891   int numberOfXtalsRing;
00892   
00893   EmcStructure* theEmcStruc=new EmcStructure() ;
00894   
00895 
00896   //number Of Theta Rings
00897   int nrOfTheRings = theEmcStruc->getNumberOfTheRings();
00898   
00899   m_nXtals = theEmcStruc->getNumberOfXtals();
00900   
00901   //init geometry
00902   for ( int the = theEmcStruc->startingTheta(); the< nrOfTheRings; the++) {
00903     
00904     numberOfXtalsRing = theEmcStruc->crystalsInRing((unsigned int) the );
00905     
00906     for ( int phi=0; phi < numberOfXtalsRing; phi++) {
00907       
00908       m_index[the][phi] = theEmcStruc->getIndex( (unsigned int)the , (unsigned int)phi);
00909       
00910     }
00911   }
00912   
00913   log << MSG::INFO <<  " Emc geometry for Bhabha calibration initialized !! " 
00914       << endl
00915       << "Number of Xtals: " << m_nXtals << endreq;
00916   delete theEmcStruc;
00917   
00918   //readout inputConst from file, only for MC data
00919   std::string constFile = m_fileDir;
00920   constFile += m_fileExt;
00921   constFile += "CalibInput.dat"; 
00922   ifstream inputConstfile(constFile.c_str());
00923   int ind=0;
00924   while( !inputConstfile.eof() ) {
00925     inputConstfile>>m_inputConst[ind];
00926     //cout<<"ind="<<ind<<" "<<m_inputConst[ind]<<endl;
00927     ind++;
00928   }
00929   inputConstfile.close();
00930 
00931 }

StatusCode EmcMCfethe::initialize  ) 
 

StatusCode EmcMCfethe::initialize  ) 
 

00190                                  {
00191   
00192   MsgStream log(msgSvc(), name());
00193   log << MSG::INFO << "in initialize()" << endreq;
00194      
00195   //---------------------------------------<<<<<<<<<<
00196   m_taken=0;
00197   m_rejected=0;
00198   m_events=0;
00199   m_oneProngsSelelected=0;
00200   m_twoProngsSelected=0;
00201    
00202   //--------------------------------------->>>>>>>>>>>
00203   
00204   StatusCode status1;
00205   
00206   NTuplePtr nt1(ntupleSvc(),"FILE302/n1");
00207   if ( nt1 ) m_tuple1 = nt1;
00208   else {
00209     m_tuple1=ntupleSvc()->book("FILE302/n1",CLID_ColumnWiseTuple,"elepos");
00210     if( m_tuple1 ) {
00211       
00212          status1 = m_tuple1->addItem ("En",En); 
00213          status1 = m_tuple1->addItem ("EnB",EnB); 
00214          status1 = m_tuple1->addItem ("EnA",EnA);
00215          status1 = m_tuple1->addItem ("Seed",Seed); 
00216          status1 = m_tuple1->addItem ("The",The);
00217          status1 = m_tuple1->addItem ("Phi",Phi);
00218          status1 = m_tuple1->addItem ("TheInd",TheInd);
00219          status1 = m_tuple1->addItem ("PhiInd",PhiInd);
00220       
00221     }
00222     else    {   // did not manage to book the N tuple....
00223       log << MSG::ERROR <<"Cannot book N-tuple:" << long(m_tuple1) << endmsg;
00224       return StatusCode::FAILURE;
00225     }
00226   }
00227 
00228   //initialize Emc geometry to convert between index <=> theta,phi
00229   initGeom();
00230  
00231   //create the object that holds the calibration data
00232   if ( m_writeMVToFile )
00233     myCalibData = new EmcBhaCalibData(m_nXtals,m_MsgFlag);
00234   else
00235     myCalibData = 0;
00236   
00237   //get EmcRecGeoSvc
00238   
00239   ISvcLocator* svcLocator = Gaudi::svcLocator();
00240   StatusCode sc = svcLocator->service("EmcRecGeoSvc",m_iGeoSvc);
00241   if(sc!=StatusCode::SUCCESS) {
00242     cout<<"Error: Can't get EmcRecGeoSvc"<<endl;
00243   }  
00244   
00245   // use EmcCalibConstSvc
00246   StatusCode scCalib; 
00247   scCalib = Gaudi::svcLocator() -> service("EmcCalibConstSvc", m_emcCalibConstSvc);
00248   if( scCalib != StatusCode::SUCCESS){
00249     log << MSG::ERROR << "can not use EmcCalibConstSvc" << endreq;
00250   } 
00251   else {
00252     std::cout << "Test EmcCalibConstSvc   DigiCalibConst(0)=  " 
00253               << m_emcCalibConstSvc -> getDigiCalibConst(0) << std::endl;
00254   }
00255 
00256   
00257   int nConstEmc;
00258   nConstEmc= m_emcCalibConstSvc -> getDigiCalibConstNo() ;
00259   log << MSG::VERBOSE << " Have starting values for " 
00260       << nConstEmc << " Xtals !" << endl
00261       << "Set the others to 1.0 ! " << endmsg;
00262   
00263   int numberXtal;
00264   //m_emcCalibConstSvc -> Dump();
00265   for ( int i = 0; i< nConstEmc; i++ ) {
00266     numberXtal=i;
00267     m_CalibConst[numberXtal]= m_emcCalibConstSvc -> getDigiCalibConst(i);
00268     // cout<<"m_calibConst[numberXtal]"<<numberXtal
00269     //<<"  "<<m_CalibConst[numberXtal]<<endl;
00270 
00271   }
00272   
00273   return StatusCode::SUCCESS;
00274 }

bool EmcMCfethe::passed  )  [inline]
 

00073 { return m_passed;}

bool EmcMCfethe::passed  )  [inline]
 

00073 { return m_passed;}

void EmcMCfethe::RetreiveShowerList  ) 
 

void EmcMCfethe::RetreiveShowerList  ) 
 

00336                               {
00337   
00338   MsgStream log(msgSvc(), name());
00339   
00340   // Retreive EmcRecShowerCol 
00341   SmartDataPtr<RecEmcShowerCol> aShowerCol(eventSvc(),"/Event/Recon/RecEmcShowerCol");
00342   if (!aShowerCol) { 
00343     log << MSG::FATAL << "Could not find RecEmcShowerCol" << endreq;
00344 
00345   }
00346   
00347   // * * * * * * * * * * * * * * * * * * * * * * * * * ** *  ** *
00348   //loop all showers of an event set EmcShower and EmcShDigi
00349   
00350   EmcShower* aShower =new EmcShower();
00351 
00352   double ene,theta,phi,eseed;
00353   double showerX,showerY,showerZ;
00354   long int thetaIndex,phiIndex,numberOfDigis;
00355   
00356   RecEmcID showerId;
00357   unsigned int showerModule;
00358   
00359   HepPoint3D showerPosition(0,0,0);
00360   
00361   if ( ! m_showerList.empty())  m_showerList.clear(); 
00362   
00363   RecEmcShowerCol::iterator iShowerCol;
00364   for(iShowerCol=aShowerCol->begin();
00365       iShowerCol!=aShowerCol->end();
00366       iShowerCol++){
00367     
00368     //ene=(*iShowerCol)->energy(); //shower energy unit GeV
00369     ene=(*iShowerCol)->e5x5(); //shower5x5 energy unit GeV
00370     eseed=(*iShowerCol)->eSeed(); //unit GeV
00371     //cout<<"eseed="<<eseed<<endl;
00372     
00373     showerPosition = (*iShowerCol)->position();
00374     theta = showerPosition.theta();
00375     phi= showerPosition.phi();
00376     showerX=showerPosition.x();
00377     showerY=showerPosition.y();
00378     showerZ=showerPosition.z();
00379 
00380     //ene=Ecorr(ene, showerPosition.cosTheta())*ene;  //shower energy correction
00381     
00382     showerId = (*iShowerCol)->getShowerId();
00383     showerModule = EmcID::barrel_ec(showerId);
00384     
00385     //The theta number is defined by Endcap_east(0-5),Barrel(0-43),Endcap_west(0-5) 
00386     //module is defined  by Endcap_east(0),Barrel(1),Endcap_west(2)      
00387 
00388     thetaIndex=EmcID::theta_module(showerId);   
00389     phiIndex=EmcID::phi_module(showerId);    
00390     
00391     //-------------------
00392 
00393     EmcShDigi* aShDigi= new EmcShDigi();
00394     EmcShDigi maxima =EmcShDigi::EmcShDigi();
00395     list<EmcShDigi> shDigiList;
00396     RecEmcID cellId;
00397     unsigned int module;
00398     double digiEne, time, fraction, digiTheta, digiPhi;
00399     double  digiX, digiY, digiZ;
00400     long int digiThetaIndex,digiPhiIndex;  
00401     HepPoint3D digiPos(0,0,0);
00402     
00403     RecEmcFractionMap::const_iterator ciFractionMap;
00404     
00405     if ( ! shDigiList.empty())  shDigiList.clear();
00406     
00407     double NewEn=0;
00408 
00409     for(ciFractionMap=(*iShowerCol)->getFractionMap5x5().begin();
00410         ciFractionMap!=(*iShowerCol)->getFractionMap5x5().end();
00411         ciFractionMap++){
00412       
00413       digiEne = ciFractionMap->second.getEnergy();  //digit energy unit GeV
00414  
00415       //cout<<"digienergy="<<digiEne<<endl;
00416       time = ciFractionMap->second.getTime();
00417       fraction = ciFractionMap->second.getFraction();
00418       
00419       cellId=ciFractionMap->second.getCellId();
00420       
00421       digiPos=m_iGeoSvc->GetCFrontCenter(cellId);
00422       digiTheta = digiPos.theta();
00423       digiPhi = digiPos.phi();   
00424       digiX = digiPos.x();
00425       digiY = digiPos.y();
00426       digiZ = digiPos.z();
00427       
00428       module=EmcID::barrel_ec(cellId);
00429       //The theta number is defined by Endcap_east(0-5),Barrel(0-43),Endcap_west(0-5) 
00430       //module is defined  by Endcap_east(0),Barrel(1),Endcap_west(2) 
00431       digiThetaIndex=EmcID::theta_module(cellId);
00432       
00433       digiPhiIndex = EmcID::phi_module(cellId);
00434       
00435       NewEn += digiEne*m_inputConst[m_index[digiThetaIndex][digiPhiIndex] ]
00436         *m_CalibConst[m_index[digiThetaIndex][digiPhiIndex] ];
00437       
00438       //set EmcShDigi
00439       aShDigi->setEnergy(digiEne);
00440       aShDigi->setTheta(digiTheta);
00441       aShDigi->setPhi(digiPhi);
00442       aShDigi->setModule(module);
00443       aShDigi->setThetaIndex(digiThetaIndex);
00444       aShDigi->setPhiIndex(digiPhiIndex);
00445       aShDigi->setTime(time);
00446       aShDigi->setFraction(fraction);
00447       aShDigi->setWhere(digiPos);
00448       aShDigi->setY(digiX);
00449       aShDigi->setY(digiY);
00450       aShDigi->setZ(digiZ);
00451       
00452       shDigiList.push_back(*aShDigi);
00453   
00454       
00455     }
00456     shDigiList.sort();          //sort energy from small to large
00457          
00458     numberOfDigis = shDigiList.size();
00459     
00460     maxima = *(--shDigiList.end());
00461     //cout<<"maxima="<<maxima.energy()<<endl;
00462     //set EmcShower
00463     //ene=NewEn;
00464     aShower->setEnergy(ene);
00465     aShower->setTheta(theta);
00466     aShower->setPhi(phi);
00467     aShower->setModule(showerModule);
00468     aShower->setThetaIndex(thetaIndex);
00469     aShower->setPhiIndex(phiIndex);
00470     aShower->setNumberOfDigis(numberOfDigis);
00471     aShower->setDigiList(shDigiList);
00472     aShower->setMaxima(maxima);
00473     aShower->setWhere(showerPosition);
00474     aShower->setX(showerX);
00475     aShower->setY(showerY);
00476     aShower->setZ(showerZ);
00477     m_showerList.push_back(*aShower);
00478 
00479     /*
00480     list<EmcShDigi>::const_iterator thedigi;
00481     for (thedigi = shDigiList.begin(); 
00482          thedigi != shDigiList.end();  thedigi++) {
00483       
00484       cout << "E:digi " << thedigi->energy() << endl;
00485     }
00486     */
00487       // cluster energy threshold cut
00488 
00489     delete aShDigi;   
00490 
00491   }
00492 
00493   m_showerList.sort();         //sort energy from small to large
00494 
00495   /*
00496     list<EmcShower>::const_iterator theshower;
00497     for (theshower = m_showerList.begin(); 
00498          theshower != m_showerList.end();  theshower++) {
00499       
00500       cout<< "E:shower " << theshower->energy() << endl;
00501     }
00502   */
00503 
00504   delete aShower;
00505 
00506 }

void EmcMCfethe::SelectBhabha  ) 
 

void EmcMCfethe::SelectBhabha  ) 
 

00511                         {
00512 
00513   MsgStream log(msgSvc(), name()); 
00514  
00515   //get the event-by-event channel status object
00516   //EmcStatus *EmcEventStatus =???
00517   //if ( _debugging)
00518   //  EmcEventStatus->print();     ????
00519   
00520   setPassed(false);
00521   
00522   ++m_events;
00523   
00525   int nrClThresh = 0;
00526  
00527   EmcShower *cl1=new EmcShower(), *cl2=new EmcShower();
00528   double newTheta1 = -1., newTheta2 = -1.;
00529   double thetaDiff_min=999.;
00530   double theta_cluster_min = 999., theta_cluster_max=0.;
00531   EmcShower *cl_tmp=new EmcShower();
00532   bool bcl1=false, bcl2=false, bcl_tmp=false;
00533   
00534   double newTheta_tmp = -1., theta_cluster_min_tmp = 999.;
00535   int onlyOneFound = -1;
00536   
00537   //Shower list
00538   
00539   if (m_showerList.size() > 0) {
00540     
00541     //first take off all digis far away from the maxima digi of a shower
00542     //make a new list with cutt of showers
00543     list<EmcShower>  goodShowersList;
00544     
00545     //---------------------------->
00546     //iterator for the bump list
00547     list<EmcShower>::const_iterator theShower;
00548     
00549     int nrGoodShowers = 0;
00550     
00551     //loop over bumps
00552     for (theShower = m_showerList.begin(); 
00553          theShower != m_showerList.end();  theShower++) {
00554       
00555       log << MSG::INFO << "E: " << theShower->energy() << " " 
00556           << "the: " << theShower->theta() << " "
00557           << "theI: " <<theShower->thetaIndex() << " "
00558           << "phi: " << theShower->phi() << " "
00559           << "phiI: " <<theShower->phiIndex() << " "
00560           << "nDig: " << theShower->numberOfDigis()
00561           << endreq;
00562 
00563       // cluster energy threshold cut
00564       
00565       if ( theShower->energy() > m_ShEneThreshCut ) {
00566         ++nrClThresh;
00567         goodShowersList.push_back( *theShower ); 
00568         nrGoodShowers++;
00569       }
00570     }
00571     
00572     //-------------------------------------------------------------------
00573     //---- loop over the good bumps and find one/two for calibration ----
00574     //
00575     
00576     if ( goodShowersList.size() > 0 ) {
00577       
00578       //iterator for the shower list
00579       list<EmcShower>::const_iterator theShower,theShower1;
00580       
00581       //loop over bumps
00582       for (theShower = goodShowersList.begin(); 
00583            theShower != goodShowersList.end();  theShower++) {
00584         
00585         //high energy clusters
00586         if ( theShower->energy() >m_ShEneLeptonCut ) {
00587           
00588           //---- sort out the two high energy clusters that are most
00589           // back to back  
00590           
00591           double newtheta = theShower->theta();   
00592           unsigned int newthetaInd = theShower->thetaIndex();
00593           
00594           if ( newthetaInd < theta_cluster_min )
00595             theta_cluster_min = newthetaInd;
00596           
00597           //keep the most backward bump in case we find only one or no
00598           //back-to-back bumps
00599           if ( newtheta > theta_cluster_max ) {
00600             *cl_tmp = *theShower;
00601             bcl_tmp=true;
00602             theta_cluster_max = newtheta;
00603             theta_cluster_min_tmp = newthetaInd;
00604             newTheta_tmp = newtheta;
00605             if ( onlyOneFound == -1 ) onlyOneFound = 1;
00606           }
00607           
00608   
00609           for (theShower1  = goodShowersList.begin(); 
00610                theShower1 != goodShowersList.end();  theShower1++) {
00611             
00612             //not the same high energy bump
00613             if ( theShower != theShower1 && 
00614                  theShower1->energy() >m_ShEneLeptonCut ) {
00615               
00616               double newtheta1 =  theShower1->theta();
00617               
00618               //difference of the two clusters in phi
00619               double phiDiff;
00620               phiDiff = ( theShower->phi() - theShower1->phi() -pi );
00621               if (phiDiff < -pi) phiDiff += twopi;
00622               if (phiDiff >  pi) phiDiff -= twopi;
00623                 
00624               //difference of the two clusters in theta
00625               double thetaDiff = fabs( theShower->theta() +
00626                                        theShower1->theta() -pi );
00627               
00628               // if ( thetaDiff < thetaDiff_min
00629               //           &&
00630               //   fabs( phiDiff ) >  m_phiDiffMinCut
00631               //   &&
00632               //   fabs( phiDiff ) <   m_phiDiffMaxCut ) {
00633               
00634               thetaDiff_min = thetaDiff;
00635               onlyOneFound = 0;
00636               
00637               if ( newtheta > newtheta1 ) {
00638                 *cl1 = *theShower;
00639                 bcl1=true;
00640                 newTheta1 = newtheta;
00641                 *cl2 = *theShower1;
00642                 bcl2=true;
00643                 newTheta2 = newtheta1;
00644               } else {
00645                 *cl1 = *theShower1;
00646                 bcl1=true;
00647                 newTheta1 = newtheta1;
00648                 *cl2 = *theShower;
00649                 bcl2=true;
00650                 newTheta2 = newtheta;
00651 
00652               }
00653               
00654               // }
00655               
00656             }
00657           }
00658         }
00659       }
00660       
00661       //if we found only one bump or no back-to-back bumps
00662       if ( bcl_tmp!=0 && onlyOneFound == 1 ) {
00663         cl1 = cl_tmp;
00664         newTheta1 = newTheta_tmp;
00665         theta_cluster_min = theta_cluster_min_tmp;
00666         cout << "Only one cluster found !" << endl;
00667       }
00668       
00669       if ( bcl1==0 && bcl2==0 ) {
00670         cout << " No matched cluster found !"
00671              << endl; 
00672       }
00673       
00674       //fill the Bhabha event
00675       if ( bcl1!=0 ) {
00676         //set properties 
00677         myBhaEvt->setPositron()->setShower(*cl1);
00678         myBhaEvt->setPositron()->setTheta(newTheta1);
00679         myBhaEvt->setPositron()->setPhi(cl1->phi());
00680         unsigned int newthetaInd ;
00681         //The thetaIndex is defined by Endcap_east(0-5),Barrel(6-49),Endcap_west(50-55)
00682         //in Emc Bhabha Calibration
00683         if (cl1->module()==0) newthetaInd = cl1->thetaIndex();
00684         if (cl1->module()==1) newthetaInd = cl1->thetaIndex() + 6;
00685         if (cl1->module()==2) newthetaInd = 55 - cl1->thetaIndex();
00686         myBhaEvt->setPositron()->setThetaIndex(newthetaInd);
00687 
00688         unsigned int  newphiInd=cl1->phiIndex();
00689         myBhaEvt->setPositron()->setPhiIndex(newphiInd);
00690         myBhaEvt->setPositron()->setFound(true); 
00691         m_showersAccepted++;
00692 
00693         log << MSG::INFO <<  name() << ": Positron: theta,phi energy "
00694             << myBhaEvt->positron()->theta() << ","
00695             << myBhaEvt->positron()->shower().phi() << " "
00696             << myBhaEvt->positron()->shower().energy()
00697             << endreq;
00698         
00699       } 
00700       
00701       if ( bcl2!=0) {
00702         //set properties including vertex corrected theta 
00703         myBhaEvt->setElectron()->setShower(*cl2);
00704         myBhaEvt->setElectron()->setTheta(newTheta2);
00705         myBhaEvt->setElectron()->setPhi(cl2->phi());      
00706         unsigned int newthetaInd;       
00707         //The thetaIndex is defined by Endcap_east(0-5),Barrel(6-49),Endcap_west(50-55)
00708         //in Emc Bhabha Calibration
00709         if (cl2->module()==0) newthetaInd = cl2->thetaIndex();
00710         if (cl2->module()==1) newthetaInd = cl2->thetaIndex() + 6;
00711         if (cl2->module()==2) newthetaInd = 55 - cl2->thetaIndex();
00712 
00713         myBhaEvt->setElectron()->setThetaIndex(newthetaInd);
00714         unsigned int newphiInd=cl2->phiIndex();
00715         myBhaEvt->setElectron()->setPhiIndex(newphiInd);        
00716         myBhaEvt->setElectron()->setFound(true); 
00717         m_showersAccepted++;
00718 
00719         log << MSG::INFO << name() << ": Electron: theta,phi energy "
00720             << myBhaEvt->electron()->theta() << ","
00721             << myBhaEvt->electron()->shower().phi() << " "
00722             << myBhaEvt->electron()->shower().energy()
00723             << endreq;
00724       } 
00725       
00726     } else //goodShowersList length > 0
00727       log << MSG::INFO << " No good showers found !"
00728           << endreq;    
00729   } //shower list length > 0
00730   else
00731     log << MSG::WARNING  << " No Showers found in event !" << endreq;
00732   
00733   if( bcl1!=0) delete cl1;
00734   if( bcl2!=0) delete cl2;
00735   if( bcl_tmp!=0) delete cl_tmp;
00736   
00737 }

void EmcMCfethe::setPassed bool  passed  )  [inline]
 

00074 { m_passed = passed;}

void EmcMCfethe::setPassed bool  passed  )  [inline]
 

00074 { m_passed = passed;}


Member Data Documentation

NTuple::Item<float> EmcMCfethe::En [private]
 

NTuple::Item<float> EmcMCfethe::En [private]
 

NTuple::Item<float> EmcMCfethe::EnA [private]
 

NTuple::Item<float> EmcMCfethe::EnA [private]
 

NTuple::Item<float> EmcMCfethe::EnB [private]
 

NTuple::Item<float> EmcMCfethe::EnB [private]
 

double EmcMCfethe::m_CalibConst [private]
 

int EmcMCfethe::m_digiRangeCut [private]
 

IEmcCalibConstSvc* EmcMCfethe::m_emcCalibConstSvc [private]
 

IEmcCalibConstSvc* EmcMCfethe::m_emcCalibConstSvc [private]
 

double EmcMCfethe::m_eNormCut [private]
 

int EmcMCfethe::m_event [private]
 

long int EmcMCfethe::m_events [private]
 

std::string EmcMCfethe::m_fileDir [private]
 

std::string EmcMCfethe::m_fileExt [private]
 

IEmcRecGeoSvc* EmcMCfethe::m_iGeoSvc [private]
 

IEmcRecGeoSvc* EmcMCfethe::m_iGeoSvc [private]
 

int** EmcMCfethe::m_index [private]
 

int** EmcMCfethe::m_index [private]
 

double EmcMCfethe::m_inputConst [private]
 

double EmcMCfethe::m_LATCut [private]
 

int EmcMCfethe::m_maxNrXtalsShowerCut [private]
 

double EmcMCfethe::m_minAngCut [private]
 

int EmcMCfethe::m_minNrXtalsShowerCut [private]
 

int EmcMCfethe::m_MsgFlag [private]
 

int EmcMCfethe::m_nrShThreshCut [private]
 

int EmcMCfethe::m_nXtals [private]
 

int EmcMCfethe::m_oneProngsSelelected [private]
 

bool EmcMCfethe::m_passed [private]
 

double EmcMCfethe::m_phiDiffMaxCut [private]
 

double EmcMCfethe::m_phiDiffMinCut [private]
 

long int EmcMCfethe::m_rejected [private]
 

int EmcMCfethe::m_run [private]
 

bool EmcMCfethe::m_setAlwaysPassed [private]
 

double EmcMCfethe::m_ShEneLeptonCut [private]
 

double EmcMCfethe::m_ShEneThreshCut [private]
 

list<EmcShower> EmcMCfethe::m_showerList [private]
 

list<EmcShower> EmcMCfethe::m_showerList [private]
 

long EmcMCfethe::m_showersAccepted [private]
 

long int EmcMCfethe::m_taken [private]
 

double EmcMCfethe::m_thetaBackwardCut [private]
 

double EmcMCfethe::m_thetaDiffCut [private]
 

double EmcMCfethe::m_thetaForwardMinAngCut [private]
 

double EmcMCfethe::m_thetaIndexForwardCut [private]
 

NTuple::Tuple* EmcMCfethe::m_tuple1 [private]
 

NTuple::Tuple* EmcMCfethe::m_tuple1 [private]
 

int EmcMCfethe::m_twoProngsSelected [private]
 

bool EmcMCfethe::m_writeMVToFile [private]
 

EmcBhabhaEvent* EmcMCfethe::myBhaEvt [private]
 

EmcBhabhaEvent* EmcMCfethe::myBhaEvt [private]
 

EmcBhaCalibData* EmcMCfethe::myCalibData [private]
 

EmcBhaCalibData* EmcMCfethe::myCalibData [private]
 

NTuple::Item<float> EmcMCfethe::Phi [private]
 

NTuple::Item<float> EmcMCfethe::Phi [private]
 

NTuple::Item<float> EmcMCfethe::PhiInd [private]
 

NTuple::Item<float> EmcMCfethe::PhiInd [private]
 

NTuple::Item<float> EmcMCfethe::Seed [private]
 

NTuple::Item<float> EmcMCfethe::Seed [private]
 

NTuple::Item<float> EmcMCfethe::The [private]
 

NTuple::Item<float> EmcMCfethe::The [private]
 

NTuple::Item<float> EmcMCfethe::TheInd [private]
 

NTuple::Item<float> EmcMCfethe::TheInd [private]
 


The documentation for this class was generated from the following files:
Generated on Wed Feb 2 16:01:29 2011 for BOSS6.5.5 by  doxygen 1.3.9.1