CMS 3D CMS Logo

HGCalLayerClusterProducer.cc
Go to the documentation of this file.
1 #ifndef __RecoLocalCalo_HGCRecProducers_HGCalLayerClusterProducer_H__
2 #define __RecoLocalCalo_HGCRecProducers_HGCalLayerClusterProducer_H__
3 
4 // user include files
8 
13 
20 
23 
27 
29 
31  public:
34  static void fillDescriptions(edm::ConfigurationDescriptions &descriptions);
35 
36  void produce(edm::Event&, const edm::EventSetup&) override;
37 
38  private:
39 
43 
45 
46  std::unique_ptr<HGCalImagingAlgo> algo;
47  bool doSharing;
49 
51 };
52 
54 
56  algoId(reco::CaloCluster::undefined),
57  doSharing(ps.getParameter<bool>("doSharing")),
58  detector(ps.getParameter<std::string >("detector")), // one of EE, FH, BH or "all"
59  verbosity((HGCalImagingAlgo::VerbosityLevel)ps.getUntrackedParameter<unsigned int>("verbosity",3)){
60  double ecut = ps.getParameter<double>("ecut");
61  std::vector<double> vecDeltas = ps.getParameter<std::vector<double> >("deltac");
62  double kappa = ps.getParameter<double>("kappa");
63  std::vector<double> dEdXweights = ps.getParameter<std::vector<double> >("dEdXweights");
64  std::vector<double> thicknessCorrection = ps.getParameter<std::vector<double> >("thicknessCorrection");
65  std::vector<double> fcPerMip = ps.getParameter<std::vector<double> >("fcPerMip");
66  double fcPerEle = ps.getParameter<double>("fcPerEle");
67  std::vector<double> nonAgedNoises = ps.getParameter<edm::ParameterSet>("noises").getParameter<std::vector<double> >("values");
68  double noiseMip = ps.getParameter<edm::ParameterSet>("noiseMip").getParameter<double>("value");
69  bool dependSensor = ps.getParameter<bool>("dependSensor");
70 
71 
72  if(detector=="all") {
73  hits_ee_token = consumes<HGCRecHitCollection>(ps.getParameter<edm::InputTag>("HGCEEInput"));
74  hits_fh_token = consumes<HGCRecHitCollection>(ps.getParameter<edm::InputTag>("HGCFHInput"));
75  hits_bh_token = consumes<HGCRecHitCollection>(ps.getParameter<edm::InputTag>("HGCBHInput"));
77  }else if(detector=="EE") {
78  hits_ee_token = consumes<HGCRecHitCollection>(ps.getParameter<edm::InputTag>("HGCEEInput"));
80  }else if(detector=="FH") {
81  hits_fh_token = consumes<HGCRecHitCollection>(ps.getParameter<edm::InputTag>("HGCFHInput"));
83  } else {
84  hits_bh_token = consumes<HGCRecHitCollection>(ps.getParameter<edm::InputTag>("HGCBHInput"));
86  }
87 
88 
89  if(doSharing){
90  double showerSigma = ps.getParameter<double>("showerSigma");
91  algo = std::make_unique<HGCalImagingAlgo>(vecDeltas, kappa, ecut, showerSigma, algoId, dependSensor, dEdXweights, thicknessCorrection, fcPerMip, fcPerEle, nonAgedNoises, noiseMip, verbosity);
92  }else{
93  algo = std::make_unique<HGCalImagingAlgo>(vecDeltas, kappa, ecut, algoId, dependSensor, dEdXweights, thicknessCorrection, fcPerMip, fcPerEle, nonAgedNoises, noiseMip, verbosity);
94  }
95 
96 
97  produces<std::vector<reco::BasicCluster> >();
98  produces<std::vector<reco::BasicCluster> >("sharing");
99 
100 }
101 
102 
104  // hgcalLayerClusters
106  desc.add<std::string>("detector", "all");
107  desc.add<bool>("doSharing", false);
108  desc.add<std::vector<double>>("deltac", {
109  2.0,
110  2.0,
111  5.0,
112  });
113  desc.add<bool>("dependSensor", true);
114  desc.add<double>("ecut", 3.0);
115  desc.add<double>("kappa", 9.0);
116  desc.addUntracked<unsigned int>("verbosity", 3);
117  desc.add<edm::InputTag>("HGCEEInput", edm::InputTag("HGCalRecHit","HGCEERecHits"));
118  desc.add<edm::InputTag>("HGCFHInput", edm::InputTag("HGCalRecHit","HGCHEFRecHits"));
119  desc.add<edm::InputTag>("HGCBHInput", edm::InputTag("HGCalRecHit","HGCHEBRecHits"));
120  desc.add<std::vector<double>>("dEdXweights",{});
121  desc.add<std::vector<double>>("thicknessCorrection",{});
122  desc.add<std::vector<double>>("fcPerMip",{});
123  desc.add<double>("fcPerEle",0.0);
124  edm::ParameterSetDescription descNestedNoises;
125  descNestedNoises.add<std::vector<double> >("values", {});
126  desc.add<edm::ParameterSetDescription>("noises", descNestedNoises);
127  edm::ParameterSetDescription descNestedNoiseMIP;
128  descNestedNoiseMIP.add<double>("value", 0 );
129  desc.add<edm::ParameterSetDescription>("noiseMip", descNestedNoiseMIP);
130  descriptions.add("hgcalLayerClusters", desc);
131 
132 }
133 
134 
136  const edm::EventSetup& es) {
137 
141 
142 
143  std::unique_ptr<std::vector<reco::BasicCluster> > clusters( new std::vector<reco::BasicCluster> ),
144  clusters_sharing( new std::vector<reco::BasicCluster> );
145 
146  algo->reset();
147 
148  algo->getEventSetup(es);
149 
150  switch(algoId){
152  evt.getByToken(hits_ee_token,ee_hits);
153  algo->populate(*ee_hits);
154  break;
156  evt.getByToken(hits_fh_token,fh_hits);
157  evt.getByToken(hits_bh_token,bh_hits);
158  if( fh_hits.isValid() ) {
159  algo->populate(*fh_hits);
160  } else if ( bh_hits.isValid() ) {
161  algo->populate(*bh_hits);
162  }
163  break;
165  evt.getByToken(hits_ee_token,ee_hits);
166  algo->populate(*ee_hits);
167  evt.getByToken(hits_fh_token,fh_hits);
168  algo->populate(*fh_hits);
169  evt.getByToken(hits_bh_token,bh_hits);
170  algo->populate(*bh_hits);
171  break;
172  default:
173  break;
174  }
175  algo->makeClusters();
176  *clusters = algo->getClusters(false);
177  if(doSharing)
178  *clusters_sharing = algo->getClusters(true);
179 
180  auto clusterHandle = evt.put(std::move(clusters));
181  auto clusterHandleSharing = evt.put(std::move(clusters_sharing),"sharing");
182  edm::PtrVector<reco::BasicCluster> clusterPtrs, clusterPtrsSharing;
183  for( unsigned i = 0; i < clusterHandle->size(); ++i ) {
184  edm::Ptr<reco::BasicCluster> ptr(clusterHandle,i);
185  clusterPtrs.push_back(ptr);
186  }
187 
188  if(doSharing){
189  for( unsigned i = 0; i < clusterHandleSharing->size(); ++i ) {
190  edm::Ptr<reco::BasicCluster> ptr(clusterHandleSharing,i);
191  clusterPtrsSharing.push_back(ptr);
192  }
193  }
194 }
195 
196 #endif
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
void produce(edm::Event &, const edm::EventSetup &) override
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
reco::CaloCluster::AlgoId algoId
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
HGCalImagingAlgo::VerbosityLevel verbosity
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void push_back(Ptr< T > const &iPtr)
Definition: PtrVector.h:140
edm::EDGetTokenT< HGCRecHitCollection > hits_bh_token
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool isValid() const
Definition: HandleBase.h:74
edm::EDGetTokenT< HGCRecHitCollection > hits_ee_token
void add(std::string const &label, ParameterSetDescription const &psetDescription)
HGCalLayerClusterProducer(const edm::ParameterSet &)
fixed size matrix
edm::EDGetTokenT< HGCRecHitCollection > hits_fh_token
static const G4double kappa
std::unique_ptr< HGCalImagingAlgo > algo
def move(src, dest)
Definition: eostools.py:511