CMS 3D CMS Logo

VisPFCluster Class Reference

#include <VisReco/Analyzer/interface/VisPFCluster.h>

Inheritance diagram for VisPFCluster:

edm::EDAnalyzer

List of all members.

Public Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
 VisPFCluster (const edm::ParameterSet &)
virtual ~VisPFCluster ()

Private Attributes

edm::InputTag inputTag_


Detailed Description

Definition at line 8 of file VisPFCluster.h.


Constructor & Destructor Documentation

VisPFCluster::VisPFCluster ( const edm::ParameterSet iConfig  ) 

Definition at line 25 of file VisPFCluster.cc.

00026     : inputTag_ (iConfig.getParameter<edm::InputTag>("visPFClusterTag"))
00027 
00028 //: friendlyName_("recoPFClusters"),
00029 //    moduleLabel_("particleFlowClusterECAL"),
00030 //     instanceName_(""),
00031 //     processName_("Rec")
00032 {}

virtual VisPFCluster::~VisPFCluster (  )  [inline, virtual]

Definition at line 12 of file VisPFCluster.h.

00013         {}


Member Function Documentation

void VisPFCluster::analyze ( const edm::Event event,
const edm::EventSetup eventSetup 
) [virtual]

Implements edm::EDAnalyzer.

Definition at line 35 of file VisPFCluster.cc.

References IgCollection::addProperty(), IgAssociationSet::associate(), collection, edmplugin::standard::config(), IgCollection::create(), PFLayer::ECAL_BARREL, PFLayer::ECAL_ENDCAP, relval_parameters_module::energy, error, Exception, edm::EventSetup::get(), IgDataStorage::getAssociationSet(), IgDataStorage::getCollection(), i, inputTag_, edm::InputTag::instance(), edm::Service< T >::isAvailable(), edm::Handle< T >::isValid(), edm::ESHandle< T >::isValid(), edm::InputTag::label(), sistrip::LAYER, edm::InputTag::process(), and EZArrayFL< T >::size().

