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/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 //#include "AtlfastUtils/CollectionCloner.h"
00029 
00030 #include <cmath> 
00031 #include <algorithm>
00032 #include <vector>
00033 
00034 // Gaudi includes
00035 #include "GaudiKernel/DataSvc.h"
00036 #include "StoreGate/DataHandle.h"
00037 #include "GaudiKernel/ISvcLocator.h"
00038 #include "GaudiKernel/MsgStream.h"
00039 
00040 //Other
00041 #include "CLHEP/Vector/LorentzVector.h"
00042 
00043 namespace Atlfast {
00044   //--------------------------------
00045   // Constructors and destructors
00046   //--------------------------------
00047   
00048   ClusterMaker::ClusterMaker
00049   ( const std::string& name, ISvcLocator* pSvcLocator ) 
00050     : Algorithm( name, pSvcLocator ){
00051     
00052     // Setting the parameter defaults.
00053     m_rConeBarrel         = 0.401; //+.001 avoids grid problem
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     // Declare the paramemters to Gaudi so that
00067     // they can be over-written via the job options file
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   // Destructor
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   // initialise() 
00098   //---------------------------------
00099   
00100   StatusCode ClusterMaker::initialize(){
00101  
00102    MsgStream log( messageService(), name() ) ;
00103    log << MSG::DEBUG<< "Cluster Maker initialising " << endreq;
00104  
00105 
00106    //    m_tesIO = new TesIO( eventDataService() );
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   // finalise() 
00162   //---------------------------------
00163   
00164   StatusCode ClusterMaker::finalize(){
00165     return StatusCode::SUCCESS ;
00166   }
00167   
00168 
00169   //----------------------------------------------
00170   // execute() method called once per event
00171   //----------------------------------------------
00172   //
00173   // This execute method is written to take care of the administration
00174   // only (accessing TES, etc).
00175   //
00176   // The actual clustering strategy is delegated to a further method
00177   // (to become an object at some point)
00178   //
00179   // All Clusters created are output to the TES
00180   
00181   StatusCode ClusterMaker::execute( ){
00182     MsgStream log( messageService(), name() ) ;
00183     std::string message;
00184     //.........................................................
00185     // Extract the elements (cells, tracks..) from the TES 
00186     //
00187     //copy to vector -cannot use DataVector fo r type change!
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     // Make a containers to store the new Cluster pointers,
00204     // and unused elements
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     // Set up for conversions of unused IKinematics back to concrete types
00220     //
00221     AssocTypeConverter<std::vector<IKinematic*> > atr(unusedLocalElements);
00222     log<<MSG::DEBUG<<"Number Of Unused Local Elements "<< unusedLocalElements.size()<<endreq;
00223 
00224     //Register the newly made clusters
00225     stat = m_tesIO -> store(clusters, m_outputLocation);
00226     message = stat ?  "Clusters stored":"Failed to store Clusters ";
00227     log<<MSG::DEBUG<<message<<endreq;
00228     //  Register the any unused IKs if they are Cells
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     //log<<MSG::DEBUG<<"Number Of Unused Cells "<< atr.cells()->size()<<endreq;
00233     //  Register the any unused IKs if they are Tracks
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     //log<<MSG::DEBUG<<"Number Of Unused Tracks "<< atr.tracks()->size()<<endreq;
00238     return stat ;
00239     
00240   }
00241   
00242 } // end of namespace bracket
00243 
00244 
00245 
00246 
00247 
00248 
00249 
00250 
00251 
00252 
00253 
00254 
00255 
00256 

Generated on Tue Mar 18 11:18:23 2003 for AtlfastAlgs by doxygen1.3-rc1