CMS 3D CMS Logo

VisCaloTower.cc

Go to the documentation of this file.
00001 //<<<<<< INCLUDES                                                       >>>>>>
00002 
00003 #include "VisReco/Analyzer/interface/VisCaloTower.h"
00004 #include "VisReco/Analyzer/interface/IguanaService.h"
00005 #include "DataFormats/CaloTowers/interface/CaloTower.h"
00006 #include "DataFormats/CaloTowers/interface/CaloTowerCollection.h"
00007 #include "FWCore/Framework/interface/Event.h"
00008 #include "FWCore/Framework/interface/EventSetup.h"
00009 #include "FWCore/Framework/interface/ESHandle.h"
00010 #include "FWCore/Framework/interface/MakerMacros.h"
00011 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00012 #include "FWCore/ServiceRegistry/interface/Service.h"
00013 #include "FWCore/Utilities/interface/Exception.h"
00014 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
00015 #include "Geometry/CaloGeometry/interface/CaloCellGeometry.h"
00016 #include "Geometry/Records/interface/CaloGeometryRecord.h"
00017 #include "Iguana/Framework/interface/IgCollection.h"
00018 #include "Iguana/Utilities/classlib/utils/DebugAids.h"
00019 #include <iostream>
00020 #include <sstream>
00021 
00022 //<<<<<< PRIVATE DEFINES                                                >>>>>>
00023 //<<<<<< PRIVATE CONSTANTS                                              >>>>>>
00024 //<<<<<< PRIVATE TYPES                                                  >>>>>>
00025 //<<<<<< PRIVATE VARIABLE DEFINITIONS                                   >>>>>>
00026 //<<<<<< PUBLIC VARIABLE DEFINITIONS                                    >>>>>>
00027 //<<<<<< CLASS STRUCTURE INITIALIZATION                                 >>>>>>
00028 //<<<<<< PRIVATE FUNCTION DEFINITIONS                                   >>>>>>
00029 //<<<<<< PUBLIC FUNCTION DEFINITIONS                                    >>>>>>
00030 //<<<<<< MEMBER FUNCTION DEFINITIONS                                    >>>>>>
00031 
00032 using namespace edm::service;
00033 
00034 VisCaloTower::VisCaloTower (const edm::ParameterSet& iConfig)
00035     : inputTag_ (iConfig.getParameter<edm::InputTag>("visCaloTowerTag"))
00036 {}
00037 
00038 void
00039 VisCaloTower::analyze( const edm::Event& event, const edm::EventSetup& eventSetup)
00040 {
00041     edm::Service<IguanaService> config;
00042     if (! config.isAvailable ()) 
00043     {
00044         throw cms::Exception ("Configuration")
00045             << "VisCaloTower requires the IguanaService\n"
00046             "which is not present in the configuration file.\n"
00047             "You must add the service in the configuration file\n"
00048             "or remove the module that requires it";
00049     }
00050     
00051     edm::Handle<CaloTowerCollection> collection;
00052     event.getByLabel (inputTag_, collection);
00053 
00054     edm::ESHandle<CaloGeometry> geom;
00055     eventSetup.get<CaloGeometryRecord> ().get (geom);
00056 
00057     if (collection.isValid () && geom.isValid ())
00058     {       
00059         IgDataStorage *storage = config->storage ();
00060         IgCollection &caloTowers = storage->getCollection("CaloTowers_V1");
00061         IgProperty ET   = caloTowers.addProperty("et", 0.0);
00062         IgProperty ETA  = caloTowers.addProperty("eta", 0.0);
00063         IgProperty PHI  = caloTowers.addProperty("phi", 0.0);
00064         IgProperty IPHI = caloTowers.addProperty("iphi", 0.0);
00065         IgProperty HE   = caloTowers.addProperty("hadEnergy", 0.0);
00066         IgProperty EE   = caloTowers.addProperty("emEnergy", 0.0);
00067         IgProperty POS  = caloTowers.addProperty("pos", IgV3d());
00068         IgProperty FRONT_1 = caloTowers.addProperty("front_1", IgV3d());
00069         IgProperty FRONT_2 = caloTowers.addProperty("front_2", IgV3d());
00070         IgProperty FRONT_3 = caloTowers.addProperty("front_3", IgV3d());
00071         IgProperty FRONT_4 = caloTowers.addProperty("front_4", IgV3d());
00072         IgProperty BACK_1 = caloTowers.addProperty("back_1", IgV3d());
00073         IgProperty BACK_2 = caloTowers.addProperty("back_2", IgV3d());
00074         IgProperty BACK_3 = caloTowers.addProperty("back_3", IgV3d());
00075         IgProperty BACK_4 = caloTowers.addProperty("back_4", IgV3d());
00076 
00077         for (CaloTowerCollection::const_iterator it=collection->begin(), itEnd=collection->end(); it!=itEnd; ++it)
00078         {
00079             const CaloCellGeometry *cell = (*geom).getGeometry((*it).id());
00080 
00081             const CaloCellGeometry::CornersVec& corners = cell->getCorners();
00082             ASSERT(corners.size()==8);
00083 
00084             IgCollectionItem itower = caloTowers.create();
00085             itower[ET] = static_cast<double>((*it).et());
00086             itower[ETA] = static_cast<double>((*it).eta());
00087             itower[PHI] = static_cast<double>((*it).phi());
00088             itower[IPHI] = static_cast<double>((*it).iphi());
00089             itower[HE] = static_cast<double>((*it).hadEnergy());
00090             itower[EE] = static_cast<double>((*it).emEnergy());
00091             itower[FRONT_1] = IgV3d(static_cast<double>(corners[0].x()/100.0), static_cast<double>(corners[0].y()/100.0), static_cast<double>(corners[0].z()/100.0));
00092             itower[FRONT_2] = IgV3d(static_cast<double>(corners[1].x()/100.0), static_cast<double>(corners[1].y()/100.0), static_cast<double>(corners[1].z()/100.0));
00093             itower[FRONT_3] = IgV3d(static_cast<double>(corners[2].x()/100.0), static_cast<double>(corners[2].y()/100.0), static_cast<double>(corners[2].z()/100.0));
00094             itower[FRONT_4] = IgV3d(static_cast<double>(corners[3].x()/100.0), static_cast<double>(corners[3].y()/100.0), static_cast<double>(corners[3].z()/100.0));
00095             itower[BACK_1] = IgV3d(static_cast<double>(corners[4].x()/100.0), static_cast<double>(corners[4].y()/100.0), static_cast<double>(corners[4].z()/100.0));
00096             itower[BACK_2] = IgV3d(static_cast<double>(corners[5].x()/100.0), static_cast<double>(corners[5].y()/100.0), static_cast<double>(corners[5].z()/100.0));
00097             itower[BACK_3] = IgV3d(static_cast<double>(corners[6].x()/100.0), static_cast<double>(corners[6].y()/100.0), static_cast<double>(corners[6].z()/100.0));
00098             itower[BACK_4] = IgV3d(static_cast<double>(corners[7].x()/100.0), static_cast<double>(corners[7].y()/100.0), static_cast<double>(corners[7].z()/100.0));
00099         }
00100     }
00101     else 
00102     {
00103         // friendlyName:moduleLabel:instanceName:processName
00104         std::string error = "### Error: CaloTowers "
00105                             + edm::TypeID (typeid (CaloTowerCollection)).friendlyClassName () + ":" 
00106                             + inputTag_.label() + ":"
00107                             + inputTag_.instance() + ":" 
00108                             + inputTag_.process() + " are not found.";
00109 
00110         IgDataStorage *storage = config->storage ();
00111         IgCollection &collection = storage->getCollection ("Errors_V1");
00112         IgProperty ERROR_MSG = collection.addProperty ("Error", std::string ());
00113         IgCollectionItem item = collection.create ();
00114         item [ERROR_MSG] = error;
00115     }
00116 }
00117 
00118 DEFINE_FWK_MODULE(VisCaloTower);

Generated on Tue Jun 9 17:50:07 2009 for CMSSW by  doxygen 1.5.4