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