00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054 #include <assert.h>
00055 #include <Stiostream.h>
00056 #include <stdlib.h>
00057 #include "St_spa_Maker.h"
00058 #include "TDataSetIter.h"
00059
00060 #include "TFile.h"
00061 #include "StMessMgr.h"
00062
00063 #include "StSsdUtil/StSsdBarrel.hh"
00064 #include "StSsdPointMaker/StSsdPointMaker.h"
00065 #include "tables/St_spa_strip_Table.h"
00066 #include "tables/St_sls_strip_Table.h"
00067 #include "tables/St_ssdDimensions_Table.h"
00068 #include "tables/St_sdm_calib_par_Table.h"
00069 #include "tables/St_slsCtrl_Table.h"
00070 #include "tables/St_sdm_calib_db_Table.h"
00071 #include "tables/St_ssdStripCalib_Table.h"
00072 #include "tables/St_ssdWafersPosition_Table.h"
00073 #include "StSsdDbMaker/StSsdDbMaker.h"
00074
00075 ClassImp(St_spa_Maker)
00076
00077
00078 St_spa_Maker::St_spa_Maker(const char *name): StMaker(name),m_noise(0),m_condition(0),m_ctrl(0) {}
00079
00080 St_spa_Maker::~St_spa_Maker(){}
00081
00082 Int_t St_spa_Maker::Init(){
00083
00084
00085 TDataSet *ssdparams = GetInputDB("svt/ssd");
00086 TDataSetIter local(ssdparams);
00087
00088 m_condition = (St_sdm_condition_db *)local("sdm_condition_db");
00089 return StMaker::Init();
00090 }
00091
00092 Int_t St_spa_Maker::InitRun(Int_t runnumber){
00093 m_noise = (St_ssdStripCalib*) GetDataBase("Calibrations/ssd/ssdStripCalib");
00094 if (! m_noise) return kStFATAL;
00095 m_ctrl = gStSsdDbMaker->GetSlsCtrl();
00096 if (!m_ctrl) {
00097 LOG_ERROR << "No access to control parameters" << endm;
00098 return kStFatal;
00099 }
00100 return kStOK;
00101 }
00102
00103 Int_t St_spa_Maker::Make()
00104 {
00105 if (Debug()==true) {LOG_DEBUG << "Make() ..." << endm;}
00106
00107 Int_t res = 0;
00108
00109 St_sls_strip *sls_strip = (St_sls_strip *)GetDataSet("sls_strip/.data/sls_strip");
00110
00111 St_spa_strip *spa_strip = new St_spa_strip("spa_strip",40000);
00112 m_DataSet->Add(spa_strip);
00113
00114
00115
00116 LOG_INFO<<"#################################################"<<endm;
00117 LOG_INFO<<"#### START OF SSD PEDESTAL ANNIHILATOR ####"<<endm;
00118 LOG_INFO<<"#### SSD BARREL INITIALIZATION ####"<<endm;
00119 StSsdBarrel *mySsd = StSsdBarrel::Instance();
00120 assert(mySsd);
00121 mySsd->readStripFromTable(sls_strip);
00122 LOG_INFO<<"#### NUMBER OF SLS STRIPS "<<sls_strip->GetNRows()<<" ####"<<endm;
00123 Int_t numberOfNoise = 0;
00124 if (m_noise) {
00125 numberOfNoise = mySsd->readNoiseFromTable(m_noise);
00126 LOG_INFO<<"#### NUMBER OF DB ENTRIES "<<numberOfNoise<<" ####"<<endm;
00127 } else {
00128 LOG_ERROR<<"m_noise is missing" <<endm;
00129 }
00130 if (m_condition) {
00131 mySsd->readConditionDbFromTable(m_condition);
00132 LOG_INFO<<"#### ADD SPA NOISE ####"<<endm;
00133 } else {
00134 LOG_ERROR<<"m_condition is missing" <<endm;
00135 }
00136 if (m_ctrl) {
00137 mySsd->addNoiseToStrip(m_ctrl);
00138 LOG_INFO<<"#### DO DAQ SIMULATION ####"<<endm;
00139 } else {
00140 LOG_ERROR<<"m_ctrl is missing" <<endm;
00141 }
00142 mySsd->doDaqSimulation(m_ctrl);
00143 Int_t nSsdStrips = mySsd->writeStripToTable(spa_strip,sls_strip);
00144
00145 spa_strip->Purge();
00146 LOG_INFO<<"#### NUMBER OF SPA STRIP "<<nSsdStrips<<" ####"<<endm;
00147 mySsd->Reset();
00148 LOG_INFO<<"#################################################"<<endm;
00149 if (nSsdStrips) res = kStOK;
00150
00151 if(res!=kStOK){
00152 LOG_WARN <<"no output"<<endm;
00153 return kStWarn;
00154 }
00155
00156 return kStOK;
00157 }
00158
00159 void St_spa_Maker::PrintInfo()
00160 {
00161 if (Debug()==true){ StMaker::PrintInfo();}
00162 }
00163
00164 Int_t St_spa_Maker::Finish() {
00165 if (Debug()==true) {LOG_DEBUG << "Finish() ... " << endm; }
00166 return kStOK;
00167 }
00168