00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include <vector>
00013 #include "TkrRecon/SiRecObjsAlg.h"
00014
00015
00016 #include "TkrRecon/GFcandidates.h"
00017
00018 #include "GlastEvent/Recon/ICsIClusters.h"
00019
00020 #include "GaudiKernel/MsgStream.h"
00021 #include "GaudiKernel/AlgFactory.h"
00022 #include "GaudiKernel/IDataProviderSvc.h"
00023 #include "GaudiKernel/SmartDataPtr.h"
00024
00025 #include "GlastSvc/GlastDetSvc/IGlastDetSvc.h"
00026
00027 static const AlgFactory<SiRecObjsAlg> Factory;
00028 const IAlgFactory& SiRecObjsAlgFactory = Factory;
00029
00030
00033
00034
00035 SiRecObjsAlg::SiRecObjsAlg(const std::string& name, ISvcLocator* pSvcLocator) :
00036 Algorithm(name, pSvcLocator)
00037
00038 {
00039 }
00040
00041
00042 StatusCode SiRecObjsAlg::initialize()
00043
00044 {
00045
00046 StatusCode sc = service("TkrGeometrySvc", pTrackerGeo);
00047
00048 m_SiRecObjs = 0;
00049 m_SiClusters = 0;
00050
00051
00052 return StatusCode::SUCCESS;
00053 }
00054
00055 StatusCode SiRecObjsAlg::execute()
00056
00057 {
00058
00059 StatusCode sc = retrieve();
00060
00061 MsgStream log(msgSvc(), name());
00062
00063 log << MSG::DEBUG << "------- Recon of new Event --------" << endreq;
00064
00065 if (sc != StatusCode::SUCCESS) return sc;
00066
00067 GFtutor::load(m_SiClusters, pTrackerGeo);
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081 searchGammas();
00082
00083
00084 searchParticles();
00085
00086 m_SiRecObjs->writeOut(log);
00087
00088 return sc;
00089 }
00090
00091 StatusCode SiRecObjsAlg::finalize()
00092
00093 {
00094
00095 return StatusCode::SUCCESS;
00096 }
00097
00098
00099
00100 StatusCode SiRecObjsAlg::retrieve()
00101
00102 {
00103 StatusCode sc = StatusCode::SUCCESS;
00104
00105 MsgStream log(msgSvc(), name());
00106
00107
00108 DataObject* pnode=0;
00109
00110 sc = eventSvc()->retrieveObject( "/Event/TkrRecon", pnode );
00111
00112 if( sc.isFailure() ) {
00113 sc = eventSvc()->registerObject("/Event/TkrRecon",new DataObject);
00114 if( sc.isFailure() ) {
00115
00116 log << MSG::ERROR << "Could not create Raw directory" << endreq;
00117 return sc;
00118 }
00119 }
00120 m_SiRecObjs = new SiRecObjs();
00121 m_SiRecObjs->clear();
00122 sc = eventSvc()->registerObject("/Event/TkrRecon/SiRecObjs",m_SiRecObjs);
00123
00124
00125 m_SiClusters = SmartDataPtr<SiClusters>(eventSvc(),"/Event/TkrRecon/SiClusters");
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00137
00138
00139
00140
00141 ICsIClusterList* pCalClusters = SmartDataPtr<ICsIClusterList>(eventSvc(),"/Event/CalRecon/CsIClusterList");
00142
00143 m_CsIEnergy = 0.03;
00144 m_CsIPosition = Point(0.,0.,0.);
00145
00146 if (pCalClusters)
00147 {
00148 ICsICluster* pCalClus = pCalClusters->Cluster(0);
00149 m_CsIEnergy = pCalClus->energySum() / 1000;
00150 m_CsIPosition = pCalClus->position();
00151 }
00152
00153
00154 if (m_CsIEnergy < 0.03)
00155 {
00157 double MINENE = 0.03;
00158 m_CsIEnergy = MINENE;
00159 m_CsIPosition = Point(0.,0.,0.);
00160 }
00161
00162 if (m_SiClusters == 0 || m_SiRecObjs ==0) sc = StatusCode::FAILURE;
00163 return sc;
00164 }
00165
00166
00167 void SiRecObjsAlg::searchGammas()
00168
00169 {
00170
00171 int ntries = 0;
00172 double factor = 1.;
00173 bool end = false;
00174
00175 while (ntries < GFcontrol::gammaTries && !end)
00176 {
00177 double sigmaCut = 3.* GFcontrol::sigmaCut;
00178
00179 double ene = m_CsIEnergy*factor;
00180 if (ene <= GFcontrol::minEnergy) ene = GFcontrol::minEnergy;
00181
00182 GFcandidates* gamma =
00183 new GFcandidates(GFcandidates::GAMMA, ene , sigmaCut, m_CsIPosition);
00184
00185 if (gamma->numCandidates() > 0) {
00186 ntries++;
00187
00188 int ican = 0;
00189 GFdata gammaCandidate = gamma->m_candidates[ican];
00190
00191 int iniLayer = gammaCandidate.firstLayer();
00192 Ray testRay = gammaCandidate.ray();
00193
00194 GFgamma* _GFgamma = new GFgamma(GFcontrol::FEne, sigmaCut,
00195 ene, iniLayer, testRay);
00196
00197 if (!_GFgamma->empty()) {
00198 _GFgamma->flagAllHits();
00199 m_SiRecObjs->addGamma(_GFgamma);
00200 } else delete _GFgamma;
00201
00202 } else end = true;
00203 delete gamma;
00204 }
00205
00206 }
00207
00208
00209 void SiRecObjsAlg::searchParticles()
00210
00211 {
00212
00213 int ntries = 0;
00214 double factor = 1./GFcontrol::particleTries;
00215 bool end = false;
00216
00217 while (ntries < GFcontrol::particleTries && !end) {
00218
00219 GFtutor::setVeto(false);
00220
00221 double ene = GFcontrol::FEneParticle*m_CsIEnergy*factor;
00222 if (ene <= GFcontrol::minEnergy) ene = GFcontrol::minEnergy;
00223 GFcandidates* tracks =
00224 new GFcandidates(GFcandidates::PARTICLE, ene, GFcontrol::sigmaCut, m_CsIPosition);
00225
00226 if (tracks->numCandidates() > 0) {
00227 ntries++;
00228 GFdata trackCandidate = tracks->m_candidates[0];
00229
00230 int iniLayer = trackCandidate.firstLayer();
00231 Ray testRay = trackCandidate.ray();
00232
00233 GFparticle* _GFparticle =
00234 new GFparticle(GFcontrol::sigmaCut, ene, iniLayer, testRay);
00235
00236 if (!_GFparticle->empty()) {
00237 m_SiRecObjs->addParticle(_GFparticle);
00238 _GFparticle->flagAllHits();
00239 } else {
00240 delete _GFparticle;
00241 }
00242 } else end = true;
00243 delete tracks;
00244
00245 GFtutor::setVeto(true);
00246 }
00247 }