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  //create the meta hit collections inorder that we can pass them into the isolation objects
94 
95  EcalRecHitMetaCollection ecalBarrelHits(*ecalBarrelRecHitHandle);
96  EcalRecHitMetaCollection ecalEndcapHits(*ecalEndcapRecHitHandle);
97 
98  //Get Calo Geometry
100  iSetup.get<CaloGeometryRecord>().get(pG);
101  const CaloGeometry* caloGeom = pG.product();
102 
103  //reco::CandViewDoubleAssociations* isoMap = new reco::CandViewDoubleAssociations( reco::CandidateBaseRefProd( emObjectHandle ) );
104  std::auto_ptr<edm::ValueMap<double> > isoMap(new edm::ValueMap<double>());
105  edm::ValueMap<double>::Filler filler(*isoMap);
106  std::vector<double> retV(emObjectHandle->size(),0);
107 
109  ecalBarrelIsol.setUseNumCrystals(useNumCrystals_);
110  ecalBarrelIsol.setVetoClustered(vetoClustered_);
111 
113  ecalEndcapIsol.setUseNumCrystals(useNumCrystals_);
114  ecalEndcapIsol.setVetoClustered(vetoClustered_);
115 
116 
117  for( size_t i = 0 ; i < emObjectHandle->size(); ++i) {
118 
119  //i need to know if its in the barrel/endcap so I get the supercluster handle to find out the detector eta
120  //this might not be the best way, are we guaranteed that eta<1.5 is barrel
121  //this can be safely replaced by another method which determines where the emobject is
122  //then we either get the isolation Et or isolation Energy depending on user selection
123  double isoValue =0.;
124 
125  reco::SuperClusterRef superClus = emObjectHandle->at(i).get<reco::SuperClusterRef>();
126 
127  if(tryBoth_){ //barrel + endcap
128  if(useIsolEt_) isoValue = ecalBarrelIsol.getEtSum(&(emObjectHandle->at(i))) + ecalEndcapIsol.getEtSum(&(emObjectHandle->at(i)));
129  else isoValue = ecalBarrelIsol.getEnergySum(&(emObjectHandle->at(i))) + ecalEndcapIsol.getEnergySum(&(emObjectHandle->at(i)));
130  }
131  else if( fabs(superClus->eta())<1.479) { //barrel
132  if(useIsolEt_) isoValue = ecalBarrelIsol.getEtSum(&(emObjectHandle->at(i)));
133  else isoValue = ecalBarrelIsol.getEnergySum(&(emObjectHandle->at(i)));
134  }
135  else{ //endcap
136  if(useIsolEt_) isoValue = ecalEndcapIsol.getEtSum(&(emObjectHandle->at(i)));
137  else isoValue = ecalEndcapIsol.getEnergySum(&(emObjectHandle->at(i)));
138  }
139 
140  //we subtract off the electron energy here as well
141  double subtractVal=0;
142 
143  if(useIsolEt_) subtractVal = superClus.get()->rawEnergy()*sin(2*atan(exp(-superClus.get()->eta())));
144  else subtractVal = superClus.get()->rawEnergy();
145 
146  if(subtract_) isoValue-= subtractVal;
147 
148  retV[i]=isoValue;
149  //all done, isolation is now in the map
150 
151  }//end of loop over em objects
152 
153  filler.insert(emObjectHandle,retV.begin(),retV.end());
154  filler.fill();
155 
156  //std::auto_ptr<reco::CandViewDoubleAssociations> isolMap(isoMap);
157  iEvent.put(isoMap);
158 
159 }
160 
161 //define this as a plug-in
162 //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:53
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:85
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
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)
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:242