/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Emc/EmcGeneralClass/EmcGeneralClass-00-00-04/src/EmcStructure.cxx

Go to the documentation of this file.
00001 
00002 #include "EmcGeneralClass/EmcStructure.h"
00003 #include <vector>
00004 #include <iostream>
00005 
00006 using namespace std;
00007 
00008 //----------------
00009 // Constructors --
00010 //----------------
00011 EmcStructure::EmcStructure()
00012 {
00013 
00014 }
00015 
00016 //--------------
00017 // Destructor --
00018 //--------------
00019 EmcStructure::~EmcStructure()
00020 {
00021 }
00022 
00023 void EmcStructure::setEmcStruc()
00024 {
00025   int index;
00026   int nrOfTheRings = getNumberOfTheRings();
00027   for ( int the = startingTheta(); the< nrOfTheRings; the++) {
00028        
00029     for ( int phi=0; phi < crystalsInRing((unsigned int) the ); phi++) {
00030       
00031       index = getIndex( (unsigned int)the , (unsigned int)phi);
00032 
00033       m_phiIndex[index]=phi;
00034       if (the>=0 && the<=5) {
00035         m_partID[index]=0;
00036         m_thetaIndex[index]=the;
00037       }
00038       if (the>=6 && the<=49) {
00039         m_partID[index]=1;
00040         m_thetaIndex[index]=the-6;
00041       }
00042       if (the>=50 && the<=55){ 
00043         m_partID[index]=2;
00044         m_thetaIndex[index]=55 - the;
00045       }
00046 
00047     }
00048     m_ThetaMaxIndex[the]=index;
00049   }
00050 
00051 }
00052 int 
00053 EmcStructure::getGeomIndex( unsigned int PartId, 
00054                             unsigned int ThetaIndex, 
00055                             unsigned int PhiIndex)  const
00056 {
00057   if (PartId>2){
00058     cout<<"PartId is out of EMC"<<endl;
00059     return -1;
00060   } else {
00061     unsigned int newThetaIndex;
00062     //The newThetaIndex is defined by Endcap_east(0-5),Barrel(6-49),Endcap_west(50-55)
00063     if (PartId==0) newThetaIndex = ThetaIndex;
00064     if (PartId==1) newThetaIndex = ThetaIndex + 6;
00065     if (PartId==2) newThetaIndex = 55 - ThetaIndex;
00066     
00067     if ( isOutofAccep(newThetaIndex, PhiIndex) ) 
00068       {
00069         return -1;
00070       } else {
00071       
00072         int index;   
00073         index = getIndex(newThetaIndex,PhiIndex);
00074       
00075         return index;
00076       }
00077   }
00078 }
00079 
00080 long 
00081 EmcStructure::getIndex(unsigned int  thetaIndex, unsigned int phiIndex ) const
00082 {
00083   long index = -1;
00084   if(thetaIndex==0){
00085     index=phiIndex;
00086   } else {
00087     index = getThisThetaMaxIndex( thetaIndex-1 ) +1 + phiIndex;
00088   }
00089   return index;
00090 }
00091 
00092 bool 
00093 EmcStructure::isOutofAccep(unsigned int thetaIndex, 
00094                            unsigned int phiIndex) const
00095 {
00096   if ( thetaIndex > 55 ) 
00097     {
00098       cout<<"warning " << " theta out of acceptance !"
00099           << endl;
00100       return true;  
00101       
00102     } 
00103   else 
00104     {
00105       if ( ((thetaIndex==0 || thetaIndex==1 || thetaIndex==55 || thetaIndex==54)
00106             && (phiIndex > 63))
00107            || ((thetaIndex==2 || thetaIndex==3 || thetaIndex==53 || thetaIndex==52)
00108                && (phiIndex > 79))
00109            || ((thetaIndex==4 || thetaIndex==5 || thetaIndex==51 || thetaIndex==50)
00110                && ( phiIndex > 95))
00111            || ((thetaIndex>=6 && thetaIndex<=49) && ( phiIndex > 119)) ) 
00112         {      
00113           cout<<"warning "<< " phi out of acceptance !" << endl;
00114           return true;    
00115         }  
00116       else 
00117         {
00118           return false;
00119         } 
00120     }
00121 }
00122 
00123 unsigned int 
00124 EmcStructure::getNumberOfTheRings()
00125 {  
00126   unsigned int numberOfTheRings=0;
00127   numberOfTheRings  = (aEmcId->getTHETA_BARREL_MAX() + 1) 
00128     + (aEmcId->getTHETA_ENDCAP_MAX() + 1 ) * 2;
00129   
00130   return  numberOfTheRings;
00131   
00132 }
00133 unsigned int 
00134 EmcStructure::getNumberOfXtals()
00135 {
00136   unsigned int numberOfXtals=0;
00137   unsigned int numberOfBarrelXtals, numberOfEndcapXtals;
00138 
00139   numberOfEndcapXtals = numberOfOneEndcapRings * (aEmcId->getPHI_ENDCAP_MAX(0)+1)
00140     + numberOfTwoEndcapRings * (aEmcId->getPHI_ENDCAP_MAX(2)+1)
00141     + numberOfThreeEndcapRings * (aEmcId->getPHI_ENDCAP_MAX(4)+1);
00142 
00143   numberOfBarrelXtals = (aEmcId->getTHETA_BARREL_MAX()+1)*(aEmcId->getPHI_BARREL_MAX()+1);
00144   
00145   numberOfXtals = numberOfBarrelXtals + numberOfEndcapXtals * 2;
00146   
00147   return numberOfXtals;
00148 }
00149 
00150 unsigned int
00151 EmcStructure::crystalsInRing( unsigned int theta ) const
00152 {
00153   //The theta index is defined by Endcap_east(0-5),Barrel(6-49),Endcap_west(50-55)
00154   //in Emc Bhabha Calibration
00155   unsigned int theXtalInRing;
00156 
00157   if (theta==0 || theta==1 || theta==55 || theta==54) 
00158     {
00159       theXtalInRing= aEmcId->getPHI_ENDCAP_MAX(0)+1;
00160     }
00161 
00162   if (theta==2 || theta==3 || theta==53 || theta==52) 
00163     {
00164       theXtalInRing=aEmcId->getPHI_ENDCAP_MAX(2)+1;
00165     }
00166 
00167   if (theta==4 || theta==5 || theta==51 || theta==50) 
00168     {
00169       theXtalInRing=aEmcId->getPHI_ENDCAP_MAX(4)+1;
00170     }
00171 
00172   if (theta>=6 && theta<=49) 
00173     {
00174       theXtalInRing=aEmcId->getPHI_BARREL_MAX()+1;
00175     }
00176 
00177   //  if (theta<0 || theta>55) theXtalInRing= 0;
00178   if (theta>55) 
00179     {
00180       theXtalInRing= 0;
00181     }
00182 
00183   return theXtalInRing;
00184 }

Generated on Tue Nov 29 22:58:17 2016 for BOSS_7.0.2 by  doxygen 1.4.7