test
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.
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  cschalodata_token_ = consumes<CSCHaloData>(IT_CSCHaloData);
51  ecalhalodata_token_ = consumes<EcalHaloData>(IT_EcalHaloData);
52  hcalhalodata_token_ = consumes<HcalHaloData>(IT_HcalHaloData);
53  globalhalodata_token_ = consumes<GlobalHaloData>(IT_GlobalHaloData);
54 
55  produces<BeamHaloSummary>();
56 }
57 
58 void BeamHaloSummaryProducer::produce(Event& iEvent, const EventSetup& iSetup)
59 {
60  // BeamHaloSummary object
61  std::auto_ptr<BeamHaloSummary> TheBeamHaloSummary( new BeamHaloSummary() );
62 
63  // CSC Specific Halo Data
64  Handle<CSCHaloData> TheCSCHaloData;
65  // iEvent.getByLabel(IT_CSCHaloData, TheCSCHaloData);
66  iEvent.getByToken(cschalodata_token_, TheCSCHaloData);
67 
68  const CSCHaloData CSCData = (*TheCSCHaloData.product() );
69 
70  //CSCLoose Id for 2011
71  if( CSCData.NumberOfHaloTriggers() ||
72  CSCData.NumberOfHaloTracks() ||
73  (CSCData.NOutOfTimeHits() > 10 && CSCData.NFlatHaloSegments() > 2 ) ||
74  CSCData.GetSegmentsInBothEndcaps() ||
75  CSCData.NTracksSmalldT() )
76  TheBeamHaloSummary->GetCSCHaloReport()[0] = 1;
77 
78  //CSCTight Id for 2011
79  if( (CSCData.NumberOfHaloTriggers() && CSCData.NumberOfHaloTracks()) ||
80  (CSCData.NOutOfTimeHits() > 10 && CSCData.NumberOfHaloTriggers() ) ||
81  (CSCData.NOutOfTimeHits() > 10 && CSCData.NumberOfHaloTracks() ) ||
82  CSCData.GetSegmentsInBothEndcaps() ||
83  (CSCData.NTracksSmalldT() && CSCData.NumberOfHaloTracks() ) ||
84  (CSCData.NFlatHaloSegments() > 3 && (CSCData.NumberOfHaloTriggers() || CSCData.NumberOfHaloTracks()) ))
85  TheBeamHaloSummary->GetCSCHaloReport()[1] = 1;
86 
87  //CSCLoose Id from 2010
88  if( CSCData.NumberOfHaloTriggers() || CSCData.NumberOfHaloTracks() || CSCData.NumberOfOutOfTimeTriggers() )
89  TheBeamHaloSummary->GetCSCHaloReport()[2] = 1;
90 
91  //CSCTight Id from 2010
92  if( (CSCData.NumberOfHaloTriggers() && CSCData.NumberOfHaloTracks()) ||
93  (CSCData.NumberOfHaloTriggers() && CSCData.NumberOfOutOfTimeTriggers()) ||
94  (CSCData.NumberOfHaloTracks() && CSCData.NumberOfOutOfTimeTriggers() ) )
95  TheBeamHaloSummary->GetCSCHaloReport()[3] = 1;
96 
97 
98  //Ecal Specific Halo Data
99  Handle<EcalHaloData> TheEcalHaloData;
100  // iEvent.getByLabel(IT_EcalHaloData, TheEcalHaloData);
101  iEvent.getByToken(ecalhalodata_token_, TheEcalHaloData);
102 
103  const EcalHaloData EcalData = (*TheEcalHaloData.product() );
104 
105  bool EcalLooseId = false, EcalTightId = false;
106  /* COMMENTED OUT, NEEDS TO BE TUNED
107  const std::vector<PhiWedge> EcalWedges = EcalData.GetPhiWedges();
108  for( std::vector<PhiWedge>::const_iterator iWedge = EcalWedges.begin() ; iWedge != EcalWedges.end() ; iWedge++ )
109  {
110  bool EcaliPhi = false;
111 
112  //Loose Id
113  if(iWedge-> Energy() > L_EcalPhiWedgeEnergy && iWedge->NumberOfConstituents() > L_EcalPhiWedgeConstituents && std::abs(iWedge->ZDirectionConfidence()) > L_EcalPhiWedgeConfidence)
114  {
115  EcalLooseId = true;
116  EcaliPhi = true;
117  }
118 
119  //Tight Id
120  if( iWedge-> Energy() > T_EcalPhiWedgeEnergy && iWedge->NumberOfConstituents() > T_EcalPhiWedgeConstituents && iWedge->ZDirectionConfidence() > L_EcalPhiWedgeConfidence )
121  {
122  EcalTightId = true;
123  EcaliPhi = true;
124  }
125 
126  for( unsigned int i = 0 ; i < TheBeamHaloSummary->GetEcaliPhiSuspects().size() ; i++ )
127  {
128  if( iWedge->iPhi() == TheBeamHaloSummary->GetEcaliPhiSuspects()[i] )
129  {
130  EcaliPhi = false; // already stored this iPhi
131  continue;
132  }
133  }
134 
135  if( EcaliPhi )
136  TheBeamHaloSummary->GetEcaliPhiSuspects().push_back( iWedge->iPhi() ) ;
137  }
138  */
139 
140  edm::ValueMap<float> vm_Angle = EcalData.GetShowerShapesAngle();
141  edm::ValueMap<float> vm_Roundness = EcalData.GetShowerShapesRoundness();
142 
143  //Access selected SuperClusters
144  for(unsigned int n = 0 ; n < EcalData.GetSuperClusters().size() ; n++ )
145  {
147 
148  float angle = vm_Angle[cluster];
149  float roundness = vm_Roundness[cluster];
150 
151  //Loose Selection
152  if( (angle > 0. && angle < L_EcalShowerShapesAngle ) && ( roundness > 0. && roundness < L_EcalShowerShapesRoundness ) )
153  {
154  if( cluster->energy() > L_EcalSuperClusterEnergy && cluster->size() > (unsigned int) L_EcalSuperClusterSize )
155  EcalLooseId = true;
156  }
157 
158  //Tight Selection
159  if( (angle > 0. && angle < T_EcalShowerShapesAngle ) && ( roundness > 0. && roundness < T_EcalShowerShapesRoundness ) )
160  {
161  if( cluster->energy() > T_EcalSuperClusterEnergy && cluster->size() > (unsigned int)T_EcalSuperClusterSize )
162  EcalTightId = true;
163  }
164  }
165 
166  if( EcalLooseId )
167  TheBeamHaloSummary->GetEcalHaloReport()[0] = 1;
168  if( EcalTightId )
169  TheBeamHaloSummary->GetEcalHaloReport()[1] = 1;
170 
171  // Hcal Specific Halo Data
172  Handle<HcalHaloData> TheHcalHaloData;
173  // iEvent.getByLabel(IT_HcalHaloData, TheHcalHaloData);
174  iEvent.getByToken(hcalhalodata_token_, TheHcalHaloData);
175 
176  const HcalHaloData HcalData = (*TheHcalHaloData.product() );
177  const std::vector<PhiWedge> HcalWedges = HcalData.GetPhiWedges();
178  bool HcalLooseId = false, HcalTightId = false;
179  for( std::vector<PhiWedge>::const_iterator iWedge = HcalWedges.begin() ; iWedge != HcalWedges.end() ; iWedge++ )
180  {
181  bool HcaliPhi = false;
182  //Loose Id
183  if( iWedge-> Energy() > L_HcalPhiWedgeEnergy && iWedge->NumberOfConstituents() > L_HcalPhiWedgeConstituents && std::abs(iWedge->ZDirectionConfidence()) > L_HcalPhiWedgeConfidence)
184  {
185  HcalLooseId = true;
186  HcaliPhi = true;
187  }
188 
189  //Tight Id
190  if( iWedge-> Energy() > T_HcalPhiWedgeEnergy && iWedge->NumberOfConstituents() > T_HcalPhiWedgeConstituents && std::abs(iWedge->ZDirectionConfidence()) > T_HcalPhiWedgeConfidence)
191  {
192  HcalTightId = true;
193  HcaliPhi = true;
194  }
195 
196  for( unsigned int i = 0 ; i < TheBeamHaloSummary->GetHcaliPhiSuspects().size() ; i++ )
197  {
198  if( iWedge->iPhi() == TheBeamHaloSummary->GetHcaliPhiSuspects()[i] )
199  {
200  HcaliPhi = false; // already stored this iPhi
201  continue;
202  }
203  }
204  if( HcaliPhi )
205  TheBeamHaloSummary->GetHcaliPhiSuspects().push_back( iWedge->iPhi() ) ;
206  }
207 
208  if( HcalLooseId )
209  TheBeamHaloSummary->GetHcalHaloReport()[0] = 1;
210  if( HcalTightId )
211  TheBeamHaloSummary->GetHcalHaloReport()[1] = 1;
212 
213  // Global Halo Data
214  Handle<GlobalHaloData> TheGlobalHaloData;
215  // iEvent.getByLabel(IT_GlobalHaloData, TheGlobalHaloData);
216  iEvent.getByToken(globalhalodata_token_, TheGlobalHaloData);
217 
218  bool GlobalLooseId = false;
219  bool GlobalTightId = false;
220  const GlobalHaloData GlobalData = (*TheGlobalHaloData.product() );
221  const std::vector<PhiWedge> MatchedHcalWedges = GlobalData.GetMatchedHcalPhiWedges();
222  const std::vector<PhiWedge> MatchedEcalWedges = GlobalData.GetMatchedEcalPhiWedges();
223 
224  //Loose Id
225  if( MatchedEcalWedges.size() || MatchedHcalWedges.size() )
226  GlobalLooseId = true;
227 
228  //Tight Id
229  for( std::vector<PhiWedge>::const_iterator iWedge = MatchedEcalWedges.begin() ; iWedge != MatchedEcalWedges.end(); iWedge ++ )
230  {
231  if( iWedge->NumberOfConstituents() > T_EcalPhiWedgeConstituents )
232  GlobalTightId = true;
233  if( std::abs(iWedge->ZDirectionConfidence() > T_EcalPhiWedgeConfidence) )
234  GlobalTightId = true;
235  }
236 
237  for( std::vector<PhiWedge>::const_iterator iWedge = MatchedHcalWedges.begin() ; iWedge != MatchedHcalWedges.end(); iWedge ++ )
238  {
239  if( iWedge->NumberOfConstituents() > T_HcalPhiWedgeConstituents )
240  GlobalTightId = true;
241  if( std::abs(iWedge->ZDirectionConfidence()) > T_HcalPhiWedgeConfidence )
242  GlobalTightId = true;
243  }
244 
245  if( GlobalLooseId )
246  TheBeamHaloSummary->GetGlobalHaloReport()[0] = 1;
247  if( GlobalTightId )
248  TheBeamHaloSummary->GetGlobalHaloReport()[1] = 1;
249 
250  iEvent.put(TheBeamHaloSummary);
251  return;
252 }
253 
254 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
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
edm::RefVector< reco::SuperClusterCollection > & GetSuperClusters()
Definition: EcalHaloData.h:36
edm::ValueMap< float > & GetShowerShapesAngle()
Definition: EcalHaloData.h:44
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
int iEvent
Definition: GenABIO.cc:230
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
short int NTracksSmalldT() const
Definition: CSCHaloData.h:49
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
short int NOutOfTimeHits() const
Definition: CSCHaloData.h:47
int NumberOfHaloTriggers(HaloData::Endcap z=HaloData::both) const
Definition: CSCHaloData.cc:32
T const * product() const
Definition: Handle.h:81
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
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
Definition: angle.h:11