Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HGCal] first version of the HGCalValidator #26099

Merged
merged 47 commits into from
Mar 27, 2019
Merged
Show file tree
Hide file tree
Changes from 46 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
3216f6c
validation in mtv style - first steps
apsallid Nov 30, 2018
fd84f7f
better keep the plots in a separate folder for now
apsallid Nov 30, 2018
83e5104
Adding CaloParticleSelector and CaloParticle histogram skeleton.
apsallid Dec 1, 2018
f2e58c7
Adding vertex related parameters in CaloParticleSelector
apsallid Dec 2, 2018
cd0f96d
Adding some layer cluster validation plots
apsallid Dec 5, 2018
ec6311a
adding layer cluster plots and accessing differently rechit tools
apsallid Dec 12, 2018
c7eafcc
forgot some variables
apsallid Dec 12, 2018
5684291
trying to make a stable version
apsallid Dec 12, 2018
3adc415
Saving the HGCal-style seed of the 2d layer cluster
apsallid Dec 13, 2018
2aa65a7
using max_element for the HGCal-style seed of the 2D cluster
apsallid Dec 14, 2018
5e79b91
Adding more histograms
apsallid Jan 11, 2019
c5d4b4a
Adding plotting support
apsallid Jan 11, 2019
c794bbd
Making a better html plotting structure and adding the missing accumu…
apsallid Jan 12, 2019
94a37f7
finalize before merging with Felice and Marco
apsallid Mar 7, 2019
c5193b8
commenting out densities for the moment
apsallid Feb 21, 2019
0ce0a9d
keeping the densities
apsallid Mar 7, 2019
f38b66a
density in validator
apsallid Mar 7, 2019
86e0b2a
plot tweaks
apsallid Feb 22, 2019
f65c634
Merging with the work by Marco and Felice
apsallid Feb 22, 2019
2dc6a5f
finalize before merging with Felice and Marco
apsallid Mar 7, 2019
8be2522
Order Layer number correctly
rovere Feb 23, 2019
b08930c
Avoiding hardcoded values in histograms
apsallid Feb 24, 2019
c2bf551
Changing the title of histograms to sensible layer numbering
apsallid Feb 24, 2019
ae7a5f8
Extending the remaining per layer histograms to the full range 0 to 103
apsallid Feb 24, 2019
ac7c055
Updating the post processor to include all plots and correcting the p…
apsallid Feb 24, 2019
931a5f1
plot tweaks
apsallid Feb 26, 2019
6162add
Improve style for few plots
rovere Feb 26, 2019
a1191e2
Fix layer number padding
rovere Feb 26, 2019
238b4d8
making different plots for z- and z+
apsallid Feb 27, 2019
88fb426
Improve Score plots rendering
rovere Feb 26, 2019
7f7f17c
Make energy weight choice more flexible
rovere Feb 26, 2019
a0b3683
Correcting the title for efficiencies/duplicates/fakes/merges
apsallid Feb 27, 2019
b5b2719
Updating the xbinlabels for efficiencies/duplicates/fakes/merges
apsallid Feb 27, 2019
8ede731
Activating all plots
apsallid Feb 27, 2019
aae7010
Improve style for cells plots
rovere Feb 27, 2019
0ae93d7
replace cout with LogDebug
apsallid Mar 7, 2019
6ed4994
apply codechecks
apsallid Mar 7, 2019
e74d65f
Once again add back the Density object that was accidentally removed …
apsallid Mar 7, 2019
cd560b0
applying first bunch from kevin corrections
apsallid Mar 8, 2019
6658397
applying the rest of the corrections from Kevin
apsallid Mar 8, 2019
d1bbcd1
some tweaks
apsallid Mar 8, 2019
8cab4d6
Specify the material budget file used in order to avoid confusion and…
apsallid Mar 9, 2019
8751965
removing the assert
apsallid Mar 10, 2019
f110ded
applying reviewer comments, that is removing couts, correcting classe…
apsallid Mar 11, 2019
370acef
moving detid related dictionaries to the appropriate place
apsallid Mar 18, 2019
61144bf
saving geometry info to avoid hardcoded values
apsallid Mar 20, 2019
3cad6d8
applying comments in CaloParticleSelector and a typo on makeHGCalVali…
apsallid Mar 24, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions DataFormats/DetId/src/classes_def.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@
<class name="std::pair<DetId,float>"/>
<class name="std::map<DetId, std::pair<unsigned int, unsigned int> >"/>
<class name="std::map<DetId, std::pair<unsigned long, unsigned long> >"/>
<class name="std::pair<const DetId,float>"/>
<class name="std::map<DetId,float>"/>
<class name="edm::Wrapper<std::map<DetId,float> >"/>

