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
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 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 * h_LayerOccupancy_ [6]
 
TH1F * h_MissingHit_ [3]
 
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 44 of file HGCalHitCalibration.cc.

Constructor & Destructor Documentation

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

Definition at line 76 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_, h_LayerOccupancy_, h_MissingHit_, gen::k, TFileService::kSharedResource, dataset::name, and AlCaHLTBitMon_QueryRunRegistry::string.

76  :
77  rawRecHits_(iConfig.getParameter<bool>("rawRecHits")),
78  cutOnPt_(iConfig.getParameter<bool>("cutOnPt")),
79  cutValue_(iConfig.getParameter<double>("cutValue")) {
80 
81  usesResource(TFileService::kSharedResource);
82  std::string detector = iConfig.getParameter<std::string >("detector");
83  _recHitsEE = consumes<HGCRecHitCollection>(edm::InputTag("HGCalRecHit","HGCEERecHits"));
84  _recHitsFH = consumes<HGCRecHitCollection>(edm::InputTag("HGCalRecHit","HGCHEFRecHits"));
85  _recHitsBH = consumes<HGCRecHitCollection>(edm::InputTag("HGCalRecHit","HGCHEBRecHits"));
86  if (detector=="all") {
87  algo_ = 1;
88  } else if (detector=="EM") {
89  algo_ = 2;
90  } else if (detector=="HAD") {
91  algo_ = 3;
92  }
93  _caloParticles = consumes<std::vector<CaloParticle> >(edm::InputTag("mix","MergedCaloTruth"));
94 
96  std::string particle[6] = {"All", "Electron", "Muon", "Photon", "ChgHad", "NeutHad"};
97  char name[100];
98  for (int k=0; k<6; ++k) {
99  sprintf(name,"h_EoP_CPene_100_calib_fraction_%s",particle[k].c_str());
100  h_EoP_CPene_100_calib_fraction_[k] = fs->make<TH1F>(name,"",1000,-0.5,2.5);
101  sprintf(name,"h_EoP_CPene_200_calib_fraction_%s",particle[k].c_str());
102  h_EoP_CPene_200_calib_fraction_[k] = fs->make<TH1F>(name,"",1000,-0.5,2.5);
103  sprintf(name,"h_EoP_CPene_300_calib_fraction_%s",particle[k].c_str());
104  h_EoP_CPene_300_calib_fraction_[k] = fs->make<TH1F>(name,"",1000,-0.5,2.5);
105  sprintf(name,"h_LayerOccupancy_%s",particle[k].c_str());
106  h_LayerOccupancy_[k] = fs->make<TH1F>(name, "", 60, 0., 60.);
107  }
108  std::string dets[3] = {"EE", "FH", "BH"};
109  for (int k=0; k<3; ++k) {
110  sprintf(name,"h_missHit_%s",dets[k].c_str());
111  h_MissingHit_[k] = fs->make<TH1F>(name, "", 200, 0., 200.);
112  }
113 }
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 115 of file HGCalHitCalibration.cc.

115 { }

Member Function Documentation

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

Definition at line 117 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, HcalObjRepresent::Fill(), DetId::Forward, runEdmFileComparison::found, 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_, h_LayerOccupancy_, h_MissingHit_, DetId::Hcal, HcalEndcap, HGCEE, HGCHEF, gen::k, cosmictrackingParticleSelector_cfi::pdgId, rawRecHits_, recHitTools, and DetId::subdetId().

Referenced by beginJob().

