Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members   Related Pages  

CalNtupleAlg Class Reference

alg to control writing of ntuple from calorimeter reconstruction. More...

List of all members.

Public Methods

 CalNtupleAlg (const std::string &name, ISvcLocator *pSvcLocator)
 Constructor of this form must be provided. More...

StatusCode initialize ()
StatusCode execute ()
StatusCode finalize ()

Private Attributes

std::string m_tupleName
CsIClusterListm_cls
CalRecLogsm_crl
INTupleWriterSvc * m_ntupleWriteSvc


Detailed Description

alg to control writing of ntuple from calorimeter reconstruction.

Definition at line 30 of file CalNtupleAlg.cxx.


Constructor & Destructor Documentation

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

Constructor of this form must be provided.

Definition at line 53 of file CalNtupleAlg.cxx.

00053                                                                           :
00054 Algorithm(name, pSvcLocator){
00055     
00056     declareProperty("tupleName",  m_tupleName="");
00057     
00058     m_cls = 0;
00059 }


Member Function Documentation

StatusCode CalNtupleAlg::execute  
 

Definition at line 88 of file CalNtupleAlg.cxx.

References CsIClusterList::Cluster(), CalRecLog::energy(), CalRecLogs::Log(), m_cls, m_crl, m_ntupleWriteSvc, m_tupleName, CalRecLogs::num(), and CsIClusterList::num().

00088                                  {
00089     
00090     StatusCode  sc = StatusCode::SUCCESS;
00091     MsgStream   log( msgSvc(), name() );
00092     
00093     m_cls  = SmartDataPtr<CsIClusterList>(eventSvc(),"/Event/CalRecon/CsIClusterList");
00094 
00095         if (m_cls == 0){ sc = StatusCode::FAILURE;
00096         
00097                 log << MSG::ERROR << "CalNtupleAlg failed to access CsIClusterList" << endreq;
00098                         return sc;
00099         }
00100 
00101 
00102         double fit_ener,fitalpha,fitlambda,profchi2,eleak,start;
00103         float energy_sum;
00104 
00105         int nClust = m_cls->num();
00106         //cout << nClust << endl;
00107         for ( int icl = 0; icl<nClust;icl++){
00108                 ICsICluster* cl = m_cls->Cluster(icl);
00109                 energy_sum = cl->energySum();
00110 
00111                 //stop writing NANs to the tuple
00112                 float zpos = -1000.0;
00113                 float xpos = -1000.0;
00114                 float ypos = -1000.0;
00115 
00116                 zpos = (cl->position()).z();
00117                 xpos = (cl->position()).x();
00118                 ypos = (cl->position()).y();
00119 
00120                 const std::vector<double>& eneLayer = cl->getEneLayer();
00121                 const std::vector<Vector>& posLayer = cl->getPosLayer();
00122 
00123                 float trans_rms = cl->getRmsTrans();
00124                 float long_rms = cl->getRmsLong();
00125 
00126                 Vector caldir = cl->direction();
00127                 float caltheta = -1000.0;
00128                 float calphi = -1000.0;
00129         if(abs(caldir.z())<1.){ caltheta=acos(caldir.z());
00130             calphi=float(M_PI/2.);
00131                     if(caldir.x()!=0.) calphi = atan(caldir.y()/caldir.x());
00132         }
00133                 fit_ener = cl->getFitEnergy();
00134                 profchi2 = cl->getProfChisq();
00135                 fitalpha = cl->getCsiAlpha();
00136                 fitlambda = cl->getCsiLambda();
00137                 start = cl->getCsiStart();
00138                 eleak = cl->energyLeak();
00139         float transvOffset = cl->getTransvOffset();
00140         
00141         float eFactor = .26 + .35 / (cl->energyCorrected());
00142         float calFitErrNrm = transvOffset/eFactor;
00143 
00144                 sc = m_ntupleWriteSvc->addItem(m_tupleName.c_str(), "Cal_Transv_Offset", transvOffset);
00145                 sc = m_ntupleWriteSvc->addItem(m_tupleName.c_str(), "Cal_Fit_errNrm", calFitErrNrm);
00146             
00147         
00148                 sc = m_ntupleWriteSvc->addItem(m_tupleName.c_str(), "Cal_Energy_Deposit", energy_sum);
00149                 sc = m_ntupleWriteSvc->addItem(m_tupleName.c_str(), "Cal_Energy_Inc_Prof", fit_ener);
00150                 sc = m_ntupleWriteSvc->addItem(m_tupleName.c_str(), "Cal_Energy_Inc_LeakCorr", eleak);
00151                 sc = m_ntupleWriteSvc->addItem(m_tupleName.c_str(), "Cal_Energy_Incident", fit_ener);  // for the moment
00152                 sc = m_ntupleWriteSvc->addItem(m_tupleName.c_str(), "Energy_Incident_CalTkr", energy_sum);  // to be updated
00153 
00154                 const std::string name_eLayer = "Cal_eLayer";
00155                 const char* digit[8]={"0","1","2","3","4","5","6","7"};
00156                 for (int layer=0; layer<8; layer++)
00157                 sc = m_ntupleWriteSvc->addItem(m_tupleName.c_str(), (name_eLayer+digit[layer]).c_str(), eneLayer[layer]);
00158         
00159                 sc = m_ntupleWriteSvc->addItem(m_tupleName.c_str(), "Cal_Z", zpos);
00160                 
00161                 sc = m_ntupleWriteSvc->addItem(m_tupleName.c_str(), "Cal_X", xpos);
00162 
00163                 sc = m_ntupleWriteSvc->addItem(m_tupleName.c_str(), "Cal_Y", ypos);
00164 
00165                 sc = m_ntupleWriteSvc->addItem(m_tupleName.c_str(), "Cal_transv_rms", trans_rms);
00166                 
00167                 sc = m_ntupleWriteSvc->addItem(m_tupleName.c_str(), "Cal_long_rms", long_rms);
00168 
00169                 sc = m_ntupleWriteSvc->addItem(m_tupleName.c_str(), "Cal_theta", caltheta);
00170 
00171                 sc = m_ntupleWriteSvc->addItem(m_tupleName.c_str(), "Cal_phi", calphi);
00172 
00173         }
00174 
00175         m_crl = SmartDataPtr<CalRecLogs>(eventSvc(),"/Event/CalRecon/CalRecLogs"); 
00176         if (m_crl == 0){ sc = StatusCode::FAILURE;
00177         
00178                 log << MSG::ERROR << "CalNtupleAlg failed to access CalRecLogs" << endreq;
00179                         return sc;
00180         }
00181         
00182         int no_xtals=0;
00183         int no_xtals_trunc=0;
00184         int nLogs = m_crl->num();
00185         for (int jlog = 0; jlog < nLogs ; jlog++) {
00186                 CalRecLog* recLog = m_crl->Log(jlog);
00187 
00188                 double eneLog = recLog->energy();
00189                 if(eneLog>0)no_xtals++;
00190                 if(eneLog>0.01*energy_sum)no_xtals_trunc++;
00191         }
00192     float cal_xtal_ratio= (no_xtals>0) ? float(no_xtals_trunc)/no_xtals : 0;
00193 
00194     sc = m_ntupleWriteSvc->addItem(m_tupleName.c_str(), "Cal_No_Xtals", no_xtals);
00195     sc = m_ntupleWriteSvc->addItem(m_tupleName.c_str(), "Cal_No_Xtals_Trunc", no_xtals_trunc);
00196         sc = m_ntupleWriteSvc->addItem(m_tupleName.c_str(), "Cal_Xtal_Ratio", cal_xtal_ratio);
00197  
00198     return sc;
00199 }

