00001
00002
00003
00004
00005
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <memory>
00023
00024
00025
00026 #include "FWCore/Framework/interface/ESHandle.h"
00027
00028 #include "FWCore/Framework/interface/Frameworkfwd.h"
00029 #include "FWCore/Framework/interface/EDAnalyzer.h"
00030
00031 #include "FWCore/Framework/interface/Event.h"
00032 #include "FWCore/Framework/interface/MakerMacros.h"
00033
00034 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00035
00036 #include "DataFormats/HLTReco/interface/TriggerEvent.h"
00037 #include "DataFormats/L1Trigger/interface/L1JetParticle.h"
00038 #include "DataFormats/L1Trigger/interface/L1JetParticleFwd.h"
00039
00040 #include "CondFormats/L1TObjects/interface/L1GtTriggerMenu.h"
00041 #include "CondFormats/DataRecord/interface/L1GtTriggerMenuRcd.h"
00042 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetupFwd.h"
00043 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetup.h"
00044 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
00045
00046 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00047 #include "DataFormats/TrackReco/interface/Track.h"
00048
00049 #include "CondFormats/L1TObjects/interface/L1GtPrescaleFactors.h"
00050 #include "CondFormats/DataRecord/interface/L1GtPrescaleFactorsAlgoTrigRcd.h"
00051 #include "CondFormats/DataRecord/interface/L1GtPrescaleFactorsTechTrigRcd.h"
00052
00053 #include "DQMServices/Core/interface/DQMStore.h"
00054 #include "DQMServices/Core/interface/MonitorElement.h"
00055 #include "FWCore/ServiceRegistry/interface/Service.h"
00056
00057 #include "DataFormats/HcalIsolatedTrack/interface/IsolatedPixelTrackCandidate.h"
00058 #include "DataFormats/HcalIsolatedTrack/interface/IsolatedPixelTrackCandidateFwd.h"
00059
00060
00061
00062
00063 #include "SimDataFormats/Track/interface/SimTrack.h"
00064 #include "SimDataFormats/Track/interface/SimTrackContainer.h"
00065
00066
00067
00068 #include "Calibration/HcalCalibAlgos/plugins/ValidationHcalIsoTrackAlCaReco.h"
00069 #include <fstream>
00070
00071 #include "TH1F.h"
00072
00073
00074 double ValidationHcalIsoTrackAlCaReco::getDist(double eta1, double phi1, double eta2, double phi2)
00075 {
00076 double dphi = fabs(phi1 - phi2);
00077 if(dphi>acos(-1)) dphi = 2*acos(-1)-dphi;
00078 double dr = sqrt(dphi*dphi + pow(eta1-eta2,2));
00079 return dr;
00080 }
00081
00082
00083
00084 double ValidationHcalIsoTrackAlCaReco::getDistInCM(double eta1, double phi1, double eta2, double phi2)
00085 {
00086 double dR, Rec;
00087 double theta1=2*atan(exp(-eta1));
00088 double theta2=2*atan(exp(-eta2));
00089 if (fabs(eta1)<1.479) Rec=129;
00090 else Rec=275;
00091
00092 dR=fabs((Rec/sin(theta1))*tan(acos(sin(theta1)*sin(theta2)*(sin(phi1)*sin(phi2)+cos(phi1)*cos(phi2))+cos(theta1)*cos(theta2))));
00093 return dR;
00094 }
00095
00096
00097
00098 std::pair<int,int> ValidationHcalIsoTrackAlCaReco::towerIndex(double eta, double phi)
00099 {
00100 int ieta=0;
00101 int iphi=0;
00102 for (int i=1; i<21; i++)
00103 {
00104 if (fabs(eta)<(i*0.087)&&fabs(eta)>(i-1)*0.087) ieta=int(fabs(eta)/eta)*i;
00105 }
00106 if (fabs(eta)>1.740&&fabs(eta)<1.830) ieta=int(fabs(eta)/eta)*21;
00107 if (fabs(eta)>1.830&&fabs(eta)<1.930) ieta=int(fabs(eta)/eta)*22;
00108 if (fabs(eta)>1.930&&fabs(eta)<2.043) ieta=int(fabs(eta)/eta)*23;
00109
00110 double delta=phi+0.174532925;
00111 if (delta<0) delta=delta+2*acos(-1);
00112 if (fabs(eta)<1.740)
00113 {
00114 for (int i=0; i<72; i++)
00115 {
00116 if (delta<(i+1)*0.087266462&&delta>i*0.087266462) iphi=i;
00117 }
00118 }
00119 else
00120 {
00121 for (int i=0; i<36; i++)
00122 {
00123 if (delta<2*(i+1)*0.087266462&&delta>2*i*0.087266462) iphi=2*i;
00124 }
00125 }
00126
00127 return std::pair<int,int>(ieta,iphi);
00128 }
00129
00130
00131 ValidationHcalIsoTrackAlCaReco::ValidationHcalIsoTrackAlCaReco(const edm::ParameterSet& iConfig)
00132
00133 {
00134 folderName_ = iConfig.getParameter<std::string>("folderName");
00135 saveToFile_=iConfig.getParameter<bool>("saveToFile");
00136 outRootFileName_=iConfig.getParameter<std::string>("outputRootFileName");
00137 hltEventTag_=iConfig.getParameter<edm::InputTag>("hltTriggerEventLabel");
00138 hltFilterTag_=iConfig.getParameter<edm::InputTag>("hltL3FilterLabel");
00139 arITrLabel_=iConfig.getParameter<edm::InputTag>("alcarecoIsoTracksLabel");
00140 recoTrLabel_=iConfig.getParameter<edm::InputTag>("recoTracksLabel");
00141 pThr_=iConfig.getUntrackedParameter<double>("pThrL3",0);
00142 heLow_=iConfig.getUntrackedParameter<double>("lowerHighEnergyCut",40);
00143 heLow_=iConfig.getUntrackedParameter<double>("upperHighEnergyCut",60);
00144
00145 nTotal=0;
00146 nHLTL3accepts=0;
00147 }
00148
00149 ValidationHcalIsoTrackAlCaReco::~ValidationHcalIsoTrackAlCaReco()
00150 {}
00151
00152 void ValidationHcalIsoTrackAlCaReco::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00153 {
00154 nTotal++;
00155
00156 edm::Handle<trigger::TriggerEvent> trEv;
00157 iEvent.getByLabel(hltEventTag_,trEv);
00158
00159 edm::Handle<reco::IsolatedPixelTrackCandidateCollection> recoIsoTracks;
00160 iEvent.getByLabel(arITrLabel_,recoIsoTracks);
00161
00162 const trigger::TriggerObjectCollection& TOCol(trEv->getObjects());
00163
00164 trigger::Keys KEYS;
00165 const trigger::size_type nFilt(trEv->sizeFilters());
00166 for (trigger::size_type iFilt=0; iFilt!=nFilt; iFilt++)
00167 {
00168 if (trEv->filterTag(iFilt)==hltFilterTag_)
00169 {
00170 KEYS=trEv->filterKeys(iFilt);
00171 }
00172 }
00173
00174 trigger::size_type nReg=KEYS.size();
00175
00176 std::vector<double> trigEta;
00177 std::vector<double> trigPhi;
00178 bool trig=false;
00179
00180
00181 for (trigger::size_type iReg=0; iReg<nReg; iReg++)
00182 {
00183 const trigger::TriggerObject& TObj(TOCol[KEYS[iReg]]);
00184 if (TObj.p()<pThr_) continue;
00185 hl3eta->Fill(TObj.eta(),1);
00186 hl3AbsEta->Fill(fabs(TObj.eta()),1);
00187 hl3phi->Fill(TObj.phi(),1);
00188
00189 if (recoIsoTracks->size()>0)
00190 {
00191 double minRecoL3dist=1000;
00192 reco::IsolatedPixelTrackCandidateCollection::const_iterator mrtr;
00193 for (reco::IsolatedPixelTrackCandidateCollection::const_iterator rtrit=recoIsoTracks->begin(); rtrit!=recoIsoTracks->end(); rtrit++)
00194 {
00195 double R=getDist(rtrit->eta(),rtrit->phi(),TObj.eta(),TObj.phi());
00196 if (R<minRecoL3dist)
00197 {
00198 mrtr=rtrit;
00199 minRecoL3dist=R;
00200 }
00201 }
00202 hOffL3TrackMatch->Fill(minRecoL3dist,1);
00203 hOffL3TrackPtRat->Fill(TObj.pt()/mrtr->pt(),1);
00204 }
00205
00206 hl3Pt->Fill(TObj.pt(),1);
00207 trig=true;
00208 trigEta.push_back(TObj.eta());
00209 trigPhi.push_back(TObj.phi());
00210 }
00211
00212
00213 for (reco::IsolatedPixelTrackCandidateCollection::const_iterator itr=recoIsoTracks->begin(); itr!=recoIsoTracks->end(); itr++)
00214 {
00215 bool match=false;
00216 for (unsigned int l=0; l<trigEta.size(); l++)
00217 {
00218 if (getDist(itr->eta(),itr->phi(),trigEta[l],trigPhi[l])<0.2) match=true;
00219 }
00220 if (match&&trig)
00221 {
00222 hOffEtaFP->Fill(itr->eta(),1);
00223 hOffPhiFP->Fill(itr->phi(),1);
00224 }
00225
00226 hOffEta->Fill(itr->eta(),1);
00227 hOffPhi->Fill(itr->phi(),1);
00228
00229 hOffAbsEta->Fill(fabs(itr->eta()),1);
00230
00231 hDeposEcalInner->Fill(itr->energyIn(),1);
00232 hDeposEcalOuter->Fill(itr->energyOut(),1);
00233
00234 hTracksSumP->Fill(itr->sumPtPxl(),1);
00235 hTracksMaxP->Fill(itr->maxPtPxl(),1);
00236
00237 if (fabs(itr->eta())<0.5) hOffP_0005->Fill(itr->p(),1);
00238 if (fabs(itr->eta())>0.5&&fabs(itr->eta())<1.0) hOffP_0510->Fill(itr->p(),1);
00239 if (fabs(itr->eta())>1.0&&fabs(itr->eta())<1.5) hOffP_1015->Fill(itr->p(),1);
00240 if (fabs(itr->eta())<1.5&&fabs(itr->eta())<2.0) hOffP_1520->Fill(itr->p(),1);
00241
00242 hOffP->Fill(itr->p(),1);
00243
00244 std::pair<int,int> TI=towerIndex(itr->eta(),itr->phi());
00245 hOccupancyFull->Fill(TI.first,TI.second,1);
00246 if (itr->p()>heLow_&&itr->p()<heUp_) hOccupancyHighEn->Fill(TI.first,TI.second,1);
00247 }
00248
00249
00250
00251 std::cout << std::endl << " End / Start " << std::endl;
00252
00253 edm::Handle<edm::SimTrackContainer> simTracks;
00254 iEvent.getByType<edm::SimTrackContainer>(simTracks);
00255
00256 for (reco::IsolatedPixelTrackCandidateCollection::const_iterator bll=recoIsoTracks->begin(); bll!=recoIsoTracks->end(); bll++)
00257 {
00258
00259 std::cout<<"ISO Pt " << bll->pt() << " P " << bll->p() << " Eta "<< bll->eta() << " Phi "<< bll->phi()<< std::endl;
00260
00261 double distanceMin = 1.;
00262 double SimPtMatched = 1.;
00263 double SimPhiMatched = 1.;
00264 double SimEtaMatched = 1.;
00265 double SimDistMatched = 1.;
00266 double SimPMatched = 1.;
00267 double neuen = 0.;
00268 double neuenm = 0.;
00269 int neun = 0;
00270
00271 for(edm::SimTrackContainer::const_iterator tracksCI = simTracks->begin();
00272 tracksCI != simTracks->end(); tracksCI++){
00273
00274 int partIndex = tracksCI->genpartIndex();
00275 if (tracksCI->momentum().eta() > (bll->eta()-0.1)
00276 && tracksCI->momentum().eta() < (bll->eta()+0.1)
00277 && tracksCI->momentum().phi() > (bll->phi()-0.1)
00278 && tracksCI->momentum().phi() < (bll->phi()+0.1)
00279
00280
00281 && tracksCI->momentum().e() > 2.
00282 && fabs(tracksCI->charge()) == 1 && partIndex >0)
00283 {
00284
00285 double distance=getDist(tracksCI->momentum().eta(),tracksCI->momentum().phi(),bll->eta(),bll->phi());
00286 double distanceCM=getDistInCM(tracksCI->momentum().eta(),tracksCI->momentum().phi(),bll->eta(),bll->phi());
00287
00288 if (distanceMin > distance) {
00289 distanceMin = distance;
00290 SimPtMatched = tracksCI->momentum().pt();
00291 SimPhiMatched = tracksCI->momentum().phi();
00292 SimEtaMatched = tracksCI->momentum().eta();
00293 SimDistMatched = distance;
00294 SimPMatched = sqrt(tracksCI->momentum().pt()*tracksCI->momentum().pt() + tracksCI->momentum().pz()*tracksCI->momentum().pz());
00295 }
00296
00297 std::cout<<" Pt "<<tracksCI->momentum().pt()
00298 << " Energy " << tracksCI->momentum().e()
00299 << " Eta "<< tracksCI->momentum().eta()
00300 << " Phi "<< tracksCI->momentum().phi()
00301 << " Ind " << partIndex
00302 << " Cha " << tracksCI->charge()
00303 << " Dis " << distance
00304 << " DCM " << distanceCM
00305 << std::endl;
00306
00307 }
00308
00309
00310 if (
00311 tracksCI->momentum().eta() > (bll->eta()-0.5)
00312 && tracksCI->momentum().eta() < (bll->eta()+0.5)
00313 && tracksCI->momentum().phi() > (bll->phi()-0.5)
00314 && tracksCI->momentum().phi() < (bll->phi()+0.5)
00315
00316 && tracksCI->charge() == 0 && partIndex >0)
00317 {
00318
00319 double distance=getDist(tracksCI->momentum().eta(),tracksCI->momentum().phi(),bll->eta(),bll->phi());
00320 double distanceCM=getDistInCM(tracksCI->momentum().eta(),tracksCI->momentum().phi(),bll->eta(),bll->phi());
00321
00322 std::cout<<"NEU Pt "<<tracksCI->momentum().pt()
00323 << " Energy " << tracksCI->momentum().e()
00324 << " Eta "<< tracksCI->momentum().eta()
00325 << " Phi "<< tracksCI->momentum().phi()
00326 << " Ind " << partIndex
00327 << " Cha " << tracksCI->charge()
00328 << " Dis " << distance
00329 << " DCM " << distanceCM
00330 << std::endl;
00331
00332 if (distanceCM < 40.){
00333
00334 neuen = neuen + tracksCI->momentum().e();
00335 neun = neun + 1;
00336 if (neuenm < tracksCI->momentum().e()) neuenm = tracksCI->momentum().e();
00337
00338 }
00339
00340 }
00341
00342 }
00343
00344 hSimNN->Fill(neun,1);
00345 hSimNE->Fill(neuen,1);
00346 hSimNM->Fill(neuenm,1);
00347
00348 if (distanceMin < 0.1) {
00349
00350 hSimPt->Fill(SimPtMatched,1);
00351 hSimPhi->Fill(SimPhiMatched,1);
00352 hSimEta->Fill(SimEtaMatched,1);
00353 hSimAbsEta->Fill(fabs(SimEtaMatched),1);
00354 hSimDist->Fill(SimDistMatched,1);
00355 hSimPtRatOff->Fill(SimPtMatched/bll->pt(),1);
00356 hSimP->Fill(SimPMatched,1);
00357 hSimN->Fill(1,1);
00358
00359 std::cout<<"S Pt "<< SimPtMatched
00360 << std::endl;
00361 }
00362
00363 if (distanceMin > 0.1) {
00364 hSimN->Fill(0,1);
00365 }
00366
00367
00368
00369
00370 }
00371
00372
00373
00374
00375
00376 }
00377
00378 void ValidationHcalIsoTrackAlCaReco::beginJob()
00379 {
00380 dbe_ = edm::Service<DQMStore>().operator->();
00381 dbe_->setCurrentFolder(folderName_);
00382
00383 hl3Pt=dbe_->book1D("hl3Pt","pT of hlt L3 objects",1000,0,1000);
00384 hl3Pt->setAxisTitle("pT(GeV)",1);
00385 hl3eta=dbe_->book1D("hl3eta","eta of hlt L3 objects",16,-2,2);
00386 hl3eta->setAxisTitle("eta",1);
00387 hl3AbsEta=dbe_->book1D("hl3AbsEta","|eta| of hlt L3 objects",8,0,2);
00388 hl3AbsEta->setAxisTitle("eta",1);
00389 hl3phi=dbe_->book1D("hl3phi","phi of hlt L3 objects",16,-3.2,3.2);
00390 hl3phi->setAxisTitle("phi",1);
00391
00392 hOffEta=dbe_->book1D("hOffEta","eta of alcareco objects",100,-2,2);
00393 hOffEta->setAxisTitle("eta",1);
00394 hOffPhi=dbe_->book1D("hOffPhi","phi of alcareco objects",100,-3.2,3.2);
00395 hOffPhi->setAxisTitle("phi",1);
00396 hOffP=dbe_->book1D("hOffP","p of alcareco objects",1000,0,1000);
00397 hOffP->setAxisTitle("E(GeV)",1);
00398 hOffP_0005=dbe_->book1D("hOffP_0005","p of alcareco objects, |eta|<0.5",1000,0,1000);
00399 hOffP_0005->setAxisTitle("E(GeV)",1);
00400 hOffP_0510=dbe_->book1D("hOffP_0510","p of alcareco objects, 0.5<|eta|<1.0",1000,0,1000);
00401 hOffP_0510->setAxisTitle("E(GeV)",1);
00402 hOffP_1015=dbe_->book1D("hOffP_1015","p of alcareco objects, 1.0<|eta|<1.5",1000,0,1000);
00403 hOffP_1015->setAxisTitle("E(GeV)",1);
00404 hOffP_1520=dbe_->book1D("hOffP_1520","p of alcareco objects, 1.5<|eta|<2.0",1000,0,1000);
00405 hOffP_1520->setAxisTitle("E(GeV)",1);
00406 hOffEtaFP=dbe_->book1D("hOffEtaFP","eta of alcareco objects, FP",16,-2,2);
00407 hOffEtaFP->setAxisTitle("eta",1);
00408 hOffAbsEta=dbe_->book1D("hOffAbsEta","|eta| of alcareco objects",8,0,2);
00409 hOffAbsEta->setAxisTitle("|eta|",1);
00410 hOffPhiFP=dbe_->book1D("hOffPhiFP","phi of alcareco objects, FP",16,-3.2,3.2);
00411 hOffPhiFP->setAxisTitle("phi",1);
00412 hTracksSumP=dbe_->book1D("hTracksSumP","summary p of tracks in the isolation cone",100,0,20);
00413 hTracksSumP->setAxisTitle("E(GeV)");
00414 hTracksMaxP=dbe_->book1D("hTracksMaxP","maximum p among tracks in the isolation cone",100,0,20);
00415 hTracksMaxP->setAxisTitle("E(GeV)");
00416
00417 hDeposEcalInner=dbe_->book1D("hDeposEcalInner","ecal energy deposition in inner cone around track",1000,0,1000);
00418 hDeposEcalInner->setAxisTitle("E(GeV)");
00419 hDeposEcalOuter=dbe_->book1D("hDeposEcalOuter","ecal energy deposition in outer cone around track",1000,0,1000);
00420 hDeposEcalOuter->setAxisTitle("E(GeV)");
00421
00422 hOccupancyFull=dbe_->book2D("hOccupancyFull","number of tracks per tower, full energy range",48,-25,25,73,0,73);
00423 hOccupancyFull->setAxisTitle("ieta",1);
00424 hOccupancyFull->setAxisTitle("iphi",2);
00425 hOccupancyFull->getTH2F()->SetOption("colz");
00426 hOccupancyFull->getTH2F()->SetStats(kFALSE);
00427 hOccupancyHighEn=dbe_->book2D("hOccupancyHighEn","number of tracks per tower, high energy tracks",48,-25,25,73,0,73);
00428 hOccupancyHighEn->setAxisTitle("ieta",1);
00429 hOccupancyHighEn->setAxisTitle("iphi",2);
00430 hOccupancyHighEn->getTH2F()->SetOption("colz");
00431 hOccupancyHighEn->getTH2F()->SetStats(kFALSE);
00432
00433 hOffL3TrackMatch=dbe_->book1D("hOffL3TrackMatch","Distance from L3 object to offline track",200,0,0.5);
00434 hOffL3TrackMatch->setAxisTitle("R(eta,phi)",1);
00435 hOffL3TrackPtRat=dbe_->book1D("hOffL3TrackPtRat","Ratio of pT: L3/offline",100,0,10);
00436 hOffL3TrackPtRat->setAxisTitle("ratio L3/offline",1);
00437
00438
00439
00440
00441 hSimPt=dbe_->book1D("hSimPt","pT of matched SimTrack",1000,0,1000);
00442 hSimPt->setAxisTitle("pT(GeV)",1);
00443
00444 hSimPhi=dbe_->book1D("hSimPhi","Phi of matched SimTrack",100,-3.2,3.2);
00445 hSimPhi->setAxisTitle("phi",1);
00446
00447 hSimEta=dbe_->book1D("hSimEta","Eta of matched SimTrack",100,-2.,2.);
00448 hSimEta->setAxisTitle("eta",1);
00449
00450 hSimAbsEta=dbe_->book1D("hSimAbsEta","|eta| of matched SimTrack",8,0.,2.);
00451 hSimAbsEta->setAxisTitle("|eta|",1);
00452
00453 hSimDist=dbe_->book1D("hSimDist","Distance from matched SimTrack to Offline Track",200,0,0.1);
00454 hSimDist->setAxisTitle("R(eta,phi)",1);
00455
00456 hSimPtRatOff=dbe_->book1D("hSimPtRatOff","pT Sim / pT Offline",100,0,10);
00457 hSimPtRatOff->setAxisTitle("pT Sim / pT Offline",1);
00458
00459 hSimP=dbe_->book1D("hSimP","p of matched SimTrack",1000,0,1000);
00460 hSimP->setAxisTitle("p(GeV)",1);
00461
00462 hSimN=dbe_->book1D("hSimN","Number matched",2,0,2);
00463 hSimN->setAxisTitle("Offline/SimTRack - Matched or Not",1);
00464
00465 hSimNN=dbe_->book1D("hSimNN","Number of the neutral particles in cone on ECAL",100,0,100);
00466 hSimNN->setAxisTitle("Number",1);
00467
00468 hSimNE=dbe_->book1D("hSimNE","Total energy of the neutral particles in cone on ECAL",100,0,100);
00469 hSimNE->setAxisTitle("Energy",1);
00470
00471 hSimNM=dbe_->book1D("hSimNM","Maximum energy of the neutral particles in cone on ECAL",100,0,100);
00472 hSimNM->setAxisTitle("Energy",1);
00473
00474
00475
00476
00477 }
00478
00479 void ValidationHcalIsoTrackAlCaReco::endJob() {
00480
00481 if(dbe_)
00482 {
00483 if (saveToFile_) dbe_->save(outRootFileName_);
00484 }
00485 }
00486