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
00026 #include "AtlfastAlgs/ContainerDispatcher.h"
00027 #include "AtlfastEvent/TypeVisitor.h"
00028
00029 #include <cmath>
00030 #include <algorithm>
00031 #include <vector>
00032
00033
00034 #include "GaudiKernel/DataSvc.h"
00035 #include "GaudiKernel/ISvcLocator.h"
00036 #include "GaudiKernel/MsgStream.h"
00037
00038
00039 #include "CLHEP/Vector/LorentzVector.h"
00040
00041 namespace Atlfast {
00042
00043
00044
00045
00046 ClusterMaker::ClusterMaker
00047 ( const std::string& name, ISvcLocator* pSvcLocator )
00048 : Algorithm( name, pSvcLocator ),
00049 m_clusterStrategy(0),
00050 m_tesIO(0)
00051 {
00052
00053
00054 m_rConeBarrel = 0.401;
00055 m_rConeForward = 0.401;
00056 m_minInitiatorET = 1.5*GeV;
00057 m_minClusterET = 5.0*GeV;
00058 m_processCells = true;
00059 m_processTracks = false;
00060 m_inputCellLocation = "/Event/AtlfastCells" ;
00061 m_inputTrackLocation = "/Event/AtlfastTracks" ;
00062 m_outputLocation = "/Event/AtlfastClusters";
00063 m_unusedCellLocation = "/Event/AtlfastUnusedCells";
00064 m_unusedTrackLocation = "/Event/AtlfastUnusedTracks";
00065 m_masslessJets = true;
00066 m_strategy = "Cone";
00067
00068 m_ktRParameter = 1.0;
00069 m_ktAngle = "deltaR";
00070 m_ktRecomScheme = "E";
00071 m_ktYCut = 0;
00072
00073
00074
00075 declareProperty( "RConeBarrel", m_rConeBarrel ) ;
00076 declareProperty( "RConeForward", m_rConeForward ) ;
00077 declareProperty( "minInitiatorET", m_minInitiatorET ) ;
00078 declareProperty( "minClusterET", m_minClusterET ) ;
00079 declareProperty( "Strategy", m_strategy ) ;
00080 declareProperty( "ProcessCells", m_processCells ) ;
00081 declareProperty( "ProcessTracks", m_processTracks ) ;
00082 declareProperty( "InputCellLocation", m_inputCellLocation ) ;
00083 declareProperty( "InputTrackLocation", m_inputTrackLocation ) ;
00084 declareProperty( "OutputLocation", m_outputLocation ) ;
00085 declareProperty( "UnusedCellLocation", m_unusedCellLocation ) ;
00086 declareProperty( "UnusedTrackLocation", m_unusedTrackLocation ) ;
00087 declareProperty( "MasslessJets", m_masslessJets ) ;
00088
00089 declareProperty( "KtRParameter", m_ktRParameter ) ;
00090 declareProperty( "KtAngle", m_ktAngle ) ;
00091 declareProperty( "KtRecomScheme", m_ktRecomScheme ) ;
00092 declareProperty( "KtYCut", m_ktYCut ) ;
00093
00094 }
00095
00096
00097 ClusterMaker::~ClusterMaker() {
00098 if(m_tesIO){
00099 delete m_tesIO;
00100 }
00101 if(m_clusterStrategy){
00102 delete m_clusterStrategy;
00103 }
00104 }
00105
00106
00107
00108
00109
00110
00111 StatusCode ClusterMaker::initialize(){
00112
00113 MsgStream log( messageService(), name() ) ;
00114 log << MSG::DEBUG<< "Cluster Maker initialising " << endreq;
00115
00116
00117 GlobalEventData* ged = GlobalEventData::Instance();
00118 m_mcLocation = ged -> mcLocation();
00119
00120
00121 m_tesIO = new TesIO(m_mcLocation, ged->justHardScatter());
00122
00123 if(m_strategy == "Cone"){
00124 m_clusterStrategy = new ClusterConeStrategy(
00125 m_rConeBarrel,
00126 m_rConeForward,
00127 m_minInitiatorET,
00128 m_minClusterET,
00129 m_masslessJets);
00130
00131 } else if(m_strategy == "Kt"){
00132 m_clusterStrategy = new ClusterKtStrategy(m_minClusterET,m_ktRParameter,m_ktAngle,m_ktRecomScheme,m_ktYCut);
00133 } else if(m_strategy == "Shared"){
00134 double barrelForwardEta = ged -> barrelForwardEta();
00135 m_clusterStrategy = new SharedConeStrategy(m_rConeBarrel,
00136 m_rConeForward,
00137 m_minInitiatorET,
00138 m_minClusterET,
00139 barrelForwardEta);
00140 }else{
00141 m_clusterStrategy = new ClusterConeStrategy(
00142 m_rConeBarrel,
00143 m_rConeForward,
00144 m_minInitiatorET,
00145 m_minClusterET,
00146 m_masslessJets);
00147
00148 m_strategy = "Cone";
00149 }
00150
00151 HeaderPrinter hp("Atlfast Cluster Maker:", log);
00152 hp.add("Cluster Strategy ", m_strategy);
00153 if(m_strategy == "Kt"){
00154 hp.add( "Kt R-Parameter ", m_ktRParameter ) ;
00155 hp.add( "Kt Angle ", m_ktAngle ) ;
00156 hp.add( "Kt Recombination Scheme ", m_ktRecomScheme ) ;
00157 hp.add( "Kt Y-Merge value ", m_ktYCut ) ;
00158 }else{
00159 hp.add("Endcap Cone Size ", m_rConeForward);
00160 hp.add("Barrel Cone Size ", m_rConeBarrel);
00161 hp.add("Min ET for Cell initiator ", m_minInitiatorET);
00162 }
00163 hp.add("Min ET for cluster ", m_minClusterET);
00164 hp.add("Process Cells ", m_processCells);
00165 hp.add("Process Tracks ", m_processTracks);
00166 if(m_processCells){
00167 hp.add("Input CellLocation ", m_inputCellLocation);
00168 }
00169 if(m_processTracks) {
00170 hp.add("Input TrackLocation ", m_inputTrackLocation);
00171 }
00172 hp.add("Output Location ", m_outputLocation);
00173 hp.add("Unused Cell Location ", m_unusedCellLocation);
00174 hp.add("Unused Track Location ", m_unusedTrackLocation);
00175 hp.add("Massless Jets ", m_masslessJets);
00176 hp.print();
00177
00178 return StatusCode::SUCCESS ;
00179 }
00180
00181
00182
00183
00184
00185 StatusCode ClusterMaker::finalize(){
00186 return StatusCode::SUCCESS ;
00187 }
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202 StatusCode ClusterMaker::execute( ){
00203 MsgStream log( messageService(), name() ) ;
00204 std::string message;
00205
00206
00207
00208
00209 std::vector<IKinematic*> elements;
00210
00211 TesIoStat stat;
00212 if(m_processCells){
00213 stat = m_tesIO->copy<ITwoCptCellCollection>(elements,
00214 m_inputCellLocation);
00215 message = stat? "Found Cells in TES":"No Cells found in TES";
00216 log<<MSG::DEBUG << message <<" "<<elements.size()<<endreq;
00217 }
00218 if(m_processTracks){
00219 stat = m_tesIO->copy<TrackCollection>(elements, m_inputTrackLocation);
00220 message = stat? "Found Tracks in TES":"No Tracks found in TES";
00221 log<<MSG::DEBUG << message <<" "<<elements.size()<<endreq;
00222 }
00223
00224
00225
00226
00227 IClusterCollection* clusters = new IClusterCollection ;
00228 IKinematicVector unusedLocalElements;
00229
00230 log << MSG::DEBUG << "Starting Clustering Strategy" << endreq ;
00231
00232 m_clusterStrategy->makeClusters(
00233 log,
00234 elements,
00235 unusedLocalElements,
00236 clusters
00237 ) ;
00238
00239
00240
00241
00242 log<<MSG::DEBUG
00243 <<"Number Of Unused Local Elements "
00244 << unusedLocalElements.size()<<endreq;
00245
00246 TypeVisitor types = ContainerDispatcher(
00247 unusedLocalElements.begin(),
00248 unusedLocalElements.end(),
00249 TypeVisitor()
00250 );
00251
00252
00253
00254
00255 stat = m_tesIO -> store(clusters, m_outputLocation);
00256 message = stat ? "Clusters stored":"Failed to store Clusters ";
00257 log<<MSG::DEBUG<<message<<endreq;
00258
00259 stat = m_tesIO -> store(new TwoCptCellVector(types.typeVector(TwoCptCell())),
00260 m_unusedCellLocation);
00261 message =stat? "unused cells stored":"unused cells store failed";
00262 log<<MSG::DEBUG<<message<<endreq;
00263
00264
00265 stat = m_tesIO -> store(new TrackVector(types.typeVector(Track())),
00266 m_unusedTrackLocation);
00267 message =stat? "unused tracks stored":"unused cells store failed";
00268 log<<MSG::DEBUG<<message<<endreq;
00269
00270 return stat ;
00271
00272 }
00273
00274 }
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288