CMS 3D CMS Logo

BeamHaloSummaryProducer.cc
Go to the documentation of this file.
3 
4 /*
5  [class]: BeamHaloSummaryProducer
6  [authors]: R. Remington, The University of Florida
7  [description]: See BeamHaloSummaryProducer.h
8  [date]: October 15, 2009
9 */
10 
11 using namespace edm;
12 using namespace std;
13 using namespace reco;
14 
15 BeamHaloSummaryProducer::BeamHaloSummaryProducer(const edm::ParameterSet& iConfig)
16 {
17  IT_CSCHaloData = iConfig.getParameter<edm::InputTag>("CSCHaloDataLabel");
18  IT_EcalHaloData = iConfig.getParameter<edm::InputTag>("EcalHaloDataLabel");
19  IT_HcalHaloData = iConfig.getParameter<edm::InputTag>("HcalHaloDataLabel");
20  IT_GlobalHaloData = iConfig.getParameter<edm::InputTag>("GlobalHaloDataLabel");
21 
22  L_EcalPhiWedgeEnergy = (float) iConfig.getParameter<double>("l_EcalPhiWedgeEnergy");
23  L_EcalPhiWedgeConstituents = iConfig.getParameter<int>("l_EcalPhiWedgeConstituents");
24  L_EcalPhiWedgeToF = (float)iConfig.getParameter<double>("l_EcalPhiWedgeToF");
25  L_EcalPhiWedgeConfidence = (float)iConfig.getParameter<double>("l_EcalPhiWedgeConfidence");
26  L_EcalShowerShapesRoundness = (float)iConfig.getParameter<double>("l_EcalShowerShapesRoundness");
27  L_EcalShowerShapesAngle =(float) iConfig.getParameter<double>("l_EcalShowerShapesAngle");
28  L_EcalSuperClusterSize = (int) iConfig.getParameter<int>("l_EcalSuperClusterSize");
29  L_EcalSuperClusterEnergy = (float) iConfig.getParameter<double>("l_EcalSuperClusterEnergy");
30 
31  T_EcalPhiWedgeEnergy = (float)iConfig.getParameter<double>("t_EcalPhiWedgeEnergy");
32  T_EcalPhiWedgeConstituents = iConfig.getParameter<int>("t_EcalPhiWedgeConstituents");
33  T_EcalPhiWedgeToF = (float)iConfig.getParameter<double>("t_EcalPhiWedgeToF");
34  T_EcalPhiWedgeConfidence = (float)iConfig.getParameter<double>("t_EcalPhiWedgeConfidence");
35  T_EcalShowerShapesRoundness = (float)iConfig.getParameter<double>("t_EcalShowerShapesRoundness");
36  T_EcalShowerShapesAngle = (float)iConfig.getParameter<double>("t_EcalShowerShapesAngle");
37  T_EcalSuperClusterSize = (int) iConfig.getParameter<int>("t_EcalSuperClusterSize");
38  T_EcalSuperClusterEnergy = (float) iConfig.getParameter<double>("t_EcalSuperClusterEnergy");
39 
40  L_HcalPhiWedgeEnergy = (float)iConfig.getParameter<double>("l_HcalPhiWedgeEnergy");
41  L_HcalPhiWedgeConstituents = iConfig.getParameter<int>("l_HcalPhiWedgeConstituents");
42  L_HcalPhiWedgeToF = (float)iConfig.getParameter<double>("l_HcalPhiWedgeToF");
43  L_HcalPhiWedgeConfidence = (float)iConfig.getParameter<double>("l_HcalPhiWedgeConfidence");
44 
45  T_HcalPhiWedgeEnergy = (float)iConfig.getParameter<double>("t_HcalPhiWedgeEnergy");
46  T_HcalPhiWedgeConstituents = iConfig.getParameter<int>("t_HcalPhiWedgeConstituents");
47  T_HcalPhiWedgeToF = (float)iConfig.getParameter<double>("t_HcalPhiWedgeToF");
48  T_HcalPhiWedgeConfidence = (float)iConfig.getParameter<double>("t_HcalPhiWedgeConfidence");
49 
50  problematicStripMinLength = (int)iConfig.getParameter<int>("problematicStripMinLength");
51 
52  cschalodata_token_ = consumes<CSCHaloData>(IT_CSCHaloData);
53  ecalhalodata_token_ = consumes<EcalHaloData>(IT_EcalHaloData);
54  hcalhalodata_token_ = consumes<HcalHaloData>(IT_HcalHaloData);
55  globalhalodata_token_ = consumes<GlobalHaloData>(IT_GlobalHaloData);
56 
57  produces<BeamHaloSummary>();
58 }
59 
60 void BeamHaloSummaryProducer::produce(Event& iEvent, const EventSetup& iSetup)
61 {
62  // BeamHaloSummary object
63  auto TheBeamHaloSummary = std::make_unique<BeamHaloSummary>();
64 
65  // CSC Specific Halo Data
66  Handle<CSCHaloData> TheCSCHaloData;
67  // iEvent.getByLabel(IT_CSCHaloData, TheCSCHaloData);
68  iEvent.getByToken(cschalodata_token_, TheCSCHaloData);
69 
70  const CSCHaloData CSCData = (*TheCSCHaloData.product() );
71 
72  //CSCLoose Id for 2011
73  if( CSCData.NumberOfHaloTriggers() ||
74  CSCData.NumberOfHaloTracks() ||
75  (CSCData.NOutOfTimeHits() > 10 && CSCData.NFlatHaloSegments() > 2 ) ||
76  CSCData.GetSegmentsInBothEndcaps() ||
77  CSCData.NTracksSmalldT() )
78  TheBeamHaloSummary->GetCSCHaloReport()[0] = 1;
79 
80  //CSCTight Id for 2011
81  if( (CSCData.NumberOfHaloTriggers() && CSCData.NumberOfHaloTracks()) ||
82  (CSCData.NOutOfTimeHits() > 10 && CSCData.NumberOfHaloTriggers() ) ||
83  (CSCData.NOutOfTimeHits() > 10 && CSCData.NumberOfHaloTracks() ) ||
84  CSCData.GetSegmentsInBothEndcaps() ||
85  (CSCData.NTracksSmalldT() && CSCData.NumberOfHaloTracks() ) ||
86  (CSCData.NFlatHaloSegments() > 3 && (CSCData.NumberOfHaloTriggers() || CSCData.NumberOfHaloTracks()) ))
87  TheBeamHaloSummary->GetCSCHaloReport()[1] = 1;
88 
89  //CSCLoose Id from 2010
90  if( CSCData.NumberOfHaloTriggers() || CSCData.NumberOfHaloTracks() || CSCData.NumberOfOutOfTimeTriggers() )
91  TheBeamHaloSummary->GetCSCHaloReport()[2] = 1;
92 
93  //CSCTight Id from 2010
94  if( (CSCData.NumberOfHaloTriggers() && CSCData.NumberOfHaloTracks()) ||
95  (CSCData.NumberOfHaloTriggers() && CSCData.NumberOfOutOfTimeTriggers()) ||
96  (CSCData.NumberOfHaloTracks() && CSCData.NumberOfOutOfTimeTriggers() ) )
97  TheBeamHaloSummary->GetCSCHaloReport()[3] = 1;
98 
99  //CSCTight Id for 2015
100  if( (CSCData.NumberOfHaloTriggers_TrkMuUnVeto() && CSCData.NumberOfHaloTracks()) ||
101  (CSCData.NOutOfTimeHits() > 10 && CSCData.NumberOfHaloTriggers_TrkMuUnVeto() ) ||
102  (CSCData.NOutOfTimeHits() > 10 && CSCData.NumberOfHaloTracks() ) ||
104  (CSCData.NTracksSmalldT() && CSCData.NumberOfHaloTracks() ) ||
105  (CSCData.NFlatHaloSegments() > 3 && (CSCData.NumberOfHaloTriggers_TrkMuUnVeto() || CSCData.NumberOfHaloTracks()) ))
106  TheBeamHaloSummary->GetCSCHaloReport()[4] = 1;
107 
108  //Update
109  if( (CSCData.NumberOfHaloTriggers_TrkMuUnVeto() && CSCData.NFlatHaloSegments_TrkMuUnVeto() ) ||
111  CSCData.GetSegmentIsCaloMatched()
112  )
113  TheBeamHaloSummary->GetCSCHaloReport()[5] = 1;
114 
115 
116 
117  //Ecal Specific Halo Data
118  Handle<EcalHaloData> TheEcalHaloData;
119  // iEvent.getByLabel(IT_EcalHaloData, TheEcalHaloData);
120  iEvent.getByToken(ecalhalodata_token_, TheEcalHaloData);
121 
122  const EcalHaloData EcalData = (*TheEcalHaloData.product() );
123 
124  bool EcalLooseId = false, EcalTightId = false;
125  /* COMMENTED OUT, NEEDS TO BE TUNED
126  const std::vector<PhiWedge> EcalWedges = EcalData.GetPhiWedges();
127  for( std::vector<PhiWedge>::const_iterator iWedge = EcalWedges.begin() ; iWedge != EcalWedges.end() ; iWedge++ )
128  {
129  bool EcaliPhi = false;
130 
131  //Loose Id
132  if(iWedge-> Energy() > L_EcalPhiWedgeEnergy && iWedge->NumberOfConstituents() > L_EcalPhiWedgeConstituents && std::abs(iWedge->ZDirectionConfidence()) > L_EcalPhiWedgeConfidence)
133  {
134  EcalLooseId = true;
135  EcaliPhi = true;
136  }
137 
138  //Tight Id
139  if( iWedge-> Energy() > T_EcalPhiWedgeEnergy && iWedge->NumberOfConstituents() > T_EcalPhiWedgeConstituents && iWedge->ZDirectionConfidence() > L_EcalPhiWedgeConfidence )
140  {
141  EcalTightId = true;
142  EcaliPhi = true;
143  }
144 
145  for( unsigned int i = 0 ; i < TheBeamHaloSummary->GetEcaliPhiSuspects().size() ; i++ )
146  {
147  if( iWedge->iPhi() == TheBeamHaloSummary->GetEcaliPhiSuspects()[i] )
148  {
149  EcaliPhi = false; // already stored this iPhi
150  continue;
151  }
152  }
153 
154  if( EcaliPhi )
155  TheBeamHaloSummary->GetEcaliPhiSuspects().push_back( iWedge->iPhi() ) ;
156  }
157  */
158 
159  edm::ValueMap<float> vm_Angle = EcalData.GetShowerShapesAngle();
160  edm::ValueMap<float> vm_Roundness = EcalData.GetShowerShapesRoundness();
161 
162  //Access selected SuperClusters
163  for(unsigned int n = 0 ; n < EcalData.GetSuperClusters().size() ; n++ )
164  {
166 
167  float angle = vm_Angle[cluster];
168  float roundness = vm_Roundness[cluster];
169 
170  //Loose Selection
171  if( (angle > 0. && angle < L_EcalShowerShapesAngle ) && ( roundness > 0. && roundness < L_EcalShowerShapesRoundness ) )
172  {
173  if( cluster->energy() > L_EcalSuperClusterEnergy && cluster->size() > (unsigned int) L_EcalSuperClusterSize )
174  EcalLooseId = true;
175  }
176 
177  //Tight Selection
178  if( (angle > 0. && angle < T_EcalShowerShapesAngle ) && ( roundness > 0. && roundness < T_EcalShowerShapesRoundness ) )
179  {
180  if( cluster->energy() > T_EcalSuperClusterEnergy && cluster->size() > (unsigned int)T_EcalSuperClusterSize )
181  EcalTightId = true;
182  }
183  }
184 
185  if( EcalLooseId )
186  TheBeamHaloSummary->GetEcalHaloReport()[0] = 1;
187  if( EcalTightId )
188  TheBeamHaloSummary->GetEcalHaloReport()[1] = 1;
189 
190  // Hcal Specific Halo Data
191  Handle<HcalHaloData> TheHcalHaloData;
192  // iEvent.getByLabel(IT_HcalHaloData, TheHcalHaloData);
193  iEvent.getByToken(hcalhalodata_token_, TheHcalHaloData);
194 
195  const HcalHaloData HcalData = (*TheHcalHaloData.product() );
196  const std::vector<PhiWedge> HcalWedges = HcalData.GetPhiWedges();
197  bool HcalLooseId = false, HcalTightId = false;
198  for( std::vector<PhiWedge>::const_iterator iWedge = HcalWedges.begin() ; iWedge != HcalWedges.end() ; iWedge++ )
199  {
200  bool HcaliPhi = false;
201  //Loose Id
202  if( iWedge-> Energy() > L_HcalPhiWedgeEnergy && iWedge->NumberOfConstituents() > L_HcalPhiWedgeConstituents && std::abs(iWedge->ZDirectionConfidence()) > L_HcalPhiWedgeConfidence)
203  {
204  HcalLooseId = true;
205  HcaliPhi = true;
206  }
207 
208  //Tight Id
209  if( iWedge-> Energy() > T_HcalPhiWedgeEnergy && iWedge->NumberOfConstituents() > T_HcalPhiWedgeConstituents && std::abs(iWedge->ZDirectionConfidence()) > T_HcalPhiWedgeConfidence)
210  {
211  HcalTightId = true;
212  HcaliPhi = true;
213  }
214 
215  for( unsigned int i = 0 ; i < TheBeamHaloSummary->GetHcaliPhiSuspects().size() ; i++ )
216  {
217  if( iWedge->iPhi() == TheBeamHaloSummary->GetHcaliPhiSuspects()[i] )
218  {
219  HcaliPhi = false; // already stored this iPhi
220  continue;
221  }
222  }
223  if( HcaliPhi )
224  TheBeamHaloSummary->GetHcaliPhiSuspects().push_back( iWedge->iPhi() ) ;
225  }
226 
227  if( HcalLooseId )
228  TheBeamHaloSummary->GetHcalHaloReport()[0] = 1;
229  if( HcalTightId )
230  TheBeamHaloSummary->GetHcalHaloReport()[1] = 1;
231 
232 
233  for( unsigned int i = 0 ; i < HcalData.getProblematicStrips().size() ; i++ ) {
234  auto const& problematicStrip = HcalData.getProblematicStrips()[i];
235  if(problematicStrip.cellTowerIds.size() < (unsigned int)problematicStripMinLength) continue;
236 
237  TheBeamHaloSummary->getProblematicStrips().push_back(problematicStrip);
238  }
239 
240 
241  // Global Halo Data
242  Handle<GlobalHaloData> TheGlobalHaloData;
243  // iEvent.getByLabel(IT_GlobalHaloData, TheGlobalHaloData);
244  iEvent.getByToken(globalhalodata_token_, TheGlobalHaloData);
245 
246  bool GlobalLooseId = false;
247  bool GlobalTightId = false;
248  const GlobalHaloData GlobalData = (*TheGlobalHaloData.product() );
249  const std::vector<PhiWedge> MatchedHcalWedges = GlobalData.GetMatchedHcalPhiWedges();
250  const std::vector<PhiWedge> MatchedEcalWedges = GlobalData.GetMatchedEcalPhiWedges();
251 
252  //Loose Id
253  if( MatchedEcalWedges.size() || MatchedHcalWedges.size() )
254  GlobalLooseId = true;
255 
256  //Tight Id
257  for( std::vector<PhiWedge>::const_iterator iWedge = MatchedEcalWedges.begin() ; iWedge != MatchedEcalWedges.end(); iWedge ++ )
258  {
259  if( iWedge->NumberOfConstituents() > T_EcalPhiWedgeConstituents )
260  GlobalTightId = true;
261  if( std::abs(iWedge->ZDirectionConfidence()) > T_EcalPhiWedgeConfidence )
262  GlobalTightId = true;
263  }
264 
265  for( std::vector<PhiWedge>::const_iterator iWedge = MatchedHcalWedges.begin() ; iWedge != MatchedHcalWedges.end(); iWedge ++ )
266  {
267  if( iWedge->NumberOfConstituents() > T_HcalPhiWedgeConstituents )
268  GlobalTightId = true;
269  if( std::abs(iWedge->ZDirectionConfidence()) > T_HcalPhiWedgeConfidence )
270  GlobalTightId = true;
271  }
272 
273  if( GlobalLooseId )
274  TheBeamHaloSummary->GetGlobalHaloReport()[0] = 1;
275  if( GlobalTightId )
276  TheBeamHaloSummary->GetGlobalHaloReport()[1] = 1;
277 
278  //GlobalTight Id for 2016
279  if((GlobalData.GetSegmentIsEBCaloMatched() || GlobalData.GetHaloPatternFoundEB() ) ||
280  (GlobalData.GetSegmentIsEECaloMatched() || GlobalData.GetHaloPatternFoundEE() ) ||
281  (GlobalData.GetSegmentIsHBCaloMatched() || GlobalData.GetHaloPatternFoundHB() ) ||
282  (GlobalData.GetSegmentIsHECaloMatched() || GlobalData.GetHaloPatternFoundHE() )
283  )
284  TheBeamHaloSummary->GetGlobalHaloReport()[2] = 1;
285 
286  //Global SuperTight Id for 2016
287  if((GlobalData.GetSegmentIsEBCaloMatched() && GlobalData.GetHaloPatternFoundEB() ) ||
288  (GlobalData.GetSegmentIsEECaloMatched() && GlobalData.GetHaloPatternFoundEE() ) ||
289  (GlobalData.GetSegmentIsHBCaloMatched() && GlobalData.GetHaloPatternFoundHB() ) ||
290  (GlobalData.GetSegmentIsHECaloMatched() && GlobalData.GetHaloPatternFoundHE() )
291  )
292  TheBeamHaloSummary->GetGlobalHaloReport()[3] = 1;
293 
294 
295 
296  iEvent.put(std::move(TheBeamHaloSummary));
297  return;
298 }
299 
300 BeamHaloSummaryProducer::~BeamHaloSummaryProducer(){}
T getParameter(std::string const &) const
bool GetSegmentIsEECaloMatched() const
int NumberOfHaloTracks(HaloData::Endcap z=HaloData::both) const
Definition: CSCHaloData.cc:65
edm::ValueMap< float > & GetShowerShapesRoundness()
Definition: EcalHaloData.h:43
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
short int NFlatHaloSegments_TrkMuUnVeto() const
Definition: CSCHaloData.h:63
edm::RefVector< reco::SuperClusterCollection > & GetSuperClusters()
Definition: EcalHaloData.h:38
edm::ValueMap< float > & GetShowerShapesAngle()
Definition: EcalHaloData.h:46
short int NumberOfOutOfTimeTriggers(HaloData::Endcap z=HaloData::both) const
Definition: CSCHaloData.cc:55
std::vector< PhiWedge > & GetMatchedEcalPhiWedges()
short int NFlatHaloSegments() const
Definition: CSCHaloData.h:56
bool GetHaloPatternFoundEE() const
bool GetSegmentsInBothEndcaps() const
Definition: CSCHaloData.h:57
int NumberOfHaloTriggers_TrkMuUnVeto(HaloData::Endcap z=HaloData::both) const
Definition: CSCHaloData.cc:44
int iEvent
Definition: GenABIO.cc:230
bool GetSegmentIsHECaloMatched() const
bool GetSegmentIsEBCaloMatched() const
short int NTracksSmalldT() const
Definition: CSCHaloData.h:51
bool GetSegmentIsCaloMatched() const
Definition: CSCHaloData.h:58
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool GetSegmentsInBothEndcaps_Loose_dTcut_TrkMuUnVeto() const
Definition: CSCHaloData.h:65
short int NOutOfTimeHits() const
Definition: CSCHaloData.h:49
bool GetHaloPatternFoundHE() const
int NumberOfHaloTriggers(HaloData::Endcap z=HaloData::both) const
Definition: CSCHaloData.cc:32
T const * product() const
Definition: Handle.h:81
bool GetHaloPatternFoundHB() const
fixed size matrix
HLT enums.
std::vector< PhiWedge > & GetMatchedHcalPhiWedges()
const std::vector< HaloTowerStrip > & getProblematicStrips() const
Definition: HcalHaloData.h:52
size_type size() const
Size of the RefVector.
Definition: RefVector.h:107
const std::vector< PhiWedge > & GetPhiWedges() const
Definition: HcalHaloData.h:48
bool GetHaloPatternFoundEB() const
bool GetSegmentsInBothEndcaps_Loose_TrkMuUnVeto() const
Definition: CSCHaloData.h:64
bool GetSegmentIsHBCaloMatched() const
def move(src, dest)
Definition: eostools.py:510
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
Definition: angle.h:11