CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
HGCalHitCalibration Class Reference
Inheritance diagram for HGCalHitCalibration:
edm::one::EDAnalyzer< edm::one::SharedResources > edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 HGCalHitCalibration (const edm::ParameterSet &)
 
 ~HGCalHitCalibration ()
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::SharedResources >
 EDAnalyzer ()=default
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDAnalyzerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &) override
 
virtual void beginJob () override
 
virtual void endJob () override
 

Private Attributes

edm::EDGetTokenT< std::vector< CaloParticle > > _caloParticles
 
edm::EDGetTokenT< HGCRecHitCollection_recHitsBH
 
edm::EDGetTokenT< HGCRecHitCollection_recHitsEE
 
edm::EDGetTokenT< HGCRecHitCollection_recHitsFH
 
int algo_
 
bool cutOnPt_
 
double cutValue_
 
std::vector< float > Energy_layer_calib
 
std::vector< float > Energy_layer_calib_fraction
 
TH1F * h_EoP_CPene_100_calib_fraction_ [6]
 
TH1F * h_EoP_CPene_200_calib_fraction_ [6]
 
TH1F * h_EoP_CPene_300_calib_fraction_ [6]
 
TH1F * LayerOccupancy_ [6]
 
bool rawRecHits_
 
hgcal::RecHitTools recHitTools
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 43 of file HGCalHitCalibration.cc.

Constructor & Destructor Documentation

HGCalHitCalibration::HGCalHitCalibration ( const edm::ParameterSet iConfig)
explicit

Definition at line 74 of file HGCalHitCalibration.cc.

References _caloParticles, _recHitsBH, _recHitsEE, _recHitsFH, algo_, gamEcalExtractorBlocks_cff::detector, edm::ParameterSet::getParameter(), h_EoP_CPene_100_calib_fraction_, h_EoP_CPene_200_calib_fraction_, h_EoP_CPene_300_calib_fraction_, gen::k, TFileService::kSharedResource, LayerOccupancy_, dataset::name, and AlCaHLTBitMon_QueryRunRegistry::string.

74  :
75  rawRecHits_(iConfig.getParameter<bool>("rawRecHits")),
76  cutOnPt_(iConfig.getParameter<bool>("cutOnPt")),
77  cutValue_(iConfig.getParameter<double>("cutValue")) {
78 
79  usesResource(TFileService::kSharedResource);
80  std::string detector = iConfig.getParameter<std::string >("detector");
81  if (detector=="all") {
82  _recHitsEE = consumes<HGCRecHitCollection>(edm::InputTag("HGCalRecHit","HGCEERecHits"));
83  _recHitsFH = consumes<HGCRecHitCollection>(edm::InputTag("HGCalRecHit","HGCHEFRecHits"));
84  _recHitsBH = consumes<HGCRecHitCollection>(edm::InputTag("HGCalRecHit","HGCHEBRecHits"));
85  algo_ = 1;
86  } else if (detector=="EM") {
87  _recHitsEE = consumes<HGCRecHitCollection>(edm::InputTag("HGCalRecHit","HGCEERecHits"));
88  algo_ = 2;
89  } else if (detector=="HAD") {
90  _recHitsFH = consumes<HGCRecHitCollection>(edm::InputTag("HGCalRecHit","HGCHEFRecHits"));
91  _recHitsBH = consumes<HGCRecHitCollection>(edm::InputTag("HGCalRecHit","HGCHEBRecHits"));
92  algo_ = 3;
93  }
94  _caloParticles = consumes<std::vector<CaloParticle> >(edm::InputTag("mix","MergedCaloTruth"));
95 
97  std::string particle[6] = {"All", "Electron", "Muon", "Photon", "ChgHad", "NeutHad"};
98  char name[100];
99  for (int k=0; k<6; ++k) {
100  sprintf(name,"h_EoP_CPene_100_calib_fraction_%s",particle[k].c_str());
101  h_EoP_CPene_100_calib_fraction_[k] = fs->make<TH1F>(name,"",1000,-0.5,2.5);
102  sprintf(name,"h_EoP_CPene_200_calib_fraction_%s",particle[k].c_str());
103  h_EoP_CPene_200_calib_fraction_[k] = fs->make<TH1F>(name,"",1000,-0.5,2.5);
104  sprintf(name,"h_EoP_CPene_300_calib_fraction_%s",particle[k].c_str());
105  h_EoP_CPene_300_calib_fraction_[k] = fs->make<TH1F>(name,"",1000,-0.5,2.5);
106  sprintf(name,"h_LayerOccupancy_%s",particle[k].c_str());
107  LayerOccupancy_[k] = fs->make<TH1F>(name, "", 60, 0., 60.);
108  }
109 }
static const std::string kSharedResource
Definition: TFileService.h:76
T getParameter(std::string const &) const
edm::EDGetTokenT< HGCRecHitCollection > _recHitsBH
edm::EDGetTokenT< std::vector< CaloParticle > > _caloParticles
edm::EDGetTokenT< HGCRecHitCollection > _recHitsFH
TH1F * h_EoP_CPene_300_calib_fraction_[6]
int k[5][pyjets_maxn]
edm::EDGetTokenT< HGCRecHitCollection > _recHitsEE
TH1F * h_EoP_CPene_200_calib_fraction_[6]
TH1F * h_EoP_CPene_100_calib_fraction_[6]
HGCalHitCalibration::~HGCalHitCalibration ( )

