00001
00002
00003
00004
00005
00013
00014
00015
00016
00017
00018
00019 #include "IsoTrig.h"
00020
00021
00022 #include "DataFormats/TrackReco/interface/Track.h"
00023 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00024 #include "DataFormats/TrackReco/interface/HitPattern.h"
00025 #include "DataFormats/TrackReco/interface/TrackBase.h"
00026
00027 #include "DataFormats/VertexReco/interface/VertexFwd.h"
00028 #include "DataFormats/VertexReco/interface/Vertex.h"
00029 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
00030
00031
00032 #include "DataFormats/Common/interface/TriggerResults.h"
00033 #include "DataFormats/HLTReco/interface/TriggerEvent.h"
00034 #include "DataFormats/HLTReco/interface/TriggerObject.h"
00035 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
00036 #include "DataFormats/Luminosity/interface/LumiDetails.h"
00037
00038 #include "FWCore/Common/interface/TriggerNames.h"
00039
00040 #include "Calibration/IsolatedParticles/interface/CaloPropagateTrack.h"
00041 #include "Calibration/IsolatedParticles/interface/ChargeIsolation.h"
00042 #include "Calibration/IsolatedParticles/interface/eCone.h"
00043 #include "Calibration/IsolatedParticles/interface/eECALMatrix.h"
00044
00045 #include "MagneticField/Engine/interface/MagneticField.h"
00046 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
00047 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
00048 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
00049 #include "Geometry/CaloEventSetup/interface/CaloTopologyRecord.h"
00050 #include "Geometry/CaloTopology/interface/CaloSubdetectorTopology.h"
00051 #include "Geometry/CaloTopology/interface/HcalTopology.h"
00052 #include "Geometry/CaloTopology/interface/CaloTopology.h"
00053 #include "CondFormats/DataRecord/interface/EcalChannelStatusRcd.h"
00054 #include "Geometry/CaloTopology/interface/EcalTrigTowerConstituentsMap.h"
00055 #include "RecoLocalCalo/EcalRecAlgos/interface/EcalSeverityLevelAlgo.h"
00056 #include "RecoLocalCalo/EcalRecAlgos/interface/EcalSeverityLevelAlgoRcd.h"
00057
00058 IsoTrig::IsoTrig(const edm::ParameterSet& iConfig) : changed(false) {
00059
00060 Det = iConfig.getParameter<std::string>("Det");
00061 verbosity = iConfig.getUntrackedParameter<int>("Verbosity",0);
00062 theTrackQuality = iConfig.getUntrackedParameter<std::string>("TrackQuality","highPurity");
00063 reco::TrackBase::TrackQuality trackQuality_=reco::TrackBase::qualityByName(theTrackQuality);
00064 selectionParameters.minPt = iConfig.getUntrackedParameter<double>("MinTrackPt", 10.0);
00065 selectionParameters.minQuality = trackQuality_;
00066 selectionParameters.maxDxyPV = iConfig.getUntrackedParameter<double>("MaxDxyPV", 0.2);
00067 selectionParameters.maxDzPV = iConfig.getUntrackedParameter<double>("MaxDzPV", 5.0);
00068 selectionParameters.maxChi2 = iConfig.getUntrackedParameter<double>("MaxChi2", 5.0);
00069 selectionParameters.maxDpOverP = iConfig.getUntrackedParameter<double>("MaxDpOverP", 0.1);
00070 selectionParameters.minOuterHit = iConfig.getUntrackedParameter<int>("MinOuterHit", 4);
00071 selectionParameters.minLayerCrossed = iConfig.getUntrackedParameter<int>("MinLayerCrossed", 8);
00072 selectionParameters.maxInMiss = iConfig.getUntrackedParameter<int>("MaxInMiss", 0);
00073 selectionParameters.maxOutMiss = iConfig.getUntrackedParameter<int>("MaxOutMiss", 0);
00074 dr_L1 = iConfig.getUntrackedParameter<double>("IsolationL1",1.0);
00075 a_coneR = iConfig.getUntrackedParameter<double>("ConeRadius",34.98);
00076 a_charIsoR = a_coneR + 28.9;
00077 a_neutIsoR = a_charIsoR*0.726;
00078 a_mipR = iConfig.getUntrackedParameter<double>("ConeRadiusMIP",14.0);
00079 a_neutR1 = iConfig.getUntrackedParameter<double>("ConeRadiusNeut1",21.0);
00080 a_neutR2 = iConfig.getUntrackedParameter<double>("ConeRadiusNeut2",29.0);
00081 cutMip = iConfig.getUntrackedParameter<double>("MIPCut", 1.0);
00082 cutCharge = iConfig.getUntrackedParameter<double>("ChargeIsolation", 2.0);
00083 cutNeutral = iConfig.getUntrackedParameter<double>("NeutralIsolation", 2.0);
00084 minRunNo = iConfig.getUntrackedParameter<int>("minRun");
00085 maxRunNo = iConfig.getUntrackedParameter<int>("maxRun");
00086 if (verbosity>=0) {
00087 std::cout <<"Parameters read from config file \n"
00088 <<"\t minPt " << selectionParameters.minPt
00089 <<"\t theTrackQuality " << theTrackQuality
00090 <<"\t minQuality " << selectionParameters.minQuality
00091 <<"\t maxDxyPV " << selectionParameters.maxDxyPV
00092 <<"\t maxDzPV " << selectionParameters.maxDzPV
00093 <<"\t maxChi2 " << selectionParameters.maxChi2
00094 <<"\t maxDpOverP " << selectionParameters.maxDpOverP
00095 <<"\t minOuterHit " << selectionParameters.minOuterHit
00096 <<"\t minLayerCrossed " << selectionParameters.minLayerCrossed
00097 <<"\t maxInMiss " << selectionParameters.maxInMiss
00098 <<"\t maxOutMiss " << selectionParameters.maxOutMiss
00099 <<"\t a_coneR " << a_coneR
00100 <<"\t a_charIsoR " << a_charIsoR
00101 <<"\t a_neutIsoR " << a_neutIsoR
00102 <<"\t a_mipR " << a_mipR
00103 <<"\t a_neutR " << a_neutR1 << ":" << a_neutR2
00104 <<"\t cuts (MIP " << cutMip << " : Charge " << cutCharge
00105 <<" : Neutral " << cutNeutral << ")"
00106 << std::endl;
00107 }
00108 }
00109
00110 IsoTrig::~IsoTrig() {
00111
00112
00113
00114 }
00115
00116 void IsoTrig::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
00117
00118 if (verbosity%10 > 0) std::cout << "Event starts====================================" << std::endl;
00119 int RunNo = iEvent.id().run();
00120 int EvtNo = iEvent.id().event();
00121 int Lumi = iEvent.luminosityBlock();
00122 int Bunch = iEvent.bunchCrossing();
00123
00124 edm::ESHandle<MagneticField> bFieldH;
00125 iSetup.get<IdealMagneticFieldRecord>().get(bFieldH);
00126 const MagneticField *bField = bFieldH.product();
00127
00128
00129 edm::ESHandle<CaloGeometry> pG;
00130 iSetup.get<CaloGeometryRecord>().get(pG);
00131 const CaloGeometry* geo = pG.product();
00132
00133 edm::Handle<reco::TrackCollection> trkCollection;
00134 iEvent.getByLabel("generalTracks", trkCollection);
00135 reco::TrackCollection::const_iterator trkItr;
00136
00137 edm::InputTag lumiProducer("LumiProducer", "", "RECO");
00138 edm::Handle<LumiDetails> Lumid;
00139 iEvent.getLuminosityBlock().getByLabel("lumiProducer",Lumid);
00140 float mybxlumi=-1;
00141 if (Lumid.isValid())
00142 mybxlumi=Lumid->lumiValue(LumiDetails::kOCC1,iEvent.bunchCrossing())*6.37;
00143 if (verbosity%10 > 0)
00144 std::cout << "RunNo " << RunNo << " EvtNo " << EvtNo << " Lumi " << Lumi
00145 << " Bunch " << Bunch << " mybxlumi " << mybxlumi << std::endl;
00146
00147 edm::InputTag triggerEvent_ ("hltTriggerSummaryAOD","","HLT");
00148 trigger::TriggerEvent triggerEvent;
00149 edm::Handle<trigger::TriggerEvent> triggerEventHandle;
00150 iEvent.getByLabel(triggerEvent_,triggerEventHandle);
00151 if (!triggerEventHandle.isValid())
00152 std::cout << "Error! Can't get the product "<< triggerEvent_.label() << std::endl;
00153 else {
00154 triggerEvent = *(triggerEventHandle.product());
00155
00156 const trigger::TriggerObjectCollection& TOC(triggerEvent.getObjects());
00158 edm::InputTag theTriggerResultsLabel ("TriggerResults","","HLT");
00159 edm::Handle<edm::TriggerResults> triggerResults;
00160 iEvent.getByLabel( theTriggerResultsLabel, triggerResults);
00161 char TrigName[50];
00162 sprintf(TrigName, "HLT_IsoTrack%s", Det.c_str());
00163 if (triggerResults.isValid()) {
00164 std::vector<std::string> modules;
00165 h_nHLT->Fill(triggerResults->size());
00166 const edm::TriggerNames & triggerNames = iEvent.triggerNames(*triggerResults);
00167
00168 const std::vector<std::string> & triggerNames_ = triggerNames.triggerNames();
00169 int hlt(-1), preL1(-1), preHLT(-1), prescale(-1);
00170 for (unsigned int i=0; i<triggerResults->size(); i++) {
00171 unsigned int triggerindx = hltConfig_.triggerIndex(triggerNames_[i]);
00172 const std::vector<std::string>& moduleLabels(hltConfig_.moduleLabels(triggerindx));
00173 if (triggerNames_[i].find(TrigName)!=std::string::npos) {
00174 const std::pair<int,int> prescales(hltConfig_.prescaleValues(iEvent,iSetup,triggerNames_[i]));
00175 hlt = triggerResults->accept(i);
00176 preL1 = prescales.first;
00177 preHLT = prescales.second;
00178 prescale = preL1*preHLT;
00179 if (verbosity%10 > 0)
00180 std::cout << triggerNames_[i] << " accept " << hlt << " preL1 "
00181 << preL1 << " preHLT " << preHLT << std::endl;
00182 if (hlt>0) {
00183 std::vector<math::XYZTLorentzVector> vec[3];
00184 if (TrigList.find(RunNo) != TrigList.end() ) {
00185 TrigList[RunNo] += 1;
00186 } else {
00187 TrigList.insert(std::pair<unsigned int, unsigned int>(RunNo,1));
00188 TrigPreList.insert(std::pair<unsigned int, std::pair<int, int>>(RunNo,prescales));
00189 }
00190
00191 for (unsigned int ifilter=0; ifilter<triggerEvent.sizeFilters(); ++ifilter) {
00192 std::vector<int> Keys;
00193 std::string label = triggerEvent.filterTag(ifilter).label();
00194
00195 for (unsigned int imodule=0; imodule<moduleLabels.size(); imodule++) {
00196 if (label.find(moduleLabels[imodule]) != std::string::npos) {
00197 if (verbosity%10 > 0) std::cout << "FILTERNAME " << label << std::endl;
00198 for (unsigned int ifiltrKey=0; ifiltrKey<triggerEvent.filterKeys(ifilter).size(); ++ifiltrKey) {
00199 Keys.push_back(triggerEvent.filterKeys(ifilter)[ifiltrKey]);
00200 const trigger::TriggerObject& TO(TOC[Keys[ifiltrKey]]);
00201 math::XYZTLorentzVector v4(TO.px(), TO.py(), TO.pz(), TO.energy());
00202 if(label.find("L2Filter") != std::string::npos) {
00203 vec[1].push_back(v4);
00204 } else if (label.find("L3Filter") != std::string::npos) {
00205 vec[2].push_back(v4);
00206 } else {
00207 vec[0].push_back(v4);
00208 h_L1ObjEnergy->Fill(TO.energy());
00209 }
00210 if (verbosity%10 > 0)
00211 std::cout << "key " << ifiltrKey << " : pt " << TO.pt() << " eta " << TO.eta() << " phi " << TO.phi() << " mass " << TO.mass() << " Id " << TO.id() << std::endl;
00212 }
00213 }
00214 }
00215 }
00216 h_nL3Objs -> Fill(vec[2].size());
00217
00219 for (int j=0; j<3; j++) {
00220 for (unsigned int k=0; k<vec[j].size(); k++) {
00221 if (verbosity%10 > 0) std::cout << "vec[" << j << "][" << k << "] pt " << vec[j][k].pt() << " eta " << vec[j][k].eta() << " phi " << vec[j][k].phi() << std::endl;
00222 fillHist(j, vec[j][k]);
00223 }
00224 }
00225
00226 double deta, dphi, dr;
00228 for (int lvl=1; lvl<3; lvl++) {
00229 for (unsigned int i=0; i<vec[lvl].size(); i++) {
00230 deta = dEta(vec[0][0],vec[lvl][i]);
00231 dphi = dPhi(vec[0][0],vec[lvl][i]);
00232 dr = dR(vec[0][0],vec[lvl][i]);
00233 if (verbosity%10 > 0) std::cout << "lvl " <<lvl << " i " << i << " deta " << deta << " dphi " << dphi << " dR " << dr << std::endl;
00234 h_dEtaL1[lvl-1] -> Fill(deta);
00235 h_dPhiL1[lvl-1] -> Fill(dphi);
00236 h_dRL1[lvl-1] -> Fill(std::sqrt(dr));
00237 }
00238 }
00239
00240 math::XYZTLorentzVector mindRvec;
00241 double mindR;
00242 for (unsigned int k=0; k<vec[2].size(); ++k) {
00244 mindR=999.9;
00245 if (verbosity%10 > 0) std::cout << "L3obj: pt " << vec[2][i].pt() << " eta " << vec[2][i].eta() << " phi " << vec[2][i].phi() << std::endl;
00246 for (unsigned int j=0; j<vec[1].size(); j++) {
00247 dr = dR(vec[2][k],vec[1][j]);
00248 if(dr<mindR) {
00249 mindR=dr;
00250 mindRvec=vec[1][j];
00251 }
00252 }
00253 fillDifferences(0, vec[2][k], mindRvec, (verbosity%10 >0));
00254 if(mindR < 0.03) {
00255 fillDifferences(1, vec[2][k], mindRvec, (verbosity%10 >0));
00256 fillHist(6, mindRvec);
00257 fillHist(8, vec[2][k]);
00258 } else {
00259 fillDifferences(2, vec[2][k], mindRvec, (verbosity%10 >0));
00260 fillHist(7, mindRvec);
00261 fillHist(9, vec[2][k]);
00262 }
00263
00265 mindR=999.9;
00266 if (verbosity%10 > 0) std::cout << "vec[2][k].eta() " << vec[2][k].eta() << " vec[k][0].phi " << vec[2][k].phi() << std::endl;
00267 reco::TrackCollection::const_iterator goodTk = trkCollection->end();
00268 if (trkCollection.isValid()) {
00269 double mindP = 9999.9;
00270 for (trkItr=trkCollection->begin();
00271 trkItr!=trkCollection->end(); trkItr++) {
00272 math::XYZTLorentzVector v4(trkItr->px(), trkItr->py(),
00273 trkItr->pz(), trkItr->p());
00274 double deltaR = dR(v4, vec[2][k]);
00275 double dp = std::abs(v4.r()/vec[2][k].r()-1.0);
00276 if (deltaR<mindR) {
00277 mindR = deltaR;
00278 mindP = dp;
00279 mindRvec = v4;
00280 goodTk = trkItr;
00281 }
00282 if ((verbosity/10)%10>1 && deltaR<1.0) {
00283 std::cout << "track: pt " << v4.pt() << " eta " << v4.eta()
00284 << " phi " << v4.phi() << " DR " << deltaR
00285 << std::endl;
00286 }
00287 }
00288 if (mindR < 0.03 && mindP > 0.1) {
00289 for (trkItr=trkCollection->begin();
00290 trkItr!=trkCollection->end(); trkItr++) {
00291 math::XYZTLorentzVector v4(trkItr->px(), trkItr->py(),
00292 trkItr->pz(), trkItr->p());
00293 double deltaR = dR(v4, vec[2][k]);
00294 double dp = std::abs(v4.r()/vec[2][k].r()-1.0);
00295 if (dp<mindP && deltaR<0.03) {
00296 mindR = deltaR;
00297 mindP = dp;
00298 mindRvec = v4;
00299 goodTk = trkItr;
00300 }
00301 }
00302 }
00303 fillDifferences(3, vec[2][k], mindRvec, (verbosity%10 >0));
00304 fillHist(3, mindRvec);
00305 if(mindR < 0.03) {
00306 fillDifferences(4, vec[2][k], mindRvec, (verbosity%10 >0));
00307 fillHist(4, mindRvec);
00308 } else {
00309 fillDifferences(5, vec[2][k], mindRvec, (verbosity%10 >0));
00310 fillHist(5, mindRvec);
00311 }
00312
00313
00314 edm::Handle<reco::VertexCollection> recVtxs;
00315 iEvent.getByLabel("offlinePrimaryVertices",recVtxs);
00316
00317 edm::Handle<reco::BeamSpot> beamSpotH;
00318 iEvent.getByLabel("offlineBeamSpot", beamSpotH);
00319 math::XYZPoint leadPV(0,0,0);
00320 if (recVtxs->size()>0 && !((*recVtxs)[0].isFake())) {
00321 leadPV = math::XYZPoint( (*recVtxs)[0].x(),(*recVtxs)[0].y(), (*recVtxs)[0].z() );
00322 } else if (beamSpotH.isValid()) {
00323 leadPV = beamSpotH->position();
00324 }
00325 if ((verbosity/100)%10>0) {
00326 std::cout << "Primary Vertex " << leadPV;
00327 if (beamSpotH.isValid()) std::cout << " Beam Spot "
00328 << beamSpotH->position();
00329 std::cout << std::endl;
00330 }
00331
00332 std::vector<spr::propagatedTrackDirection> trkCaloDirections;
00333 spr::propagateCALO(trkCollection, geo, bField, theTrackQuality, trkCaloDirections, ((verbosity/100)%10>2));
00334 std::vector<spr::propagatedTrackDirection>::const_iterator trkDetItr;
00335
00336 edm::Handle<EcalRecHitCollection> barrelRecHitsHandle;
00337 edm::Handle<EcalRecHitCollection> endcapRecHitsHandle;
00338 iEvent.getByLabel("ecalRecHit","EcalRecHitsEB",barrelRecHitsHandle);
00339 iEvent.getByLabel("ecalRecHit","EcalRecHitsEE",endcapRecHitsHandle);
00340
00341 unsigned int nTracks=0, ngoodTk=0, nselTk=0;
00342 int ieta=999;
00343 for (trkDetItr = trkCaloDirections.begin(); trkDetItr != trkCaloDirections.end(); trkDetItr++,nTracks++){
00344 bool l3Track = (trkDetItr->trkItr == goodTk);
00345 const reco::Track* pTrack = &(*(trkDetItr->trkItr));
00346 math::XYZTLorentzVector v4(pTrack->px(), pTrack->py(),
00347 pTrack->pz(), pTrack->p());
00348 bool selectTk = spr::goodTrack(pTrack,leadPV,selectionParameters,((verbosity/100)%10>2));
00349 double eMipDR=9999., e_inCone=0, conehmaxNearP=0, mindR=999.9;
00350 if (trkDetItr->okHCAL) {
00351 HcalDetId detId = (HcalDetId)(trkDetItr->detIdHCAL);
00352 ieta = detId.ieta();
00353 }
00354 for (unsigned k=0; k<vec[0].size(); ++k) {
00355 double deltaR = dR(v4, vec[0][k]);
00356 if (deltaR<mindR) mindR = deltaR;
00357 }
00358 if (selectTk && trkDetItr->okECAL && trkDetItr->okHCAL) {
00359 ngoodTk++;
00360 int nRH_eMipDR=0, nNearTRKs=0;
00361 double e1 = spr::eCone_ecal(geo, barrelRecHitsHandle, endcapRecHitsHandle,
00362 trkDetItr->pointHCAL, trkDetItr->pointECAL,
00363 a_neutR1, trkDetItr->directionECAL, nRH_eMipDR);
00364 double e2 = spr::eCone_ecal(geo, barrelRecHitsHandle, endcapRecHitsHandle,
00365 trkDetItr->pointHCAL, trkDetItr->pointECAL,
00366 a_neutR2, trkDetItr->directionECAL, nRH_eMipDR);
00367 eMipDR = spr::eCone_ecal(geo, barrelRecHitsHandle, endcapRecHitsHandle,
00368 trkDetItr->pointHCAL, trkDetItr->pointECAL,
00369 a_mipR, trkDetItr->directionECAL, nRH_eMipDR);
00370 conehmaxNearP = spr::chargeIsolationCone(nTracks, trkCaloDirections, a_charIsoR, nNearTRKs, ((verbosity/100)%10>2));
00371 e_inCone = e2 - e1;
00372 if (eMipDR<1.0) nselTk++;
00373 }
00374 if (l3Track) {
00375 fillHist(10,v4);
00376 if (selectTk) {
00377 fillHist(11,v4);
00378 fillCuts(0, eMipDR, conehmaxNearP, e_inCone, v4, ieta, (mindR>dr_L1));
00379 if (conehmaxNearP < cutCharge) {
00380 fillHist(12,v4);
00381 if (eMipDR < cutMip) {
00382 fillHist(13,v4);
00383 if (e_inCone < cutNeutral) fillHist(14, v4);
00384 }
00385 }
00386 }
00387 } else {
00388 fillHist(15,v4);
00389 if (selectTk) {
00390 fillHist(16,v4);
00391 fillCuts(1, eMipDR, conehmaxNearP, e_inCone, v4, ieta, (mindR>dr_L1));
00392 if (conehmaxNearP < cutCharge) {
00393 fillHist(17,v4);
00394 if (eMipDR < cutMip) {
00395 fillHist(18,v4);
00396 if (e_inCone < cutNeutral) fillHist(19, v4);
00397 }
00398 }
00399 }
00400 }
00401 }
00402 }
00403 }
00404 }
00405 break;
00406 }
00407 }
00408
00409 h_HLT -> Fill(hlt);
00410 h_PreL1 -> Fill(preL1);
00411 h_PreHLT -> Fill(preHLT);
00412 h_Pre -> Fill(prescale);
00413 h_PreL1wt -> Fill(preL1, mybxlumi);
00414 h_PreHLTwt -> Fill(preHLT, mybxlumi);
00415
00416
00417 if (changed) {
00418 changed = false;
00419 if ((verbosity/10)%10 > 1) {
00420 std::cout<<"New trigger menu found !!!" << std::endl;
00421 const unsigned int n(hltConfig_.size());
00422 for (unsigned itrig=0; itrig<triggerNames_.size(); itrig++) {
00423 unsigned int triggerindx = hltConfig_.triggerIndex(triggerNames_[itrig]);
00424 std::cout << triggerNames_[itrig] << " " << triggerindx << " ";
00425 if (triggerindx >= n)
00426 std::cout << "does not exist in the current menu" << std::endl;
00427 else
00428 std::cout << "exists" << std::endl;
00429 }
00430 }
00431 }
00432 }
00433 }
00434 }
00435
00436 void IsoTrig::beginJob() {
00437 char hname[100], htit[100];
00438 std::string levels[20] = {"L1", "L2", "L3",
00439 "Reco", "RecoMatch", "RecoNoMatch",
00440 "L2Match", "L2NoMatch", "L3Match", "L3NoMatch",
00441 "HLTTrk", "HLTGoodTrk", "HLTIsoTrk", "HLTMip", "HLTSelect",
00442 "nonHLTTrk", "nonHLTGoodTrk", "nonHLTIsoTrk", "nonHLTMip", "nonHLTSelect"};
00443 std::string pairs[6] = {"L2L3", "L2L3Match", "L2L3NoMatch", "L3Reco", "L3RecoMatch", "L3RecoNoMatch"};
00444
00445 std::string cuts[2] = {"HLTMatched", "HLTNotMatched"};
00446 std::string cuts2[2] = {"All", "Away from L1"};
00447 h_nHLT = fs->make<TH1I>("h_nHLT" , "size of rigger Names", 1000, 1, 1000);
00448 h_HLT = fs->make<TH1I>("h_HLT" , "HLT accept", 3, -1, 2);
00449 h_PreL1 = fs->make<TH1I>("h_PreL1", "L1 Prescale", 500, 0, 500);
00450 h_PreHLT = fs->make<TH1I>("h_PreHLT", "HLT Prescale", 50, 0, 50);
00451 h_Pre = fs->make<TH1I>("h_Pre", "Prescale", 3000, 0, 3000);
00452 h_nL3Objs = fs->make<TH1I>("h_nL3Objs", "Number of L3 objects", 10, 0, 10);
00453
00454 h_PreL1wt = fs->make<TH1D>("h_PreL1wt", "Weighted L1 Prescale", 500, 0, 500);
00455 h_PreHLTwt = fs->make<TH1D>("h_PreHLTwt", "Weighted HLT Prescale", 500, 0, 100);
00456 h_L1ObjEnergy = fs->make<TH1D>("h_L1ObjEnergy", "Energy of L1Object", 500, 0.0, 500.0);
00457
00458 for(int ipair=0; ipair<6; ipair++) {
00459 sprintf(hname, "h_dEta%s", pairs[ipair].c_str());
00460 sprintf(htit, "dEta for %s", pairs[ipair].c_str());
00461 h_dEta[ipair] = fs->make<TH1D>(hname, htit, 200, -10.0, 10.0);
00462 h_dEta[ipair]->GetXaxis()->SetTitle("d#eta");
00463
00464 sprintf(hname, "h_dPhi%s", pairs[ipair].c_str());
00465 sprintf(htit, "dPhi for %s", pairs[ipair].c_str());
00466 h_dPhi[ipair] = fs->make<TH1D>(hname, htit, 140, -7.0, 7.0);
00467 h_dPhi[ipair]->GetXaxis()->SetTitle("d#phi");
00468
00469 sprintf(hname, "h_dPt%s", pairs[ipair].c_str());
00470 sprintf(htit, "dPt for %s objects", pairs[ipair].c_str());
00471 h_dPt[ipair] = fs->make<TH1D>(hname, htit, 400, -200.0, 200.0);
00472 h_dPt[ipair]->GetXaxis()->SetTitle("dp_{T} (GeV)");
00473
00474 sprintf(hname, "h_dP%s", pairs[ipair].c_str());
00475 sprintf(htit, "dP for %s objects", pairs[ipair].c_str());
00476 h_dP[ipair] = fs->make<TH1D>(hname, htit, 400, -200.0, 200.0);
00477 h_dP[ipair]->GetXaxis()->SetTitle("dP (GeV)");
00478
00479 sprintf(hname, "h_dinvPt%s", pairs[ipair].c_str());
00480 sprintf(htit, "dinvPt for %s objects", pairs[ipair].c_str());
00481 h_dinvPt[ipair] = fs->make<TH1D>(hname, htit, 500, -0.4, 0.1);
00482 h_dinvPt[ipair]->GetXaxis()->SetTitle("d(1/p_{T})");
00483
00484 sprintf(hname, "h_mindR%s", pairs[ipair].c_str());
00485 sprintf(htit, "mindR for %s objects", pairs[ipair].c_str());
00486 h_mindR[ipair] = fs->make<TH1D>(hname, htit, 500, 0.0, 1.0);
00487 h_mindR[ipair]->GetXaxis()->SetTitle("dR");
00488 }
00489
00490 for(int ilevel=0; ilevel<20; ilevel++) {
00491 sprintf(hname, "h_p%s", levels[ilevel].c_str());
00492 sprintf(htit, "p for %s objects", levels[ilevel].c_str());
00493 h_p[ilevel] = fs->make<TH1D>(hname, htit, 100, 0.0, 500.0);
00494 h_p[ilevel]->GetXaxis()->SetTitle("p (GeV)");
00495
00496 sprintf(hname, "h_pt%s", levels[ilevel].c_str());
00497 sprintf(htit, "pt for %s objects", levels[ilevel].c_str());
00498 h_pt[ilevel] = fs->make<TH1D>(hname, htit, 100, 0.0, 500.0);
00499 h_pt[ilevel]->GetXaxis()->SetTitle("p_{T} (GeV)");
00500
00501 sprintf(hname, "h_eta%s", levels[ilevel].c_str());
00502 sprintf(htit, "eta for %s objects", levels[ilevel].c_str());
00503 h_eta[ilevel] = fs->make<TH1D>(hname, htit, 100, -5.0, 5.0);
00504 h_eta[ilevel]->GetXaxis()->SetTitle("#eta");
00505
00506 sprintf(hname, "h_phi%s", levels[ilevel].c_str());
00507 sprintf(htit, "phi for %s objects", levels[ilevel].c_str());
00508 h_phi[ilevel] = fs->make<TH1D>(hname, htit, 70, -3.5, 3.50);
00509 h_phi[ilevel]->GetXaxis()->SetTitle("#phi");
00510 }
00511 for(int lvl=0; lvl<2; lvl++) {
00512 sprintf(hname, "h_dEtaL1%s", levels[lvl+1].c_str());
00513 sprintf(htit, "dEta for L1 and %s objects", levels[lvl+1].c_str());
00514 h_dEtaL1[lvl] = fs->make<TH1D>(hname, htit, 400, -10.0, 10.0);
00515
00516 sprintf(hname, "h_dPhiL1%s", levels[lvl+1].c_str());
00517 sprintf(htit, "dPhi for L1 and %s objects", levels[lvl+1].c_str());
00518 h_dPhiL1[lvl] = fs->make<TH1D>(hname, htit, 280, -7.0, 7.0);
00519
00520 sprintf(hname, "h_dRL1%s", levels[lvl+1].c_str());
00521 sprintf(htit, "dR for L1 and %s objects", levels[lvl+1].c_str());
00522 h_dRL1[lvl] = fs->make<TH1D>(hname, htit, 100, 0.0, 10.0);
00523 }
00524
00525 for(int icut=0; icut<2; icut++) {
00526 sprintf(hname, "h_eMip%s", cuts[icut].c_str());
00527 sprintf(htit, "eMip for %s tracks", cuts[icut].c_str());
00528 h_eMip[icut] =fs->make<TH1D>(hname, htit, 200, 0.0, 10.0);
00529 h_eMip[icut]->GetXaxis()->SetTitle("E_{Mip} (GeV)");
00530
00531 sprintf(hname, "h_eMaxNearP%s", cuts[icut].c_str());
00532 sprintf(htit, "eMaxNearP for %s tracks", cuts[icut].c_str());
00533 h_eMaxNearP[icut]=fs->make<TH1D>(hname, htit, 240, -2.0, 10.0);
00534 h_eMaxNearP[icut]->GetXaxis()->SetTitle("E_{MaxNearP} (GeV)");
00535
00536 sprintf(hname, "h_eNeutIso%s", cuts[icut].c_str());
00537 sprintf(htit, "eNeutIso for %s ", cuts[icut].c_str());
00538 h_eNeutIso[icut] =fs->make<TH1D>(hname, htit, 200, 0.0, 10.0);
00539 h_eNeutIso[icut]->GetXaxis()->SetTitle("E_{NeutIso} (GeV)");
00540
00541 for (int kcut=0; kcut<2; ++kcut) {
00542 sprintf(hname, "h_etaCalibTracks%s%d", cuts[icut].c_str(), kcut);
00543 sprintf(htit, "etaCalibTracks for %s (%s)", cuts[icut].c_str(), cuts2[kcut].c_str());
00544 h_etaCalibTracks[icut][kcut]=fs->make<TH1D>(hname, htit, 60, -30.0, 30.0);
00545 h_etaCalibTracks[icut][kcut]->GetXaxis()->SetTitle("i#eta");
00546
00547 sprintf(hname, "h_etaMipTracks%s%d", cuts[icut].c_str(), kcut);
00548 sprintf(htit, "etaMipTracks for %s (%s)", cuts[icut].c_str(), cuts2[kcut].c_str());
00549 h_etaMipTracks[icut][kcut]=fs->make<TH1D>(hname, htit, 60, -30.0, 30.0);
00550 h_etaMipTracks[icut][kcut]->GetXaxis()->SetTitle("i#eta");
00551 }
00552 }
00553 }
00554
00555 void IsoTrig::endJob() {
00556 unsigned int preL1, preHLT;
00557 std::map<unsigned int, unsigned int>::iterator itr;
00558 std::map<unsigned int, const std::pair<int, int>>::iterator itrPre;
00559 std::cout << "RunNo vs HLT accepts for " << Det << std::endl;
00560 unsigned int n = maxRunNo - minRunNo +1;
00561 g_Pre = fs->make<TH1I>("h_PrevsRN", "PreScale Vs Run Number", n, minRunNo, maxRunNo);
00562 g_PreL1 = fs->make<TH1I>("h_PreL1vsRN", "L1 PreScale Vs Run Number", n, minRunNo, maxRunNo);
00563 g_PreHLT = fs->make<TH1I>("h_PreHLTvsRN", "HLT PreScale Vs Run Number", n, minRunNo, maxRunNo);
00564 g_Accepts = fs->make<TH1I>("h_HLTAcceptsvsRN", "HLT Accepts Vs Run Number", n, minRunNo, maxRunNo);
00565
00566 for (itr=TrigList.begin(), itrPre=TrigPreList.begin(); itr!=TrigList.end(); itr++, itrPre++) {
00567 preL1 = (itrPre->second).first;
00568 preHLT = (itrPre->second).second;
00569 std::cout << itr->first << " " << itr->second << " " << itrPre->first << " " << preL1 << " " << preHLT << std::endl;
00570 g_Accepts->Fill(itr->first, itr->second);
00571 g_PreL1->Fill(itr->first, preL1);
00572 g_PreHLT->Fill(itr->first, preHLT);
00573 g_Pre->Fill(itr->first, preL1*preHLT);
00574 }
00575 }
00576
00577
00578 void IsoTrig::beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) {
00579 std::cout << "Run " << iRun.run() << " hltconfig.init "
00580 << hltConfig_.init(iRun,iSetup,"HLT",changed) << std::endl;;
00581 }
00582
00583
00584 void IsoTrig::endRun(edm::Run const&, edm::EventSetup const&) {}
00585
00586
00587 void IsoTrig::beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) {}
00588
00589 void IsoTrig::endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) {}
00590
00591 void IsoTrig::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
00592
00593
00594 edm::ParameterSetDescription desc;
00595 desc.setUnknown();
00596 descriptions.addDefault(desc);
00597 }
00598
00599 void IsoTrig::fillHist(int indx, math::XYZTLorentzVector& vec) {
00600 h_p[indx]->Fill(vec.r());
00601 h_pt[indx]->Fill(vec.pt());
00602 h_eta[indx]->Fill(vec.eta());
00603 h_phi[indx]->Fill(vec.phi());
00604 }
00605
00606 void IsoTrig::fillDifferences(int indx, math::XYZTLorentzVector& vec1,
00607 math::XYZTLorentzVector& vec2, bool debug) {
00608 double dr = dR(vec1,vec2);
00609 double deta = dEta(vec1, vec2);
00610 double dphi = dPhi(vec1, vec2);
00611 double dpt = dPt(vec1, vec2);
00612 double dp = dP(vec1, vec2);
00613 double dinvpt = dinvPt(vec1, vec2);
00614 h_dEta[indx] ->Fill(deta);
00615 h_dPhi[indx] ->Fill(dphi);
00616 h_dPt[indx] ->Fill(dpt);
00617 h_dP[indx] ->Fill(dp);
00618 h_dinvPt[indx]->Fill(dinvpt);
00619 h_mindR[indx] ->Fill(dr);
00620 if (debug) std::cout << "mindR for index " << indx << " is " << dr << " deta " << deta
00621 << " dphi " << dphi << " dpt " << dpt << " dinvpt " << dinvpt <<std::endl;
00622 }
00623
00624 void IsoTrig::fillCuts(int indx, double eMipDR, double conehmaxNearP, double e_inCone, math::XYZTLorentzVector& vec, int ieta, bool cut) {
00625 h_eMip[indx] ->Fill(eMipDR);
00626 h_eMaxNearP[indx]->Fill(conehmaxNearP);
00627 h_eNeutIso[indx] ->Fill(e_inCone);
00628 if (conehmaxNearP < cutCharge && eMipDR < cutMip && vec.r()<60 && vec.r()>40) {
00629 h_etaMipTracks[indx][0]->Fill((double)(ieta));
00630 if (cut) h_etaMipTracks[indx][1]->Fill((double)(ieta));
00631 if (e_inCone < cutNeutral) {
00632 h_etaCalibTracks[indx][0]->Fill((double)(ieta));
00633 if (cut) h_etaCalibTracks[indx][1]->Fill((double)(ieta));
00634 }
00635 }
00636 }
00637
00638 double IsoTrig::dEta(math::XYZTLorentzVector& vec1, math::XYZTLorentzVector& vec2) {
00639 return (vec1.eta()-vec2.eta());
00640 }
00641
00642 double IsoTrig::dPhi(math::XYZTLorentzVector& vec1, math::XYZTLorentzVector& vec2) {
00643
00644 double phi1 = vec1.phi();
00645 if (phi1 < 0) phi1 += 2.0*M_PI;
00646 double phi2 = vec2.phi();
00647 if (phi2 < 0) phi2 += 2.0*M_PI;
00648 double dphi = phi1-phi2;
00649 if (dphi > M_PI) dphi -= 2.*M_PI;
00650 else if (dphi < -M_PI) dphi += 2.*M_PI;
00651 return dphi;
00652 }
00653
00654 double IsoTrig::dR(math::XYZTLorentzVector& vec1, math::XYZTLorentzVector& vec2) {
00655 double deta = dEta(vec1,vec2);
00656 double dphi = dPhi(vec1,vec2);
00657 return std::sqrt(deta*deta + dphi*dphi);
00658 }
00659
00660 double IsoTrig::dPt(math::XYZTLorentzVector& vec1, math::XYZTLorentzVector& vec2) {
00661 return (vec1.pt()-vec2.pt());
00662 }
00663
00664 double IsoTrig::dP(math::XYZTLorentzVector& vec1, math::XYZTLorentzVector& vec2) {
00665 return (std::abs(vec1.r()-vec2.r()));
00666 }
00667
00668 double IsoTrig::dinvPt(math::XYZTLorentzVector& vec1, math::XYZTLorentzVector& vec2) {
00669 return ((1/vec1.pt())-(1/vec2.pt()));
00670 }
00671
00672 DEFINE_FWK_MODULE(IsoTrig);