36 theMaxLoops( iConfig.getUntrackedParameter<unsigned
int>(
"maxLoops",0) ),
37 ecalHitsProducer_( iConfig.getParameter<
std::
string > (
"ecalRecHitsProducer") ),
38 barrelHits_( iConfig.getParameter<
std::
string > (
"barrelHitCollection") )
41 std::cout <<
"[Pi0FixedMassWindowCalibration] Constructor "<<std::endl;
53 double barrelSeedThreshold = iConfig.
getParameter<
double>(
"IslandBarrelSeedThr");
54 double endcapSeedThreshold = iConfig.
getParameter<
double>(
"IslandEndcapSeedThr");
86 const std::vector<std::string> seedflagnamesEB = iConfig.
getParameter<std::vector<std::string> >(
"SeedRecHitFlagToBeExcludedEB");
87 const std::vector<int> seedflagsexclEB = StringToEnumValue<EcalRecHit::Flags>(seedflagnamesEB);
89 const std::vector<std::string> seedflagnamesEE = iConfig.
getParameter<std::vector<std::string> >(
"SeedRecHitFlagToBeExcludedEE");
90 const std::vector<int> seedflagsexclEE = StringToEnumValue<EcalRecHit::Flags>(seedflagnamesEE);
92 const std::vector<std::string> flagnamesEB = iConfig.
getParameter<std::vector<std::string> >(
"RecHitFlagToBeExcludedEB");
93 const std::vector<int> flagsexclEB = StringToEnumValue<EcalRecHit::Flags>(flagnamesEB);
95 const std::vector<std::string> flagnamesEE = iConfig.
getParameter<std::vector<std::string> >(
"RecHitFlagToBeExcludedEE");
96 const std::vector<int> flagsexclEE = StringToEnumValue<EcalRecHit::Flags>(flagnamesEE);
118 desc.
add<
unsigned int>(
"maxLoops", 0);
125 desc.
add<
double>(
"IslandBarrelSeedThr", 0);
126 desc.
add<
double>(
"IslandEndcapSeedThr", 0);
128 desc.
add<
double>(
"selePi0PtGammaOneMin", 0);
129 desc.
add<
double>(
"selePi0PtGammaTwoMin", 0);
131 desc.
add<
double>(
"selePi0DRBelt", 0);
132 desc.
add<
double>(
"selePi0DetaBelt", 0);
134 desc.
add<
double>(
"selePi0PtPi0Min", 0);
136 desc.
add<
double>(
"selePi0S4S9GammaOneMin", 0);
137 desc.
add<
double>(
"selePi0S4S9GammaTwoMin", 0);
138 desc.
add<
double>(
"selePi0S9S25GammaOneMin", 0);
139 desc.
add<
double>(
"selePi0S9S25GammaTwoMin", 0);
141 desc.
add<
double>(
"selePi0EtBeltIsoRatioMax", 0);
143 desc.
add<
double>(
"selePi0MinvMeanFixed", 0);
144 desc.
add<
double>(
"selePi0MinvSigmaFixed", 0);
147 posCalcParameters.add<
bool>(
"LogWeighted",
true);
148 posCalcParameters.add<
double>(
"T0_barl", 7.4);
149 posCalcParameters.add<
double>(
"T0_endc", 3.1);
150 posCalcParameters.add<
double>(
"T0_endcPresh", 1.2);
151 posCalcParameters.add<
double>(
"W0", 4.2);
152 posCalcParameters.add<
double>(
"X0", 0.89);
155 desc.
add<
std::string>(
"clustershapecollectionEB",
"islandBarrelShape");
156 desc.
add<
std::string>(
"barrelShapeAssociation",
"islandBarrelShapeAssoc");
158 desc.
add<std::vector<std::string>>(
"SeedRecHitFlagToBeExcludedEB", {});
159 desc.
add<std::vector<std::string>>(
"SeedRecHitFlagToBeExcludedEE", {});
160 desc.
add<std::vector<std::string>>(
"RecHitFlagToBeExcludedEB", {});
161 desc.
add<std::vector<std::string>>(
"RecHitFlagToBeExcludedEE", {});
163 descriptions.
add(
"Pi0FixedMassWindowCalibration", desc);
184 std::cout <<
"[Pi0FixedMassWindowCalibration] endOfJob"<<endl;
190 std::vector<DetId>::const_iterator barrelIt=
barrelCells.begin();
193 int ieta = eb.
ieta();
194 int iphi = eb.
iphi();
207 for (
int ieta=0; ieta<85; ieta++) {
208 for (
int iphi=0; iphi<360; iphi++) {
214 std::cout <<
"[Pi0FixedMassWindowCalibration] Starting loop number " << iLoop<<std::endl;
225 std::cout <<
"[Pi0FixedMassWindowCalibration] Ending loop " << iLoop<<std::endl;
228 for (
int ieta=0; ieta<85; ieta++) {
229 for (
int iphi=0; iphi<360; iphi++) {
245 std::vector<DetId>::const_iterator barrelIt=
barrelCells.begin();
248 int ieta = eb.
ieta();
249 int iphi = eb.
iphi();
253 std::cout <<
"Calib constant for barrel crystal " 254 <<
" (" << ieta <<
"," << iphi <<
") changed from " 263 for (
int ieta=0; ieta<85; ieta++) {
264 for (
int iphi=0; iphi<360; iphi++) {
293 for (
int ieta=0; ieta<85; ieta++) {
294 for (
int iphi=0; iphi<360; iphi++) {
310 std::cout <<
"Taken EcalIntercalibConstants" << std::endl;
314 std::cerr <<
"Error! can't get EcalIntercalibConstants " << std::endl;
325 std::vector<DetId>::const_iterator barrelIt;
331 if ( itcalib == imap.
end() ) {
337 if (eb.
iphi()==1)
std::cout <<
"Read old constant for crystal " 338 <<
" (" << eb.
ieta() <<
"," << eb.
iphi()
339 <<
") : " << calib << std::endl;
356 std::cout <<
"[Pi0FixedMassWindowCalibration] Events processed: "<<
nevent<<std::endl;
366 cout <<
" ECAL Barrel RecHits # "<< ecalRecHitBarrelCollection->
size() <<endl;
371 EBDetId ebrhdetid = aRecHitEB->detid();
378 recalibEcalRecHitCollection->push_back(aHit);
394 std::pair<DetId, EcalRecHit> map_entry(aRecHitEB->id(), *aRecHitEB);
446 std::vector <reco::ClusterShape> ClusVec_recalib;
447 for (
int erg=0;erg<
int(clusters_recalib.size());++erg){
449 ClusVec_recalib.push_back(TestShape_recalib);
454 clustersshapes_p_recalib->assign(ClusVec_recalib.begin(), ClusVec_recalib.end());
456 cout<<
"[Pi0FixedMassWindowCalibration][recalibration] Basic Cluster collection size: "<<clusters_recalib.size()<<endl;
457 cout<<
"[Pi0FixedMassWindowCalibration][recalibration] Basic Cluster Shape Collection size: "<<clustersshapes_p_recalib->size()<<endl;
464 static const int MAXBCEB = 200;
465 static const int MAXBCEBRH = 200;
467 float eIslandBCEB[MAXBCEB];
468 float etIslandBCEB[MAXBCEB];
469 float etaIslandBCEB[MAXBCEB];
470 float phiIslandBCEB[MAXBCEB];
471 float e2x2IslandBCEB[MAXBCEB];
472 float e3x3IslandBCEB[MAXBCEB];
473 float e5x5IslandBCEB[MAXBCEB];
476 int nIslandBCEBRecHits[MAXBCEB];
478 int ietaIslandBCEBRecHits[MAXBCEB][MAXBCEBRH];
479 int iphiIslandBCEBRecHits[MAXBCEB][MAXBCEBRH];
480 int zsideIslandBCEBRecHits[MAXBCEB][MAXBCEBRH];
481 float eIslandBCEBRecHits[MAXBCEB][MAXBCEBRH];
484 for(
int i=0;
i<MAXBCEB;
i++){
487 etaIslandBCEB[
i] = 0;
488 phiIslandBCEB[
i] = 0;
489 e2x2IslandBCEB[
i] = 0;
490 e3x3IslandBCEB[
i] = 0;
491 e5x5IslandBCEB[
i] = 0;
492 nIslandBCEBRecHits[
i] = 0;
493 for(
int j=0;j<MAXBCEBRH;j++){
495 ietaIslandBCEBRecHits[
i][j] = 0;
496 iphiIslandBCEBRecHits[
i][j] = 0;
497 zsideIslandBCEBRecHits[
i][j] = 0;
498 eIslandBCEBRecHits[
i][j] = 0;
504 for(reco::BasicClusterCollection::const_iterator aClus = clusters_recalib.begin(); aClus != clusters_recalib.end(); aClus++) {
505 cout<<
" CLUSTER [recalibration] : #,NHits,e,et,eta,phi,e2x2,e3x3,e5x5: "<<iClus_recalib<<
" "<<aClus->size()<<
" "<<aClus->energy()<<
" "<<aClus->energy()*
sin(aClus->position().theta())<<
" "<<aClus->position().eta()<<
" "<<aClus->position().phi()<<
" "<<(*clustersshapes_p_recalib)[iClus_recalib].e2x2()<<
" "<<(*clustersshapes_p_recalib)[iClus_recalib].e3x3()<<
" "<<(*clustersshapes_p_recalib)[iClus_recalib].e5x5()<<endl;
507 eIslandBCEB[nIslandBCEB] = aClus->energy();
508 etIslandBCEB[nIslandBCEB] = aClus->energy()*
sin(aClus->position().theta());
509 etaIslandBCEB[nIslandBCEB] = aClus->position().eta();
510 phiIslandBCEB[nIslandBCEB] = aClus->position().phi();
512 e2x2IslandBCEB[nIslandBCEB] = (*clustersshapes_p_recalib)[nIslandBCEB].e2x2();
513 e3x3IslandBCEB[nIslandBCEB] = (*clustersshapes_p_recalib)[nIslandBCEB].e3x3();
514 e5x5IslandBCEB[nIslandBCEB] = (*clustersshapes_p_recalib)[nIslandBCEB].e5x5();
516 nIslandBCEBRecHits[nIslandBCEB] = aClus->size();
518 std::vector<std::pair< DetId,float> >
hits = aClus->hitsAndFractions();
519 std::vector<std::pair< DetId,float> >::iterator
hit;
520 std::map<DetId, EcalRecHit>::iterator aHit;
523 for(hit = hits.begin(); hit != hits.end(); hit++)
529 EBDetId sel_rh = aHit->second.detid();
534 ietaIslandBCEBRecHits[nIslandBCEB][irhcount] = sel_rh.
ieta();
535 iphiIslandBCEBRecHits[nIslandBCEB][irhcount] = sel_rh.
iphi();
536 zsideIslandBCEBRecHits[nIslandBCEB][irhcount] = sel_rh.
zside();
537 eIslandBCEBRecHits[nIslandBCEB][irhcount] = aHit->second.energy();
551 for(
int i=0 ;
i<nIslandBCEB ;
i++)
553 for(
int j=
i+1 ; j<nIslandBCEB ; j++)
559 float theta_0 = 2. * atan(
exp(-etaIslandBCEB[
i]));
560 float theta_1 = 2. * atan(
exp(-etaIslandBCEB[j]));
562 float p0x = eIslandBCEB[
i] *
sin(theta_0) *
cos(phiIslandBCEB[i]);
563 float p1x = eIslandBCEB[j] *
sin(theta_1) *
cos(phiIslandBCEB[j]);
565 float p0y = eIslandBCEB[
i] *
sin(theta_0) *
sin(phiIslandBCEB[i]);
566 float p1y = eIslandBCEB[j] *
sin(theta_1) *
sin(phiIslandBCEB[j]);
568 float p0z = eIslandBCEB[
i] *
cos(theta_0);
569 float p1z = eIslandBCEB[j] *
cos(theta_1);
571 float pi0_px = p0x + p1x;
572 float pi0_py = p0y + p1y;
573 float pi0_pz = p0z + p1z;
575 float pi0_ptot =
sqrt (pi0_px*pi0_px + pi0_py*pi0_py + pi0_pz*pi0_pz);
577 float pi0_theta = acos(pi0_pz/pi0_ptot);
578 float pi0_eta = -
log(
tan(pi0_theta/2));
579 float pi0_phi = atan(pi0_py/pi0_px);
585 for(Int_t
k=0 ;
k<nIslandBCEB ;
k++)
587 if( (
k != i) && (
k != j) )
589 float dr_pi0_k =
sqrt( (etaIslandBCEB[
k]-pi0_eta)*(etaIslandBCEB[
k]-pi0_eta) + (phiIslandBCEB[
k]-pi0_phi)*(phiIslandBCEB[
k]-pi0_phi) );
590 float deta_pi0_k = fabs(etaIslandBCEB[
k]-pi0_eta);
596 float pt_pi0 =
sqrt( (p0x+p1x)*(p0x+p1x) + (p0y+p1y)*(p0y+p1y));
602 float m_inv =
sqrt ( (eIslandBCEB[i] + eIslandBCEB[j])*(eIslandBCEB[i] + eIslandBCEB[j]) - (p0x+p1x)*(p0x+p1x) - (p0y+p1y)*(p0y+p1y) - (p0z+p1z)*(p0z+p1z) );
603 cout <<
" pi0 (pt>2.5 GeV) m_inv = "<<m_inv<<endl;
605 float s4s9_1 = e2x2IslandBCEB[
i]/e3x3IslandBCEB[
i];
606 float s4s9_2 = e2x2IslandBCEB[j]/e3x3IslandBCEB[j];
608 float s9s25_1 = e3x3IslandBCEB[
i]/e5x5IslandBCEB[
i];
609 float s9s25_2 = e3x3IslandBCEB[j]/e5x5IslandBCEB[j];
620 cout<<
" Pi0 Good candidate : minv = "<<m_inv<<endl;
621 for(
int kk=0 ;
kk<nIslandBCEBRecHits[
i] ;
kk++)
623 int ieta_xtal = ietaIslandBCEBRecHits[
i][
kk];
624 int iphi_xtal = iphiIslandBCEBRecHits[
i][
kk];
625 int sign = zsideIslandBCEBRecHits[
i][
kk]>0 ? 1 : 0;
628 cout<<
"[Pi0FixedMassWindowCalibration] eta, phi, sign, e, e3x3, wxtals and mwxtals: "<<ieta_xtal<<
" "<<iphi_xtal<<
" "<<sign<<
" "<<eIslandBCEBRecHits[
i][
kk]<<
" "<<e3x3IslandBCEB[
i]<<
" "<<
wxtals[
abs(ieta_xtal)-1][iphi_xtal-1][
sign]<<
" "<<
mwxtals[
abs(ieta_xtal)-1][iphi_xtal-1][
sign]<<endl;
631 for(
int kk=0 ;
kk<nIslandBCEBRecHits[j] ;
kk++)
633 int ieta_xtal = ietaIslandBCEBRecHits[j][
kk];
634 int iphi_xtal = iphiIslandBCEBRecHits[j][
kk];
635 int sign = zsideIslandBCEBRecHits[j][
kk]>0 ? 1 : 0;
636 wxtals[
abs(ieta_xtal)-1][iphi_xtal-1][
sign] =
wxtals[
abs(ieta_xtal)-1][iphi_xtal-1][
sign] + eIslandBCEBRecHits[j][
kk]/e3x3IslandBCEB[j];
638 cout<<
"[Pi0FixedMassWindowCalibration] eta, phi, sign, e, e3x3, wxtals and mwxtals: "<<ieta_xtal<<
" "<<iphi_xtal<<
" "<<sign<<
" "<<eIslandBCEBRecHits[j][
kk]<<
" "<<e3x3IslandBCEB[j]<<
" "<<
wxtals[
abs(ieta_xtal)-1][iphi_xtal-1][
sign]<<
" "<<
mwxtals[
abs(ieta_xtal)-1][iphi_xtal-1][
sign]<<endl;
652 cout<<
" Not enough ECAL Barrel Basic Clusters: "<<nIslandBCEB<<endl;
double selePi0PtGammaTwoMin_
T getParameter(std::string const &) const
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
edm::ParameterSet theParameterSet
void startingNewLoop(unsigned int iLoop) override
Called at beginning of loop.
void beginOfJob() override
Called at beginning of job.
std::string clustershapecollectionEB_
double selePi0S9S25GammaOneMin_
Status endOfLoop(const edm::EventSetup &, unsigned int iLoop) override
Called at end of loop.
CaloTopology const * topology(0)
const self & getMap() const
void writeLine(EBDetId const &, float)
Sin< T >::type sin(const T &t)
std::vector< DetId > barrelCells
double selePi0S4S9GammaOneMin_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
constexpr uint32_t rawId() const
get the raw id
std::vector< EcalRecHit >::const_iterator const_iterator
def setup(process, global_tag, zero_tesla=False)
std::vector< ClusterShape > ClusterShapeCollection
collection of ClusterShape objects
IslandClusterAlgo::VerbosityLevel verbosity
PositionCalc posCalculator_
int iphi() const
get the crystal iphi
double selePi0PtGammaOneMin_
reco::ClusterShape Calculate(const reco::BasicCluster &passedCluster, const EcalRecHitCollection *hits, const CaloSubdetectorGeometry *geometry, const CaloSubdetectorTopology *topology)
MVATrainerComputer * calib
double selePi0MinvMeanFixed_
std::string barrelClusterCollection_
Cos< T >::type cos(const T &t)
Tan< T >::type tan(const T &t)
double selePi0MinvSigmaFixed_
Abs< T >::type abs(const T &t)
double selePi0S9S25GammaTwoMin_
int ieta() const
get the crystal ieta
ParameterDescriptionBase * add(U const &iLabel, T const &value)
const EcalRecHitCollection * ecalRecHitBarrelCollection
const_iterator end() const
double newCalibs_barl[85][360][2]
std::vector< reco::BasicCluster > makeClusters(const EcalRecHitCollection *hits, const CaloSubdetectorGeometry *geometry, const CaloSubdetectorTopology *topology_p, const CaloSubdetectorGeometry *geometryES_p, EcalPart ecalPart, bool regional=false, const std::vector< RectangularEtaPhiRegion > ®ions=std::vector< RectangularEtaPhiRegion >())
double selePi0EtBeltIsoRatioMax_
T const * product() const
std::vector< Item >::const_iterator const_iterator
Status duringLoop(const edm::Event &, const edm::EventSetup &) override
Called at each event.
double selePi0S4S9GammaTwoMin_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::vector< BasicCluster > BasicClusterCollection
collection of BasicCluster objects
std::string barrelClusterShapeAssociation_
IslandClusterAlgo * island_p
std::vector< DetId > getValidDetIds() const
Get the list of all valid detector ids.
double mwxtals[85][360][2]
std::string ecalHitsProducer_
const_iterator find(uint32_t rawId) const
double oldCalibs_barl[85][360][2]
const_iterator end() const
std::map< DetId, EcalRecHit > * recHitsEB_map
Pi0FixedMassWindowCalibration(const edm::ParameterSet &iConfig)
Constructor.
~Pi0FixedMassWindowCalibration() override
Destructor.
T const * product() const
const EcalRecHitCollection * recalibEcalRecHitCollection
void endOfJob() override
Called at end of job.
const_iterator begin() const
ClusterShapeAlgo shapeAlgo_
int zside() const
get the z-side of the crystal (1/-1)
float EcalIntercalibConstant
double wxtals[85][360][2]