test
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 
30 
32 {
33  // use configuration file to setup input/output collection names
34  //inputs
35  emObjectProducer_ = conf_.getParameter<edm::InputTag>("emObjectProducer");
36  ecalBarrelRecHitProducer_ = conf_.getParameter<edm::InputTag>("ecalBarrelRecHitProducer");
37  ecalBarrelRecHitCollection_ = conf_.getParameter<edm::InputTag>("ecalBarrelRecHitCollection");
38  ecalEndcapRecHitProducer_ = conf_.getParameter<edm::InputTag>("ecalEndcapRecHitProducer");
39  ecalEndcapRecHitCollection_ = conf_.getParameter<edm::InputTag>("ecalEndcapRecHitCollection");
40 
41  //vetos
42  egIsoPtMinBarrel_ = conf_.getParameter<double>("etMinBarrel");
43  egIsoEMinBarrel_ = conf_.getParameter<double>("eMinBarrel");
44  egIsoPtMinEndcap_ = conf_.getParameter<double>("etMinEndcap");
45  egIsoEMinEndcap_ = conf_.getParameter<double>("eMinEndcap");
46  egIsoConeSizeInBarrel_ = conf_.getParameter<double>("intRadiusBarrel");
47  egIsoConeSizeInEndcap_ = conf_.getParameter<double>("intRadiusEndcap");
48  egIsoConeSizeOut_ = conf_.getParameter<double>("extRadius");
49  egIsoJurassicWidth_ = conf_.getParameter<double>("jurassicWidth");
50 
51 
52 
53  // options
54  useIsolEt_ = conf_.getParameter<bool>("useIsolEt");
55  tryBoth_ = conf_.getParameter<bool>("tryBoth");
56  subtract_ = conf_.getParameter<bool>("subtract");
57  useNumCrystals_ = conf_.getParameter<bool>("useNumCrystals");
58  vetoClustered_ = conf_.getParameter<bool>("vetoClustered");
59 
60  //register your products
61  produces < edm::ValueMap<double> >();
62 }
63 
64 
66 
67 
68 //
69 // member functions
70 //
71 
72 // ------------ method called to produce the data ------------
73 void
75 {
76 
77 
78  // Get the filtered objects
80  iEvent.getByLabel(emObjectProducer_,emObjectHandle);
81 
82  // Next get Ecal hits barrel
83  edm::Handle<EcalRecHitCollection> ecalBarrelRecHitHandle; //EcalRecHitCollection is a typedef to
85 
86  // Next get Ecal hits endcap
87  edm::Handle<EcalRecHitCollection> ecalEndcapRecHitHandle;
89 
91  iSetup.get<EcalSeverityLevelAlgoRcd>().get(sevlv);
92  const EcalSeverityLevelAlgo* sevLevel = sevlv.product();
93 
94  //Get Calo Geometry
96  iSetup.get<CaloGeometryRecord>().get(pG);
97  const CaloGeometry* caloGeom = pG.product();
98 
99  //reco::CandViewDoubleAssociations* isoMap = new reco::CandViewDoubleAssociations( reco::CandidateBaseRefProd( emObjectHandle ) );
100  std::auto_ptr<edm::ValueMap<double> > isoMap(new edm::ValueMap<double>());
101  edm::ValueMap<double>::Filler filler(*isoMap);
102  std::vector<double> retV(emObjectHandle->size(),0);
103 
105  ecalBarrelIsol.setUseNumCrystals(useNumCrystals_);
106  ecalBarrelIsol.setVetoClustered(vetoClustered_);
107 
109  ecalEndcapIsol.setUseNumCrystals(useNumCrystals_);
110  ecalEndcapIsol.setVetoClustered(vetoClustered_);
111 
112 
113  for( size_t i = 0 ; i < emObjectHandle->size(); ++i) {
114 
115  //i need to know if its in the barrel/endcap so I get the supercluster handle to find out the detector eta
116  //this might not be the best way, are we guaranteed that eta<1.5 is barrel
117  //this can be safely replaced by another method which determines where the emobject is
118  //then we either get the isolation Et or isolation Energy depending on user selection
119  double isoValue =0.;
120 
121  reco::SuperClusterRef superClus = emObjectHandle->at(i).get<reco::SuperClusterRef>();
122 
123  if(tryBoth_){ //barrel + endcap
124  if(useIsolEt_) isoValue = ecalBarrelIsol.getEtSum(&(emObjectHandle->at(i))) + ecalEndcapIsol.getEtSum(&(emObjectHandle->at(i)));
125  else isoValue = ecalBarrelIsol.getEnergySum(&(emObjectHandle->at(i))) + ecalEndcapIsol.getEnergySum(&(emObjectHandle->at(i)));
126  }
127  else if( fabs(superClus->eta())<1.479) { //barrel
128  if(useIsolEt_) isoValue = ecalBarrelIsol.getEtSum(&(emObjectHandle->at(i)));
129  else isoValue = ecalBarrelIsol.getEnergySum(&(emObjectHandle->at(i)));
130  }
131  else{ //endcap
132  if(useIsolEt_) isoValue = ecalEndcapIsol.getEtSum(&(emObjectHandle->at(i)));
133  else isoValue = ecalEndcapIsol.getEnergySum(&(emObjectHandle->at(i)));
134  }
135 
136  //we subtract off the electron energy here as well
137  double subtractVal=0;
138 
139  if(useIsolEt_) subtractVal = superClus.get()->rawEnergy()*sin(2*atan(exp(-superClus.get()->eta())));
140  else subtractVal = superClus.get()->rawEnergy();
141 
142  if(subtract_) isoValue-= subtractVal;
143 
144  retV[i]=isoValue;
145  //all done, isolation is now in the map
146 
147  }//end of loop over em objects
148 
149  filler.insert(emObjectHandle,retV.begin(),retV.end());
150  filler.fill();
151 
152  //std::auto_ptr<reco::CandViewDoubleAssociations> isolMap(isoMap);
153  iEvent.put(isoMap);
154 
155 }
156 
157 //define this as a plug-in
158 //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
EgammaEcalRecHitIsolationProducer(const edm::ParameterSet &)
double getEnergySum(const reco::Candidate *emObject) const
void setUseNumCrystals(bool b=true)
int iEvent
Definition: GenABIO.cc:230
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:244
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:418
const T & get() const
Definition: EventSetup.h:56
T const * product() const
Definition: ESHandle.h:86
std::string const & label() const
Definition: InputTag.h:36
virtual void produce(edm::Event &, const edm::EventSetup &)
void setVetoClustered(bool b=true)