CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/HLTrigger/HLTanalyzers/src/HLTHeavyIon.cc

Go to the documentation of this file.
00001 #include <iostream>
00002 #include <sstream>
00003 #include <istream>
00004 #include <fstream>
00005 #include <iomanip>
00006 #include <string>
00007 #include <cmath>
00008 #include <functional>
00009 #include <stdlib.h>
00010 #include <string.h>
00011 
00012 #include "HLTrigger/HLTanalyzers/interface/HLTHeavyIon.h"
00013 #include "FWCore/Common/interface/TriggerNames.h"
00014 
00015 // L1 related
00016 #include "L1Trigger/GlobalTriggerAnalyzer/interface/L1GtUtils.h"
00017 
00018 #include "DataFormats/HeavyIonEvent/interface/Centrality.h"
00019 using namespace std;
00020 
00021 HLTHeavyIon::HLTHeavyIon() {
00022 
00023   //set parameter defaults 
00024    _Monte = false;
00025   _Debug=false;
00026   _OR_BXes=false;
00027   UnpackBxInEvent=1;
00028 
00029 }
00030 
00031 void HLTHeavyIon::beginRun(const edm::Run& run, const edm::EventSetup& c){ 
00032 
00033 
00034   bool changed(true);
00035   if (hltConfig_.init(run,c,processName_,changed)) {
00036     // if init returns TRUE, initialisation has succeeded!
00037     if (changed) {
00038       // The HLT config has actually changed wrt the previous Run, hence rebook your
00039       // histograms or do anything else dependent on the revised HLT config
00040       cout << "Initalizing HLTConfigProvider"  << endl;
00041     }
00042   } else {
00043     // if init returns FALSE, initialisation has NOT succeeded, which indicates a problem
00044     // with the file and/or code and needs to be investigated!
00045     cout << " HLT config extraction failure with process name " << processName_ << endl;
00046     // In this case, all access methods will return empty values!
00047   }
00048 
00049 }
00050 
00051 /*  Setup the analysis to put the branch-variables into the tree. */
00052 void HLTHeavyIon::setup(const edm::ParameterSet& pSet, TTree* HltTree) {
00053 
00054 
00055   processName_ = pSet.getParameter<std::string>("HLTProcessName") ;
00056 
00057   edm::ParameterSet myHltParams = pSet.getParameter<edm::ParameterSet>("RunParameters") ;
00058   vector<std::string> parameterNames = myHltParams.getParameterNames() ;
00059   
00060   for ( vector<std::string>::iterator iParam = parameterNames.begin();
00061         iParam != parameterNames.end(); iParam++ ){
00062     if ( (*iParam) == "Debug" ) _Debug =  myHltParams.getParameter<bool>( *iParam );
00063     if ( (*iParam) == "Monte" ) _Monte =  myHltParams.getParameter<bool>( *iParam );
00064 
00065   }
00066 
00067   HltEvtCnt = 0;
00068   const int kMaxEvtPlanes = 1000;
00069 
00070   fNpart = -1;
00071   fNcoll = -1;
00072   fNhard = -1;
00073   fPhi0 = -1;
00074   fb = -1;
00075   fNcharged = -1;
00076   fNchargedMR = -1;
00077   fMeanPt = -1;
00078   fMeanPtMR = -1;
00079 
00080   fEtMR = -1;
00081   fNchargedPtCut = -1;
00082   fNchargedPtCutMR = -1;
00083 
00084   nEvtPlanes = 0;
00085   hiBin = -1;
00086   hiEvtPlane = new float[kMaxEvtPlanes];
00087 
00088   HltTree->Branch("Npart",&fNpart,"Npart/F");
00089   HltTree->Branch("Ncoll",&fNcoll,"Ncoll/F");
00090   HltTree->Branch("Nhard",&fNhard,"Nhard/F");
00091   HltTree->Branch("phi0",&fPhi0,"NPhi0/F");
00092   HltTree->Branch("b",&fb,"b/F");
00093   HltTree->Branch("Ncharged",&fNcharged,"Ncharged/I");
00094   HltTree->Branch("NchargedMR",&fNchargedMR,"NchargedMR/I");
00095   HltTree->Branch("MeanPt",&fMeanPt,"MeanPt/F");
00096   HltTree->Branch("MeanPtMR",&fMeanPtMR,"MeanPtMR/F");
00097   HltTree->Branch("EtMR",&fEtMR,"EtMR/F");
00098   HltTree->Branch("NchargedPtCut",&fNchargedPtCut,"NchargedPtCut/I");
00099   HltTree->Branch("NchargedPtCutMR",&fNchargedPtCutMR,"NchargedPtCutMR/I");
00100   HltTree->Branch("hiBin",&hiBin,"hiBin/I");
00101   HltTree->Branch("hiHF",&hiHF,"hiHF/F");
00102   HltTree->Branch("hiHFplus",&hiHFplus,"hiHFplus/F");
00103   HltTree->Branch("hiHFminus",&hiHFminus,"hiHFminus/F");
00104   HltTree->Branch("hiZDC",&hiZDC,"hiZDC/F");
00105   HltTree->Branch("hiZDCplus",&hiZDCplus,"hiZDCplus/F");
00106   HltTree->Branch("hiZDCminus",&hiZDCminus,"hiZDCminus/F");
00107 
00108   HltTree->Branch("hiHFhit",&hiHFhit,"hiHFhit/F");
00109   HltTree->Branch("hiHFhitPlus",&hiHFhitPlus,"hiHFhitPlus/F");
00110   HltTree->Branch("hiHFhitMinus",&hiHFhitMinus,"hiHFhitMinus/F");
00111 
00112   HltTree->Branch("hiET",&hiET,"hiET/F");
00113   HltTree->Branch("hiEE",&hiEE,"hiEE/F");
00114   HltTree->Branch("hiEB",&hiEB,"hiEB/F");
00115   HltTree->Branch("hiEEplus",&hiEEplus,"hiEEplus/F");
00116   HltTree->Branch("hiEEminus",&hiEEminus,"hiEEminus/F");
00117   HltTree->Branch("hiNpix",&hiNpix,"hiNpix/I");
00118   HltTree->Branch("hiNpixelTracks",&hiNpixelTracks,"hiNpixelTracks/I");
00119   HltTree->Branch("hiNtracks",&hiNtracks,"hiNtracks/I");
00120   HltTree->Branch("hiNevtPlane",&nEvtPlanes,"hiNevtPlane/I");
00121   HltTree->Branch("hiEvtPlanes",hiEvtPlane,"hiEvtPlanes/F");
00122   HltTree->Branch("hiNtracksPtCut",&hiNtracksPtCut,"hiNtracksPtCut/I");
00123   HltTree->Branch("hiNtracksEtaCut",&hiNtracksEtaCut,"hiNtracksEtaCut/I");
00124   HltTree->Branch("hiNtracksEtaPtCut",&hiNtracksEtaPtCut,"hiNtracksEtaPtCut/I");
00125 
00126 }
00127 
00128 /* **Analyze the event** */
00129 void HLTHeavyIon::analyze(const edm::Handle<edm::TriggerResults>                 & hltresults,
00130                           const edm::Handle<reco::Centrality>    & centrality,
00131                           const edm::Handle<reco::EvtPlaneCollection> & evtPlanes,
00132                           const edm::Handle<edm::GenHIEvent> & mc,
00133                       edm::EventSetup const& eventSetup,
00134                       edm::Event const& iEvent,
00135                       TTree* HltTree) {
00136 
00137    std::cout << " Beginning HLTHeavyIon " << std::endl;
00138 
00139    if(_Monte){
00140       fb = mc->b();
00141       fNpart = mc->Npart();
00142       fNcoll = mc->Ncoll();
00143       fNhard = mc->Nhard();
00144       fPhi0 = mc->evtPlane();
00145       fNcharged = mc->Ncharged();
00146       fNchargedMR = mc->NchargedMR();
00147       fMeanPt = mc->MeanPt();
00148       fMeanPtMR = mc->MeanPtMR();
00149       fEtMR = mc->EtMR();
00150       fNchargedPtCut = mc->NchargedPtCut();
00151       fNchargedPtCutMR = mc->NchargedPtCutMR();
00152    }
00153 
00154    edm::Handle<int> binHandle;
00155    iEvent.getByLabel("centralityBin",binHandle);
00156    hiBin = *binHandle;
00157 
00158   hiNpix = centrality->multiplicityPixel();
00159   hiNpixelTracks = centrality->NpixelTracks();
00160   hiNtracks = centrality->Ntracks();
00161   hiNtracksPtCut = centrality->NtracksPtCut();
00162   hiNtracksEtaCut = centrality->NtracksEtaCut();
00163   hiNtracksEtaPtCut = centrality->NtracksEtaPtCut();
00164 
00165   hiHF = centrality->EtHFtowerSum();
00166   hiHFplus = centrality->EtHFtowerSumPlus();
00167   hiHFminus = centrality->EtHFtowerSumMinus();
00168   hiHFhit = centrality->EtHFhitSum();
00169   hiHFhitPlus = centrality->EtHFhitSumPlus();
00170   hiHFhitMinus = centrality->EtHFhitSumMinus();
00171 
00172   hiZDC = centrality->zdcSum();
00173   hiZDCplus = centrality->zdcSumPlus();
00174   hiZDCminus = centrality->zdcSumMinus();
00175 
00176   hiEEplus = centrality->EtEESumPlus();
00177   hiEEminus = centrality->EtEESumMinus();
00178   hiEE = centrality->EtEESum();
00179   hiEB = centrality->EtEBSum();
00180   hiET = centrality->EtMidRapiditySum();
00181 
00182   
00183   if(evtPlanes.isValid()){
00184      nEvtPlanes = evtPlanes->size();
00185      for(unsigned int i = 0; i < evtPlanes->size(); ++i){
00186         hiEvtPlane[i] = (*evtPlanes)[i].angle();     
00187      }
00188   }
00189   
00190 }