18 #include "CLHEP/Vector/LorentzVector.h"
66 #include "TGraphErrors.h"
85 std::cout<<
"[ZeeCalibration] Starting the ctor"<<std::endl;
117 outputFile_ = TFile::Open(outputFileName_.c_str(),
"RECREATE");
119 myTree =
new TTree(
"myTree",
"myTree");
121 myTree->Branch(
"zMass",&
mass4tree,
"mass/F");
160 findingRecord<EcalIntercalibConstantsRcd> () ;
162 for(
int i = 0;
i<50;
i++){
172 std::cout<<
"[ZeeCalibration] Done with the ctor"<<std::endl;
186 boost::shared_ptr<EcalIntercalibConstants>
189 std::cout <<
"@SUB=ZeeCalibration::produceEcalIntercalibConstants" << std::endl;
212 if(ieta==0)
continue;
246 std::cout<<
"Writing histos..."<<std::endl;
275 for(
unsigned int i =0;
i<25;
i++){
312 Double_t
mean[25] = {0.};
313 Double_t
num[25] = {0.};
314 Double_t meanErr[25] = {0.};
315 Float_t
rms[25] = {0.};
316 Float_t tempRms[10][25];
318 for(
int ia = 0; ia<10; ia++){
319 for(
int ib = 0; ib<25; ib++){
321 tempRms[ia][ib] = 0.;
334 bool isNearCrack =
false;
399 if(
k>=170 &&
k<=204){
439 if(
k>=205 &&
k<=208){
487 for(
int ic = 0; ic< 17; ic++){
489 mean[ic] = mean[ic] / num[ic];
491 meanErr[ic] = 1. /
sqrt(meanErr[ic]);
497 for(
int ic = 0; ic< 25; ic++){
498 for(
int id = 0;
id< 10;
id++){
500 if(tempRms[
id][ic] > 0.){
502 rms[ic] += (tempRms[
id][ic] - mean[
j])*(tempRms[
id][ic] - mean[j]);
507 rms[ic] =
sqrt(rms[ic]);
514 Double_t xtalEta[25] = {1.4425, 1.3567,1.2711,1.1855,
516 0.7468,0.6612,0.5756,0.4897,0.3985,0.3117,0.2250,0.1384,0.0487,
517 1.546, 1.651, 1.771, 1.908, 2.071, 2.267, 2.516, 2.8};
519 Double_t
zero[25] = {0.026};
521 for(
int j = 0; j <25; j++)
528 px->SetXTitle(
"Eta channel");
529 px->SetYTitle(
"recalibCoeff");
549 double weightSumMeanBarrel = 0.;
550 double weightSumMeanEndcap = 0.;
588 std::cout<<
"Weight sum mean on channels in Barrel is :"<<weightSumMeanBarrel<<std::endl;
589 std::cout<<
"Weight sum mean on channels in Endcap is :"<<weightSumMeanEndcap<<std::endl;
601 TGraphErrors*
graph =
new TGraphErrors(25,xtalEta,mean,zero,meanErr);
605 double zero50[50] = { 0. };
608 residualSigmaGraph->SetName(
"residualSigmaGraph");
609 residualSigmaGraph->Draw(
"APL");
610 residualSigmaGraph->Write();
613 coefficientDistanceAtIterationGraph->SetName(
"coefficientDistanceAtIterationGraph");
614 coefficientDistanceAtIterationGraph->Draw(
"APL");
615 coefficientDistanceAtIterationGraph->Write();
617 Float_t noError[250] = {0.};
619 Float_t ringInd[250];
620 for(
int i =0;
i<250;
i++)
624 graphCoeff->SetName(
"graphCoeff");
625 graphCoeff->Draw(
"APL");
664 std::cout<<
"[ZeeCalibration] Entering duringLoop"<<std::endl;
683 std::cout<<
"[ZeeCalibration::beginOfJob] Histograms booked "<<std::endl;
701 std::cout<<
"[ZeeCalibration::beginOfJob] Parsed EB miscal file"<<std::endl;
710 std::cout<<
"[ZeeCalibration::beginOfJob] Parsed EE miscal file"<<std::endl;
714 std::cout <<
" theAlgorithm_->getNumberOfChannels() "
724 std::vector<DetId> ringIds;
738 for (
unsigned int iid=0; iid<ringIds.size();++iid)
740 float miscalib=* (miscalibMap->
get().
getMap().
find(ringIds[iid]) );
759 std::vector<DetId> ringIds;
771 for (
unsigned int iid=0; iid<ringIds.size();++iid){
775 EBDetId myEBDetId(ringIds[iid]);
781 EEDetId myEEDetId(ringIds[iid]);
782 if(myEEDetId.
zside() < 0)
785 if(myEEDetId.
zside() > 0)
790 ical->setValue( ringIds[iid], *(miscalibMap->
get().
getMap().
find(ringIds[iid]) ) );
813 for(
unsigned int iHLT=0; iHLT<200; ++iHLT) {
818 std::cout<<
"[ZeeCalibration::duringLoop] Done with initializing aHLTresults[] "<<std::endl;
824 if(!hltTriggerResultHandle.isValid()) {
828 hltCount = hltTriggerResultHandle->size();
834 std::cout<<
"[ZeeCalibration::duringLoop] Done with myZeePlots_->fillHLTInfo(hltTriggerResultHandle); "<<std::endl;
852 std::cout<<
"[ZeeCalibration::duringLoop] End HLT section"<<std::endl;
858 std::vector<HepMC::GenParticle*> mcEle;
860 float myGenZMass(-1);
870 const HepMC::GenEvent * myGenEvent = hepProd->GetEvent();
876 std::cout<<
"[ZeeCalibration::duringLoop] Done with myZeePlots_->fillZMCInfo( & (*myGenEvent) ); "<<std::endl;
880 for ( HepMC::GenEvent::particle_const_iterator
p = myGenEvent->particles_begin();
881 p != myGenEvent->particles_end(); ++
p ) {
883 if ( (*p)->pdg_id() == 23 && (*p)->status()==2){
885 myGenZMass = (*p)->momentum().m();
898 for ( HepMC::GenEvent::particle_const_iterator
p = myGenEvent->particles_begin();
899 p != myGenEvent->particles_end(); ++
p ) {
901 if (
abs( (*p)->pdg_id() ) == 11 )
903 mcEle.push_back( (*
p) );
910 if(mcEle.size()==2 && fabs(mcEle[0]->momentum().
eta())<2.4 && fabs(mcEle[1]->momentum().
eta())<2.4 ){
913 if( fabs(mcEle[0]->momentum().
eta())<1.479 && fabs(mcEle[1]->momentum().
eta())<1.479 )
MCZBB++;
915 if( (fabs(mcEle[0]->momentum().
eta())>1.479 && fabs(mcEle[1]->momentum().
eta())<1.479) || (fabs(mcEle[0]->momentum().
eta())<1.479 && fabs(mcEle[1]->momentum().
eta())>1.479) )
MCZEB++;
917 if( fabs(mcEle[0]->momentum().eta())>1.479 && fabs(mcEle[1]->momentum().eta())>1.479 )
MCZEE++;
931 std::cerr <<
"Error! can't get the product EBRecHitCollection " << std::endl;
940 std::cerr <<
"Error! can't get the product EERecHitCollection " << std::endl;
950 std::cerr <<
"Error! can't get the product SuperClusterCollection "<< std::endl;
955 std::cout<<
"scCollection->size()"<<scCollection->size()<<std::endl;
956 for(reco::SuperClusterCollection::const_iterator scIt = scCollection->begin(); scIt != scCollection->end(); scIt++)
967 std::cerr <<
"Error! can't get the product IslandSuperClusterCollection "<< std::endl;
972 std::cout<<
"scCollection->size()"<<scIslandCollection->size()<<std::endl;
975 if( ( scCollection->size()+scIslandCollection->size() ) < 2)
983 std::cerr <<
"Error! can't get the product ElectronCollection "<< std::endl;
996 if(electronCollection->size() < 2)
999 if ( !hits && !ehits){
1004 if (hits->size() == 0 && ehits->size() == 0){
1005 std::cout <<
"hits->size() == 0" << std::endl;
1009 if (!electronCollection){
1010 std::cout <<
"!electronCollection" << std::endl;
1014 if (electronCollection->size() == 0){
1015 std::cout <<
"electronCollection->size() == 0" << std::endl;
1032 std::cout <<
" Starting with myZeePlots_->fillEleInfo(electronCollection); " << std::endl;
1039 std::cout <<
" Done with myZeePlots_->fillEleInfo(electronCollection); " << std::endl;
1045 std::vector<calib::CalibElectron> calibElectrons;
1051 for(
unsigned int e_it = 0 ; e_it != electronCollection->size() ; e_it++)
1055 std::cout << calibElectrons.back().getRecoElectron()->superCluster()->energy() <<
" " << calibElectrons.back().getRecoElectron()->energy() << std::endl;
1063 std::cout <<
"Filled histos" << std::endl;
1067 std::vector<std::pair<calib::CalibElectron*,calib::CalibElectron*> > zeeCandidates;
1071 double DeltaMinvMin(5000.);
1073 if (calibElectrons.size() < 2)
1076 for(
unsigned int e_it = 0 ; e_it != calibElectrons.size() - 1 ; e_it++){
1077 for(
unsigned int p_it = e_it + 1 ; p_it != calibElectrons.size() ; p_it++)
1080 std::cout << e_it <<
" " << calibElectrons[e_it].getRecoElectron()->charge() <<
" " << p_it <<
" " << calibElectrons[p_it].getRecoElectron()->charge() << std::endl;
1082 if (calibElectrons[e_it].getRecoElectron()->
charge() * calibElectrons[p_it].getRecoElectron()->
charge() != -1)
1091 std::cout <<
"#######################mass "<<
mass << std::endl;
1094 zeeCandidates.push_back(std::pair<calib::CalibElectron*,calib::CalibElectron*>(&(calibElectrons[e_it]),&(calibElectrons[p_it])));
1095 double DeltaMinv = fabs(
mass -
MZ);
1097 if( DeltaMinv < DeltaMinvMin)
1099 DeltaMinvMin = DeltaMinv;
1100 myBestZ=zeeCandidates.size()-1;
1111 if(zeeCandidates.size()==0 || myBestZ==-1 )
1118 std::cout <<
"Found ZCandidates " << myBestZ << std::endl;
1129 int class1 = zeeCandidates[myBestZ].first->getRecoElectron()->classification();
1130 int class2 = zeeCandidates[myBestZ].second->getRecoElectron()->classification();
1157 if( class1==10 || class1 ==20)
1159 if( class1==110 || class1 ==120)
1161 if( class1>=30 && class1 <=34)
1163 if( class1>=130 && class1 <=134)
1174 if( class2==10 || class2 ==20)
1176 if( class2==110 || class2 ==120)
1178 if( class2>=30 && class2 <=34)
1180 if( class2>=130 && class2 <=134)
1192 DetId firstElehottestDetId =
getHottestDetId( zeeCandidates[myBestZ].
first->getRecoElectron()->superCluster()->seed()->hitsAndFractions() , hits, ehits ).
first;
1193 DetId secondElehottestDetId =
getHottestDetId( zeeCandidates[myBestZ].
second->getRecoElectron()->superCluster()->seed()->hitsAndFractions() , hits, ehits ).
first;
1195 bool firstElectronIsOnModuleBorder(
false);
1196 bool secondElectronIsOnModuleBorder(
false);
1202 if( firstElehottestDetId.subdetId() ==
EcalBarrel)
1207 if( firstElehottestDetId.subdetId() ==
EcalBarrel && !firstElectronIsOnModuleBorder )
1214 if( secondElehottestDetId.subdetId() ==
EcalBarrel)
1219 if( secondElehottestDetId.subdetId() ==
EcalBarrel && !secondElectronIsOnModuleBorder )
1226 if ( firstElehottestDetId.subdetId() ==
EcalBarrel && firstElectronIsOnModuleBorder ){
1233 if ( secondElehottestDetId.subdetId() ==
EcalBarrel && secondElectronIsOnModuleBorder ){
1243 if(class1<100 && class2<100){
1245 if(class1==0 && class2==0)
BBZN_gg++;
1246 if(class1<21 && class2<21)
BBZN_tt++;
1247 if(class1<21 || class2<21)
BBZN_t0++;
1251 if(class1>=100 && class2>=100){
1253 if(class1==100 && class2==100)
EEZN_gg++;
1254 if(class1<121 && class2<121)
EEZN_tt++;
1255 if(class1<121 || class2<121)
EEZN_t0++;
1259 if( (class1<100 && class2>=100) || (class2<100 && class1>=100)){
1261 if( (class1==0 && class2==100)||(class2==0 && class1==100) )
EBZN_gg++;
1262 if( ( class1<21 && class2<121) ||(class2<21 && class1<121) )
EBZN_tt++;
1263 if( class2<21 || class1<21 || class2<121 || class1<121 )
EBZN_t0++;
1275 bool selectionBool=
false;
1280 float theta1 = 2. * atan(
exp(- zeeCandidates[myBestZ].
first->getRecoElectron()->superCluster()->eta()) );
1281 bool ET_1 = ( (zeeCandidates[myBestZ].first->getRecoElectron()->superCluster()->energy() *
sin( theta1) ) > 20.);
1283 float theta2 = 2. * atan(
exp(- zeeCandidates[myBestZ].
second->getRecoElectron()->superCluster()->eta()) );
1284 bool ET_2 = ( (zeeCandidates[myBestZ].second->getRecoElectron()->superCluster()->energy() *
sin( theta2) ) > 20.);
1287 bool HoE_1 = (zeeCandidates[myBestZ].first->getRecoElectron()->hadronicOverEm() < 0.115);
1288 bool HoE_2 = (zeeCandidates[myBestZ].second->getRecoElectron()->hadronicOverEm() < 0.115);
1290 bool DeltaPhiIn_1 = ( zeeCandidates[myBestZ].first->getRecoElectron()->deltaPhiSuperClusterTrackAtVtx() < 0.090);
1291 bool DeltaPhiIn_2 = ( zeeCandidates[myBestZ].second->getRecoElectron()->deltaPhiSuperClusterTrackAtVtx() < 0.090);
1293 bool DeltaEtaIn_1 = ( zeeCandidates[myBestZ].first->getRecoElectron()->deltaEtaSuperClusterTrackAtVtx() < 0.0090);
1294 bool DeltaEtaIn_2 = ( zeeCandidates[myBestZ].second->getRecoElectron()->deltaEtaSuperClusterTrackAtVtx() < 0.0090);
1298 if(! (invMassBool &&
1301 DeltaPhiIn_1 && DeltaPhiIn_2 &&
1302 DeltaEtaIn_1 && DeltaEtaIn_2
1314 zeeCandidates[myBestZ].first->getRecoElectron()->classification()!= 40 &&
1315 zeeCandidates[myBestZ].first->getRecoElectron()->classification()!= 40 &&
1316 zeeCandidates[myBestZ].second->getRecoElectron()->classification()!= 40 &&
1317 zeeCandidates[myBestZ].second->getRecoElectron()->classification()!= 140);
1322 (zeeCandidates[myBestZ].first->getRecoElectron()->classification() ==0 ||
1323 zeeCandidates[myBestZ].first->getRecoElectron()->classification() ==10 ||
1324 zeeCandidates[myBestZ].first->getRecoElectron()->classification() ==20 ||
1325 zeeCandidates[myBestZ].first->getRecoElectron()->classification() ==100 ||
1326 zeeCandidates[myBestZ].first->getRecoElectron()->classification() ==110 ||
1327 zeeCandidates[myBestZ].first->getRecoElectron()->classification() ==120
1329 (zeeCandidates[myBestZ].
second->getRecoElectron()->classification() == 0 ||
1330 zeeCandidates[myBestZ].second->getRecoElectron()->classification() == 10 ||
1331 zeeCandidates[myBestZ].second->getRecoElectron()->classification() == 20 ||
1332 zeeCandidates[myBestZ].second->getRecoElectron()->classification() == 100 ||
1333 zeeCandidates[myBestZ].second->getRecoElectron()->classification() == 110 ||
1334 zeeCandidates[myBestZ].second->getRecoElectron()->classification() == 120
1340 (zeeCandidates[myBestZ].first->getRecoElectron()->classification() == 0 ||
1341 zeeCandidates[myBestZ].first->getRecoElectron()->classification() == 100
1343 (zeeCandidates[myBestZ].
second->getRecoElectron()->classification() == 0 ||
1344 zeeCandidates[myBestZ].second->getRecoElectron()->classification() == 100
1350 (zeeCandidates[myBestZ].first->getRecoElectron()->classification() >=30 &&
1351 zeeCandidates[myBestZ].first->getRecoElectron()->classification() <=34)
1353 ((zeeCandidates[myBestZ].
first->getRecoElectron()->classification() >=130 &&
1354 zeeCandidates[myBestZ].first->getRecoElectron()->classification() <=134))
1357 ( (zeeCandidates[myBestZ].
second->getRecoElectron()->classification() >=30 &&
1358 zeeCandidates[myBestZ].second->getRecoElectron()->classification() <=34)
1360 ((zeeCandidates[myBestZ].
second->getRecoElectron()->classification() >=130 &&
1361 zeeCandidates[myBestZ].second->getRecoElectron()->classification() <=134))
1372 (zeeCandidates[myBestZ].first->getRecoElectron()->classification() ==0 ||
1373 zeeCandidates[myBestZ].first->getRecoElectron()->classification() ==10 ||
1374 zeeCandidates[myBestZ].first->getRecoElectron()->classification() ==20
1375 ) && zeeCandidates[myBestZ].
second->getRecoElectron()->classification()>=100
1376 && zeeCandidates[myBestZ].second->getRecoElectron()->classification()!=140
1382 (zeeCandidates[myBestZ].
second->getRecoElectron()->classification() ==0 ||
1383 zeeCandidates[myBestZ].second->getRecoElectron()->classification() ==10 ||
1384 zeeCandidates[myBestZ].second->getRecoElectron()->classification() ==20
1385 ) && zeeCandidates[myBestZ].
first->getRecoElectron()->classification()>=100
1386 && zeeCandidates[myBestZ].first->getRecoElectron()->classification()!=140
1396 zeeCandidates[myBestZ].first->getRecoElectron()->classification()>=100 &&
1397 zeeCandidates[myBestZ].second->getRecoElectron()->classification()>= 100 &&
1398 zeeCandidates[myBestZ].first->getRecoElectron()->classification()!= 140 &&
1399 zeeCandidates[myBestZ].second->getRecoElectron()->classification()!= 140);
1404 zeeCandidates[myBestZ].first->getRecoElectron()->classification()<100 &&
1405 zeeCandidates[myBestZ].second->getRecoElectron()->classification()< 100 &&
1406 zeeCandidates[myBestZ].first->getRecoElectron()->classification()!= 40 &&
1407 zeeCandidates[myBestZ].second->getRecoElectron()->classification()!= 40);
1412 !(zeeCandidates[myBestZ].first->getRecoElectron()->classification()<100 &&
1413 zeeCandidates[myBestZ].second->getRecoElectron()->classification()>=100) &&
1414 !(zeeCandidates[myBestZ].
first->getRecoElectron()->classification()>=100 &&
1415 zeeCandidates[myBestZ].second->getRecoElectron()->classification()<100) );
1418 float ele1EnergyCorrection(1.);
1419 float ele2EnergyCorrection(1.);
1428 if (invMassBool && selectionBool)
1441 std::map<HepMC::GenParticle*,const reco::GsfElectron*> myMCmap;
1443 std::vector<const reco::GsfElectron*> dauElectronCollection;
1445 dauElectronCollection.push_back(zeeCandidates[myBestZ].
first->getRecoElectron() );
1446 dauElectronCollection.push_back(zeeCandidates[myBestZ].
second->getRecoElectron() );
1448 fillMCmap(&dauElectronCollection,mcEle,myMCmap);
1460 if(zeeCandidates[myBestZ].first->getRecoElectron()->classification()<100 && zeeCandidates[myBestZ].second->getRecoElectron()->classification()<100 )
1464 if(zeeCandidates[myBestZ].first->getRecoElectron()->classification()>=100 && zeeCandidates[myBestZ].second->getRecoElectron()->classification()>=100 )
1481 std::cout <<
"Added event to algorithm" << std::endl;
1493 std::cout<<
"[ZeeCalibration] Starting loop number " << iLoop<<std::endl;
1502 std::cout<<
"[ZeeCalibration] exiting from startingNewLoop" << std::endl;
1532 std::cout<<
"[ZeeCalibration] Ending loop " << iLoop<<std::endl;
1544 std::cout<<
"Optimized coefficients " << optimizedCoefficients.size() <<std::endl;
1550 for (
unsigned int ieta=0;ieta<optimizedCoefficients.size();ieta++)
1564 std::cout<<
"size "<<optimizedCoefficients.size()<<std::endl;
1566 for (
unsigned int ieta=0;ieta<optimizedCoefficients.size();ieta++)
1568 calibCoeff[ieta] *= optimizedCoefficients[ieta];
1574 std::cout<< ieta <<
" " << optimizedCoefficients[ieta] <<std::endl;
1577 std::vector<DetId> ringIds;
1589 for (
unsigned int iid=0; iid<ringIds.size();++iid){
1592 EBDetId myEBDetId(ringIds[iid]);
1598 EEDetId myEEDetId(ringIds[iid]);
1599 if(myEEDetId.
zside() < 0)
1602 if(myEEDetId.
zside() > 0)
1608 ical->setValue( ringIds[iid], *(
ical->getMap().find(ringIds[iid]) ) * optimizedCoefficients[ieta] );
1645 double parResidual[3];
1646 double errparResidual[3];
1658 std::cout<<
"Fit on residuals, sigma is "<<parResidual[2]<<
" +/- "<<errparResidual[2]<<std::endl;
1697 h1_seedOverSC_=
new TH1F(
"h1_seedOverSC",
"h1_seedOverSC", 400, 0., 2.);
1704 h2_fEtaBarrelGood_ =
new TH2F(
"fEtaBarrelGood",
"fEtaBarrelGood",800,-4.,4.,800,0.8,1.2);
1708 h2_fEtaBarrelBad_ =
new TH2F(
"fEtaBarrelBad",
"fEtaBarrelBad",800,-4.,4.,800,0.8,1.2);
1712 h2_fEtaEndcapGood_ =
new TH2F(
"fEtaEndcapGood",
"fEtaEndcapGood",800,-4.,4.,800,0.8,1.2);
1716 h2_fEtaEndcapBad_ =
new TH2F(
"fEtaEndcapBad",
"fEtaEndcapBad",800,-4.,4.,800,0.8,1.2);
1720 for (
int i=0;
i<2;
i++)
1724 sprintf(histoName,
"h_eleEffEta_%d",
i);
1725 h_eleEffEta_[
i] =
new TH1F(histoName,histoName, 150, 0., 2.7);
1728 sprintf(histoName,
"h_eleEffPhi_%d",
i);
1729 h_eleEffPhi_[
i] =
new TH1F(histoName,histoName, 400, -4., 4.);
1732 sprintf(histoName,
"h_eleEffPt_%d",
i);
1733 h_eleEffPt_[
i] =
new TH1F(histoName,histoName, 200, 0., 200.);
1747 for (
int i=0;
i<25;
i++)
1751 sprintf(histoName,
"h_ESCEtrueVsEta_%d",
i);
1757 sprintf(histoName,
"h_ESCEtrue_%d",
i);
1759 h_ESCEtrue_[
i] =
new TH1F(histoName,histoName, 300,0.,1.5);
1761 sprintf(histoName,
"h2_chi2_%d",
i);
1762 h2_chi2_[
i] =
new TH2F(histoName,histoName, 1000,-150,150, 1000, -1, 5);
1764 sprintf(histoName,
"h2_iterations_%d",
i);
1765 h2_iterations_[
i] =
new TH2F(histoName,histoName, 1000,-150,150, 1000, -1, 15);
1767 sprintf(histoName,
"h_ESCcorrEtrueVsEta_%d",
i);
1773 sprintf(histoName,
"h_ESCcorrEtrue_%d",
i);
1777 sprintf(histoName,
"h2_xtalRecalibCoeffBarrel_%d",
i);
1783 sprintf(histoName,
"h2_xtalRecalibCoeffEndcapMinus_%d",
i);
1788 sprintf(histoName,
"h2_xtalRecalibCoeffEndcapPlus_%d",
i);
1814 h1_zMassResol_ =
new TH1F(
"zMassResol",
"zMassResol", 200, -50., 50.);
1818 h1_eleEtaResol_ =
new TH1F(
"eleEtaResol",
"eleEtaResol", 100, -0.01, 0.01);
1834 h1_elePhiResol_ =
new TH1F(
"elePhiResol",
"elePhiResol", 100, -0.01, 0.01);
1839 h1_zEtaResol_ =
new TH1F(
"zEtaResol",
"zEtaResol", 200, -1., 1.);
1844 h1_zPhiResol_ =
new TH1F(
"zPhiResol",
"zPhiResol", 200, -1., 1.);
1848 h1_nEleReco_ =
new TH1F(
"nEleReco",
"Number of reco electrons",10,-0.5,10.5);
1861 h1_occupancy_ =
new TH1F(
"occupancy",
"occupancy",1000,0,10000);
1886 h1_ZCandMult_ =
new TH1F(
"ZCandMult",
"Multiplicity of Z candidates in one event",10,-0.5,10.5);
1889 h1_reco_ZMass_ =
new TH1F(
"reco_ZMass",
"Inv. mass of 2 reco Electrons",200,0.,150.);
1893 h1_reco_ZMassCorr_ =
new TH1F(
"reco_ZMassCorr",
"Inv. mass of 2 corrected reco Electrons",200,0.,150.);
1897 h1_reco_ZMassCorrBB_ =
new TH1F(
"reco_ZMassCorrBB",
"Inv. mass of 2 corrected reco Electrons",200,0.,150.);
1901 h1_reco_ZMassCorrEE_ =
new TH1F(
"reco_ZMassCorrEE",
"Inv. mass of 2 corrected reco Electrons",200,0.,150.);
1907 h2_coeffVsEta_=
new TH2F(
"h2_calibCoeffVsEta",
"h2_calibCoeffVsEta",249,-124,125, 200, 0., 2.);
1911 h2_coeffVsEtaGrouped_=
new TH2F(
"h2_calibCoeffVsEtaGrouped",
"h2_calibCoeffVsEtaGrouped", 200, 0., 3., 200, 0.6, 1.4);
1915 h2_zMassVsLoop_=
new TH2F(
"h2_zMassVsLoop",
"h2_zMassVsLoop",1000,0,40, 90, 80.,95.);
1917 h2_zMassDiffVsLoop_=
new TH2F(
"h2_zMassDiffVsLoop",
"h2_zMassDiffVsLoop",1000,0,40, 100, -1., 1.);
1921 h2_zWidthVsLoop_=
new TH2F(
"h2_zWidthVsLoop",
"h2_zWidthVsLoop",1000,0,40, 100, 0.,10.);
1923 h2_coeffVsLoop_=
new TH2F(
"h2_coeffVsLoop",
"h2_coeffVsLoop",1000,0,40, 100, 0., 2.);
1925 h2_residualSigma_=
new TH2F(
"h2_residualSigma",
"h2_residualSigma",1000, 0, 40, 100, 0., .5);
1927 h2_miscalRecal_ =
new TH2F(
"h2_miscalRecal",
"h2_miscalRecal", 500, 0., 2., 500, 0., 2.);
1931 h2_miscalRecalEB_ =
new TH2F(
"h2_miscalRecalEB",
"h2_miscalRecalEB", 500, 0., 2., 500, 0., 2.);
1935 h2_miscalRecalEE_ =
new TH2F(
"h2_miscalRecalEE",
"h2_miscalRecalEE", 500, 0., 2., 500, 0., 2.);
1939 h1_mc_ =
new TH1F(
"h1_residualMiscalib",
"h1_residualMiscalib", 200, -0.2, 0.2);
1940 h1_mcEB_ =
new TH1F(
"h1_residualMiscalibEB",
"h1_residualMiscalibEB", 200, -0.2, 0.2);
1941 h1_mcEE_ =
new TH1F(
"h1_residualMiscalibEE",
"h1_residualMiscalibEE", 200, -0.2, 0.2);
1943 for (
int i=0;
i<25;
i++)
1963 sprintf(histoName,
"h1_residualMiscalibParz_%d",
i);
1964 h1_mcParz_[
i] =
new TH1F(histoName,histoName, 200, -0.2, 0.2);
1965 sprintf(histoName,
"h1_residualMiscalibEBParz_%d",
i);
1966 h1_mcEBParz_[
i] =
new TH1F(histoName,histoName, 200, -0.2, 0.2);
1967 sprintf(histoName,
"h1_residualMiscalibEEParz_%d",
i);
1968 h1_mcEEParz_[
i] =
new TH1F(histoName,histoName, 200, -0.2, 0.2);
1978 float p0 = 1.00153e+00;
1979 float p1 = 3.29331e-02;
1980 float p2 = 1.21187e-03;
1982 double x = (double) fabs(scEta);
1984 return 1. / ( p0 + p1*x*x + p2*x*x*x*
x );
1992 float p0 = 1.06819e+00;
1993 float p1 = -1.53189e-02;
1994 float p2 = 4.01707e-04 ;
1996 double x = (double) fabs(scEta);
1998 return 1. / ( p0 + p1*x*x + p2*x*x*x*
x );
2004 float p0 = 1.17382e+00;
2005 float p1 = -6.52319e-02;
2006 float p2 = 6.26108e-03;
2008 double x = (double) fabs(scEta);
2010 return 1. / ( p0 + p1*x*x + p2*x*x*x*
x );
2016 float p0 = 9.99782e-01 ;
2017 float p1 = 1.26983e-02;
2018 float p2 = 2.16344e-03;
2020 double x = (double) fabs(scEta);
2022 return 1. / ( p0 + p1*x*x + p2*x*x*x*
x );
2029 void ZeeCalibration::fillMCmap(
const std::vector<const reco::GsfElectron*>* electronCollection,
const std::vector<HepMC::GenParticle*>& mcEle,std::map<HepMC::GenParticle*,const reco::GsfElectron*>& myMCmap)
2031 for (
unsigned int i=0;
i<mcEle.size();
i++)
2035 for (
unsigned int j=0;
j<electronCollection->size();
j++)
2037 float dr=
EvalDR(mcEle[
i]->momentum().pseudoRapidity(),(*(*electronCollection)[
j]).
eta(),mcEle[
i]->momentum().
phi(),(*(*electronCollection)[j]).
phi());
2040 myMatchEle = (*electronCollection)[
j];
2044 myMCmap.insert(std::pair<HepMC::GenParticle*,const reco::GsfElectron*>(mcEle[
i],myMatchEle));
2052 if (Phi_ref<0) Phi_ref = 2*
TMath::Pi() + Phi_ref;
2053 float DPhi = Phi - Phi_ref ;
2056 float DEta = Eta - Eta_ref ;
2058 float DR =
sqrt( DEta*DEta + DPhi*DPhi );
2065 if (Phi_ref<0) Phi_ref = 2*
TMath::Pi() + Phi_ref;
2066 return (Phi - Phi_ref);
2072 for (
unsigned int i=0;
i<mcEle.size();
i++)
2075 h_eleEffEta_[0]->Fill(fabs(mcEle[
i]->momentum().pseudoRapidity()));
2079 std::map<HepMC::GenParticle*,const reco::GsfElectron*>::const_iterator mIter = associationMap.find(mcEle[
i]);
2080 if (mIter == associationMap.end() )
2087 h_eleEffEta_[1]->Fill(fabs(mcEle[i]->momentum().pseudoRapidity()));
2122 if(k>=0 && k<=84)index = k - 85;
2124 if(k>=85 && k<=169)index = k - 84;
2126 if(k>=170 && k<=208)index = - k + 84;
2128 if(k>=209 && k<=247)index = k - 123;
2134 if(k>=0 && k<=71)index = k - 72;
2136 if(k>=72 && k<=143)index = k - 71;
2146 double correction(1.);
2179 double maxEnergy = -9999.;
2182 std::pair<DetId, double> myPair (
DetId(0), -9999.);
2185 for( std::vector<std::pair<DetId,float> >::const_iterator idIt=mySCRecHits.begin(); idIt != mySCRecHits.end(); idIt++){
2189 hottestRecHit = & (* ( ebhits->
find((*idIt).first) ) );
2191 if( hottestRecHit == & (*( ebhits->
end())) )
2193 std::cout<<
"@@@@@@@@@@@@@@@@@@@@@@@@@@@ NO RECHIT FOUND SHOULD NEVER HAPPEN"<<std::endl;
2197 else if (idIt->first.subdetId() ==
EcalEndcap )
2199 hottestRecHit = & (* ( eehits->
find((*idIt).first) ) );
2200 if( hottestRecHit == & (*( eehits->
end())) )
2202 std::cout<<
"@@@@@@@@@@@@@@@@@@@@@@@@@@@ NO RECHIT FOUND SHOULD NEVER HAPPEN"<<std::endl;
2209 if(hottestRecHit && hottestRecHit->
energy() > maxEnergy){
2211 maxEnergy = hottestRecHit->
energy();
2213 myPair.first = hottestRecHit ->
id();
2214 myPair.second = maxEnergy;
2231 short ieta = myEBDetId.
ieta();
2232 short iphi = myEBDetId.
iphi();
2236 myBool = (
abs( ieta ) == 1 ||
abs( ieta ) == 25
2237 ||
abs( ieta ) ==26 ||
abs( ieta ) == 45
2238 ||
abs( ieta ) ==46 ||
abs( ieta ) == 65
2239 ||
abs( ieta ) ==66 ||
abs( ieta ) == 85 );
2241 for(
int i = 0;
i < 19;
i++){
2243 if(iphi == ( 20*
i + 1 ) || iphi == 20*
i )
2259 bool isNearCrack =
false;
2271 dist +=
pow( v1[
i]-v2[
i], 2 );
2327 for (
int i=0;
i<2;
i++)
2385 ofstream
fout(
"ZeeStatistics.txt");
2388 std::cout <<
"Cannot open output file.\n";
2391 fout<<
"ZeeStatistics"<<std::endl;
2393 fout<<
"##########################RECO#########################"<<std::endl;
2394 fout<<
"##################Zee with Barrel-Barrel electrons: "<<
BBZN<<std::endl;
2397 fout<<
"##################Zee with Barrel-Endcap electrons: "<<
EBZN<<std::endl;
2399 fout<<
"##################Zee with Endcap-Endcap electrons: "<<
EEZN<<std::endl;
2402 fout<<
"\n"<<std::endl;
2404 fout<<
"##########################GEN#########################"<<std::endl;
2405 fout<<
"##################Zee with Barrel-Barrel electrons: "<<(float)
MCZBB/
NEVT<<std::endl;
2406 fout<<
"##################Zee with Barrel-Endcap electrons: "<<(float)
MCZEB/
NEVT<<std::endl;
2407 fout<<
"##################Zee with Endcap-Endcap electrons: "<<(float)
MCZEE/
NEVT<<std::endl;
TH1 * weightedRescaleFactor[50][250]
static bool validDetId(int i, int j)
check if a valid index combination
virtual void endOfJob()
Called at end of job.
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
const math::XYZPoint & position() const
cluster centroid position
const ZIterativeAlgorithmWithFitPlots * getHistos() const
std::string outputFileName_
static const int MIN_IPHI
double fEtaEndcapGood(double scEta) const
std::string scIslandCollection_
std::string electronCollection_
int BARREL_ELECTRONS_AFTER_BORDER_CUT
TH1F * h1_eventsBeforeEWKSelection_
double fEtaBarrelBad(double scEta) const
float computeCoefficientDistanceAtIteration(float v1[250], float v2[250], int size)
virtual Status endOfLoop(const edm::EventSetup &, unsigned int iLoop)
Called at end of loop.
virtual void beginOfJob()
Called at beginning of job.
const self & getMap() const
void fillEleInfo(const reco::GsfElectronCollection *)
void fillEleMCInfo(const HepMC::GenEvent *)
const std::vector< float > & getOptimizedChiSquare() const
int GOLDEN_ELECTRONS_IN_ENDCAP
void fillZMCInfo(const HepMC::GenEvent *)
TH1F * h1_eventsAfterBorderSelection_
int getNumberOfChannels() const
edm::InputTag hlTriggerResults_
Sin< T >::type sin(const T &t)
std::pair< DetId, double > getHottestDetId(std::vector< std::pair< DetId, float > > mySCRecHits, const EBRecHitCollection *ebhits, const EERecHitCollection *eehits)
bool parseXMLMiscalibFile(std::string configFile)
void fillMCmap(const std::vector< const reco::GsfElectron * > *electronCollection, const std::vector< HepMC::GenParticle * > &mcEle, std::map< HepMC::GenParticle *, const reco::GsfElectron * > &myMCmap)
const std::vector< float > & getOptimizedCoefficients() const
TH1F * h1_occupancyEndcap_
bool addEvent(calib::CalibElectron *, calib::CalibElectron *, float)
void writeMCEleHistograms()
virtual Status duringLoop(const edm::Event &, const edm::EventSetup &)
Called at each event.
TH1F * h1_eventsBeforeBorderSelection_
TH1F * h1_electronCosTheta_SC_
void writeMCZHistograms()
double fEtaEndcapBad(double scEta) const
TH1F * h1_reco_ZMassCorr_
static void gausfit(TH1F *histoou, double *par, double *errpar, float nsigmalow, float nsigmaup, double *mychi2, int *iterations)
int GOLDEN_ELECTRONS_IN_BARREL
TH2F * h2_coeffVsEtaGrouped_
TH1F * h1_occupancyVsEta_
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
std::string rechitCollection_
virtual double eta() const
momentum pseudorapidity
void setWhatProduced(T *iThis, const es::Label &iLabel=es::Label())
TH1F * h1_occupancyBarrel_
float EvalDR(float Eta, float Eta_ref, float Phi, float Phi_ref)
int iphi() const
get the crystal iphi
uint32_t rawId() const
get the raw id
U second(std::pair< T, U > const &p)
TH1F * h1_electronCosTheta_TK_
~ZeeCalibration()
Destructor.
TH2F * h_ESCcorrEtrueVsEta_[25]
boost::shared_ptr< EcalIntercalibConstants > ical
std::string rechitProducer_
const EcalIntercalibConstants & get()
int ringNumberCorrector(int k)
std::string scIslandProducer_
int SILVER_ELECTRONS_IN_BARREL
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
int TOTAL_ELECTRONS_IN_ENDCAP
int BARREL_ELECTRONS_BEFORE_BORDER_CUT
void fillHLTInfo(edm::Handle< edm::TriggerResults >)
int SHOWER_ELECTRONS_IN_ENDCAP
virtual SuperClusterRef superCluster() const
reference to a SuperCluster
int getNumberOfIterations() const
std::string erechitProducer_
double energy() const
cluster energy
ZIterativeAlgorithmWithFit * theAlgorithm_
int ieta() const
get the crystal ieta
unsigned int electronSelection_
bool xtalIsOnModuleBorder(EBDetId myEBDetId)
TH2F * h2_xtalRecalibCoeffBarrel_[25]
float EvalDPhi(float Phi, float Phi_ref)
TH1F * h1_eventsAfterEWKSelection_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
TH1F * h1_preshowerOverSC_
TH1F * h1_electronCosTheta_SC_TK_
double coefficientDistanceAtIteration[50]
const_iterator end() const
TH2F * h2_zMassDiffVsLoop_
std::string scCollection_
const std::vector< float > & getOptimizedCoefficientsError() const
static const int MAX_IPHI
DetId id() const
get the id
void writeEleHistograms()
edm::ParameterSet theParameterSet
Classification classification() const
TH1F * h_ESCcorrEtrue_[25]
TH2F * h2_xtalMiscalibCoeffEndcapPlus_
static const int MAX_IETA
virtual boost::shared_ptr< EcalIntercalibConstants > produceEcalIntercalibConstants(const EcalIntercalibConstantsRcd &iRecord)
Produce Ecal interCalibrations.
float initCalibCoeff[250]
int SILVER_ELECTRONS_IN_ENDCAP
EcalIntercalibConstantMap EcalIntercalibConstants
TH1F * h1_reco_ZMassCorrBB_
void writeLine(EBDetId const &, float)
iterator find(key_type k)
T perp() const
Magnitude of transverse component.
virtual void startingNewLoop(unsigned int iLoop)
Called at beginning of loop.
TH1F * h1_reco_ZMassCorrEE_
TH2F * h2_xtalMiscalibCoeffBarrel_
void fillZInfo(std::pair< calib::CalibElectron *, calib::CalibElectron * > myZeeCandidate)
void fillEleInfo(std::vector< HepMC::GenParticle * > &a, std::map< HepMC::GenParticle *, const reco::GsfElectron * > &b)
const_iterator find(uint32_t rawId) const
TH1F * h1_weightSumMeanBarrel_
double fEtaBarrelGood(double scEta) const
TH2F * h_ESCEtrueVsEta_[25]
TH2F * h2_iterations_[25]
const CaloClusterPtr & seed() const
seed BasicCluster
ZeeCalibration(const edm::ParameterSet &iConfig)
Constructor.
void Reset(std::vector< TH2F > &depth)
double preshowerEnergy() const
energy deposited in preshower
float calibCoeffError[250]
TH2F * h2_xtalRecalibCoeffEndcapPlus_[25]
int CRACK_ELECTRONS_IN_ENDCAP
int CRACK_ELECTRONS_IN_BARREL
TH2F * h2_fEtaEndcapGood_
TH2F * h2_xtalRecalibCoeffEndcapMinus_[25]
void bookEleMCHistograms()
std::string electronProducer_
double getEtaCorrection(const reco::GsfElectron *)
virtual double phi() const
momentum azimuthal angle
TH2F * h2_fEtaBarrelGood_
std::string erechitCollection_
tuple size
Write out results.
Power< A, B >::type pow(const A &a, const B &b)
TH1F * h1_borderElectronClassification_
TH2F * h2_xtalMiscalibCoeffEndcapMinus_
double sigmaErrorArray[50]
int SHOWER_ELECTRONS_IN_BARREL
const std::vector< int > & getOptimizedIterations() const
int TOTAL_ELECTRONS_IN_BARREL
TH1F * h1_weightSumMeanEndcap_