CMS 3D CMS Logo

AlCaHcalNoiseProducer.cc
Go to the documentation of this file.
1 /*
2 Original author Grigory Safronov
3 
4 27/03/09 - compilation from :
5 HLTrigger/special/src/HLTHcalNoiseFilter.cc
6 Calibration/HcalAlCaRecoProducers/src/AlCaEcalHcalReadoutsProducer.cc
7 Calibration/HcalIsolatedTrackReco/src/SubdetFEDSelector.cc
8 
9 */
10 
12 
15 
17 
22 
24 
26  tok_jets_ = consumes<reco::CaloJetCollection>(iConfig.getParameter<edm::InputTag>("JetSource"));
27  tok_met_ = consumes<reco::CaloMETCollection>(iConfig.getParameter<edm::InputTag>("MetSource"));
28  tok_tower_ = consumes<CaloTowerCollection>(iConfig.getParameter<edm::InputTag>("TowerSource"));
29  useMet_ = iConfig.getParameter<bool>("UseMET");
30  useJet_ = iConfig.getParameter<bool>("UseJet");
31  MetCut_ = iConfig.getParameter<double>("MetCut");
32  JetMinE_ = iConfig.getParameter<double>("JetMinE");
33  JetHCALminEnergyFraction_ = iConfig.getParameter<double>("JetHCALminEnergyFraction");
34 
35  tok_ho_ = consumes<HORecHitCollection>(iConfig.getParameter<edm::InputTag>("hoInput"));
36  tok_hf_ = consumes<HFRecHitCollection>(iConfig.getParameter<edm::InputTag>("hfInput"));
37  tok_hbhe_ = consumes<HBHERecHitCollection>(iConfig.getParameter<edm::InputTag>("hbheInput"));
38  ecalLabels_ = iConfig.getParameter<std::vector<edm::InputTag> >("ecalInputs");
39  tok_ps_ = consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("ecalPSInput"));
40  tok_raw_ = consumes<FEDRawDataCollection>(iConfig.getParameter<edm::InputTag>("rawInput"));
41 
42  const unsigned nLabels = ecalLabels_.size();
43  for (unsigned i = 0; i != nLabels; i++)
44  toks_ecal_.push_back(consumes<EcalRecHitCollection>(ecalLabels_[i]));
45 
46  //register products
47  produces<HBHERecHitCollection>("HBHERecHitCollectionFHN");
48  produces<HORecHitCollection>("HORecHitCollectionFHN");
49  produces<HFRecHitCollection>("HFRecHitCollectionFHN");
50 
51  produces<EcalRecHitCollection>("EcalRecHitCollectionFHN");
52  produces<EcalRecHitCollection>("PSEcalRecHitCollectionFHN");
53 
54  produces<FEDRawDataCollection>("HcalFEDsFHN");
55 }
56 
58 
59 // ------------ method called to produce the data ------------
61  bool acceptEvent = false;
62 
63  // filtering basing on HLTrigger/special/src/HLTHcalNoiseFilter.cc:
64 
65  bool isAnomalous_BasedOnMET = false;
66  bool isAnomalous_BasedOnEnergyFraction = false;
67 
68  if (useMet_) {
70  iEvent.getByToken(tok_met_, metHandle);
71  const reco::CaloMETCollection* metCol = metHandle.product();
72  const reco::CaloMET met = metCol->front();
73 
74  if (met.pt() > MetCut_)
75  isAnomalous_BasedOnMET = true;
76  }
77 
78  if (useJet_) {
80  iEvent.getByToken(tok_jets_, calojetHandle);
81 
83  iEvent.getByToken(tok_tower_, towerHandle);
84 
85  std::vector<CaloTower> TowerContainer;
86  std::vector<reco::CaloJet> JetContainer;
87  TowerContainer.clear();
88  JetContainer.clear();
89  CaloTower seedTower;
90  nEvents++;
91  for (reco::CaloJetCollection::const_iterator calojetIter = calojetHandle->begin();
92  calojetIter != calojetHandle->end();
93  ++calojetIter) {
94  if (((calojetIter->et()) * cosh(calojetIter->eta()) > JetMinE_) &&
95  (calojetIter->energyFractionHadronic() > JetHCALminEnergyFraction_)) {
96  JetContainer.push_back(*calojetIter);
97  double maxTowerE = 0.0;
98  for (CaloTowerCollection::const_iterator kal = towerHandle->begin(); kal != towerHandle->end(); kal++) {
99  double dR = deltaR((*calojetIter).eta(), (*calojetIter).phi(), (*kal).eta(), (*kal).phi());
100  if ((dR < 0.50) && (kal->p() > maxTowerE)) {
101  maxTowerE = kal->p();
102  seedTower = *kal;
103  }
104  }
105  TowerContainer.push_back(seedTower);
106  }
107  }
108  if (!JetContainer.empty()) {
110  isAnomalous_BasedOnEnergyFraction = true;
111  }
112  }
113 
114  acceptEvent = ((useMet_ && isAnomalous_BasedOnMET) || (useJet_ && isAnomalous_BasedOnEnergyFraction));
115 
117 
118  //Create empty output collections
119 
120  auto miniHBHERecHitCollection = std::make_unique<HBHERecHitCollection>();
121  auto miniHORecHitCollection = std::make_unique<HORecHitCollection>();
122  auto miniHFRecHitCollection = std::make_unique<HFRecHitCollection>();
123 
124  auto outputEColl = std::make_unique<EcalRecHitCollection>();
125  auto outputESColl = std::make_unique<EcalRecHitCollection>();
126 
127  auto outputFEDs = std::make_unique<FEDRawDataCollection>();
128 
129  // if good event get and save all colletions
130  if (acceptEvent) {
134 
135  iEvent.getByToken(tok_hbhe_, hbhe);
136  iEvent.getByToken(tok_ho_, ho);
137  iEvent.getByToken(tok_hf_, hf);
138 
140  iEvent.getByToken(tok_ps_, pRecHits);
141 
142  // temporary collection of EB+EE recHits
143 
144  auto tmpEcalRecHitCollection = std::make_unique<EcalRecHitCollection>();
145 
146  std::vector<edm::EDGetTokenT<EcalRecHitCollection> >::const_iterator i;
147  for (i = toks_ecal_.begin(); i != toks_ecal_.end(); i++) {
149  iEvent.getByToken(*i, ec);
150  for (EcalRecHitCollection::const_iterator recHit = (*ec).begin(); recHit != (*ec).end(); ++recHit) {
151  tmpEcalRecHitCollection->push_back(*recHit);
152  }
153  }
154 
156 
158  const HBHERecHitCollection Hithbhe = *(hbhe.product());
159  for (HBHERecHitCollection::const_iterator hbheItr = Hithbhe.begin(); hbheItr != Hithbhe.end(); hbheItr++) {
160  miniHBHERecHitCollection->push_back(*hbheItr);
161  }
162  const HORecHitCollection Hitho = *(ho.product());
163  for (HORecHitCollection::const_iterator hoItr = Hitho.begin(); hoItr != Hitho.end(); hoItr++) {
164  miniHORecHitCollection->push_back(*hoItr);
165  }
166 
167  const HFRecHitCollection Hithf = *(hf.product());
168  for (HFRecHitCollection::const_iterator hfItr = Hithf.begin(); hfItr != Hithf.end(); hfItr++) {
169  miniHFRecHitCollection->push_back(*hfItr);
170  }
172 
174  for (std::vector<EcalRecHit>::const_iterator ehit = tmpEcalRecHitCollection->begin();
175  ehit != tmpEcalRecHitCollection->end();
176  ehit++) {
177  outputEColl->push_back(*ehit);
178  }
180 
181  // write PS
182  const EcalRecHitCollection& psrechits = *(pRecHits.product());
183 
184  for (EcalRecHitCollection::const_iterator i = psrechits.begin(); i != psrechits.end(); i++) {
185  outputESColl->push_back(*i);
186  }
187 
188  // get HCAL FEDs
190  iEvent.getByToken(tok_raw_, rawIn);
191 
192  std::vector<int> selFEDs;
193  for (int i = FEDNumbering::MINHCALFEDID; i <= FEDNumbering::MAXHCALFEDID; i++) {
194  selFEDs.push_back(i);
195  }
197 
198  // Copying FEDs :
199  const FEDRawDataCollection* rdc = rawIn.product();
200 
201  // if ( ( rawData[i].provenance()->processName() != e.processHistory().rbegin()->processName() ) )
202  // continue ; // skip all raw collections not produced by the current process
203 
204  for (int j = 0; j < FEDNumbering::MAXFEDID; ++j) {
205  bool rightFED = false;
206  for (uint32_t k = 0; k < selFEDs.size(); k++) {
207  if (j == selFEDs[k]) {
208  rightFED = true;
209  }
210  }
211  if (!rightFED)
212  continue;
213  const FEDRawData& fedData = rdc->FEDData(j);
214  size_t size = fedData.size();
215 
216  if (size > 0) {
217  // this fed has data -- lets copy it
218  FEDRawData& fedDataProd = outputFEDs->FEDData(j);
219  if (fedDataProd.size() != 0) {
220  // std::cout << " More than one FEDRawDataCollection with data in FED ";
221  // std::cout << j << " Skipping the 2nd\n";
222  continue;
223  }
224  fedDataProd.resize(size);
225  unsigned char* dataProd = fedDataProd.data();
226  const unsigned char* data = fedData.data();
227  for (unsigned int k = 0; k < size; ++k) {
228  dataProd[k] = data[k];
229  }
230  }
231  }
233  }
234 
235  //Put selected information in the event
236  iEvent.put(std::move(miniHBHERecHitCollection), "HBHERecHitCollectionFHN");
237  iEvent.put(std::move(miniHORecHitCollection), "HORecHitCollectionFHN");
238  iEvent.put(std::move(miniHFRecHitCollection), "HFRecHitCollectionFHN");
239  iEvent.put(std::move(outputEColl), "EcalRecHitCollectionFHN");
240  iEvent.put(std::move(outputESColl), "PSEcalRecHitCollectionFHN");
241  iEvent.put(std::move(outputFEDs), "HcalFEDsFHN");
242 }
edm::EDGetTokenT< HFRecHitCollection > tok_hf_
size
Write out results.
T getParameter(std::string const &) const
edm::EDGetTokenT< HORecHitCollection > tok_ho_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
std::vector< CaloTower >::const_iterator const_iterator
std::vector< edm::EDGetTokenT< EcalRecHitCollection > > toks_ecal_
edm::EDGetTokenT< CaloTowerCollection > tok_tower_
void push_back(T const &t)
double pt() const final
transverse momentum
edm::EDGetTokenT< EcalRecHitCollection > tok_ps_
edm::EDGetTokenT< FEDRawDataCollection > tok_raw_
edm::EDGetTokenT< reco::CaloJetCollection > tok_jets_
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
std::vector< edm::InputTag > ecalLabels_
int iEvent
Definition: GenABIO.cc:224
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
void resize(size_t newsize)
Definition: FEDRawData.cc:28
void produce(edm::Event &, const edm::EventSetup &) override
const_iterator end() const
std::vector< reco::CaloMET > CaloMETCollection
collection of CaloMET objects
T const * product() const
Definition: Handle.h:69
AlCaHcalNoiseProducer(const edm::ParameterSet &)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
edm::EDGetTokenT< HBHERecHitCollection > tok_hbhe_
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
def move(src, dest)
Definition: eostools.py:511
edm::EDGetTokenT< reco::CaloMETCollection > tok_met_
const_iterator begin() const