Definition at line 111 of file HGCalHitCalibration.cc.

111 { }

Member Function Documentation

void HGCalHitCalibration::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Definition at line 113 of file HGCalHitCalibration.cc.

References _caloParticles, _recHitsBH, _recHitsEE, _recHitsFH, funct::abs(), algo_, edm::SortedCollection< T, SORT >::begin(), caloTruthProducer_cfi::caloParticles, gather_cfg::cout, TkAlMuonSelectors_cfi::cut, cutOnPt_, cutValue_, DetId::det(), edm::SortedCollection< T, SORT >::end(), Energy_layer_calib, Energy_layer_calib_fraction, DetId::Forward, edm::Event::getByToken(), hgcal::RecHitTools::getEventSetup(), hgcal::RecHitTools::getLayerWithOffset(), hgcal::RecHitTools::getSiThickness(), h_EoP_CPene_100_calib_fraction_, h_EoP_CPene_200_calib_fraction_, h_EoP_CPene_300_calib_fraction_, HGCEE, HGCHEB, HGCHEF, LayerOccupancy_, cosmictrackingParticleSelector_cfi::pdgId, rawRecHits_, recHitTools, and DetId::subdetId().

Referenced by beginJob().

113  {
114 
115  recHitTools.getEventSetup(iSetup);
116 
117  edm::Handle<HGCRecHitCollection> recHitHandleEE;
118  edm::Handle<HGCRecHitCollection> recHitHandleFH;
119  edm::Handle<HGCRecHitCollection> recHitHandleBH;
120  iEvent.getByToken(_recHitsEE,recHitHandleEE);
121  iEvent.getByToken(_recHitsFH,recHitHandleFH);
122  iEvent.getByToken(_recHitsBH,recHitHandleBH);
123 
124  edm::Handle<std::vector<CaloParticle> > caloParticleHandle;
125  iEvent.getByToken(_caloParticles, caloParticleHandle);
126  const std::vector<CaloParticle>& caloParticles = *caloParticleHandle;
127  const int pdgId[3] = {11, 13, 22};
128 
129  // loop over caloParticles
130  for (auto it_caloPart = caloParticles.begin();
131  it_caloPart != caloParticles.end(); ++it_caloPart) {
132  double cut = (cutOnPt_) ? it_caloPart->pt() : it_caloPart->energy();
133  if (cut > cutValue_) {
134  int type(5);
135  if (std::abs(it_caloPart->pdgId()) == pdgId[0]) type = 1;
136  else if (std::abs(it_caloPart->pdgId()) == pdgId[1]) type = 2;
137  else if (it_caloPart->pdgId() == pdgId[2]) type = 3;
138  else if (it_caloPart->threeCharge() != 0) type = 4;
139  const SimClusterRefVector simClusterRefVector = it_caloPart->simClusters();
140 
141  //size should be HGC layers 52 is enough
142  Energy_layer_calib.assign(60,0.);
143  Energy_layer_calib_fraction.assign(60,0.);
144 
145  int seedDet = 0;
146  float seedEnergy = 0.;
147  int simClusterCount = 0;
148 
149  for ( const auto & simCluster : simClusterRefVector) {
150  ++simClusterCount;
151 #ifdef EDM_ML_DEBUG
152  std::cout << ">>> simCluster.energy() = " << simCluster->energy() << std::endl;
153 #endif
154  const std::vector<std::pair<uint32_t,float> > hits_and_fractions = simCluster->hits_and_fractions();
155 
156  //loop over hits
157  for (auto it_haf = hits_and_fractions.begin();
158  it_haf != hits_and_fractions.end(); ++it_haf) {
159  unsigned int hitlayer = recHitTools.getLayerWithOffset(it_haf->first);
160  DetId hitid = (it_haf->first);
161 
162  // dump raw RecHits and match
163  if (rawRecHits_) {
164  if (hitid.det() == DetId::Forward && hitid.subdetId() == HGCEE &&
165  (algo_ == 1 || algo_ == 2)) {
166  const HGCRecHitCollection& rechitsEE = *recHitHandleEE;
167  // loop over EE RecHits
168  for (auto it_hit = rechitsEE.begin();
169  it_hit < rechitsEE.end(); ++it_hit) {
170  const HGCalDetId detid = it_hit->detid();
171  unsigned int layer = recHitTools.getLayerWithOffset(detid);
172  if(detid == hitid){
173  if(hitlayer != layer) {
174 #ifdef EDM_ML_DEBUG
175  std::cout << " recHit ID problem EE " << std::endl;
176 #endif
177  return;
178  }
179  Energy_layer_calib_fraction[layer] += it_hit->energy()*it_haf->second;
180  LayerOccupancy_[0]->Fill(layer);
181  LayerOccupancy_[type]->Fill(layer);
182  if(seedEnergy < it_hit->energy()){
183  seedEnergy = it_hit->energy();
184  seedDet = recHitTools.getSiThickness(detid);
185  }
186  break;
187  }
188  }
189  }
190  if (hitid.det() == DetId::Forward && hitid.subdetId() == HGCHEF &&
191  (algo_ == 1 || algo_ == 3)) {
192  const HGCRecHitCollection& rechitsFH = *recHitHandleFH;
193  // loop over HEF RecHits
194  for (auto it_hit = rechitsFH.begin();
195  it_hit < rechitsFH.end(); ++it_hit) {
196  const HGCalDetId detid = it_hit->detid();
197  unsigned int layer = recHitTools.getLayerWithOffset(detid);
198  if(detid == hitid){
199  if (hitlayer != layer) {
200 #ifdef EDM_ML_DEBUG
201  std::cout << " recHit ID problem FH " << std::endl;
202 #endif
203  return;
204  }
205  Energy_layer_calib_fraction[layer] += it_hit->energy()*it_haf->second;
206  LayerOccupancy_[0]->Fill(layer);
207  LayerOccupancy_[type]->Fill(layer);
208  if(seedEnergy < it_hit->energy()){
209  seedEnergy = it_hit->energy();
210  seedDet = recHitTools.getSiThickness(detid);
211  }
212  break;
213  }
214  }
215  }
216  if (hitid.det() == DetId::Forward && hitid.subdetId() == HGCHEB &&
217  (algo_ == 1 || algo_ == 3)) {
218  const HGCRecHitCollection& rechitsBH = *recHitHandleBH;
219  // loop over BH RecHits
220  for (auto it_hit = rechitsBH.begin();
221  it_hit < rechitsBH.end(); ++it_hit) {
222  const HcalDetId detid = it_hit->detid();
223  unsigned int layer = recHitTools.getLayerWithOffset(detid);
224  if(detid == hitid){
225  if (hitlayer != layer) {
226 #ifdef EDM_ML_DEBUG
227  std::cout << " recHit ID problem BH " << std::endl;
228 #endif
229  return;
230  }
231  Energy_layer_calib_fraction[layer] += it_hit->energy()*it_haf->second;
232  LayerOccupancy_[0]->Fill(layer);
233  LayerOccupancy_[type]->Fill(layer);
234  if (seedEnergy < it_hit->energy()){
235  seedEnergy = it_hit->energy();
236  seedDet = recHitTools.getSiThickness(detid);
237  }
238  break;
239  }
240  }
241  }
242 
243  }//end recHits
244  }// end simHit
245  }//end simCluster
246 
247  float sumCalibRecHitCalib_fraction = 0;
248  for(unsigned int iL=0; iL<Energy_layer_calib_fraction.size(); ++iL){
249  sumCalibRecHitCalib_fraction += Energy_layer_calib_fraction[iL];
250  }
251 
252  double ebyp = sumCalibRecHitCalib_fraction / it_caloPart->energy();
253  if(seedDet == 100) {
254  h_EoP_CPene_100_calib_fraction_[0]->Fill(ebyp);
256  } else if (seedDet == 200) {
257  h_EoP_CPene_200_calib_fraction_[0]->Fill(ebyp);
259  } else if (seedDet == 300){
260  h_EoP_CPene_300_calib_fraction_[0]->Fill(ebyp);
262  }
263  }
264  }//end caloparticle
265 
266 }
type
Definition: HCALResponse.h:21
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
edm::EDGetTokenT< HGCRecHitCollection > _recHitsBH
void getEventSetup(const edm::EventSetup &)
Definition: RecHitTools.cc:66
edm::EDGetTokenT< std::vector< CaloParticle > > _caloParticles
edm::EDGetTokenT< HGCRecHitCollection > _recHitsFH
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
TH1F * h_EoP_CPene_300_calib_fraction_[6]
const_iterator end() const
std::float_t getSiThickness(const DetId &) const
Definition: RecHitTools.cc:86
Definition: DetId.h:18
edm::EDGetTokenT< HGCRecHitCollection > _recHitsEE
std::vector< float > Energy_layer_calib_fraction
unsigned int getLayerWithOffset(const DetId &) const
Definition: RecHitTools.cc:126
hgcal::RecHitTools recHitTools
TH1F * h_EoP_CPene_200_calib_fraction_[6]
std::vector< float > Energy_layer_calib
Detector det() const
get the detector field from this detid
Definition: DetId.h:35
TH1F * h_EoP_CPene_100_calib_fraction_[6]
const_iterator begin() const
virtual void HGCalHitCalibration::beginJob ( void  )
inlineoverrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 51 of file HGCalHitCalibration.cc.