117  {
118 
119  recHitTools.getEventSetup(iSetup);
120 
121  edm::Handle<HGCRecHitCollection> recHitHandleEE;
122  edm::Handle<HGCRecHitCollection> recHitHandleFH;
123  edm::Handle<HGCRecHitCollection> recHitHandleBH;
124  iEvent.getByToken(_recHitsEE,recHitHandleEE);
125  iEvent.getByToken(_recHitsFH,recHitHandleFH);
126  iEvent.getByToken(_recHitsBH,recHitHandleBH);
127  const HGCRecHitCollection& rechitsEE = *recHitHandleEE;
128  const HGCRecHitCollection& rechitsFH = *recHitHandleFH;
129  const HGCRecHitCollection& rechitsBH = *recHitHandleBH;
130 
131  edm::Handle<std::vector<CaloParticle> > caloParticleHandle;
132  iEvent.getByToken(_caloParticles, caloParticleHandle);
133  const std::vector<CaloParticle>& caloParticles = *caloParticleHandle;
134  const int pdgId[3] = {11, 13, 22};
135 
136  // loop over caloParticles
137  int mhit[3] = {0,0,0};
138  for (auto it_caloPart = caloParticles.begin();
139  it_caloPart != caloParticles.end(); ++it_caloPart) {
140  double cut = (cutOnPt_) ? it_caloPart->pt() : it_caloPart->energy();
141  if (cut > cutValue_) {
142  int type(5);
143  if (std::abs(it_caloPart->pdgId()) == pdgId[0]) type = 1;
144  else if (std::abs(it_caloPart->pdgId()) == pdgId[1]) type = 2;
145  else if (it_caloPart->pdgId() == pdgId[2]) type = 3;
146  else if (it_caloPart->threeCharge() != 0) type = 4;
147  const SimClusterRefVector simClusterRefVector = it_caloPart->simClusters();
148 
149  //size should be HGC layers 52 is enough
150  Energy_layer_calib.assign(60,0.);
151  Energy_layer_calib_fraction.assign(60,0.);
152 
153  int seedDet = 0;
154  float seedEnergy = 0.;
155  int simClusterCount = 0;
156 
157  for ( const auto & simCluster : simClusterRefVector) {
158  ++simClusterCount;
159 #ifdef EDM_ML_DEBUG
160  std::cout << ">>> simCluster.energy() = " << simCluster->energy() << std::endl;
161 #endif
162  const std::vector<std::pair<uint32_t,float> > hits_and_fractions = simCluster->hits_and_fractions();
163 
164  //loop over hits
165  for (auto it_haf = hits_and_fractions.begin();
166  it_haf != hits_and_fractions.end(); ++it_haf) {
167  unsigned int hitlayer = recHitTools.getLayerWithOffset(it_haf->first);
168  DetId hitid = (it_haf->first);
169 
170  // dump raw RecHits and match
171  if (rawRecHits_) {
172  if (hitid.det() == DetId::Forward && hitid.subdetId() == HGCEE &&
173  (algo_ == 1 || algo_ == 2)) {
174  // loop over EE RecHits
175  bool found(false);
176  for (auto it_hit = rechitsEE.begin();
177  it_hit < rechitsEE.end(); ++it_hit) {
178  const HGCalDetId detid = it_hit->detid();
179  unsigned int layer = recHitTools.getLayerWithOffset(detid);
180  if (detid == hitid) {
181  found = true;
182  if (hitlayer != layer) {
183 #ifdef EDM_ML_DEBUG
184  std::cout << " recHit ID problem EE " << std::endl;
185 #endif
186  return;
187  }
188  Energy_layer_calib_fraction[layer] += it_hit->energy()*it_haf->second;
189  h_LayerOccupancy_[0]->Fill(layer);
190  h_LayerOccupancy_[type]->Fill(layer);
191  if(seedEnergy < it_hit->energy()){
192  seedEnergy = it_hit->energy();
193  seedDet = recHitTools.getSiThickness(detid);
194  }
195  break;
196  }
197  }
198  if (!found) ++mhit[0];
199  }
200  if (hitid.det() == DetId::Forward && hitid.subdetId() == HGCHEF &&
201  (algo_ == 1 || algo_ == 3)) {
202  // loop over HEF RecHits
203  bool found(false);
204  for (auto it_hit = rechitsFH.begin();
205  it_hit < rechitsFH.end(); ++it_hit) {
206  const HGCalDetId detid = it_hit->detid();
207  unsigned int layer = recHitTools.getLayerWithOffset(detid);
208  if (detid == hitid) {
209  found = true;
210  if (hitlayer != layer) {
211 #ifdef EDM_ML_DEBUG
212  std::cout << " recHit ID problem FH " << std::endl;
213 #endif
214  return;
215  }
216  Energy_layer_calib_fraction[layer] += it_hit->energy()*it_haf->second;
217  h_LayerOccupancy_[0]->Fill(layer);
218  h_LayerOccupancy_[type]->Fill(layer);
219  if(seedEnergy < it_hit->energy()){
220  seedEnergy = it_hit->energy();
221  seedDet = recHitTools.getSiThickness(detid);
222  }
223  break;
224  }
225  }
226  if (!found) ++mhit[1];
227  }
228  if (hitid.det() == DetId::Hcal && hitid.subdetId() == HcalEndcap &&
229  (algo_ == 1 || algo_ == 3)) {
230  // loop over BH RecHits
231  bool found(false);
232  for (auto it_hit = rechitsBH.begin();
233  it_hit < rechitsBH.end(); ++it_hit) {
234  const HcalDetId detid = it_hit->detid();
235  unsigned int layer = recHitTools.getLayerWithOffset(detid);
236  if (detid == hitid) {
237  found = true;
238  if (hitlayer != layer) {
239 #ifdef EDM_ML_DEBUG
240  std::cout << " recHit ID problem BH " << std::endl;
241 #endif
242  return;
243  }
244  Energy_layer_calib_fraction[layer] += it_hit->energy()*it_haf->second;
245  h_LayerOccupancy_[0]->Fill(layer);
246  h_LayerOccupancy_[type]->Fill(layer);
247  if (seedEnergy < it_hit->energy()){
248  seedEnergy = it_hit->energy();
249  seedDet = 300; // recHitTools.getSiThickness(detid);
250  }
251  break;
252  }
253  }
254  if (!found) ++mhit[2];
255  }
256 
257  }//end recHits
258  }// end simHit
259  }//end simCluster
260 
261  float sumCalibRecHitCalib_fraction = 0;
262  for(unsigned int iL=0; iL<Energy_layer_calib_fraction.size(); ++iL){
263  sumCalibRecHitCalib_fraction += Energy_layer_calib_fraction[iL];
264  }
265 
266  double ebyp = sumCalibRecHitCalib_fraction / it_caloPart->energy();
267  if(seedDet == 100) {
268  h_EoP_CPene_100_calib_fraction_[0]->Fill(ebyp);
270  } else if (seedDet == 200) {
271  h_EoP_CPene_200_calib_fraction_[0]->Fill(ebyp);
273  } else if (seedDet == 300){
274  h_EoP_CPene_300_calib_fraction_[0]->Fill(ebyp);
276  }
277  }
278  }//end caloparticle
279 
280  for (int k=0; k<3; ++k) h_MissingHit_[k]->Fill(mhit[k]);
281 }
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
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
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]
int k[5][pyjets_maxn]
const_iterator end() const
std::float_t getSiThickness(const DetId &) const
Definition: RecHitTools.cc:99
Definition: DetId.h:18
edm::EDGetTokenT< HGCRecHitCollection > _recHitsEE
std::vector< float > Energy_layer_calib_fraction
unsigned int getLayerWithOffset(const DetId &) const
Definition: RecHitTools.cc:139
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 52 of file HGCalHitCalibration.cc.

