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

XANAClusters.cpp

Go to the documentation of this file.
00001 
00002 #include <Utilities/Configuration/interface/Architecture.h>
00003 
00004 #include <XANADOO/XANAUtilities/interface/XANAToolkit.h>
00005 #include <XANADOO/XANAClusters/interface/XANAEmCluster.h>
00006 #include <XANADOO/XANAClusters/interface/XANAHadCluster.h>
00007 #include <XANADOO/XANAClusters/interface/XANACaloRecHit.h>
00008 #include <XANADOO/XANAClusters/interface/XANACellID.h>
00009 
00010 #include <ElectronPhoton/EgammaClusters/interface/EgammaBasicCluster.h>
00011 #include <ElectronPhoton/EgammaClusters/interface/EgammaBasicDynamic.h>
00012 #include <ElectronPhoton/EgammaClusters/interface/EgammaBasicIsland.h>
00013 #include <ElectronPhoton/EgammaClusters/interface/EgammaBasicHybrid.h>
00014 #include <ElectronPhoton/EgammaClusters/interface/EGBLogPosCorr.h>
00015 #include <ElectronPhoton/ClusterTools/interface/IsoCalculator.h>
00016 #include <ElectronPhoton/EgammaAnalysis/interface/EgammaHAnalyzer.h>
00017 #include <ElectronPhoton/EgammaAnalysis/interface/EgammaAlgorithm.h>
00018 
00019 #include <Calorimetry/CaloRecHit/interface/CaloRecHit.h>
00020 
00021 #include <CARF/G3Event/interface/G3EventProxy.h>
00022 #include <CARF/Reco/interface/AutoRecCollection.h>
00023 
00024 #include <Utilities/Notification/interface/Observer.h>
00025 #include <Utilities/Notification/interface/PackageInitializer.h>
00026 #include <Utilities/UI/interface/SimpleConfigurable.h> 
00027 #include <Utilities/Notification/interface/Singleton.h>
00028 
00029 #include <vector>
00030 
00031 struct ClusterObserver : public Observer<G3EventProxy *> {
00032 
00033   int nbClusters_ ;
00034   double energySum_ ;
00035   SimpleConfigurable<bool> writeCaloRecHits_;
00036   SimpleConfigurable<bool> produceReference_;
00037   SimpleConfigurable<string> clusterizer_;
00038 
00039   ClusterObserver()
00040    : nbClusters_(0), energySum_(0)
00041    { 
00042     // initialize observer
00043     Observer<G3EventProxy *>::init() ;      
00044     
00045     // steering
00046     writeCaloRecHits_=SimpleConfigurable<bool>(false,"XANAClusters:ESDWithCaloRecHits");
00047     produceReference_=SimpleConfigurable<bool>(false,"XANAClusters:produceReference");
00048     clusterizer_=SimpleConfigurable<string>("EGBCluster","XANAClusters:Clusterizer");
00049    }
00050    
00051   ~ClusterObserver()
00052    {
00053     std::cout<<"[OVAL] number of clusters : "<<nbClusters_<<endl ;
00054     std::cout<<"[OVAL] mean energy : "<<energySum_/nbClusters_<<endl ;
00055    }
00056 
00057    
00058   void upDate( G3EventProxy * ev )
00059    { 
00060     
00061     if (!ev) return ;    
00062     
00063     RecCollection<EgammaBasicCluster> clusters ( RecQuery(clusterizer_.value()) );
00064     RecCollection<EgammaBasicCluster> ::const_iterator cluster ;
00065     
00066     // to produce reference
00067     if (produceReference_) {
00068       // BasicClusters
00069       for (cluster=clusters.begin(); cluster!=clusters.end(); cluster++)  
00070        {
00071         // remove double reconstruction in case of EGBCluster
00072         if (clusterizer_.value() == "EGBCluster") {
00073           // hybrid is algo>=100 and is used in barrel only
00074           // island is algo 1 and is used everywhere
00075           if ( (cluster->whichAlgo()>99 && fabs(cluster->eta())>1.4791) || 
00076              (cluster->whichAlgo()<99 && fabs(cluster->eta())<1.4791) ) continue;
00077         }
00078         nbClusters_++ ;
00079         energySum_ += cluster->energy() ;
00080         std::cout<<"[OVAL] new cluster with energy "<<cluster->energy()<<flush ;
00081         std::cout<<" and "<<cluster->numberOfDigis()<<" crystal(s)"<<endl ;
00082        }
00083        return ;
00084     } 
00085     
00086     // construct XANAEmClusters from BasicClusters
00087     vector<XANACluster> xclusters;
00088     XANACluster *xcluster;
00089     for (cluster=clusters.begin(); cluster!=clusters.end(); cluster++)  
00090      {
00091       // remove double reconstruction in case of EGBCluster
00092       if (clusterizer_.value() == "EGBCluster") {
00093         // hybrid is algo>=100 and is used in barrel only
00094         // island is algo 1 and is used everywhere
00095         if ( (cluster->whichAlgo()>99 && fabs(cluster->eta())>1.4791) || 
00096            (cluster->whichAlgo()<99 && fabs(cluster->eta())<1.4791) ) continue;
00097       }
00098       xana::out(2) << "[update] new cluster with energy " << cluster->energy() << " from algo " << cluster->whichAlgo() << std::endl;
00099       nbClusters_++ ;
00100       // for naming, stick to the RecAlgo names
00101       std::string name = "";
00102       if (cluster->whichAlgo() == 1) name="EGBCluster";
00103       else if (cluster->whichAlgo() == 2) name="EGBDynamicCluster";
00104       else if (cluster->whichAlgo() == 100) name="EGBCluster";
00105       xcluster = new XANAEmCluster(cluster->energy(), cluster->position(), cluster->chi2(), name); 
00106       if (writeCaloRecHits_) {
00107         std::vector<const CaloRecHit *> rhits=cluster->rHits();
00108         for (vector<const CaloRecHit *>::const_iterator
00109          it=rhits.begin(); it != rhits.end(); it++) {
00110           xcluster->addHit(new XANACaloRecHit((*it)->energy(), (*it)->time(),
00111           (*it)->chi2(), XANACellID((*it)->getMyCell().position())));
00112 //        (*it)->chi2(), new XANACellID((*it)->getMyCell().position())));
00113         } 
00114       } else 
00115         xcluster->setNumberOfRecHits(cluster->numberOfDigis());
00116       xclusters.push_back(*xcluster);
00117      }
00118      
00119     // read XANAEmClusters 
00120     vector<XANACluster>::iterator it;
00121     for (it=xclusters.begin(); it!=xclusters.end(); it++)  
00122      {
00123       std::cout<<"[OVAL] new cluster with energy "<<it->getEnergy()<<flush ;
00124       std::cout<<" and position "<<it->getPosition()<<endl ;
00125      }
00126    }
00127       
00128 } ;
00129  
00130 static PKBuilder<ClusterObserver> clusterObserver("ClusterObserver") ;
00131 
00132 

Generated on Tue May 10 10:01:24 2005 for XANADOO by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002