Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

ClusterMaker.cxx

Go to the documentation of this file.
00001 // ================================================
00002 //        ClusterMaker class Implementation
00003 //
00004 //  + PreCluster helper class
00005 //
00006 // ================================================
00007 //
00008 // Namespace Atlfast
00009 //
00010 
00011 // This package includes
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/Cluster.h"
00020 #include "AtlfastUtils/IClusterStrategy.h"
00021 #include "AtlfastUtils/TesIO.h"
00022 #include "AtlfastAlgs/GlobalEventData.h"
00023 #include "AtlfastUtils/AssocTypeRecoverer.h"
00024 #include "AtlfastUtils/CastAwayConst.h"
00025 
00026 #include <cmath> 
00027 #include <algorithm>
00028 #include <vector>
00029 
00030 // Gaudi includes
00031 #include "GaudiKernel/DataSvc.h"
00032 #include "StoreGate/DataHandle.h"
00033 #include "GaudiKernel/ISvcLocator.h"
00034 #include "GaudiKernel/MsgStream.h"
00035 
00036 //Other
00037 #include "CLHEP/Vector/LorentzVector.h"
00038 
00039 namespace Atlfast {
00040   //--------------------------------
00041   // Constructors and destructors
00042   //--------------------------------
00043   
00044   ClusterMaker::ClusterMaker
00045   ( const std::string& name, ISvcLocator* pSvcLocator ) 
00046     : Algorithm( name, pSvcLocator ){
00047     
00048     // Setting the parameter defaults.
00049     m_rConeBarrel         = 0.401; //+.001 avoids grid problem
00050     m_rConeForward        = 0.401;
00051     m_minInitiatorET      = 1.5;
00052     m_minClusterET        = 5.;
00053     m_processCells        = true;
00054     m_processTracks       = false;
00055     m_inputCellLocation   = "/Event/AtlfastCells" ;
00056     m_inputTrackLocation  = "/Event/AtlfastTracks" ;
00057     m_outputLocation      = "/Event/AtlfastClusters";
00058     m_unusedCellLocation  = "/Event/AtlfastUnusedCells";
00059     m_unusedTrackLocation = "/Event/AtlfastUnusedTracks";
00060     m_masslessJets        = true;
00061     m_strategy            = "Cone";
00062     // Declare the paramemters to Gaudi so that
00063     // they can be over-written via the job options file
00064     
00065     declareProperty( "RConeBarrel",         m_rConeBarrel ) ;
00066     declareProperty( "RConeForward",        m_rConeForward ) ;
00067     declareProperty( "minInitiatorET",      m_minInitiatorET ) ;
00068     declareProperty( "minClusterET",        m_minClusterET ) ;
00069     declareProperty( "Strategy",            m_strategy ) ;
00070     declareProperty( "ProcessCells",        m_processCells ) ;
00071     declareProperty( "ProcessTracks",       m_processTracks ) ;
00072     declareProperty( "InputCellLocation",   m_inputCellLocation ) ;
00073     declareProperty( "InputTrackLocation",  m_inputTrackLocation ) ;
00074     declareProperty( "OutputLocation",      m_outputLocation ) ;
00075     declareProperty( "UnusedCellLocation",  m_unusedCellLocation ) ;
00076     declareProperty( "UnusedTrackLocation", m_unusedTrackLocation ) ;
00077     declareProperty( "MasslessJets",        m_masslessJets ) ;
00078     
00079   }
00080 
00081   // Destructor
00082   ClusterMaker::~ClusterMaker() {
00083     if(m_tesIO){ 
00084       delete m_tesIO;
00085     }
00086     if(m_clusterStrategy){ 
00087       delete m_clusterStrategy;
00088     }
00089   } 
00090 
00091   
00092   //---------------------------------
00093   // initialise() 
00094   //---------------------------------
00095   
00096   StatusCode ClusterMaker::initialize(){
00097  
00098    MsgStream log( messageService(), name() ) ;
00099    log << MSG::DEBUG<< "Cluster Maker initialising " << endreq;
00100  
00101 
00102    //    m_tesIO = new TesIO( eventDataService() );
00103    m_tesIO = new TesIO();
00104     if(m_strategy == "Cone"){
00105       m_clusterStrategy = new ClusterConeStrategy(
00106                                                   m_rConeBarrel,   
00107                                                   m_rConeForward,
00108                                                   m_minInitiatorET,
00109                                                   m_minClusterET,
00110                                                   m_masslessJets);
00111 
00112     } else if(m_strategy == "Kt"){
00113       m_clusterStrategy = new ClusterKtStrategy(m_minClusterET);
00114     } else if(m_strategy == "Shared"){
00115       GlobalEventData* ged = GlobalEventData::Instance();
00116       double barrelForwardEta = ged -> barrelForwardEta();
00117       m_clusterStrategy = new SharedConeStrategy(m_rConeBarrel,   
00118                                                  m_rConeForward,
00119                                                  m_minInitiatorET,
00120                                                  m_minClusterET,
00121                                                  barrelForwardEta);
00122     }else{
00123       m_clusterStrategy = new ClusterConeStrategy(
00124                                                   m_rConeBarrel,   
00125                                                   m_rConeForward,
00126                                                   m_minInitiatorET,
00127                                                   m_minClusterET,
00128                                                   m_masslessJets);
00129       
00130       m_strategy = "Cone";
00131     }
00132 
00133     HeaderPrinter hp("Atlfast Cluster Maker:", log);
00134     hp.add("Endcap Cone Size            ", m_rConeForward);
00135     hp.add("Barrel Cone Size            ", m_rConeBarrel);
00136     hp.add("Min ET for Cell initiator   ", m_minInitiatorET);
00137     hp.add("Min ET for cluster          ", m_minClusterET);
00138     hp.add("Cluster Strategy            ", m_strategy);  
00139     hp.add("Process Cells               ", m_processCells);
00140     hp.add("Process Tracks              ", m_processTracks);
00141     if(m_processCells){
00142       hp.add("Input CellLocation          ", m_inputCellLocation);
00143     }
00144     if(m_processTracks) {
00145       hp.add("Input TrackLocation         ", m_inputTrackLocation);
00146     }
00147     hp.add("Output Location             ", m_outputLocation);    
00148     hp.add("Unused Cell Location        ", m_unusedCellLocation);    
00149     hp.add("Unused Track Location       ", m_unusedTrackLocation);    
00150     hp.add("Massless Jets               ", m_masslessJets);    
00151     hp.print();
00152 
00153     return StatusCode::SUCCESS ;
00154   }
00155   
00156   //---------------------------------
00157   // finalise() 
00158   //---------------------------------
00159   
00160   StatusCode ClusterMaker::finalize(){
00161     return StatusCode::SUCCESS ;
00162   }
00163   
00164 
00165   //----------------------------------------------
00166   // execute() method called once per event
00167   //----------------------------------------------
00168   //
00169   // This execute method is written to take care of the administration
00170   // only (accessing TES, etc).
00171   //
00172   // The actual clustering strategy is delegated to a further method
00173   // (to become an object at some point)
00174   //
00175   // All Clusters created are output to the TES
00176   
00177   StatusCode ClusterMaker::execute( ){
00178     MsgStream log( messageService(), name() ) ;
00179     std::string message;
00180     //.........................................................
00181     // Extract the elements (cells, tracks..) from the TES 
00182     //
00183     IKinematicCollection elements;
00184     TesIoStat stat;
00185     if(m_processCells){
00186       stat = m_tesIO->copy<CellCollection>(elements, m_inputCellLocation);
00187       message = stat?  "Found Cells in TES":"No Cells found in TES";
00188       log<<MSG::DEBUG << message <<" "<<elements.size()<<endreq;
00189     }
00190     if(m_processTracks){
00191       stat = m_tesIO->copy<TrackCollection>(elements, m_inputTrackLocation);
00192       message = stat?  "Found Tracks in TES":"No Tracks found in TES";
00193       log<<MSG::DEBUG << message <<" "<<elements.size()<<endreq;
00194     }
00195     
00196     // ......................
00197     // Make a containers to store the new Cluster pointers,
00198     // and unused elements
00199     
00200     ClusterCollection* clusters = new ClusterCollection ;
00201     IKinematicCollection unusedLocalElements;
00202 
00203     log << MSG::DEBUG << "Starting Clustering Strategy"  << endreq ;
00204     
00205     m_clusterStrategy->makeClusters( log, elements, unusedLocalElements, clusters) ;
00206     
00207     //......................................
00208     // Set up for conversions of unused IKinematics back to concrete types
00209     //
00210     AssocTypeRecoverer<IKinematicCollection> atr(unusedLocalElements);
00211 
00212     //Register the newly made clusters
00213     stat = m_tesIO -> store(clusters, m_outputLocation);
00214     message = stat ?  "Clusters stored":"Failed to store Clusters ";
00215     log<<MSG::DEBUG<<message<<endreq;
00216 
00217     //  Register the any unused IKs if they are Cells
00218     stat = m_tesIO -> store(atr.cells(), m_unusedCellLocation);
00219     message =stat? "unused cells stored":"unused cells store failed";
00220     log<<MSG::DEBUG<<message<<endreq;
00221     
00222     //  Register the any unused IKs if they are Tracks
00223     stat = m_tesIO -> store(atr.tracks(), m_unusedTrackLocation);
00224     message =stat? "unused tracks stored":"unused cells store failed";
00225     log<<MSG::DEBUG<<message<<endreq;
00226     
00227     return stat ;
00228     
00229   }
00230   
00231 } // end of namespace bracket
00232 
00233 
00234 
00235 
00236 
00237 
00238 
00239 
00240 
00241 
00242 
00243 
00244 
00245 

Generated on Tue Jan 28 09:57:12 2003 for AtlfastAlgs by doxygen1.3-rc1