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  //Loose Id (any one of the three criteria)
63  if( CSCData.NumberOfHaloTriggers() || CSCData.NumberOfHaloTracks() || CSCData.NumberOfOutOfTimeTriggers() )
64  TheBeamHaloSummary->GetCSCHaloReport()[0] = 1;
65 
66  //Tight Id (any two of the previous three criteria)
67  if( (CSCData.NumberOfHaloTriggers() && CSCData.NumberOfHaloTracks()) ||
68  (CSCData.NumberOfHaloTriggers() && CSCData.NumberOfOutOfTimeTriggers()) ||
69  (CSCData.NumberOfHaloTracks() && CSCData.NumberOfOutOfTimeTriggers() ) )
70  TheBeamHaloSummary->GetCSCHaloReport()[1] = 1;
71 
72  //Ecal Specific Halo Data
73  Handle<EcalHaloData> TheEcalHaloData;
74  iEvent.getByLabel(IT_EcalHaloData, TheEcalHaloData);
75 
76  const EcalHaloData EcalData = (*TheEcalHaloData.product() );
77 
78  bool EcalLooseId = false, EcalTightId = false;
79  /* COMMENTED OUT, NEEDS TO BE TUNED
80  const std::vector<PhiWedge> EcalWedges = EcalData.GetPhiWedges();
81  for( std::vector<PhiWedge>::const_iterator iWedge = EcalWedges.begin() ; iWedge != EcalWedges.end() ; iWedge++ )
82  {
83  bool EcaliPhi = false;
84 
85  //Loose Id
86  if(iWedge-> Energy() > L_EcalPhiWedgeEnergy && iWedge->NumberOfConstituents() > L_EcalPhiWedgeConstituents && std::abs(iWedge->ZDirectionConfidence()) > L_EcalPhiWedgeConfidence)
87  {
88  EcalLooseId = true;
89  EcaliPhi = true;
90  }
91 
92  //Tight Id
93  if( iWedge-> Energy() > T_EcalPhiWedgeEnergy && iWedge->NumberOfConstituents() > T_EcalPhiWedgeConstituents && iWedge->ZDirectionConfidence() > L_EcalPhiWedgeConfidence )
94  {
95  EcalTightId = true;
96  EcaliPhi = true;
97  }
98 
99  for( unsigned int i = 0 ; i < TheBeamHaloSummary->GetEcaliPhiSuspects().size() ; i++ )
100  {
101  if( iWedge->iPhi() == TheBeamHaloSummary->GetEcaliPhiSuspects()[i] )
102  {
103  EcaliPhi = false; // already stored this iPhi
104  continue;
105  }
106  }
107 
108  if( EcaliPhi )
109  TheBeamHaloSummary->GetEcaliPhiSuspects().push_back( iWedge->iPhi() ) ;
110  }
111  */
112 
113  edm::ValueMap<float> vm_Angle = EcalData.GetShowerShapesAngle();
114  edm::ValueMap<float> vm_Roundness = EcalData.GetShowerShapesRoundness();
115 
116  //Access selected SuperClusters
117  for(unsigned int n = 0 ; n < EcalData.GetSuperClusters().size() ; n++ )
118  {
120 
121  float angle = vm_Angle[cluster];
122  float roundness = vm_Roundness[cluster];
123 
124  //Loose Selection
125  if( (angle > 0. && angle < L_EcalShowerShapesAngle ) && ( roundness > 0. && roundness < L_EcalShowerShapesRoundness ) )
126  {
127  if( cluster->energy() > L_EcalSuperClusterEnergy && cluster->size() > (unsigned int) L_EcalSuperClusterSize )
128  EcalLooseId = true;
129  }
130 
131  //Tight Selection
132  if( (angle > 0. && angle < T_EcalShowerShapesAngle ) && ( roundness > 0. && roundness < T_EcalShowerShapesRoundness ) )
133  {
134  if( cluster->energy() > T_EcalSuperClusterEnergy && cluster->size() > (unsigned int)T_EcalSuperClusterSize )
135  EcalTightId = true;
136  }
137  }
138 
139  if( EcalLooseId )
140  TheBeamHaloSummary->GetEcalHaloReport()[0] = 1;
141  if( EcalTightId )
142  TheBeamHaloSummary->GetEcalHaloReport()[1] = 1;
143 
144 
145 
146  // Hcal Specific Halo Data
147  Handle<HcalHaloData> TheHcalHaloData;
148  iEvent.getByLabel(IT_HcalHaloData, TheHcalHaloData);
149  const HcalHaloData HcalData = (*TheHcalHaloData.product() );
150  const std::vector<PhiWedge> HcalWedges = HcalData.GetPhiWedges();
151  bool HcalLooseId = false, HcalTightId = false;
152  for( std::vector<PhiWedge>::const_iterator iWedge = HcalWedges.begin() ; iWedge != HcalWedges.end() ; iWedge++ )
153  {
154  bool HcaliPhi = false;
155  //Loose Id
156  if( iWedge-> Energy() > L_HcalPhiWedgeEnergy && iWedge->NumberOfConstituents() > L_HcalPhiWedgeConstituents && std::abs(iWedge->ZDirectionConfidence()) > L_HcalPhiWedgeConfidence)
157  {
158  HcalLooseId = true;
159  HcaliPhi = true;
160  }
161 
162  //Tight Id
163  if( iWedge-> Energy() > T_HcalPhiWedgeEnergy && iWedge->NumberOfConstituents() > T_HcalPhiWedgeConstituents && std::abs(iWedge->ZDirectionConfidence()) > T_HcalPhiWedgeConfidence)
164  {
165  HcalTightId = true;
166  HcaliPhi = true;
167  }
168 
169  for( unsigned int i = 0 ; i < TheBeamHaloSummary->GetHcaliPhiSuspects().size() ; i++ )
170  {
171  if( iWedge->iPhi() == TheBeamHaloSummary->GetHcaliPhiSuspects()[i] )
172  {
173  HcaliPhi = false; // already stored this iPhi
174  continue;
175  }
176  }
177  if( HcaliPhi )
178  TheBeamHaloSummary->GetHcaliPhiSuspects().push_back( iWedge->iPhi() ) ;
179  }
180 
181  if( HcalLooseId )
182  TheBeamHaloSummary->GetHcalHaloReport()[0] = 1;
183  if( HcalTightId )
184  TheBeamHaloSummary->GetHcalHaloReport()[1] = 1;
185 
186  // Global Halo Data
187  Handle<GlobalHaloData> TheGlobalHaloData;
188  iEvent.getByLabel(IT_GlobalHaloData, TheGlobalHaloData);
189  bool GlobalLooseId = false;
190  bool GlobalTightId = false;
191  const GlobalHaloData GlobalData = (*TheGlobalHaloData.product() );
192  const std::vector<PhiWedge> MatchedHcalWedges = GlobalData.GetMatchedHcalPhiWedges();
193  const std::vector<PhiWedge> MatchedEcalWedges = GlobalData.GetMatchedEcalPhiWedges();
194 
195  //Loose Id
196  if( MatchedEcalWedges.size() || MatchedHcalWedges.size() )
197  GlobalLooseId = true;
198 
199  //Tight Id
200  for( std::vector<PhiWedge>::const_iterator iWedge = MatchedEcalWedges.begin() ; iWedge != MatchedEcalWedges.end(); iWedge ++ )
201  {
202  if( iWedge->NumberOfConstituents() > T_EcalPhiWedgeConstituents )
203  GlobalTightId = true;
204  if( std::abs(iWedge->ZDirectionConfidence() > T_EcalPhiWedgeConfidence) )
205  GlobalTightId = true;
206  }
207 
208  for( std::vector<PhiWedge>::const_iterator iWedge = MatchedHcalWedges.begin() ; iWedge != MatchedHcalWedges.end(); iWedge ++ )
209  {
210  if( iWedge->NumberOfConstituents() > T_HcalPhiWedgeConstituents )
211  GlobalTightId = true;
212  if( std::abs(iWedge->ZDirectionConfidence()) > T_HcalPhiWedgeConfidence )
213  GlobalTightId = true;
214  }
215 
216  if( GlobalLooseId )
217  TheBeamHaloSummary->GetGlobalHaloReport()[0] = 1;
218  if( GlobalTightId )
219  TheBeamHaloSummary->GetGlobalHaloReport()[1] = 1;
220 
221  iEvent.put(TheBeamHaloSummary);
222  return;
223 }
224 
226 void BeamHaloSummaryProducer::endJob(){return;}
227 void BeamHaloSummaryProducer::beginRun(edm::Run&, const edm::EventSetup&){return;}
228 void BeamHaloSummaryProducer::endRun(edm::Run&, const edm::EventSetup&){return;}
229 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:83
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:73
std::vector< PhiWedge > & GetMatchedEcalPhiWedges()
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:84
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:359
int NumberOfHaloTriggers(HaloData::Endcap z=HaloData::both) const
Definition: CSCHaloData.cc:63
T const * product() const
Definition: Handle.h:74
std::vector< PhiWedge > & GetMatchedHcalPhiWedges()
size_type size() const
Size of the RefVector.
Definition: RefVector.h:85
const std::vector< PhiWedge > & GetPhiWedges() const
Definition: HcalHaloData.h:21
Definition: Run.h:31
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
Definition: angle.h:11