00036 {
00037     edm::Service<IguanaService> config;
00038     
00039     if ( ! config.isAvailable() ) 
00040     {
00041         throw cms::Exception("Configuration")
00042             << "VisPFCluster requires the IguanaService\n"
00043             "which is not present in the configuration file.\n"
00044             "You must add the service in the configuration file\n"
00045             "or remove the module that requires it";
00046     }
00047     
00048     edm::Handle<reco::PFClusterCollection> collection;
00049     event.getByLabel (inputTag_, collection);
00050 
00051     edm::ESHandle<CaloGeometry> caloGeometry;
00052     eventSetup.get<CaloGeometryRecord>().get(caloGeometry);
00053 
00054     if ( collection.isValid() && caloGeometry.isValid() )
00055     {       
00056         IgDataStorage *storage = config->storage();
00057 
00058         IgCollection& pfclusters = storage->getCollection("PFClusters_V1");
00059         
00060         IgProperty ID = pfclusters.addProperty("id", 0);
00061         IgProperty NAME = pfclusters.addProperty("name", std::string());
00062         
00063         IgCollection& rechits = storage->getCollection("PFRecHitFractions_V1");
00064         
00065         IgProperty E = rechits.addProperty("energy", 0.0); 
00066         IgProperty FRAC = rechits.addProperty("fraction", 0.0);
00067         IgProperty LAYER = rechits.addProperty("layer", std::string());
00068         
00069         // or just make the corners an item of the rechit?
00070         IgCollection& corners = storage->getCollection("Corners_V1");
00071 
00072         IgProperty F1 = corners.addProperty("front1", IgV3d());
00073         IgProperty F2 = corners.addProperty("front2", IgV3d());
00074         IgProperty F3 = corners.addProperty("front3", IgV3d());
00075         IgProperty F4 = corners.addProperty("front4", IgV3d());
00076         
00077         IgProperty B1 = corners.addProperty("back1", IgV3d());
00078         IgProperty B2 = corners.addProperty("back2", IgV3d());
00079         IgProperty B3 = corners.addProperty("back3", IgV3d());
00080         IgProperty B4 = corners.addProperty("back4", IgV3d());
00081         
00082         IgAssociationSet& clusterRecHits = storage->getAssociationSet("PFClusterPFRecHitFractions_V1");
00083         IgAssociationSet& recHitCorners = storage->getAssociationSet("PFRecHitFractionCorners_V1");
00084 
00085         unsigned int i = 0;
00086 
00087         //std::cout<<"There are "<< collection->size() <<" PFClusters"<<std::endl;
00088         
00089         for ( std::vector<reco::PFCluster>::const_iterator cluster = collection->begin(), clusterEnd = collection->end();
00090               cluster != clusterEnd; ++cluster, ++i )
00091         {
00092             //std::cout<<"PFCluster #"<< i++ <<std::endl;
00093 
00094             IgCollectionItem cl = pfclusters.create();
00095             cl[ID] = i;
00096             cl["name"] = std::string("PFCluster");
00097             
00098             std::vector<reco::PFRecHitFraction>::const_iterator iR;
00099 
00100             //std::cout<<"There are "<< (*cluster).recHitFractions().size() <<" RecHits"<<std::endl;
00101 
00102             for ( iR  = (*cluster).recHitFractions().begin();
00103                   iR != (*cluster).recHitFractions().end(); ++iR )
00104             {   
00105                 //std::cout<<"RecHit #"<< j++ <<std::endl;
00106                 IgCollectionItem rh = rechits.create();
00107    
00108                 double energy = (*iR).recHitRef()->energy();
00109                 
00110                 rh["energy"] = energy;
00111                 rh["fraction"] = (*iR).fraction();              
00112                 
00113                 if ( (*cluster).layer() == PFLayer::ECAL_BARREL )
00114                     rh[LAYER] = std::string("EB");
00115                          
00116                 else if ( (*cluster).layer() == PFLayer::ECAL_ENDCAP )
00117                     rh[LAYER] = std::string("EE");
00118                 
00119                 else
00120                     rh[LAYER] = std::string("UNDEFINED");
00121                   
00122                 clusterRecHits.associate(cl,rh);
00123                 
00124                 // NOTE: Which corners are which depends on whether it's ECAL or HCAL.
00125                 // Fix this later.
00126 
00127                 double f1x, f1y, f1z;
00128                 double f2x, f2y, f2z;
00129                 double f3x, f3y, f3z;
00130                 double f4x, f4y, f4z;
00131                 
00132                 double b1x, b1y, b1z;
00133                 double b2x, b2y, b2z;
00134                 double b3x, b3y, b3z;
00135                 double b4x, b4y, b4z;
00136                 
00137                 const CaloCellGeometry::CornersVec& cornerPoints 
00138                     = (*caloGeometry).getGeometry((*iR).recHitRef()->detId())->getCorners();
00139                 
00140                 assert(cornerPoints.size() == 8);
00141                 
00142                 IgCollectionItem cr = corners.create();
00143 
00144                 f1x = cornerPoints[3].x()/100.0;
00145                 f1y = cornerPoints[3].y()/100.0;
00146                 f1z = cornerPoints[3].z()/100.0;
00147 
00148                 cr[F1] = IgV3d(f1x, f1y, f1z);
00149                 
00150                 f2x = cornerPoints[2].x()/100.0;
00151                 f2y = cornerPoints[2].y()/100.0;
00152                 f2z = cornerPoints[2].z()/100.0;
00153 
00154                 cr[F2] = IgV3d(f2x, f2y, f2z);
00155 
00156                 f3x = cornerPoints[1].x()/100.0;
00157                 f3y = cornerPoints[1].y()/100.0;
00158                 f3z = cornerPoints[1].z()/100.0;
00159 
00160                 cr[F3] = IgV3d(f3x, f3y, f3z);
00161 
00162                 f4x = cornerPoints[0].x()/100.0;
00163                 f4y = cornerPoints[0].y()/100.0;
00164                 f4z = cornerPoints[0].z()/100.0;
00165 
00166                 cr[F4] = IgV3d(f4x, f4y, f4z);
00167 
00168                 b1x = cornerPoints[7].x()/100.0;
00169                 b1y = cornerPoints[7].y()/100.0;
00170                 b1z = cornerPoints[7].z()/100.0;
00171 
00172                 cr["back1"] = IgV3d(b1x, b1y, b1z);
00173 
00174                 b2x = cornerPoints[6].x()/100.0;
00175                 b2y = cornerPoints[6].y()/100.0;
00176                 b2z = cornerPoints[6].z()/100.0;
00177 
00178                 cr["back2"] = IgV3d(b2x, b2y, b2z);
00179 
00180                 b3x = cornerPoints[5].x()/100.0;
00181                 b3y = cornerPoints[5].y()/100.0;
00182                 b3z = cornerPoints[5].z()/100.0;
00183 
00184                 cr["back3"] = IgV3d(b3x, b3y, b3z);
00185 
00186                 b4x = cornerPoints[4].x()/100.0;
00187                 b4y = cornerPoints[4].y()/100.0;
00188                 b4z = cornerPoints[4].z()/100.0;
00189 
00190                 cr["back4"] = IgV3d(b4x, b4y, b4z);
00191 
00192                 recHitCorners.associate(rh, cr);
00193                 
00194                 /*
00195                 std::cout<<"F1: "<< f1x <<","<< f1y <<","<< f1z <<std::endl;
00196                 std::cout<<"F2: "<< f2x <<","<< f2y <<","<< f2z <<std::endl;
00197                 std::cout<<"F3: "<< f3x <<","<< f3y <<","<< f3z <<std::endl;
00198                 std::cout<<"F4: "<< f4x <<","<< f4y <<","<< f4z <<std::endl;
00199 
00200                 std::cout<<"B1: "<< b1x <<","<< b1y <<","<< b1z <<std::endl;
00201                 std::cout<<"B2: "<< b2x <<","<< b2y <<","<< b2z <<std::endl;
00202                 std::cout<<"B3: "<< b3x <<","<< b3y <<","<< b3z <<std::endl;
00203                 std::cout<<"B4: "<< b4x <<","<< b4y <<","<< b4z <<std::endl;
00204                 */
00205 
00206             } // Done iterating over RecHits
00207 
00208             //std::cout<<"Done iterating over recHitFractions"<<std::endl;
00209             
00210         } // Done iterating over PFClusters
00211     } // if collection is valid
00212     else 
00213     {
00214         //std::cout<<"Collection not valid. No PFClusters?!"<<std::endl;
00215         
00216         // friendlyName:moduleLabel:instanceName:processName
00217         std::string error = "### Error: PFClusters "
00218                             + edm::TypeID (typeid (reco::PFClusterCollection)).friendlyClassName () + ":" 
00219                             + inputTag_.label() + ":"
00220                             + inputTag_.instance() + ":" 
00221                             + inputTag_.process() + " are not found.";
00222 
00223         IgDataStorage *storage = config->storage ();
00224         IgCollection &collection = storage->getCollection ("Errors_V1");
00225         IgProperty errorMsg = collection.addProperty ("Error", std::string ());
00226         IgCollectionItem item = collection.create ();
00227         item ["Error"] = error;
00228     }
00229 }


Member Data Documentation

edm::InputTag VisPFCluster::inputTag_ [private]

Definition at line 18 of file VisPFCluster.h.

Referenced by analyze().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:35:34 2009 for CMSSW by  doxygen 1.5.4