References analyze().

51 {}
virtual void HGCalHitCalibration::endJob ( void  )
inlineoverrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 53 of file HGCalHitCalibration.cc.

53 {}
void HGCalHitCalibration::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 270 of file HGCalHitCalibration.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), DEFINE_FWK_MODULE, and AlCaHLTBitMon_QueryRunRegistry::string.

270  {
271  //The following says we do not know what parameters are allowed so do no validation
272  // Please change this to state exactly what you do use, even if it is no parameters
274  desc.add<std::string>("detector","all");
275  desc.add<bool>("rawRecHits",true);
276  desc.add<bool>("cutOnPt",true);
277  desc.add<double>("cutValue",10.0);
278  descriptions.add("hgcalHitCalibration",desc);
279 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)

Member Data Documentation

edm::EDGetTokenT<std::vector<CaloParticle> > HGCalHitCalibration::_caloParticles
private

Definition at line 58 of file HGCalHitCalibration.cc.

Referenced by analyze(), and HGCalHitCalibration().

edm::EDGetTokenT<HGCRecHitCollection> HGCalHitCalibration::_recHitsBH
private

Definition at line 57 of file HGCalHitCalibration.cc.

Referenced by analyze(), and HGCalHitCalibration().

edm::EDGetTokenT<HGCRecHitCollection> HGCalHitCalibration::_recHitsEE
private

