CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/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 
00063   //CSCLoose Id for 2011 
00064   if( CSCData.NumberOfHaloTriggers() ||
00065       CSCData.NumberOfHaloTracks()   ||
00066       (CSCData.NOutOfTimeHits() > 10 && CSCData.NFlatHaloSegments() > 2 ) ||
00067       CSCData.GetSegmentsInBothEndcaps() ||
00068       CSCData.NTracksSmalldT() )
00069     TheBeamHaloSummary->GetCSCHaloReport()[0] = 1;
00070 
00071   //CSCTight Id for 2011
00072   if( (CSCData.NumberOfHaloTriggers() && CSCData.NumberOfHaloTracks()) ||
00073       (CSCData.NOutOfTimeHits() > 10 && CSCData.NumberOfHaloTriggers() ) ||
00074       (CSCData.NOutOfTimeHits() > 10 && CSCData.NumberOfHaloTracks() ) ||
00075       CSCData.GetSegmentsInBothEndcaps() ||
00076       (CSCData.NTracksSmalldT() && CSCData.NumberOfHaloTracks() ) ||
00077       (CSCData.NFlatHaloSegments() > 3 && (CSCData.NumberOfHaloTriggers() || CSCData.NumberOfHaloTracks()) ))
00078     TheBeamHaloSummary->GetCSCHaloReport()[1] = 1;
00079 
00080   //CSCLoose Id from 2010
00081   if( CSCData.NumberOfHaloTriggers() || CSCData.NumberOfHaloTracks() || CSCData.NumberOfOutOfTimeTriggers() )
00082     TheBeamHaloSummary->GetCSCHaloReport()[2] = 1;
00083 
00084   //CSCTight Id from 2010
00085   if( (CSCData.NumberOfHaloTriggers() && CSCData.NumberOfHaloTracks()) ||
00086       (CSCData.NumberOfHaloTriggers() && CSCData.NumberOfOutOfTimeTriggers()) ||
00087       (CSCData.NumberOfHaloTracks() && CSCData.NumberOfOutOfTimeTriggers() ) )
00088     TheBeamHaloSummary->GetCSCHaloReport()[3] = 1;
00089 
00090 
00091   //Ecal Specific Halo Data
00092   Handle<EcalHaloData> TheEcalHaloData;
00093   iEvent.getByLabel(IT_EcalHaloData, TheEcalHaloData);
00094   
00095   const EcalHaloData EcalData = (*TheEcalHaloData.product() );
00096   
00097   bool EcalLooseId = false, EcalTightId = false;
00098   /*  COMMENTED OUT, NEEDS TO BE TUNED 
00099       const std::vector<PhiWedge> EcalWedges = EcalData.GetPhiWedges();
00100       for( std::vector<PhiWedge>::const_iterator iWedge = EcalWedges.begin() ; iWedge != EcalWedges.end() ; iWedge++ )
00101     {
00102       bool EcaliPhi = false;
00103       
00104       //Loose Id
00105       if(iWedge-> Energy() > L_EcalPhiWedgeEnergy && iWedge->NumberOfConstituents() > L_EcalPhiWedgeConstituents && std::abs(iWedge->ZDirectionConfidence()) > L_EcalPhiWedgeConfidence)
00106         {
00107           EcalLooseId = true;
00108           EcaliPhi = true;
00109         }
00110 
00111       //Tight Id
00112       if( iWedge-> Energy() > T_EcalPhiWedgeEnergy  && iWedge->NumberOfConstituents() > T_EcalPhiWedgeConstituents && iWedge->ZDirectionConfidence() > L_EcalPhiWedgeConfidence )
00113         {
00114           EcalTightId = true;
00115           EcaliPhi = true;
00116         }
00117 
00118       for( unsigned int i = 0 ; i < TheBeamHaloSummary->GetEcaliPhiSuspects().size() ; i++ )
00119         {
00120           if( iWedge->iPhi() == TheBeamHaloSummary->GetEcaliPhiSuspects()[i] )
00121             {
00122               EcaliPhi = false;  // already stored this iPhi 
00123               continue;
00124             }
00125         }
00126 
00127       if( EcaliPhi ) 
00128         TheBeamHaloSummary->GetEcaliPhiSuspects().push_back( iWedge->iPhi() ) ;
00129         }
00130   */
00131 
00132   edm::ValueMap<float> vm_Angle = EcalData.GetShowerShapesAngle();
00133   edm::ValueMap<float> vm_Roundness = EcalData.GetShowerShapesRoundness();
00134   
00135   //Access selected SuperClusters
00136   for(unsigned int n = 0 ; n < EcalData.GetSuperClusters().size() ; n++ )
00137     {
00138       edm::Ref<SuperClusterCollection> cluster(EcalData.GetSuperClusters(), n );
00139       
00140       float angle = vm_Angle[cluster];
00141       float roundness = vm_Roundness[cluster];
00142       
00143       //Loose Selection
00144       if(  (angle > 0. && angle < L_EcalShowerShapesAngle ) && ( roundness > 0. && roundness < L_EcalShowerShapesRoundness ) )
00145         {
00146           if( cluster->energy() > L_EcalSuperClusterEnergy && cluster->size() > (unsigned int) L_EcalSuperClusterSize )
00147             EcalLooseId = true;
00148         }
00149 
00150       //Tight Selection 
00151       if(  (angle > 0. && angle < T_EcalShowerShapesAngle ) && ( roundness > 0. && roundness < T_EcalShowerShapesRoundness ) )
00152         {
00153           if( cluster->energy() > T_EcalSuperClusterEnergy && cluster->size() > (unsigned int)T_EcalSuperClusterSize )
00154             EcalTightId = true;
00155         }
00156     }
00157   
00158   if( EcalLooseId ) 
00159     TheBeamHaloSummary->GetEcalHaloReport()[0] = 1;
00160   if( EcalTightId ) 
00161     TheBeamHaloSummary->GetEcalHaloReport()[1] = 1;
00162 
00163   // Hcal Specific Halo Data
00164   Handle<HcalHaloData> TheHcalHaloData;
00165   iEvent.getByLabel(IT_HcalHaloData, TheHcalHaloData);
00166   const HcalHaloData HcalData = (*TheHcalHaloData.product() );
00167   const std::vector<PhiWedge> HcalWedges = HcalData.GetPhiWedges();
00168   bool HcalLooseId = false, HcalTightId = false;
00169   for( std::vector<PhiWedge>::const_iterator iWedge = HcalWedges.begin() ; iWedge != HcalWedges.end() ; iWedge++ )
00170     {
00171       bool HcaliPhi = false;
00172       //Loose Id
00173       if( iWedge-> Energy() > L_HcalPhiWedgeEnergy  && iWedge->NumberOfConstituents() > L_HcalPhiWedgeConstituents && std::abs(iWedge->ZDirectionConfidence()) > L_HcalPhiWedgeConfidence)
00174         {
00175           HcalLooseId = true;
00176           HcaliPhi = true;
00177         }
00178 
00179       //Tight Id
00180       if( iWedge-> Energy() > T_HcalPhiWedgeEnergy  && iWedge->NumberOfConstituents() > T_HcalPhiWedgeConstituents && std::abs(iWedge->ZDirectionConfidence()) > T_HcalPhiWedgeConfidence)
00181         {
00182           HcalTightId = true;
00183           HcaliPhi = true;
00184         }
00185       
00186       for( unsigned int i = 0 ; i < TheBeamHaloSummary->GetHcaliPhiSuspects().size() ; i++ )
00187         {
00188           if( iWedge->iPhi() == TheBeamHaloSummary->GetHcaliPhiSuspects()[i] )
00189             {
00190               HcaliPhi = false;  // already stored this iPhi 
00191               continue;
00192             }
00193         }
00194       if( HcaliPhi ) 
00195         TheBeamHaloSummary->GetHcaliPhiSuspects().push_back( iWedge->iPhi() ) ;
00196     }
00197   
00198   if( HcalLooseId ) 
00199     TheBeamHaloSummary->GetHcalHaloReport()[0] = 1;
00200   if( HcalTightId ) 
00201     TheBeamHaloSummary->GetHcalHaloReport()[1] = 1;
00202 
00203   // Global Halo Data
00204   Handle<GlobalHaloData> TheGlobalHaloData;
00205   iEvent.getByLabel(IT_GlobalHaloData, TheGlobalHaloData);
00206   bool GlobalLooseId = false;
00207   bool GlobalTightId = false;
00208   const GlobalHaloData GlobalData = (*TheGlobalHaloData.product() );
00209   const std::vector<PhiWedge> MatchedHcalWedges = GlobalData.GetMatchedHcalPhiWedges();
00210   const std::vector<PhiWedge> MatchedEcalWedges = GlobalData.GetMatchedEcalPhiWedges();
00211 
00212   //Loose Id
00213   if( MatchedEcalWedges.size() || MatchedHcalWedges.size() ) 
00214     GlobalLooseId = true;
00215 
00216   //Tight Id
00217   for( std::vector<PhiWedge>::const_iterator iWedge = MatchedEcalWedges.begin() ; iWedge != MatchedEcalWedges.end(); iWedge ++ )
00218     {
00219       if( iWedge->NumberOfConstituents() > T_EcalPhiWedgeConstituents )
00220         GlobalTightId = true;
00221       if( std::abs(iWedge->ZDirectionConfidence() > T_EcalPhiWedgeConfidence) )
00222         GlobalTightId = true;
00223     }
00224 
00225   for( std::vector<PhiWedge>::const_iterator iWedge = MatchedHcalWedges.begin() ; iWedge != MatchedHcalWedges.end(); iWedge ++ )
00226     {
00227       if( iWedge->NumberOfConstituents() > T_HcalPhiWedgeConstituents )
00228         GlobalTightId = true;
00229       if( std::abs(iWedge->ZDirectionConfidence()) > T_HcalPhiWedgeConfidence )
00230         GlobalTightId = true;
00231     }
00232 
00233   if( GlobalLooseId ) 
00234     TheBeamHaloSummary->GetGlobalHaloReport()[0] = 1;
00235   if( GlobalTightId )
00236     TheBeamHaloSummary->GetGlobalHaloReport()[1] = 1;
00237  
00238   iEvent.put(TheBeamHaloSummary);
00239   return;
00240 }
00241 
00242 BeamHaloSummaryProducer::~BeamHaloSummaryProducer(){}