StatusCode CalNtupleAlg::finalize  
 

Definition at line 203 of file CalNtupleAlg.cxx.

00203                                   {
00204     StatusCode  sc = StatusCode::SUCCESS;
00205     
00206     MsgStream log(msgSvc(), name());
00207     log << MSG::INFO << "finalize CalNtupleAlg " << endreq;
00208     
00209     return StatusCode::SUCCESS;
00210 }

StatusCode CalNtupleAlg::initialize  
 

Definition at line 64 of file CalNtupleAlg.cxx.

References m_ntupleWriteSvc.

00064                                     {
00065     
00066     StatusCode sc = StatusCode::SUCCESS;
00067     
00068     MsgStream log(msgSvc(), name());
00069     log << MSG::INFO << "Initialize" << endreq;
00070     
00071     // Use the Job options service to set the Algorithm's parameters
00072     setProperties();
00073     
00074     // get a pointer to our ntupleWriterSvc
00075     sc = service("ntupleWriterSvc", m_ntupleWriteSvc);
00076     
00077     if( sc.isFailure() ) {
00078         log << MSG::ERROR << "CalNtupleAlg failed to get the ntupleWriterSvc" << endreq;
00079         return sc;
00080     }
00081     
00082     return sc;
00083 }


Member Data Documentation

CsIClusterList* CalNtupleAlg::m_cls [private]
 

Definition at line 42 of file CalNtupleAlg.cxx.

Referenced by execute().

CalRecLogs* CalNtupleAlg::m_crl [private]
 

Definition at line 43 of file CalNtupleAlg.cxx.

Referenced by execute().

INTupleWriterSvc* CalNtupleAlg::m_ntupleWriteSvc [private]
 

Definition at line 44 of file CalNtupleAlg.cxx.

Referenced by execute(), and initialize().

std::string CalNtupleAlg::m_tupleName [private]
 

Definition at line 41 of file CalNtupleAlg.cxx.

Referenced by execute().


The documentation for this class was generated from the following file:
Generated on Thu Nov 29 16:38:53 2001 by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001