00001
00002
00003 #include "VisReco/Analyzer/interface/VisJet.h"
00004 #include "VisReco/Analyzer/interface/IguanaService.h"
00005 #include "DataFormats/JetReco/interface/CaloJet.h"
00006 #include "DataFormats/JetReco/interface/CaloJetCollection.h"
00007 #include "FWCore/Framework/interface/Event.h"
00008 #include "FWCore/Framework/interface/EventSetup.h"
00009 #include "FWCore/Framework/interface/MakerMacros.h"
00010 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00011 #include "FWCore/ServiceRegistry/interface/Service.h"
00012 #include "FWCore/Utilities/interface/Exception.h"
00013 #include "Iguana/Framework/interface/IgCollection.h"
00014 #include <iostream>
00015 #include <sstream>
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 using namespace edm::service;
00028
00029 VisJet::VisJet (const edm::ParameterSet& iConfig)
00030 : inputTag_ (iConfig.getParameter<edm::InputTag>("visJetTag")),
00031 energyCut_(iConfig.getUntrackedParameter<double>("energyCut", 0.1))
00032 {}
00033
00034 void
00035 VisJet::analyze( const edm::Event& event, const edm::EventSetup& eventSetup)
00036 {
00037 edm::Service<IguanaService> config;
00038 if (! config.isAvailable ())
00039 {
00040 throw cms::Exception ("Configuration")
00041 << "VisJet requires the IguanaService\n"
00042 "which is not present in the configuration file.\n"
00043 "You must add the service in the configuration file\n"
00044 "or remove the module that requires it";
00045 }
00046
00047 edm::Handle<reco::CaloJetCollection> collection;
00048 event.getByLabel (inputTag_, collection);
00049
00050 std::vector<edm::Handle<CaloTowerCollection> > towerCollections;
00051 event.getManyByType (towerCollections);
00052
00053 if (collection.isValid ())
00054 {
00055 IgDataStorage *storage = config->storage ();
00056 IgCollection &jets = storage->getCollection ("Jets_V1");
00057
00058 IgProperty ET = jets.addProperty ("et", 0.0);
00059 IgProperty ETA = jets.addProperty ("eta", 0.0);
00060 IgProperty THETA = jets.addProperty ("theta", 0.0);
00061 IgProperty PHI = jets.addProperty ("phi", 0.0);
00062
00063 for (reco::CaloJetCollection::const_iterator it = collection->begin (), itEnd = collection->end (); it != itEnd; ++it)
00064 {
00065 IgCollectionItem ijet = jets.create ();
00066 ijet[ET] = static_cast<double>((*it).et ());
00067 ijet[ETA] = static_cast<double>((*it).eta ());
00068 ijet[THETA] = static_cast<double>(2.0 * atan (exp (-(*it).eta ())));
00069 ijet[PHI] = static_cast<double>((*it).phi());
00070 }
00071 }
00072 else
00073 {
00074
00075 std::string error = "### Error: Jets "
00076 + edm::TypeID (typeid (reco::CaloJetCollection)).friendlyClassName () + ":"
00077 + inputTag_.label() + ":"
00078 + inputTag_.instance() + ":"
00079 + inputTag_.process() + " are not found.";
00080
00081 IgDataStorage *storage = config->storage ();
00082 IgCollection &collection = storage->getCollection ("Errors_V1");
00083 IgProperty ERROR_MSG = collection.addProperty ("Error", std::string ());
00084 IgCollectionItem item = collection.create ();
00085 item [ERROR_MSG] = error;
00086 }
00087 }
00088
00089 DEFINE_FWK_MODULE(VisJet);