CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
BeamHaloSummaryProducer.cc
Go to the documentation of this file.
2 
3 /*
4  [class]: BeamHaloSummaryProducer
5  [authors]: R. Remington, The University of Florida
6  [description]: See BeamHaloSummaryProducer.h
7  [date]: October 15, 2009
8 */
9 
10 using namespace edm;
11 using namespace std;
12 using namespace reco;
13 
14 BeamHaloSummaryProducer::BeamHaloSummaryProducer(const edm::ParameterSet& iConfig)
15 {
16  IT_CSCHaloData = iConfig.getParameter<edm::InputTag>("CSCHaloDataLabel");
17  IT_EcalHaloData = iConfig.getParameter<edm::InputTag>("EcalHaloDataLabel");
18  IT_HcalHaloData = iConfig.getParameter<edm::InputTag>("HcalHaloDataLabel");
19  IT_GlobalHaloData = iConfig.getParameter<edm::InputTag>("GlobalHaloDataLabel");
20 
21  L_EcalPhiWedgeEnergy = (float) iConfig.getParameter<double>("l_EcalPhiWedgeEnergy");
22  L_EcalPhiWedgeConstituents = iConfig.getParameter<int>("l_EcalPhiWedgeConstituents");
23  L_EcalPhiWedgeToF = (float)iConfig.getParameter<double>("l_EcalPhiWedgeToF");
24  L_EcalPhiWedgeConfidence = (float)iConfig.getParameter<double>("l_EcalPhiWedgeConfidence");
25  L_EcalShowerShapesRoundness = (float)iConfig.getParameter<double>("l_EcalShowerShapesRoundness");
26  L_EcalShowerShapesAngle =(float) iConfig.getParameter<double>("l_EcalShowerShapesAngle");
27  L_EcalSuperClusterSize = (int) iConfig.getParameter<int>("l_EcalSuperClusterSize");
28  L_EcalSuperClusterEnergy = (float) iConfig.getParameter<double>("l_EcalSuperClusterEnergy");
29 
30  T_EcalPhiWedgeEnergy = (float)iConfig.getParameter<double>("t_EcalPhiWedgeEnergy");
31  T_EcalPhiWedgeConstituents = iConfig.getParameter<int>("t_EcalPhiWedgeConstituents");
32  T_EcalPhiWedgeToF = (float)iConfig.getParameter<double>("t_EcalPhiWedgeToF");
33  T_EcalPhiWedgeConfidence = (float)iConfig.getParameter<double>("t_EcalPhiWedgeConfidence");
34  T_EcalShowerShapesRoundness = (float)iConfig.getParameter<double>("t_EcalShowerShapesRoundness");
35  T_EcalShowerShapesAngle = (float)iConfig.getParameter<double>("t_EcalShowerShapesAngle");
36  T_EcalSuperClusterSize = (int) iConfig.getParameter<int>("t_EcalSuperClusterSize");
37  T_EcalSuperClusterEnergy = (float) iConfig.getParameter<double>("t_EcalSuperClusterEnergy");
38 
39  L_HcalPhiWedgeEnergy = (float)iConfig.getParameter<double>("l_HcalPhiWedgeEnergy");
40  L_HcalPhiWedgeConstituents = iConfig.getParameter<int>("l_HcalPhiWedgeConstituents");
41  L_HcalPhiWedgeToF = (float)iConfig.getParameter<double>("l_HcalPhiWedgeToF");
42  L_HcalPhiWedgeConfidence = (float)iConfig.getParameter<double>("l_HcalPhiWedgeConfidence");
43 
44  T_HcalPhiWedgeEnergy = (float)iConfig.getParameter<double>("t_HcalPhiWedgeEnergy");
45  T_HcalPhiWedgeConstituents = iConfig.getParameter<int>("t_HcalPhiWedgeConstituents");
46  T_HcalPhiWedgeToF = (float)iConfig.getParameter<double>("t_HcalPhiWedgeToF");
47  T_HcalPhiWedgeConfidence = (float)iConfig.getParameter<double>("t_HcalPhiWedgeConfidence");
48 
49  produces<BeamHaloSummary>();
50 }
51 
52 void BeamHaloSummaryProducer::produce(Event& iEvent, const EventSetup& iSetup)
53 {
54  // BeamHaloSummary object
55  std::auto_ptr<BeamHaloSummary> TheBeamHaloSummary( new BeamHaloSummary() );
56 
57  // CSC Specific Halo Data
58  Handle<CSCHaloData> TheCSCHaloData;
59  iEvent.getByLabel(IT_CSCHaloData, TheCSCHaloData);
60 
61  const CSCHaloData CSCData = (*TheCSCHaloData.product() );
62 
63  //CSCLoose Id for 2011
64  if( CSCData.NumberOfHaloTriggers() ||
65  CSCData.NumberOfHaloTracks() ||
66  (CSCData.NOutOfTimeHits() > 10 && CSCData.NFlatHaloSegments() > 2 ) ||
67  CSCData.GetSegmentsInBothEndcaps() ||
68  CSCData.NTracksSmalldT() )
69  TheBeamHaloSummary->GetCSCHaloReport()[0] = 1;
70 
71  //CSCTight Id for 2011
72  if( (CSCData.NumberOfHaloTriggers() && CSCData.NumberOfHaloTracks()) ||
73  (CSCData.NOutOfTimeHits() > 10 && CSCData.NumberOfHaloTriggers() ) ||
74  (CSCData.NOutOfTimeHits() > 10 && CSCData.NumberOfHaloTracks() ) ||
75  CSCData.GetSegmentsInBothEndcaps() ||
76  (CSCData.NTracksSmalldT() && CSCData.NumberOfHaloTracks() ) ||
77  (CSCData.NFlatHaloSegments() > 3 && (CSCData.NumberOfHaloTriggers() || CSCData.NumberOfHaloTracks()) ))
78  TheBeamHaloSummary->GetCSCHaloReport()[1] = 1;
79 
80  //CSCLoose Id from 2010
81  if( CSCData.NumberOfHaloTriggers() || CSCData.NumberOfHaloTracks() || CSCData.NumberOfOutOfTimeTriggers() )
82  TheBeamHaloSummary->GetCSCHaloReport()[2] = 1;
83 
84  //CSCTight Id from 2010
85  if( (CSCData.NumberOfHaloTriggers() && CSCData.NumberOfHaloTracks()) ||
86  (CSCData.NumberOfHaloTriggers() && CSCData.NumberOfOutOfTimeTriggers()) ||
87  (CSCData.NumberOfHaloTracks() && CSCData.NumberOfOutOfTimeTriggers() ) )
88  TheBeamHaloSummary->GetCSCHaloReport()[3] = 1;
89 
90 
91  //Ecal Specific Halo Data
92  Handle<EcalHaloData> TheEcalHaloData;
93  iEvent.getByLabel(IT_EcalHaloData, TheEcalHaloData);
94 
95  const EcalHaloData EcalData = (*TheEcalHaloData.product() );
96 
97  bool EcalLooseId = false, EcalTightId = false;
98  /* COMMENTED OUT, NEEDS TO BE TUNED
99  const std::vector<PhiWedge> EcalWedges = EcalData.GetPhiWedges();
100  for( std::vector<PhiWedge>::const_iterator iWedge = EcalWedges.begin() ; iWedge != EcalWedges.end() ; iWedge++ )
101  {
102  bool EcaliPhi = false;
103 
104  //Loose Id
105  if(iWedge-> Energy() > L_EcalPhiWedgeEnergy && iWedge->NumberOfConstituents() > L_EcalPhiWedgeConstituents && std::abs(iWedge->ZDirectionConfidence()) > L_EcalPhiWedgeConfidence)
106  {
107  EcalLooseId = true;
108  EcaliPhi = true;
109  }
110 
111  //Tight Id
112  if( iWedge-> Energy() > T_EcalPhiWedgeEnergy && iWedge->NumberOfConstituents() > T_EcalPhiWedgeConstituents && iWedge->ZDirectionConfidence() > L_EcalPhiWedgeConfidence )
113  {
114  EcalTightId = true;
115  EcaliPhi = true;
116  }
117 
118  for( unsigned int i = 0 ; i < TheBeamHaloSummary->GetEcaliPhiSuspects().size() ; i++ )
119  {
120  if( iWedge->iPhi() == TheBeamHaloSummary->GetEcaliPhiSuspects()[i] )
121  {
122  EcaliPhi = false; // already stored this iPhi
123  continue;
124  }
125  }
126 
127  if( EcaliPhi )
128  TheBeamHaloSummary->GetEcaliPhiSuspects().push_back( iWedge->iPhi() ) ;
129  }
130  */
131 
132  edm::ValueMap<float> vm_Angle = EcalData.GetShowerShapesAngle();
133  edm::ValueMap<float> vm_Roundness = EcalData.GetShowerShapesRoundness();
134 
135  //Access selected SuperClusters
136  for(unsigned int n = 0 ; n < EcalData.GetSuperClusters().size() ; n++ )
137  {
139 
140  float angle = vm_Angle[cluster];
141  float roundness = vm_Roundness[cluster];
142 
143  //Loose Selection
144  if( (angle > 0. && angle < L_EcalShowerShapesAngle ) && ( roundness > 0. && roundness < L_EcalShowerShapesRoundness ) )
145  {
146  if( cluster->energy() > L_EcalSuperClusterEnergy && cluster->size() > (unsigned int) L_EcalSuperClusterSize )
147  EcalLooseId = true;
148  }
149 
150  //Tight Selection
151  if( (angle > 0. && angle < T_EcalShowerShapesAngle ) && ( roundness > 0. && roundness < T_EcalShowerShapesRoundness ) )
152  {
153  if( cluster->energy() > T_EcalSuperClusterEnergy && cluster->size() > (unsigned int)T_EcalSuperClusterSize )
154  EcalTightId = true;
155  }
156  }
157 
158  if( EcalLooseId )
159  TheBeamHaloSummary->GetEcalHaloReport()[0] = 1;
160  if( EcalTightId )
161  TheBeamHaloSummary->GetEcalHaloReport()[1] = 1;
162 
163  // Hcal Specific Halo Data
164  Handle<HcalHaloData> TheHcalHaloData;
165  iEvent.getByLabel(IT_HcalHaloData, TheHcalHaloData);
166  const HcalHaloData HcalData = (*TheHcalHaloData.product() );
167  const std::vector<PhiWedge> HcalWedges = HcalData.GetPhiWedges();
168  bool HcalLooseId = false, HcalTightId = false;
169  for( std::vector<PhiWedge>::const_iterator iWedge = HcalWedges.begin() ; iWedge != HcalWedges.end() ; iWedge++ )
170  {
171  bool HcaliPhi = false;
172  //Loose Id
173  if( iWedge-> Energy() > L_HcalPhiWedgeEnergy && iWedge->NumberOfConstituents() > L_HcalPhiWedgeConstituents && std::abs(iWedge->ZDirectionConfidence()) > L_HcalPhiWedgeConfidence)
174  {
175  HcalLooseId = true;
176  HcaliPhi = true;
177  }
178 
179  //Tight Id
180  if( iWedge-> Energy() > T_HcalPhiWedgeEnergy && iWedge->NumberOfConstituents() > T_HcalPhiWedgeConstituents && std::abs(iWedge->ZDirectionConfidence()) > T_HcalPhiWedgeConfidence)
181  {
182  HcalTightId = true;
183  HcaliPhi = true;
184  }
185 
186  for( unsigned int i = 0 ; i < TheBeamHaloSummary->GetHcaliPhiSuspects().size() ; i++ )
187  {
188  if( iWedge->iPhi() == TheBeamHaloSummary->GetHcaliPhiSuspects()[i] )
189  {
190  HcaliPhi = false; // already stored this iPhi
191  continue;
192  }
193  }
194  if( HcaliPhi )
195  TheBeamHaloSummary->GetHcaliPhiSuspects().push_back( iWedge->iPhi() ) ;
196  }
197 
198  if( HcalLooseId )
199  TheBeamHaloSummary->GetHcalHaloReport()[0] = 1;
200  if( HcalTightId )
201  TheBeamHaloSummary->GetHcalHaloReport()[1] = 1;
202 
203  // Global Halo Data
204  Handle<GlobalHaloData> TheGlobalHaloData;
205  iEvent.getByLabel(IT_GlobalHaloData, TheGlobalHaloData);
206  bool GlobalLooseId = false;
207  bool GlobalTightId = false;
208  const GlobalHaloData GlobalData = (*TheGlobalHaloData.product() );
209  const std::vector<PhiWedge> MatchedHcalWedges = GlobalData.GetMatchedHcalPhiWedges();
210  const std::vector<PhiWedge> MatchedEcalWedges = GlobalData.GetMatchedEcalPhiWedges();
211 
212  //Loose Id
213  if( MatchedEcalWedges.size() || MatchedHcalWedges.size() )
214  GlobalLooseId = true;
215 
216  //Tight Id
217  for( std::vector<PhiWedge>::const_iterator iWedge = MatchedEcalWedges.begin() ; iWedge != MatchedEcalWedges.end(); iWedge ++ )
218  {
219  if( iWedge->NumberOfConstituents() > T_EcalPhiWedgeConstituents )
220  GlobalTightId = true;
221  if( std::abs(iWedge->ZDirectionConfidence() > T_EcalPhiWedgeConfidence) )
222  GlobalTightId = true;
223  }
224 
225  for( std::vector<PhiWedge>::const_iterator iWedge = MatchedHcalWedges.begin() ; iWedge != MatchedHcalWedges.end(); iWedge ++ )
226  {
227  if( iWedge->NumberOfConstituents() > T_HcalPhiWedgeConstituents )
228  GlobalTightId = true;
229  if( std::abs(iWedge->ZDirectionConfidence()) > T_HcalPhiWedgeConfidence )
230  GlobalTightId = true;
231  }
232 
233  if( GlobalLooseId )
234  TheBeamHaloSummary->GetGlobalHaloReport()[0] = 1;
235  if( GlobalTightId )
236  TheBeamHaloSummary->GetGlobalHaloReport()[1] = 1;
237 
238  iEvent.put(TheBeamHaloSummary);
239  return;
240 }
241 
243 void BeamHaloSummaryProducer::endJob(){return;}
244 void BeamHaloSummaryProducer::beginRun(edm::Run&, const edm::EventSetup&){return;}
245 void BeamHaloSummaryProducer::endRun(edm::Run&, const edm::EventSetup&){return;}
246 BeamHaloSummaryProducer::~BeamHaloSummaryProducer(){}
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
int NumberOfHaloTracks(HaloData::Endcap z=HaloData::both) const
Definition: CSCHaloData.cc:52
edm::ValueMap< float > & GetShowerShapesRoundness()
Definition: EcalHaloData.h:41
edm::RefVector< reco::SuperClusterCollection > & GetSuperClusters()
Definition: EcalHaloData.h:36
edm::ValueMap< float > & GetShowerShapesAngle()
Definition: EcalHaloData.h:44
#define abs(x)
Definition: mlp_lapack.h:159
short int NumberOfOutOfTimeTriggers(HaloData::Endcap z=HaloData::both) const
Definition: CSCHaloData.cc:42
std::vector< PhiWedge > & GetMatchedEcalPhiWedges()
short int NFlatHaloSegments() const
Definition: CSCHaloData.h:54
bool GetSegmentsInBothEndcaps() const
Definition: CSCHaloData.h:55
void beginJob()
Definition: Breakpoints.cc:15
int iEvent
Definition: GenABIO.cc:243
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
short int NTracksSmalldT() const
Definition: CSCHaloData.h:49
short int NOutOfTimeHits() const
Definition: CSCHaloData.h:47
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
int NumberOfHaloTriggers(HaloData::Endcap z=HaloData::both) const
Definition: CSCHaloData.cc:32
T const * product() const
Definition: Handle.h:74
std::vector< PhiWedge > & GetMatchedHcalPhiWedges()
size_type size() const
Size of the RefVector.
Definition: RefVector.h:89
const std::vector< PhiWedge > & GetPhiWedges() const
Definition: HcalHaloData.h:21
Definition: Run.h:33
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
Definition: angle.h:11