</lcgdict>
1 change: 0 additions & 1 deletion DataFormats/EgammaReco/src/classes_def.xml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,5 @@
<class name="edm::Wrapper<edm::RefVector<edm::AssociationMap<edm::OneToOne<vector<reco::CaloCluster>,vector<reco::ClusterShape>,unsigned int> >,edm::helpers::KeyVal<edm::Ref<vector<reco::CaloCluster>,reco::CaloCluster,edm::refhelper::FindUsingAdvance<vector<reco::CaloCluster>,reco::CaloCluster> >,edm::Ref<vector<reco::ClusterShape>,reco::ClusterShape,edm::refhelper::FindUsingAdvance<vector<reco::ClusterShape>,reco::ClusterShape> > >,edm::AssociationMap<edm::OneToOne<vector<reco::CaloCluster>,vector<reco::ClusterShape>,unsigned int> >::Find> >" />
<class name="edm::Wrapper<edm::RefVector<edm::AssociationMap<edm::OneToOne<vector<reco::SuperCluster>,vector<reco::HFEMClusterShape>,unsigned int> >,edm::helpers::KeyVal<edm::Ref<vector<reco::SuperCluster>,reco::SuperCluster,edm::refhelper::FindUsingAdvance<vector<reco::SuperCluster>,reco::SuperCluster> >,edm::Ref<vector<reco::HFEMClusterShape>,reco::HFEMClusterShape,edm::refhelper::FindUsingAdvance<vector<reco::HFEMClusterShape>,reco::HFEMClusterShape> > >,edm::AssociationMap<edm::OneToOne<vector<reco::SuperCluster>,vector<reco::HFEMClusterShape>,unsigned int> >::Find> >" />


</lcgdict>

26 changes: 25 additions & 1 deletion RecoLocalCalo/HGCalRecAlgos/interface/HGCalImagingAlgo.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

#include "KDTreeLinkerAlgoT.h"

//Density collection
typedef std::map< DetId, float > Density;

