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;
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  edm::LogWarning("HcalNoise") << " More than one FEDRawDataCollection with data in FED " << j
221  << " 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 }
FEDNumbering.h
AlCaHcalNoiseProducer::tok_jets_
edm::EDGetTokenT< reco::CaloJetCollection > tok_jets_
Definition: AlCaHcalNoiseProducer.h:61
CaloJet.h
mps_fire.i
i
Definition: mps_fire.py:428
edm::SortedCollection< CaloTower >::const_iterator
std::vector< CaloTower >::const_iterator const_iterator
Definition: SortedCollection.h:80
AlCaHcalNoiseProducer::nEvents
int nEvents
Definition: AlCaHcalNoiseProducer.h:57
MessageLogger.h
CaloTower.h
edm::Handle::product
T const * product() const
Definition: Handle.h:70
AlCaHcalNoiseProducer::AlCaHcalNoiseProducer
AlCaHcalNoiseProducer(const edm::ParameterSet &)
Definition: AlCaHcalNoiseProducer.cc:25
AlCaHcalNoiseProducer.h
FEDRawDataCollection
Definition: FEDRawDataCollection.h:18
edm::SortedCollection
Definition: SortedCollection.h:49
FEDNumbering::MAXFEDID
Definition: FEDNumbering.h:26
AlCaHcalNoiseProducer::ecalLabels_
std::vector< edm::InputTag > ecalLabels_
Definition: AlCaHcalNoiseProducer.h:59
AlCaHcalNoiseProducer::~AlCaHcalNoiseProducer
~AlCaHcalNoiseProducer() override
Definition: AlCaHcalNoiseProducer.cc:57
FEDRawData.h
edm::Handle< reco::CaloMETCollection >
edm::SortedCollection::push_back
void push_back(T const &t)
Definition: SortedCollection.h:188
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
rpcPointValidation_cfi.recHit
recHit
Definition: rpcPointValidation_cfi.py:7
FEDRawData::data
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
FEDRawData
Definition: FEDRawData.h:19
AlCaHcalNoiseProducer::useJet_
bool useJet_
Definition: AlCaHcalNoiseProducer.h:52
BTaggingMonitor_cfi.met
met
Definition: BTaggingMonitor_cfi.py:84
reco::CaloMET
Definition: CaloMET.h:21
FEDNumbering::MAXHCALFEDID
Definition: FEDNumbering.h:48
AlCaHcalNoiseProducer::toks_ecal_
std::vector< edm::EDGetTokenT< EcalRecHitCollection > > toks_ecal_
Definition: AlCaHcalNoiseProducer.h:71
photonIsolationHIProducer_cfi.hf
hf
Definition: photonIsolationHIProducer_cfi.py:9
CaloMET.h
edm::SortedCollection::begin
const_iterator begin() const
Definition: SortedCollection.h:262
RawDataFEDSelector.h
dqmdumpme.k
k
Definition: dqmdumpme.py:60
AlCaHcalNoiseProducer::tok_ps_
edm::EDGetTokenT< EcalRecHitCollection > tok_ps_
Definition: AlCaHcalNoiseProducer.h:69
FEDRawDataCollection::FEDData
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
Definition: FEDRawDataCollection.cc:19
PbPb_ZMuSkimMuonDPG_cff.deltaR
deltaR
Definition: PbPb_ZMuSkimMuonDPG_cff.py:63
AlCaHcalNoiseProducer::JetHCALminEnergyFraction_
double JetHCALminEnergyFraction_
Definition: AlCaHcalNoiseProducer.h:55
AlCaHcalNoiseProducer::JetMinE_
double JetMinE_
Definition: AlCaHcalNoiseProducer.h:54
AlCaHcalNoiseProducer::tok_tower_
edm::EDGetTokenT< CaloTowerCollection > tok_tower_
Definition: AlCaHcalNoiseProducer.h:63
edm::ParameterSet
Definition: ParameterSet.h:47
AlCaHcalNoiseProducer::tok_met_
edm::EDGetTokenT< reco::CaloMETCollection > tok_met_
Definition: AlCaHcalNoiseProducer.h:62
deltaR.h
FEDNumbering::MINHCALFEDID
Definition: FEDNumbering.h:47
edm::SortedCollection::end
const_iterator end() const
Definition: SortedCollection.h:267
iEvent
int iEvent
Definition: GenABIO.cc:224
CaloTower
Definition: CaloTower.h:26
photonIsolationHIProducer_cfi.ho
ho
Definition: photonIsolationHIProducer_cfi.py:10
AlCaHcalNoiseProducer::tok_hf_
edm::EDGetTokenT< HFRecHitCollection > tok_hf_
Definition: AlCaHcalNoiseProducer.h:67
edm::EventSetup
Definition: EventSetup.h:58
AlCaHcalNoiseProducer::tok_raw_
edm::EDGetTokenT< FEDRawDataCollection > tok_raw_
Definition: AlCaHcalNoiseProducer.h:70
FEDRawData::size
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
photonIsolationHIProducer_cfi.hbhe
hbhe
Definition: photonIsolationHIProducer_cfi.py:8
eostools.move
def move(src, dest)
Definition: eostools.py:511
AlCaHcalNoiseProducer::MetCut_
double MetCut_
Definition: AlCaHcalNoiseProducer.h:53
AlCaHcalNoiseProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: AlCaHcalNoiseProducer.cc:60
FEDRawData::resize
void resize(size_t newsize)
Definition: FEDRawData.cc:28
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
reco::CaloMETCollection
std::vector< reco::CaloMET > CaloMETCollection
collection of CaloMET objects
Definition: CaloMETCollection.h:20
HGC3DClusterGenMatchSelector_cfi.dR
dR
Definition: HGC3DClusterGenMatchSelector_cfi.py:7
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
AlCaHcalNoiseProducer::tok_ho_
edm::EDGetTokenT< HORecHitCollection > tok_ho_
Definition: AlCaHcalNoiseProducer.h:66
AlCaHcalNoiseProducer::nAnomalousEvents
int nAnomalousEvents
Definition: AlCaHcalNoiseProducer.h:56
edm::Event
Definition: Event.h:73
AlCaHcalNoiseProducer::tok_hbhe_
edm::EDGetTokenT< HBHERecHitCollection > tok_hbhe_
Definition: AlCaHcalNoiseProducer.h:65
AlCaHcalNoiseProducer::useMet_
bool useMet_
Definition: AlCaHcalNoiseProducer.h:51
edm::InputTag
Definition: InputTag.h:15
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443