CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EgammaEcalRecHitIsolationProducer.cc
Go to the documentation of this file.
1 //*****************************************************************************
2 // File: EgammaEcalRecHitIsolationProducer.cc
3 // ----------------------------------------------------------------------------
4 // OrigAuth: Matthias Mozer
5 // Institute: IIHE-VUB
6 //=============================================================================
7 //*****************************************************************************
8 
9 
11 
12 // Framework
16 
22 
25 
27 
29 {
30  // use configuration file to setup input/output collection names
31  //inputs
32  emObjectProducer_ = conf_.getParameter<edm::InputTag>("emObjectProducer");
33  ecalBarrelRecHitProducer_ = conf_.getParameter<edm::InputTag>("ecalBarrelRecHitProducer");
34  ecalBarrelRecHitCollection_ = conf_.getParameter<edm::InputTag>("ecalBarrelRecHitCollection");
35  ecalEndcapRecHitProducer_ = conf_.getParameter<edm::InputTag>("ecalEndcapRecHitProducer");
36  ecalEndcapRecHitCollection_ = conf_.getParameter<edm::InputTag>("ecalEndcapRecHitCollection");
37 
38  //vetos
39  egIsoPtMinBarrel_ = conf_.getParameter<double>("etMinBarrel");
40  egIsoEMinBarrel_ = conf_.getParameter<double>("eMinBarrel");
41  egIsoPtMinEndcap_ = conf_.getParameter<double>("etMinEndcap");
42  egIsoEMinEndcap_ = conf_.getParameter<double>("eMinEndcap");
43  egIsoConeSizeInBarrel_ = conf_.getParameter<double>("intRadiusBarrel");
44  egIsoConeSizeInEndcap_ = conf_.getParameter<double>("intRadiusEndcap");
45  egIsoConeSizeOut_ = conf_.getParameter<double>("extRadius");
46  egIsoJurassicWidth_ = conf_.getParameter<double>("jurassicWidth");
47 
48 
49 
50  // options
51  useIsolEt_ = conf_.getParameter<bool>("useIsolEt");
52  tryBoth_ = conf_.getParameter<bool>("tryBoth");
53  subtract_ = conf_.getParameter<bool>("subtract");
54  useNumCrystals_ = conf_.getParameter<bool>("useNumCrystals");
55  vetoClustered_ = conf_.getParameter<bool>("vetoClustered");
56 
57  //register your products
58  produces < edm::ValueMap<double> >();
59 }
60 
61 
63 
64 
65 //
66 // member functions
67 //
68 
69 // ------------ method called to produce the data ------------
70 void
72 {
73 
74 
75  // Get the filtered objects
77  iEvent.getByLabel(emObjectProducer_,emObjectHandle);
78 
79  // Next get Ecal hits barrel
80  edm::Handle<EcalRecHitCollection> ecalBarrelRecHitHandle; //EcalRecHitCollection is a typedef to
82 
83  // Next get Ecal hits endcap
84  edm::Handle<EcalRecHitCollection> ecalEndcapRecHitHandle;
86 
87  //create the meta hit collections inorder that we can pass them into the isolation objects
88 
89  EcalRecHitMetaCollection ecalBarrelHits(*ecalBarrelRecHitHandle);
90  EcalRecHitMetaCollection ecalEndcapHits(*ecalEndcapRecHitHandle);
91 
92  //Get Calo Geometry
94  iSetup.get<CaloGeometryRecord>().get(pG);
95  const CaloGeometry* caloGeom = pG.product();
96 
97  //reco::CandViewDoubleAssociations* isoMap = new reco::CandViewDoubleAssociations( reco::CandidateBaseRefProd( emObjectHandle ) );
98  std::auto_ptr<edm::ValueMap<double> > isoMap(new edm::ValueMap<double>());
99  edm::ValueMap<double>::Filler filler(*isoMap);
100  std::vector<double> retV(emObjectHandle->size(),0);
101 
102 
104  ecalBarrelIsol.setUseNumCrystals(useNumCrystals_);
105  ecalBarrelIsol.setVetoClustered(vetoClustered_);
106 
108  ecalEndcapIsol.setUseNumCrystals(useNumCrystals_);
109  ecalEndcapIsol.setVetoClustered(vetoClustered_);
110 
111 
112  for( size_t i = 0 ; i < emObjectHandle->size(); ++i) {
113 
114  //i need to know if its in the barrel/endcap so I get the supercluster handle to find out the detector eta
115  //this might not be the best way, are we guaranteed that eta<1.5 is barrel
116  //this can be safely replaced by another method which determines where the emobject is
117  //then we either get the isolation Et or isolation Energy depending on user selection
118  double isoValue =0.;
119 
120  reco::SuperClusterRef superClus = emObjectHandle->at(i).get<reco::SuperClusterRef>();
121 
122  if(tryBoth_){ //barrel + endcap
123  if(useIsolEt_) isoValue = ecalBarrelIsol.getEtSum(&(emObjectHandle->at(i))) + ecalEndcapIsol.getEtSum(&(emObjectHandle->at(i)));
124  else isoValue = ecalBarrelIsol.getEnergySum(&(emObjectHandle->at(i))) + ecalEndcapIsol.getEnergySum(&(emObjectHandle->at(i)));
125  }
126  else if( fabs(superClus->eta())<1.479) { //barrel
127  if(useIsolEt_) isoValue = ecalBarrelIsol.getEtSum(&(emObjectHandle->at(i)));
128  else isoValue = ecalBarrelIsol.getEnergySum(&(emObjectHandle->at(i)));
129  }
130  else{ //endcap
131  if(useIsolEt_) isoValue = ecalEndcapIsol.getEtSum(&(emObjectHandle->at(i)));
132  else isoValue = ecalEndcapIsol.getEnergySum(&(emObjectHandle->at(i)));
133  }
134 
135  //we subtract off the electron energy here as well
136  double subtractVal=0;
137 
138  if(useIsolEt_) subtractVal = superClus.get()->rawEnergy()*sin(2*atan(exp(-superClus.get()->eta())));
139  else subtractVal = superClus.get()->rawEnergy();
140 
141  if(subtract_) isoValue-= subtractVal;
142 
143  retV[i]=isoValue;
144  //all done, isolation is now in the map
145 
146  }//end of loop over em objects
147 
148  filler.insert(emObjectHandle,retV.begin(),retV.end());
149  filler.fill();
150 
151  //std::auto_ptr<reco::CandViewDoubleAssociations> isolMap(isoMap);
152  iEvent.put(isoMap);
153 
154 }
155 
156 //define this as a plug-in
157 //DEFINE_FWK_MODULE(EgammaRecHitIsolation,Producer);
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
double getEtSum(const reco::Candidate *emObject) const
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
void insert(const H &h, I begin, I end)
Definition: ValueMap.h:52
Exp< T >::type exp(const T &t)
Definition: Exp.h:22
EgammaEcalRecHitIsolationProducer(const edm::ParameterSet &)
double getEnergySum(const reco::Candidate *emObject) const
void setUseNumCrystals(bool b=true)
int iEvent
Definition: GenABIO.cc:243
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:359
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
std::string const & label() const
Definition: InputTag.h:25
virtual void produce(edm::Event &, const edm::EventSetup &)
void setVetoClustered(bool b=true)
tuple config
Definition: cmsDriver.py:17
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:239