template <typename T>
std::vector<size_t> sorted_indices(const std::vector<T> &v) {
Expand All @@ -41,6 +43,19 @@ std::vector<size_t> sorted_indices(const std::vector<T> &v) {
return idx;
}

template <typename T>
size_t max_index(const std::vector<T> &v) {

// initialize original index locations
std::vector<size_t> idx(v.size(),0);
std::iota (std::begin(idx), std::end(idx), 0);

// take the max index based on comparing values in v
auto maxidx = std::max_element(idx.begin(), idx.end(), [&v](size_t i1, size_t i2) {return v[i1].data.rho < v[i2].data.rho;});

return (*maxidx);
}

class HGCalImagingAlgo
{

Expand Down Expand Up @@ -161,6 +176,9 @@ void reset(){
}
void computeThreshold();

//getDensity
Density getDensity();

/// point in the space
typedef math::XYZPoint Point;

Expand Down Expand Up @@ -195,6 +213,9 @@ hgcal::RecHitTools rhtools_;
// The algo id
reco::CaloCluster::AlgoId algoId_;

// For keeping the density per hit
Density density_;

// various parameters used for calculating the noise levels for a given sensor (and whether to use them)
bool dependSensor_;
std::vector<double> dEdXweights_;
Expand All @@ -204,7 +225,7 @@ double fcPerEle_;
std::vector<double> nonAgedNoises_;
double noiseMip_;
std::vector<std::vector<double> > thresholds_;
std::vector<std::vector<double> > v_sigmaNoise_;
std::vector<std::vector<double> > sigmaNoise_;

// The verbosity level
VerbosityLevel verbosity_;
Expand Down Expand Up @@ -297,6 +318,9 @@ double calculateDistanceToHigher(std::vector<KDNode> &) const;
int findAndAssignClusters(std::vector<KDNode> &, KDTree &, double, KDTreeBox &, const unsigned int, std::vector<std::vector<KDNode> >&) const;
math::XYZPoint calculatePosition(std::vector<KDNode> &) const;

//For keeping the density information
void setDensity(const std::vector<KDNode> &nd);

// attempt to find subclusters within a given set of hexels
std::vector<unsigned> findLocalMaximaInCluster(const std::vector<KDNode>&);
math::XYZPoint calculatePositionWithFraction(const std::vector<KDNode>&, const std::vector<double>&);
Expand Down
31 changes: 26 additions & 5 deletions RecoLocalCalo/HGCalRecAlgos/src/HGCalImagingAlgo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void HGCalImagingAlgo::populate(const HGCRecHitCollection &hits) {
if (thickness_index == -1)
thickness_index = 3;
double storedThreshold = thresholds_[layer - 1][thickness_index];
sigmaNoise = v_sigmaNoise_[layer - 1][thickness_index];
sigmaNoise = sigmaNoise_[layer - 1][thickness_index];

if (hgrh.energy() < storedThreshold)
continue; // this sets the ZS threshold at ecut times the sigma noise
Expand Down Expand Up @@ -98,6 +98,8 @@ void HGCalImagingAlgo::makeClusters() {
double maxdensity = calculateLocalDensity(
points_[i], hit_kdtree, actualLayer); // also stores rho (energy
// density) for each point (node)
//Now that we have the density per point we can store it
setDensity(points_[i]);
// calculate distance to nearest point with higher density storing
// distance (delta) and point's index
calculateDistanceToHigher(points_[i]);
Expand All @@ -115,6 +117,9 @@ std::vector<reco::BasicCluster> HGCalImagingAlgo::getClusters(bool doSharing) {
for (unsigned int i = 0; i < clsOnLayer.size(); ++i) {
double energy = 0;
Point position;

//Will save the maximum density hit of the cluster
size_t rsmax = max_index(clsOnLayer[i]);

if (doSharing) {

Expand Down Expand Up @@ -158,7 +163,8 @@ std::vector<reco::BasicCluster> HGCalImagingAlgo::getClusters(bool doSharing) {
}
clusters_v_.emplace_back(energy, position, caloID, thisCluster,
algoId_);
thisCluster.clear();
if (!clusters_v_.empty()){ clusters_v_.back().setSeed( clsOnLayer[i][rsmax].data.detid); }
thisCluster.clear();
}
} else {
position = calculatePosition(clsOnLayer[i]); // energy-weighted position
Expand All @@ -178,6 +184,7 @@ std::vector<reco::BasicCluster> HGCalImagingAlgo::getClusters(bool doSharing) {
std::cout << "*****************************" << std::endl;
}
clusters_v_.emplace_back(energy, position, caloID, thisCluster, algoId_);
if (!clusters_v_.empty()){ clusters_v_.back().setSeed( clsOnLayer[i][rsmax].data.detid); }
thisCluster.clear();
}
}
Expand Down Expand Up @@ -652,19 +659,33 @@ void HGCalImagingAlgo::computeThreshold() {
const unsigned maxNumberOfThickIndices = 3;
dummy.resize(maxNumberOfThickIndices + 1, 0); // +1 to accomodate for the Scintillators
thresholds_.resize(maxlayer, dummy);
v_sigmaNoise_.resize(maxlayer, dummy);
sigmaNoise_.resize(maxlayer, dummy);

for (unsigned ilayer = 1; ilayer <= maxlayer; ++ilayer) {
for (unsigned ithick = 0; ithick < maxNumberOfThickIndices; ++ithick) {
float sigmaNoise =
0.001f * fcPerEle_ * nonAgedNoises_[ithick] * dEdXweights_[ilayer] /
(fcPerMip_[ithick] * thicknessCorrection_[ithick]);
thresholds_[ilayer - 1][ithick] = sigmaNoise * ecut_;
v_sigmaNoise_[ilayer - 1][ithick] = sigmaNoise;
sigmaNoise_[ilayer - 1][ithick] = sigmaNoise;
}
float scintillators_sigmaNoise = 0.001f * noiseMip_ * dEdXweights_[ilayer];
thresholds_[ilayer - 1][maxNumberOfThickIndices] = ecut_ * scintillators_sigmaNoise;
v_sigmaNoise_[ilayer -1][maxNumberOfThickIndices] = scintillators_sigmaNoise;
sigmaNoise_[ilayer -1][maxNumberOfThickIndices] = scintillators_sigmaNoise;
}

}

void HGCalImagingAlgo::setDensity(const std::vector<KDNode> &nd){

// for each node calculate local density rho and store it
for (auto &i : nd){
density_[ i.data.detid ] = i.data.rho ;
} // end loop nodes
}

//Density
Density HGCalImagingAlgo::getDensity(){
return density_;
}

Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ HGCalLayerClusterProducer::HGCalLayerClusterProducer(const edm::ParameterSet &ps

produces<std::vector<reco::BasicCluster> >();
produces<std::vector<reco::BasicCluster> >("sharing");
//density
produces< Density >();
//time for layer clusters
produces<edm::ValueMap<float> > (timeClname);

Expand Down Expand Up @@ -168,6 +170,7 @@ void HGCalLayerClusterProducer::produce(edm::Event& evt,

std::unique_ptr<std::vector<reco::BasicCluster> > clusters( new std::vector<reco::BasicCluster> ),
clusters_sharing( new std::vector<reco::BasicCluster> );
auto density = std::make_unique<Density>();

algo->reset();

Expand Down Expand Up @@ -218,6 +221,11 @@ void HGCalLayerClusterProducer::produce(edm::Event& evt,

auto clusterHandle = evt.put(std::move(clusters));
auto clusterHandleSharing = evt.put(std::move(clusters_sharing),"sharing");

//Keep the density
*density = algo->getDensity();
evt.put(std::move(density));

edm::PtrVector<reco::BasicCluster> clusterPtrs, clusterPtrsSharing;

std::vector<float> times;
Expand Down
2 changes: 1 addition & 1 deletion Validation/Configuration/python/autoValidation.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
'miniAODValidation' : ['prevalidationMiniAOD','validationMiniAOD','validationHarvestingMiniAOD'],
'standardValidation' : ['prevalidation','validation','validationHarvesting'],
'standardValidationNoHLT' : ['prevalidationNoHLT','validationNoHLT','validationHarvestingNoHLT'],
'HGCalValidation' : ['', 'globalValidationHGCal', ''],
'HGCalValidation' : ['', 'globalValidationHGCal', 'hgcalValidatorPostProcessor'],
'OuterTrackerValidation' : ['', 'globalValidationOuterTracker', 'postValidationOuterTracker'],
}

Expand Down
7 changes: 6 additions & 1 deletion Validation/Configuration/python/hgcalSimValid_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
from Validation.HGCalValidation.rechitValidation_cff import *
from Validation.HGCalValidation.hgcalHitValidation_cfi import *

from Validation.HGCalValidation.HGCalValidator_cfi import hgcalValidator

hgcalValidatorSequence = cms.Sequence(hgcalValidator)

hgcalValidation = cms.Sequence(hgcalSimHitValidationEE
+ hgcalSimHitValidationHEF
+ hgcalSimHitValidationHEB
Expand All @@ -14,4 +18,5 @@
+ hgcalRecHitValidationEE
+ hgcalRecHitValidationHEF
+ hgcalRecHitValidationHEB
+ hgcalHitValidationSequence)
+ hgcalHitValidationSequence
+ hgcalValidatorSequence)
33 changes: 33 additions & 0 deletions Validation/HGCalValidation/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<use name="CalibFormats/HcalObjects"/>
<use name="CondFormats/GeometryObjects"/>
<use name="DataFormats/ForwardDetId"/>
<use name="DataFormats/HcalDetId"/>
<use name="DataFormats/HepMCCandidate"/>
<use name="DataFormats/ParticleFlowCandidate"/>
<use name="DetectorDescription/Core"/>
<use name="DQMServices/Core"/>
<use name="FWCore/Framework"/>
<use name="FWCore/ParameterSet"/>
<use name="FWCore/MessageLogger"/>
<use name="FWCore/PluginManager"/>
<use name="Geometry/HcalCommonData"/>
<use name="Geometry/HGCalCommonData"/>
<use name="Geometry/HGCalGeometry"/>
<use name="Geometry/Records"/>
<use name="SimDataFormats/CaloHit"/>
<use name="SimDataFormats/CaloTest"/>
<use name="SimDataFormats/CaloAnalysis"/>
<use name="SimDataFormats/GeneratorProducts"/>
<use name="SimDataFormats/Track"/>
<use name="SimDataFormats/ValidationFormats"/>
<use name="SimG4Core/Notification"/>
<use name="SimG4Core/Watcher"/>
<use name="SimG4CMS/Calo"/>
<use name="RecoLocalCalo/HGCalRecAlgos"/>
<use name="geant4core"/>
<use name="clhep"/>
<use name="hepmc"/>

<export>
<lib name="ValidationHGCalValidation"/>
</export>
52 changes: 52 additions & 0 deletions Validation/HGCalValidation/data/D28.cumulative.xo
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
1.0 0.434
2.0 1.402
3.0 2.273
4.0 3.241
5.0 4.112
6.0 5.08
7.0 5.951
8.0 6.919
9.0 7.79
10.0 8.758
11.0 9.629
12.0 10.597
13.0 11.468
14.0 12.436
15.0 13.307
16.0 14.275
17.0 15.146
18.0 16.114
19.0 16.985
20.0 17.953
21.0 18.824
22.0 19.792
23.0 20.663
24.0 21.631
25.0 22.502
26.0 23.47
27.0 24.341
28.0 25.309
29.0 27.793
30.0 30.324
31.0 32.856
32.0 35.387
33.0 37.919
34.0 40.45
35.0 42.982
36.0 45.513
37.0 48.045
38.0 50.576
39.0 53.108
40.0 55.639
41.0 60.072
42.0 64.505
43.0 68.969
44.0 73.44
45.0 77.912
46.0 82.383
47.0 86.854
48.0 91.325
49.0 95.797
50.0 100.268
51.0 104.739
52.0 109.211
Loading