00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "AtlfastAlgs/ClusterMaker.h"
00013 #include "AtlfastAlgs/ClusterConeStrategy.h"
00014 #include "AtlfastAlgs/SharedConeStrategy.h"
00015 #include "AtlfastAlgs/ClusterKtStrategy.h"
00016 #include "AtlfastUtils/FunctionObjects.h"
00017 #include "AtlfastUtils/HeaderPrinter.h"
00018 #include "AtlfastEvent/Cell.h"
00019 #include "AtlfastEvent/TwoCptCell.h"
00020 #include "AtlfastEvent/ITwoCptCell.h"
00021 #include "AtlfastEvent/Cluster.h"
00022 #include "AtlfastUtils/IClusterStrategy.h"
00023 #include "AtlfastUtils/TesIO.h"
00024 #include "AtlfastAlgs/GlobalEventData.h"
00025 #include "AtlfastAlgs/AssocTypeRecoverer.h"
00026 #include "AtlfastAlgs/AssocTypeConverter.h"
00027 #include "AtlfastUtils/CastAwayConst.h"
00028
00029
00030 #include <cmath>
00031 #include <algorithm>
00032 #include <vector>
00033
00034
00035 #include "GaudiKernel/DataSvc.h"
00036 #include "StoreGate/DataHandle.h"
00037 #include "GaudiKernel/ISvcLocator.h"
00038 #include "GaudiKernel/MsgStream.h"
00039
00040
00041 #include "CLHEP/Vector/LorentzVector.h"
00042
00043 namespace Atlfast {
00044
00045
00046
00047
00048 ClusterMaker::ClusterMaker
00049 ( const std::string& name, ISvcLocator* pSvcLocator )
00050 : Algorithm( name, pSvcLocator ){
00051
00052
00053 m_rConeBarrel = 0.401;
00054 m_rConeForward = 0.401;
00055 m_minInitiatorET = 1.5;
00056 m_minClusterET = 5.;
00057 m_processCells = true;
00058 m_processTracks = false;
00059 m_inputCellLocation = "/Event/AtlfastCells" ;
00060 m_inputTrackLocation = "/Event/AtlfastTracks" ;
00061 m_outputLocation = "/Event/AtlfastClusters";
00062 m_unusedCellLocation = "/Event/AtlfastUnusedCells";
00063 m_unusedTrackLocation = "/Event/AtlfastUnusedTracks";
00064 m_masslessJets = true;
00065 m_strategy = "Cone";
00066
00067
00068
00069 declareProperty( "RConeBarrel", m_rConeBarrel ) ;
00070 declareProperty( "RConeForward", m_rConeForward ) ;
00071 declareProperty( "minInitiatorET", m_minInitiatorET ) ;
00072 declareProperty( "minClusterET", m_minClusterET ) ;
00073 declareProperty( "Strategy", m_strategy ) ;
00074 declareProperty( "ProcessCells", m_processCells ) ;
00075 declareProperty( "ProcessTracks", m_processTracks ) ;
00076 declareProperty( "InputCellLocation", m_inputCellLocation ) ;
00077 declareProperty( "InputTrackLocation", m_inputTrackLocation ) ;
00078 declareProperty( "OutputLocation", m_outputLocation ) ;
00079 declareProperty( "UnusedCellLocation", m_unusedCellLocation ) ;
00080 declareProperty( "UnusedTrackLocation", m_unusedTrackLocation ) ;
00081 declareProperty( "MasslessJets", m_masslessJets ) ;
00082
00083 }
00084
00085
00086 ClusterMaker::~ClusterMaker() {
00087 if(m_tesIO){
00088 delete m_tesIO;
00089 }
00090 if(m_clusterStrategy){
00091 delete m_clusterStrategy;
00092 }
00093 }
00094
00095
00096
00097
00098
00099
00100 StatusCode ClusterMaker::initialize(){
00101
00102 MsgStream log( messageService(), name() ) ;
00103 log << MSG::DEBUG<< "Cluster Maker initialising " << endreq;
00104
00105
00106
00107 m_tesIO = new TesIO();
00108 if(m_strategy == "Cone"){
00109 m_clusterStrategy = new ClusterConeStrategy(
00110 m_rConeBarrel,
00111 m_rConeForward,
00112 m_minInitiatorET,
00113 m_minClusterET,
00114 m_masslessJets);
00115
00116 } else if(m_strategy == "Kt"){
00117 m_clusterStrategy = new ClusterKtStrategy(m_minClusterET);
00118 } else if(m_strategy == "Shared"){
00119 GlobalEventData* ged = GlobalEventData::Instance();
00120 double barrelForwardEta = ged -> barrelForwardEta();
00121 m_clusterStrategy = new SharedConeStrategy(m_rConeBarrel,
00122 m_rConeForward,
00123 m_minInitiatorET,
00124 m_minClusterET,
00125 barrelForwardEta);
00126 }else{
00127 m_clusterStrategy = new ClusterConeStrategy(
00128 m_rConeBarrel,
00129 m_rConeForward,
00130 m_minInitiatorET,
00131 m_minClusterET,
00132 m_masslessJets);
00133
00134 m_strategy = "Cone";
00135 }
00136
00137 HeaderPrinter hp("Atlfast Cluster Maker:", log);
00138 hp.add("Endcap Cone Size ", m_rConeForward);
00139 hp.add("Barrel Cone Size ", m_rConeBarrel);
00140 hp.add("Min ET for Cell initiator ", m_minInitiatorET);
00141 hp.add("Min ET for cluster ", m_minClusterET);
00142 hp.add("Cluster Strategy ", m_strategy);
00143 hp.add("Process Cells ", m_processCells);
00144 hp.add("Process Tracks ", m_processTracks);
00145 if(m_processCells){
00146 hp.add("Input CellLocation ", m_inputCellLocation);
00147 }
00148 if(m_processTracks) {
00149 hp.add("Input TrackLocation ", m_inputTrackLocation);
00150 }
00151 hp.add("Output Location ", m_outputLocation);
00152 hp.add("Unused Cell Location ", m_unusedCellLocation);
00153 hp.add("Unused Track Location ", m_unusedTrackLocation);
00154 hp.add("Massless Jets ", m_masslessJets);
00155 hp.print();
00156
00157 return StatusCode::SUCCESS ;
00158 }
00159
00160
00161
00162
00163
00164 StatusCode ClusterMaker::finalize(){
00165 return StatusCode::SUCCESS ;
00166 }
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181 StatusCode ClusterMaker::execute( ){
00182 MsgStream log( messageService(), name() ) ;
00183 std::string message;
00184
00185
00186
00187
00188 std::vector<IKinematic*> elements;
00189
00190 TesIoStat stat;
00191 if(m_processCells){
00192 stat = m_tesIO->copy<ITwoCptCellCollection>(elements,
00193 m_inputCellLocation);
00194 message = stat? "Found Cells in TES":"No Cells found in TES";
00195 log<<MSG::DEBUG << message <<" "<<elements.size()<<endreq;
00196 }
00197 if(m_processTracks){
00198 stat = m_tesIO->copy<TrackCollection>(elements, m_inputTrackLocation);
00199 message = stat? "Found Tracks in TES":"No Tracks found in TES";
00200 log<<MSG::DEBUG << message <<" "<<elements.size()<<endreq;
00201 }
00202
00203
00204
00205
00206 ClusterCollection* clusters = new ClusterCollection ;
00207 std::vector<IKinematic*> unusedLocalElements;
00208
00209 log << MSG::DEBUG << "Starting Clustering Strategy" << endreq ;
00210
00211 m_clusterStrategy->makeClusters(
00212 log,
00213 elements,
00214 unusedLocalElements,
00215 clusters
00216 ) ;
00217
00218
00219
00220
00221 AssocTypeConverter<std::vector<IKinematic*> > atr(unusedLocalElements);
00222 log<<MSG::DEBUG<<"Number Of Unused Local Elements "<< unusedLocalElements.size()<<endreq;
00223
00224
00225 stat = m_tesIO -> store(clusters, m_outputLocation);
00226 message = stat ? "Clusters stored":"Failed to store Clusters ";
00227 log<<MSG::DEBUG<<message<<endreq;
00228
00229 stat = m_tesIO -> store(atr.cells(), m_unusedCellLocation);
00230 message =stat? "unused cells stored":"unused cells store failed";
00231 log<<MSG::DEBUG<<message<<endreq;
00232
00233
00234 stat = m_tesIO -> store(atr.tracks(), m_unusedTrackLocation);
00235 message =stat? "unused tracks stored":"unused cells store failed";
00236 log<<MSG::DEBUG<<message<<endreq;
00237
00238 return stat ;
00239
00240 }
00241
00242 }
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256