CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/RecoMET/METProducers/src/BeamHaloSummaryProducer.cc

Go to the documentation of this file.
00001 #include "RecoMET/METProducers/interface/BeamHaloSummaryProducer.h"
00002 
00003 /*
00004   [class]:  BeamHaloSummaryProducer
00005   [authors]: R. Remington, The University of Florida
00006   [description]: See BeamHaloSummaryProducer.h
00007   [date]: October 15, 2009
00008 */
00009 
00010 using namespace edm;
00011 using namespace std;
00012 using namespace reco;
00013 
00014 BeamHaloSummaryProducer::BeamHaloSummaryProducer(const edm::ParameterSet& iConfig)
00015 {
00016   IT_CSCHaloData = iConfig.getParameter<edm::InputTag>("CSCHaloDataLabel");
00017   IT_EcalHaloData = iConfig.getParameter<edm::InputTag>("EcalHaloDataLabel");
00018   IT_HcalHaloData = iConfig.getParameter<edm::InputTag>("HcalHaloDataLabel");
00019   IT_GlobalHaloData = iConfig.getParameter<edm::InputTag>("GlobalHaloDataLabel");
00020   
00021   L_EcalPhiWedgeEnergy = (float) iConfig.getParameter<double>("l_EcalPhiWedgeEnergy");
00022   L_EcalPhiWedgeConstituents = iConfig.getParameter<int>("l_EcalPhiWedgeConstituents");
00023   L_EcalPhiWedgeToF = (float)iConfig.getParameter<double>("l_EcalPhiWedgeToF");
00024   L_EcalPhiWedgeConfidence = (float)iConfig.getParameter<double>("l_EcalPhiWedgeConfidence");
00025   L_EcalShowerShapesRoundness = (float)iConfig.getParameter<double>("l_EcalShowerShapesRoundness");
00026   L_EcalShowerShapesAngle =(float) iConfig.getParameter<double>("l_EcalShowerShapesAngle");  
00027   L_EcalSuperClusterSize = (int) iConfig.getParameter<int>("l_EcalSuperClusterSize");
00028   L_EcalSuperClusterEnergy = (float) iConfig.getParameter<double>("l_EcalSuperClusterEnergy");
00029 
00030   T_EcalPhiWedgeEnergy = (float)iConfig.getParameter<double>("t_EcalPhiWedgeEnergy");
00031   T_EcalPhiWedgeConstituents = iConfig.getParameter<int>("t_EcalPhiWedgeConstituents");
00032   T_EcalPhiWedgeToF = (float)iConfig.getParameter<double>("t_EcalPhiWedgeToF");
00033   T_EcalPhiWedgeConfidence = (float)iConfig.getParameter<double>("t_EcalPhiWedgeConfidence");
00034   T_EcalShowerShapesRoundness = (float)iConfig.getParameter<double>("t_EcalShowerShapesRoundness");
00035   T_EcalShowerShapesAngle = (float)iConfig.getParameter<double>("t_EcalShowerShapesAngle");
00036   T_EcalSuperClusterSize = (int) iConfig.getParameter<int>("t_EcalSuperClusterSize");
00037   T_EcalSuperClusterEnergy = (float) iConfig.getParameter<double>("t_EcalSuperClusterEnergy");
00038 
00039   L_HcalPhiWedgeEnergy = (float)iConfig.getParameter<double>("l_HcalPhiWedgeEnergy");
00040   L_HcalPhiWedgeConstituents = iConfig.getParameter<int>("l_HcalPhiWedgeConstituents");
00041   L_HcalPhiWedgeToF = (float)iConfig.getParameter<double>("l_HcalPhiWedgeToF");
00042   L_HcalPhiWedgeConfidence = (float)iConfig.getParameter<double>("l_HcalPhiWedgeConfidence");
00043   
00044   T_HcalPhiWedgeEnergy = (float)iConfig.getParameter<double>("t_HcalPhiWedgeEnergy");
00045   T_HcalPhiWedgeConstituents = iConfig.getParameter<int>("t_HcalPhiWedgeConstituents");
00046   T_HcalPhiWedgeToF = (float)iConfig.getParameter<double>("t_HcalPhiWedgeToF");
00047   T_HcalPhiWedgeConfidence = (float)iConfig.getParameter<double>("t_HcalPhiWedgeConfidence");
00048 
00049   produces<BeamHaloSummary>();
00050 }
00051 
00052 void BeamHaloSummaryProducer::produce(Event& iEvent, const EventSetup& iSetup)
00053 {
00054   // BeamHaloSummary object 
00055   std::auto_ptr<BeamHaloSummary> TheBeamHaloSummary( new BeamHaloSummary() );
00056 
00057   // CSC Specific Halo Data
00058   Handle<CSCHaloData> TheCSCHaloData;
00059   iEvent.getByLabel(IT_CSCHaloData, TheCSCHaloData);
00060 
00061   const CSCHaloData CSCData = (*TheCSCHaloData.product() );
00062   //Loose Id (any one of the three criteria)
00063   if( CSCData.NumberOfHaloTriggers() || CSCData.NumberOfHaloTracks() || CSCData.NumberOfOutOfTimeTriggers() )
00064     TheBeamHaloSummary->GetCSCHaloReport()[0] = 1;
00065 
00066   //Tight Id (any two of the previous three criteria)
00067   if( (CSCData.NumberOfHaloTriggers() && CSCData.NumberOfHaloTracks()) ||
00068       (CSCData.NumberOfHaloTriggers() && CSCData.NumberOfOutOfTimeTriggers()) ||
00069       (CSCData.NumberOfHaloTracks() && CSCData.NumberOfOutOfTimeTriggers() ) )
00070     TheBeamHaloSummary->GetCSCHaloReport()[1] = 1;
00071   
00072   //Ecal Specific Halo Data
00073   Handle<EcalHaloData> TheEcalHaloData;
00074   iEvent.getByLabel(IT_EcalHaloData, TheEcalHaloData);
00075   
00076   const EcalHaloData EcalData = (*TheEcalHaloData.product() );
00077 
00078   bool EcalLooseId = false, EcalTightId = false;
00079   /*  COMMENTED OUT, NEEDS TO BE TUNED 
00080   const std::vector<PhiWedge> EcalWedges = EcalData.GetPhiWedges();
00081   for( std::vector<PhiWedge>::const_iterator iWedge = EcalWedges.begin() ; iWedge != EcalWedges.end() ; iWedge++ )
00082     {
00083       bool EcaliPhi = false;
00084       
00085       //Loose Id
00086       if(iWedge-> Energy() > L_EcalPhiWedgeEnergy && iWedge->NumberOfConstituents() > L_EcalPhiWedgeConstituents && std::abs(iWedge->ZDirectionConfidence()) > L_EcalPhiWedgeConfidence)
00087         {
00088           EcalLooseId = true;
00089           EcaliPhi = true;
00090         }
00091 
00092       //Tight Id
00093       if( iWedge-> Energy() > T_EcalPhiWedgeEnergy  && iWedge->NumberOfConstituents() > T_EcalPhiWedgeConstituents && iWedge->ZDirectionConfidence() > L_EcalPhiWedgeConfidence )
00094         {
00095           EcalTightId = true;
00096           EcaliPhi = true;
00097         }
00098 
00099       for( unsigned int i = 0 ; i < TheBeamHaloSummary->GetEcaliPhiSuspects().size() ; i++ )
00100         {
00101           if( iWedge->iPhi() == TheBeamHaloSummary->GetEcaliPhiSuspects()[i] )
00102             {
00103               EcaliPhi = false;  // already stored this iPhi 
00104               continue;
00105             }
00106         }
00107 
00108       if( EcaliPhi ) 
00109         TheBeamHaloSummary->GetEcaliPhiSuspects().push_back( iWedge->iPhi() ) ;
00110         }
00111   */
00112 
00113   edm::ValueMap<float> vm_Angle = EcalData.GetShowerShapesAngle();
00114   edm::ValueMap<float> vm_Roundness = EcalData.GetShowerShapesRoundness();
00115 
00116   //Access selected SuperClusters
00117   for(unsigned int n = 0 ; n < EcalData.GetSuperClusters().size() ; n++ )
00118     {
00119       edm::Ref<SuperClusterCollection> cluster(EcalData.GetSuperClusters(), n );
00120 
00121       float angle = vm_Angle[cluster];
00122       float roundness = vm_Roundness[cluster];
00123 
00124       //Loose Selection
00125       if(  (angle > 0. && angle < L_EcalShowerShapesAngle ) && ( roundness > 0. && roundness < L_EcalShowerShapesRoundness ) )
00126         {
00127           if( cluster->energy() > L_EcalSuperClusterEnergy && cluster->size() > (unsigned int) L_EcalSuperClusterSize )
00128             EcalLooseId = true;
00129         }
00130 
00131       //Tight Selection 
00132       if(  (angle > 0. && angle < T_EcalShowerShapesAngle ) && ( roundness > 0. && roundness < T_EcalShowerShapesRoundness ) )
00133         {
00134           if( cluster->energy() > T_EcalSuperClusterEnergy && cluster->size() > (unsigned int)T_EcalSuperClusterSize )
00135             EcalTightId = true;
00136         }
00137     }
00138 
00139  if( EcalLooseId ) 
00140     TheBeamHaloSummary->GetEcalHaloReport()[0] = 1;
00141   if( EcalTightId ) 
00142     TheBeamHaloSummary->GetEcalHaloReport()[1] = 1;
00143   
00144 
00145 
00146   // Hcal Specific Halo Data
00147   Handle<HcalHaloData> TheHcalHaloData;
00148   iEvent.getByLabel(IT_HcalHaloData, TheHcalHaloData);
00149   const HcalHaloData HcalData = (*TheHcalHaloData.product() );
00150   const std::vector<PhiWedge> HcalWedges = HcalData.GetPhiWedges();
00151   bool HcalLooseId = false, HcalTightId = false;
00152   for( std::vector<PhiWedge>::const_iterator iWedge = HcalWedges.begin() ; iWedge != HcalWedges.end() ; iWedge++ )
00153     {
00154       bool HcaliPhi = false;
00155       //Loose Id
00156       if( iWedge-> Energy() > L_HcalPhiWedgeEnergy  && iWedge->NumberOfConstituents() > L_HcalPhiWedgeConstituents && std::abs(iWedge->ZDirectionConfidence()) > L_HcalPhiWedgeConfidence)
00157         {
00158           HcalLooseId = true;
00159           HcaliPhi = true;
00160         }
00161 
00162       //Tight Id
00163       if( iWedge-> Energy() > T_HcalPhiWedgeEnergy  && iWedge->NumberOfConstituents() > T_HcalPhiWedgeConstituents && std::abs(iWedge->ZDirectionConfidence()) > T_HcalPhiWedgeConfidence)
00164         {
00165           HcalTightId = true;
00166           HcaliPhi = true;
00167         }
00168       
00169       for( unsigned int i = 0 ; i < TheBeamHaloSummary->GetHcaliPhiSuspects().size() ; i++ )
00170         {
00171           if( iWedge->iPhi() == TheBeamHaloSummary->GetHcaliPhiSuspects()[i] )
00172             {
00173               HcaliPhi = false;  // already stored this iPhi 
00174               continue;
00175             }
00176         }
00177       if( HcaliPhi ) 
00178         TheBeamHaloSummary->GetHcaliPhiSuspects().push_back( iWedge->iPhi() ) ;
00179     }
00180   
00181   if( HcalLooseId ) 
00182     TheBeamHaloSummary->GetHcalHaloReport()[0] = 1;
00183   if( HcalTightId ) 
00184     TheBeamHaloSummary->GetHcalHaloReport()[1] = 1;
00185 
00186   // Global Halo Data
00187   Handle<GlobalHaloData> TheGlobalHaloData;
00188   iEvent.getByLabel(IT_GlobalHaloData, TheGlobalHaloData);
00189   bool GlobalLooseId = false;
00190   bool GlobalTightId = false;
00191   const GlobalHaloData GlobalData = (*TheGlobalHaloData.product() );
00192   const std::vector<PhiWedge> MatchedHcalWedges = GlobalData.GetMatchedHcalPhiWedges();
00193   const std::vector<PhiWedge> MatchedEcalWedges = GlobalData.GetMatchedEcalPhiWedges();
00194 
00195   //Loose Id
00196   if( MatchedEcalWedges.size() || MatchedHcalWedges.size() ) 
00197     GlobalLooseId = true;
00198 
00199   //Tight Id
00200   for( std::vector<PhiWedge>::const_iterator iWedge = MatchedEcalWedges.begin() ; iWedge != MatchedEcalWedges.end(); iWedge ++ )
00201     {
00202       if( iWedge->NumberOfConstituents() > T_EcalPhiWedgeConstituents )
00203         GlobalTightId = true;
00204       if( std::abs(iWedge->ZDirectionConfidence() > T_EcalPhiWedgeConfidence) )
00205         GlobalTightId = true;
00206     }
00207 
00208   for( std::vector<PhiWedge>::const_iterator iWedge = MatchedHcalWedges.begin() ; iWedge != MatchedHcalWedges.end(); iWedge ++ )
00209     {
00210       if( iWedge->NumberOfConstituents() > T_HcalPhiWedgeConstituents )
00211         GlobalTightId = true;
00212       if( std::abs(iWedge->ZDirectionConfidence()) > T_HcalPhiWedgeConfidence )
00213         GlobalTightId = true;
00214     }
00215 
00216   if( GlobalLooseId ) 
00217     TheBeamHaloSummary->GetGlobalHaloReport()[0] = 1;
00218   if( GlobalTightId )
00219     TheBeamHaloSummary->GetGlobalHaloReport()[1] = 1;
00220  
00221   iEvent.put(TheBeamHaloSummary);
00222   return;
00223 }
00224 
00225 void BeamHaloSummaryProducer::beginJob(){return;}
00226 void BeamHaloSummaryProducer::endJob(){return;}
00227 void BeamHaloSummaryProducer::beginRun(edm::Run&, const edm::EventSetup&){return;}
00228 void BeamHaloSummaryProducer::endRun(edm::Run&, const edm::EventSetup&){return;}
00229 BeamHaloSummaryProducer::~BeamHaloSummaryProducer(){}