CMS 3D CMS Logo

VisPFRecHit Class Reference

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

Inheritance diagram for VisPFRecHit:

edm::EDAnalyzer

List of all members.

Public Member Functions

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

Private Attributes

edm::InputTag inputTag_


Detailed Description

Definition at line 8 of file VisPFRecHit.h.


Constructor & Destructor Documentation

VisPFRecHit::VisPFRecHit ( const edm::ParameterSet iConfig  ) 

Definition at line 22 of file VisPFRecHit.cc.

00023     : inputTag_ (iConfig.getParameter<edm::InputTag>("visPFRecHitTag"))
00024 {}

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

Definition at line 12 of file VisPFRecHit.h.

00013         {}


Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 26 of file VisPFRecHit.cc.

References IgCollection::addProperty(), IgAssociationSet::associate(), collection, edmplugin::standard::config(), IgCollection::create(), PFLayer::ECAL_BARREL, PFLayer::ECAL_ENDCAP, relval_parameters_module::energy, error, ETA, eta, 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, PHI, phi, edm::InputTag::process(), and EZArrayFL< T >::size().

00027 {
00028     edm::Service<IguanaService> config;
00029     
00030     if ( ! config.isAvailable() ) 
00031     {
00032         throw cms::Exception("Configuration")
00033             << "VisPFRecHit requires the IguanaService\n"
00034             "which is not present in the configuration file.\n"
00035             "You must add the service in the configuration file\n"
00036             "or remove the module that requires it";
00037     }
00038     
00039     edm::Handle<reco::PFRecHitCollection> collection;
00040     event.getByLabel(inputTag_, collection);
00041 
00042     edm::ESHandle<CaloGeometry> caloGeometry;
00043     eventSetup.get<CaloGeometryRecord>().get(caloGeometry);
00044 
00045     if ( collection.isValid() && caloGeometry.isValid() )
00046     {
00047         IgDataStorage *storage = config->storage();
00048         
00049         IgCollection& rechits = storage->getCollection("PFRecHits_V1");
00050 
00051         IgProperty ID = rechits.addProperty("id", 0);
00052         IgProperty NAME = rechits.addProperty("name", std::string());
00053 
00054         IgProperty E = rechits.addProperty("energy", 0.0); 
00055         IgProperty ETA = rechits.addProperty("eta", 0.0);
00056         IgProperty PHI = rechits.addProperty("phi", 0.0);
00057 
00058         IgProperty LAYER = rechits.addProperty("layer", std::string());
00059 
00060         IgCollection& corners = storage->getCollection("Corners_V1");
00061 
00062         IgProperty F1 = corners.addProperty("front1", IgV3d());
00063         IgProperty F2 = corners.addProperty("front2", IgV3d());
00064         IgProperty F3 = corners.addProperty("front3", IgV3d());
00065         IgProperty F4 = corners.addProperty("front4", IgV3d());
00066         
00067         IgProperty B1 = corners.addProperty("back1", IgV3d());
00068         IgProperty B2 = corners.addProperty("back2", IgV3d());
00069         IgProperty B3 = corners.addProperty("back3", IgV3d());
00070         IgProperty B4 = corners.addProperty("back4", IgV3d());
00071 
00072         IgAssociationSet& recHitCorners = storage->getAssociationSet("PFRecHitCorners_V1");
00073 
00074         unsigned int i = 0;
00075 
00076         for ( std::vector<reco::PFRecHit>::const_iterator rechit = collection->begin();
00077                  rechit != collection->end(); ++rechit, ++i )
00078             {
00079                 IgCollectionItem rh = rechits.create();
00080 
00081                 rh[ID] = i;
00082                 rh["name"] = std::string("PFRecHit");
00083 
00084                 if ( (*rechit).layer() == PFLayer::ECAL_BARREL )
00085                     rh[LAYER] = std::string("EB");
00086                 
00087                 else if ( (*rechit).layer() == PFLayer::ECAL_ENDCAP )
00088                     rh[LAYER] = std::string("EE");
00089 
00090                 // NOTE: Add HCAL support. Is there still the detector ID problem in PF with HCAL?
00091 
00092                 else
00093                     rh[LAYER] = std::string("UNDEFINED");
00094                    
00095                 double energy = (*rechit).energy();
00096                 rh["energy"] = energy;
00097 
00098                 double eta = (*rechit).position().Eta();
00099                 double phi = (*rechit).position().Phi();
00100 
00101                 rh[ETA] = eta;
00102                 rh[PHI] = phi;
00103                 
00104                 // NOTE: Which corners are which depends on whether it's ECAL or HCAL.
00105                 // Fix this later.
00106 
00107                 double f1x, f1y, f1z;
00108                 double f2x, f2y, f2z;
00109                 double f3x, f3y, f3z;
00110                 double f4x, f4y, f4z;
00111                 
00112                 double b1x, b1y, b1z;
00113                 double b2x, b2y, b2z;
00114                 double b3x, b3y, b3z;
00115                 double b4x, b4y, b4z;
00116                 
00117                 const CaloCellGeometry::CornersVec& cornerPoints 
00118                     = (*caloGeometry).getGeometry((*rechit).detId())->getCorners();
00119                 
00120                 assert(cornerPoints.size() == 8);
00121                 
00122                 IgCollectionItem cr = corners.create();
00123 
00124                 f1x = cornerPoints[3].x()/100.0;
00125                 f1y = cornerPoints[3].y()/100.0;
00126                 f1z = cornerPoints[3].z()/100.0;
00127 
00128                 cr[F1] = IgV3d(f1x, f1y, f1z);
00129                 
00130                 f2x = cornerPoints[2].x()/100.0;
00131                 f2y = cornerPoints[2].y()/100.0;
00132                 f2z = cornerPoints[2].z()/100.0;
00133 
00134                 cr[F2] = IgV3d(f2x, f2y, f2z);
00135 
00136                 f3x = cornerPoints[1].x()/100.0;
00137                 f3y = cornerPoints[1].y()/100.0;
00138                 f3z = cornerPoints[1].z()/100.0;
00139 
00140                 cr[F3] = IgV3d(f3x, f3y, f3z);
00141 
00142                 f4x = cornerPoints[0].x()/100.0;
00143                 f4y = cornerPoints[0].y()/100.0;
00144                 f4z = cornerPoints[0].z()/100.0;
00145 
00146                 cr[F4] = IgV3d(f4x, f4y, f4z);
00147 
00148                 b1x = cornerPoints[7].x()/100.0;
00149                 b1y = cornerPoints[7].y()/100.0;
00150                 b1z = cornerPoints[7].z()/100.0;
00151 
00152                 cr["back1"] = IgV3d(b1x, b1y, b1z);
00153 
00154                 b2x = cornerPoints[6].x()/100.0;
00155                 b2y = cornerPoints[6].y()/100.0;
00156                 b2z = cornerPoints[6].z()/100.0;
00157 
00158                 cr["back2"] = IgV3d(b2x, b2y, b2z);
00159 
00160                 b3x = cornerPoints[5].x()/100.0;
00161                 b3y = cornerPoints[5].y()/100.0;
00162                 b3z = cornerPoints[5].z()/100.0;
00163 
00164                 cr["back3"] = IgV3d(b3x, b3y, b3z);
00165 
00166                 b4x = cornerPoints[4].x()/100.0;
00167                 b4y = cornerPoints[4].y()/100.0;
00168                 b4z = cornerPoints[4].z()/100.0;
00169 
00170                 cr["back4"] = IgV3d(b4x, b4y, b4z);
00171 
00172                 recHitCorners.associate(rh, cr);
00173             }    
00174         }
00175     
00176     else 
00177     {
00178         //std::cout<<"Collection not valid. No PFRecHits?!"<<std::endl;
00179         
00180         // friendlyName:moduleLabel:instanceName:processName
00181         std::string error = "### Error: PFRecHits "
00182                             + edm::TypeID (typeid (reco::PFRecHitCollection)).friendlyClassName() + ":" 
00183                             + inputTag_.label() + ":"
00184                             + inputTag_.instance() + ":" 
00185                             + inputTag_.process() + " are not found.";
00186 
00187         IgDataStorage *storage = config->storage();
00188         IgCollection &collection = storage->getCollection("Errors_V1");
00189         IgProperty errorMsg = collection.addProperty("Error", std::string());
00190         IgCollectionItem item = collection.create();
00191         item ["Error"] = error;
00192     }
00193 }


Member Data Documentation

edm::InputTag VisPFRecHit::inputTag_ [private]

Definition at line 18 of file VisPFRecHit.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