Definition at line 55 of file HGCalHitCalibration.cc.

Referenced by analyze(), and HGCalHitCalibration().

edm::EDGetTokenT<HGCRecHitCollection> HGCalHitCalibration::_recHitsFH
private

Definition at line 56 of file HGCalHitCalibration.cc.

Referenced by analyze(), and HGCalHitCalibration().

int HGCalHitCalibration::algo_
private

Definition at line 62 of file HGCalHitCalibration.cc.

Referenced by analyze(), and HGCalHitCalibration().

bool HGCalHitCalibration::cutOnPt_
private

Definition at line 60 of file HGCalHitCalibration.cc.

Referenced by analyze().

double HGCalHitCalibration::cutValue_
private

Definition at line 61 of file HGCalHitCalibration.cc.

Referenced by analyze().

std::vector<float> HGCalHitCalibration::Energy_layer_calib
private

Definition at line 70 of file HGCalHitCalibration.cc.

Referenced by analyze().

std::vector<float> HGCalHitCalibration::Energy_layer_calib_fraction
private

Definition at line 71 of file HGCalHitCalibration.cc.

Referenced by analyze().

TH1F* HGCalHitCalibration::h_EoP_CPene_100_calib_fraction_[6]
private

Definition at line 65 of file HGCalHitCalibration.cc.

Referenced by analyze(), and HGCalHitCalibration().

TH1F* HGCalHitCalibration::h_EoP_CPene_200_calib_fraction_[6]
private

Definition at line 66 of file HGCalHitCalibration.cc.

Referenced by analyze(), and HGCalHitCalibration().

TH1F* HGCalHitCalibration::h_EoP_CPene_300_calib_fraction_[6]
private

Definition at line 67 of file HGCalHitCalibration.cc.

Referenced by analyze(), and HGCalHitCalibration().

TH1F* HGCalHitCalibration::LayerOccupancy_[6]
private

Definition at line 68 of file HGCalHitCalibration.cc.

Referenced by analyze(), and HGCalHitCalibration().

bool HGCalHitCalibration::rawRecHits_
private

Definition at line 60 of file HGCalHitCalibration.cc.

Referenced by analyze().

hgcal::RecHitTools HGCalHitCalibration::recHitTools
private

Definition at line 63 of file HGCalHitCalibration.cc.

Referenced by analyze().