35 theMaxLoops( iConfig.getUntrackedParameter<unsigned int>(
"maxLoops",0) ),
36 ecalHitsProducer_( iConfig.getParameter< std::
string > (
"ecalRecHitsProducer") ),
37 barrelHits_( iConfig.getParameter< std::
string > (
"barrelHitCollection") )
40 std::cout <<
"[Pi0FixedMassWindowCalibration] Constructor "<<std::endl;
52 double barrelSeedThreshold = iConfig.
getParameter<
double>(
"IslandBarrelSeedThr");
53 double endcapSeedThreshold = iConfig.
getParameter<
double>(
"IslandEndcapSeedThr");
122 std::cout <<
"[Pi0FixedMassWindowCalibration] endOfJob"<<endl;
128 std::vector<DetId>::const_iterator barrelIt=
barrelCells.begin();
131 int ieta = eb.
ieta();
132 int iphi = eb.
iphi();
145 for (
int ieta=0; ieta<85; ieta++) {
146 for (
int iphi=0; iphi<360; iphi++) {
152 std::cout <<
"[Pi0FixedMassWindowCalibration] Starting loop number " << iLoop<<std::endl;
163 std::cout <<
"[Pi0FixedMassWindowCalibration] Ending loop " << iLoop<<std::endl;
166 for (
int ieta=0; ieta<85; ieta++) {
167 for (
int iphi=0; iphi<360; iphi++) {
183 std::vector<DetId>::const_iterator barrelIt=
barrelCells.begin();
186 int ieta = eb.
ieta();
187 int iphi = eb.
iphi();
191 std::cout <<
"Calib constant for barrel crystal "
192 <<
" (" << ieta <<
"," << iphi <<
") changed from "
201 for (
int ieta=0; ieta<85; ieta++) {
202 for (
int iphi=0; iphi<360; iphi++) {
231 for (
int ieta=0; ieta<85; ieta++) {
232 for (
int iphi=0; iphi<360; iphi++) {
248 std::cout <<
"Taken EcalIntercalibConstants" << std::endl;
249 imap = pIcal.
product()->getMap();
252 std::cerr <<
"Error! can't get EcalIntercalibConstants " << std::endl;
263 std::vector<DetId>::const_iterator barrelIt;
269 if ( itcalib == imap.
end() ) {
275 if (eb.
iphi()==1)
std::cout <<
"Read old constant for crystal "
276 <<
" (" << eb.
ieta() <<
"," << eb.
iphi()
277 <<
") : " << calib << std::endl;
294 std::cout <<
"[Pi0FixedMassWindowCalibration] Events processed: "<<
nevent<<std::endl;
309 EBDetId ebrhdetid = aRecHitEB->detid();
316 recalibEcalRecHitCollection->push_back(aHit);
332 std::pair<DetId, EcalRecHit> map_entry(aRecHitEB->id(), *aRecHitEB);
385 std::vector <reco::ClusterShape> ClusVec_recalib;
386 for (
int erg=0;erg<int(clusters_recalib.size());++erg){
388 ClusVec_recalib.push_back(TestShape_recalib);
393 clustersshapes_p_recalib->assign(ClusVec_recalib.begin(), ClusVec_recalib.end());
395 cout<<
"[Pi0FixedMassWindowCalibration][recalibration] Basic Cluster collection size: "<<clusters_recalib.size()<<endl;
396 cout<<
"[Pi0FixedMassWindowCalibration][recalibration] Basic Cluster Shape Collection size: "<<clustersshapes_p_recalib->size()<<endl;
403 static const int MAXBCEB = 200;
404 static const int MAXBCEBRH = 200;
406 float eIslandBCEB[MAXBCEB];
407 float etIslandBCEB[MAXBCEB];
408 float etaIslandBCEB[MAXBCEB];
409 float phiIslandBCEB[MAXBCEB];
410 float e2x2IslandBCEB[MAXBCEB];
411 float e3x3IslandBCEB[MAXBCEB];
412 float e5x5IslandBCEB[MAXBCEB];
415 int nIslandBCEBRecHits[MAXBCEB];
417 int ietaIslandBCEBRecHits[MAXBCEB][MAXBCEBRH];
418 int iphiIslandBCEBRecHits[MAXBCEB][MAXBCEBRH];
419 int zsideIslandBCEBRecHits[MAXBCEB][MAXBCEBRH];
420 float eIslandBCEBRecHits[MAXBCEB][MAXBCEBRH];
423 for(
int i=0;
i<MAXBCEB;
i++){
426 etaIslandBCEB[
i] = 0;
427 phiIslandBCEB[
i] = 0;
428 e2x2IslandBCEB[
i] = 0;
429 e3x3IslandBCEB[
i] = 0;
430 e5x5IslandBCEB[
i] = 0;
431 nIslandBCEBRecHits[
i] = 0;
432 for(
int j=0;
j<MAXBCEBRH;
j++){
434 ietaIslandBCEBRecHits[
i][
j] = 0;
435 iphiIslandBCEBRecHits[
i][
j] = 0;
436 zsideIslandBCEBRecHits[
i][
j] = 0;
437 eIslandBCEBRecHits[
i][
j] = 0;
443 for(reco::BasicClusterCollection::const_iterator aClus = clusters_recalib.begin(); aClus != clusters_recalib.end(); aClus++) {
444 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;
446 eIslandBCEB[nIslandBCEB] = aClus->energy();
447 etIslandBCEB[nIslandBCEB] = aClus->energy()*
sin(aClus->position().theta());
448 etaIslandBCEB[nIslandBCEB] = aClus->position().eta();
449 phiIslandBCEB[nIslandBCEB] = aClus->position().phi();
451 e2x2IslandBCEB[nIslandBCEB] = (*clustersshapes_p_recalib)[nIslandBCEB].e2x2();
452 e3x3IslandBCEB[nIslandBCEB] = (*clustersshapes_p_recalib)[nIslandBCEB].e3x3();
453 e5x5IslandBCEB[nIslandBCEB] = (*clustersshapes_p_recalib)[nIslandBCEB].e5x5();
455 nIslandBCEBRecHits[nIslandBCEB] = aClus->size();
457 std::vector<std::pair< DetId,float> > hits = aClus->hitsAndFractions();
458 std::vector<std::pair< DetId,float> >::iterator
hit;
459 std::map<DetId, EcalRecHit>::iterator aHit;
462 for(hit = hits.begin(); hit != hits.end(); hit++)
468 EBDetId sel_rh = aHit->second.detid();
473 ietaIslandBCEBRecHits[nIslandBCEB][irhcount] = sel_rh.
ieta();
474 iphiIslandBCEBRecHits[nIslandBCEB][irhcount] = sel_rh.
iphi();
475 zsideIslandBCEBRecHits[nIslandBCEB][irhcount] = sel_rh.
zside();
476 eIslandBCEBRecHits[nIslandBCEB][irhcount] = aHit->second.energy();
490 for(
int i=0 ;
i<nIslandBCEB ;
i++)
492 for(
int j=
i+1 ;
j<nIslandBCEB ;
j++)
498 float theta_0 = 2. * atan(
exp(-etaIslandBCEB[
i]));
499 float theta_1 = 2. * atan(
exp(-etaIslandBCEB[
j]));
501 float p0x = eIslandBCEB[
i] *
sin(theta_0) *
cos(phiIslandBCEB[i]);
502 float p1x = eIslandBCEB[
j] *
sin(theta_1) *
cos(phiIslandBCEB[j]);
504 float p0y = eIslandBCEB[
i] *
sin(theta_0) *
sin(phiIslandBCEB[i]);
505 float p1y = eIslandBCEB[
j] *
sin(theta_1) *
sin(phiIslandBCEB[j]);
507 float p0z = eIslandBCEB[
i] *
cos(theta_0);
508 float p1z = eIslandBCEB[
j] *
cos(theta_1);
510 float pi0_px = p0x + p1x;
511 float pi0_py = p0y + p1y;
512 float pi0_pz = p0z + p1z;
514 float pi0_ptot =
sqrt (pi0_px*pi0_px + pi0_py*pi0_py + pi0_pz*pi0_pz);
516 float pi0_theta = acos(pi0_pz/pi0_ptot);
517 float pi0_eta = -
log(
tan(pi0_theta/2));
518 float pi0_phi = atan(pi0_py/pi0_px);
524 for(Int_t
k=0 ;
k<nIslandBCEB ;
k++)
526 if( (
k != i) && (
k != j) )
528 float dr_pi0_k =
sqrt( (etaIslandBCEB[
k]-pi0_eta)*(etaIslandBCEB[
k]-pi0_eta) + (phiIslandBCEB[
k]-pi0_phi)*(phiIslandBCEB[
k]-pi0_phi) );
529 float deta_pi0_k = fabs(etaIslandBCEB[
k]-pi0_eta);
535 float pt_pi0 =
sqrt( (p0x+p1x)*(p0x+p1x) + (p0y+p1y)*(p0y+p1y));
541 float m_inv =
sqrt ( (eIslandBCEB[i] + eIslandBCEB[j])*(eIslandBCEB[i] + eIslandBCEB[j]) - (p0x+p1x)*(p0x+p1x) - (p0y+p1y)*(p0y+p1y) - (p0z+p1z)*(p0z+p1z) );
542 cout <<
" pi0 (pt>2.5 GeV) m_inv = "<<m_inv<<endl;
544 float s4s9_1 = e2x2IslandBCEB[
i]/e3x3IslandBCEB[
i];
545 float s4s9_2 = e2x2IslandBCEB[
j]/e3x3IslandBCEB[
j];
547 float s9s25_1 = e3x3IslandBCEB[
i]/e5x5IslandBCEB[
i];
548 float s9s25_2 = e3x3IslandBCEB[
j]/e5x5IslandBCEB[
j];
559 cout<<
" Pi0 Good candidate : minv = "<<m_inv<<endl;
560 for(
int kk=0 ;
kk<nIslandBCEBRecHits[
i] ;
kk++)
562 int ieta_xtal = ietaIslandBCEBRecHits[
i][
kk];
563 int iphi_xtal = iphiIslandBCEBRecHits[
i][
kk];
564 int sign = zsideIslandBCEBRecHits[
i][
kk]>0 ? 1 : 0;
567 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;
570 for(
int kk=0 ;
kk<nIslandBCEBRecHits[
j] ;
kk++)
572 int ieta_xtal = ietaIslandBCEBRecHits[
j][
kk];
573 int iphi_xtal = iphiIslandBCEBRecHits[
j][
kk];
574 int sign = zsideIslandBCEBRecHits[
j][
kk]>0 ? 1 : 0;
577 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;
591 cout<<
" Not enough ECAL Barrel Basic Clusters: "<<nIslandBCEB<<endl;
double selePi0PtGammaTwoMin_
virtual void beginOfJob()
Called at beginning of job.
T getParameter(std::string const &) const
edm::ParameterSet theParameterSet
std::string clustershapecollectionEB_
double selePi0S9S25GammaOneMin_
virtual void startingNewLoop(unsigned int iLoop)
Called at beginning of loop.
void writeLine(EBDetId const &, float)
Sin< T >::type sin(const T &t)
std::vector< DetId > barrelCells
double selePi0S4S9GammaOneMin_
std::vector< EcalRecHit >::const_iterator const_iterator
std::vector< ClusterShape > ClusterShapeCollection
collection of ClusterShape objects
IslandClusterAlgo::VerbosityLevel verbosity
PositionCalc posCalculator_
int iphi() const
get the crystal iphi
uint32_t rawId() const
get the raw id
double selePi0PtGammaOneMin_
virtual Status duringLoop(const edm::Event &, const edm::EventSetup &)
Called at each event.
reco::ClusterShape Calculate(const reco::BasicCluster &passedCluster, const EcalRecHitCollection *hits, const CaloSubdetectorGeometry *geometry, const CaloSubdetectorTopology *topology)
MVATrainerComputer * calib
double selePi0MinvMeanFixed_
virtual Status endOfLoop(const edm::EventSetup &, unsigned int iLoop)
Called at end of loop.
std::string barrelClusterCollection_
Cos< T >::type cos(const T &t)
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< EcalEtaPhiRegion > ®ions=std::vector< EcalEtaPhiRegion >())
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
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
const EcalRecHitCollection * ecalRecHitBarrelCollection
const_iterator end() const
double newCalibs_barl[85][360][2]
double selePi0EtBeltIsoRatioMax_
virtual void endOfJob()
Called at end of job.
~Pi0FixedMassWindowCalibration()
Destructor.
std::vector< Item >::const_iterator const_iterator
T const * product() const
double selePi0S4S9GammaTwoMin_
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.
ESHandle< TrackerGeometry > geometry
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.
const EcalRecHitCollection * recalibEcalRecHitCollection
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
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]