References analyze().

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

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 54 of file HGCalHitCalibration.cc.

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

Definition at line 285 of file HGCalHitCalibration.cc.

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

285  {
286  //The following says we do not know what parameters are allowed so do no validation
287  // Please change this to state exactly what you do use, even if it is no parameters
289  desc.add<std::string>("detector","all");
290  desc.add<bool>("rawRecHits",true);
291  desc.add<bool>("cutOnPt",true);
292  desc.add<double>("cutValue",10.0);
293  descriptions.add("hgcalHitCalibration",desc);
294 }
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 59 of file HGCalHitCalibration.cc.

Referenced by analyze(), and HGCalHitCalibration().

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

Definition at line 58 of file HGCalHitCalibration.cc.

Referenced by analyze(), and HGCalHitCalibration().

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

Definition at line 56 of file HGCalHitCalibration.cc.

Referenced by analyze(), and HGCalHitCalibration().

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

Definition at line 57 of file HGCalHitCalibration.cc.

Referenced by analyze(), and HGCalHitCalibration().

int HGCalHitCalibration::algo_
private

Definition at line 63 of file HGCalHitCalibration.cc.

Referenced by analyze(), and HGCalHitCalibration().

bool HGCalHitCalibration::cutOnPt_
private

Definition at line 61 of file HGCalHitCalibration.cc.

Referenced by analyze().

double HGCalHitCalibration::cutValue_
private

Definition at line 62 of file HGCalHitCalibration.cc.

Referenced by analyze().

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

Definition at line 72 of file HGCalHitCalibration.cc.

Referenced by analyze().

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

Definition at line 73 of file HGCalHitCalibration.cc.

Referenced by analyze().

TH1F* HGCalHitCalibration::h_EoP_CPene_100_calib_fraction_[6]
private

Definition at line 66 of file HGCalHitCalibration.cc.

Referenced by analyze(), and HGCalHitCalibration().

TH1F* HGCalHitCalibration::h_EoP_CPene_200_calib_fraction_[6]
private

Definition at line 67 of file HGCalHitCalibration.cc.

Referenced by analyze(), and HGCalHitCalibration().

TH1F* HGCalHitCalibration::h_EoP_CPene_300_calib_fraction_[6]
private

Definition at line 68 of file HGCalHitCalibration.cc.

Referenced by analyze(), and HGCalHitCalibration().

TH1F* HGCalHitCalibration::h_LayerOccupancy_[6]
private

Definition at line 69 of file HGCalHitCalibration.cc.

Referenced by analyze(), and HGCalHitCalibration().

TH1F* HGCalHitCalibration::h_MissingHit_[3]
private

Definition at line 70 of file HGCalHitCalibration.cc.

Referenced by analyze(), and HGCalHitCalibration().

bool HGCalHitCalibration::rawRecHits_
private

Definition at line 61 of file HGCalHitCalibration.cc.

Referenced by analyze().

hgcal::RecHitTools HGCalHitCalibration::recHitTools
private

Definition at line 64 of file HGCalHitCalibration.cc.

Referenced by analyze().