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/TypeRecoverer.h"
00026 #include "AtlfastAlgs/ContainerDispatcher.h"
00027 #include "AtlfastEvent/TypeVisitor.h"
00028 
00029 #include <cmath> 
00030 #include <algorithm>
00031 #include <vector>
00032 
00033 // Gaudi includes
00034 #include "GaudiKernel/DataSvc.h"
00035 #include "GaudiKernel/ISvcLocator.h"
00036 #include "GaudiKernel/MsgStream.h"
00037 
00038 //Other
00039 #include "CLHEP/Vector/LorentzVector.h"
00040 
00041 namespace Atlfast {
00042   //--------------------------------
00043   // Constructors and destructors
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     // Setting the parameter defaults.
00054     m_rConeBarrel         = 0.401; //+.001 avoids grid problem
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     // Declare the paramemters to Gaudi so that
00073     // they can be over-written via the job options file
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   // Destructor
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   // initialise() 
00109   //---------------------------------
00110   
00111   StatusCode ClusterMaker::initialize(){
00112  
00113    MsgStream log( messageService(), name() ) ;
00114    log << MSG::DEBUG<< "Cluster Maker initialising " << endreq;
00115  
00116    //moved this before TesIO
00117    GlobalEventData* ged = GlobalEventData::Instance();
00118    m_mcLocation  = ged -> mcLocation();
00119 
00120    //    m_tesIO = new TesIO( eventDataService() );
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   // finalise() 
00183   //---------------------------------
00184   
00185   StatusCode ClusterMaker::finalize(){
00186     return StatusCode::SUCCESS ;
00187   }
00188   
00189 
00190   //----------------------------------------------
00191   // execute() method called once per event
00192   //----------------------------------------------
00193   //
00194   // This execute method is written to take care of the administration
00195   // only (accessing TES, etc).
00196   //
00197   // The actual clustering strategy is delegated to a further method
00198   // (to become an object at some point)
00199   //
00200   // All Clusters created are output to the TES
00201   
00202   StatusCode ClusterMaker::execute( ){
00203     MsgStream log( messageService(), name() ) ;
00204     std::string message;
00205     //.........................................................
00206     // Extract the elements (cells, tracks..) from the TES 
00207     //
00208     //copy to vector -cannot use DataVector fo r type change!
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     // Make a containers to store the new Cluster pointers,
00225     // and unused elements
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     // Set up for conversions of unused IKinematics back to concrete types
00241     //
00242     log<<MSG::DEBUG
00243        <<"Number Of Unused Local Elements "
00244        << unusedLocalElements.size()<<endreq;
00245     //    TypeRecoverer atr(unusedLocalElements);
00246     TypeVisitor types = ContainerDispatcher(
00247                                           unusedLocalElements.begin(),
00248                                           unusedLocalElements.end(),
00249                                           TypeVisitor()
00250                                           );
00251     //log<<MSG::DEBUG <<"Recovered Types "<<endreq;
00252 
00253 
00254     //Register the newly made clusters
00255     stat = m_tesIO -> store(clusters, m_outputLocation);
00256     message = stat ?  "Clusters stored":"Failed to store Clusters ";
00257     log<<MSG::DEBUG<<message<<endreq;
00258     //  Register the any unused IKs if they are Cells
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     //log<<MSG::DEBUG<<"Number Of Unused Cells "<< atr.cells()->size()<<endreq;
00264     //  Register the any unused IKs if they are Tracks
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     //log<<MSG::DEBUG<<"Number Of Unused Tracks "<< atr.tracks()->size()<<endreq;
00270     return stat ;
00271     
00272   }
00273   
00274 } // end of namespace bracket
00275 
00276 
00277 
00278 
00279 
00280 
00281 
00282 
00283 
00284 
00285 
00286 
00287 
00288 

Generated on Mon Sep 24 14:19:12 2007 for AtlfastAlgs by  doxygen 1.5.1