Go to the documentation of this file.00001 #include "RecoEcal/EgammaCoreTools/interface/Mustache.h"
00002 #include "TMath.h"
00003 using namespace std;
00004 using namespace reco;
00005
00006 void Mustache::MustacheID(const reco::SuperCluster& sc, int & nclusters, float & EoutsideMustache)
00007 {
00008 CaloClusterPtrVector clusters;
00009
00010 for(CaloCluster_iterator iter = sc.clustersBegin(); iter != sc.clustersEnd(); ++iter){
00011 clusters.push_back(*iter);
00012 }
00013
00014 MustacheID(clusters, nclusters, EoutsideMustache);
00015 }
00016
00017 void Mustache::MustacheID(CaloClusterPtrVector& clusters, int & nclusters, float & EoutsideMustache) {
00018 std::vector<const CaloCluster*> myClusters;
00019 unsigned myNclusters(clusters.size());
00020 for(unsigned icluster=0;icluster<myNclusters;++icluster) {
00021 myClusters.push_back(&(*clusters[icluster]));
00022 }
00023 MustacheID(myClusters,nclusters,EoutsideMustache);
00024 }
00025
00026 void Mustache::MustacheID(std::vector<const CaloCluster*>clusters, int & nclusters, float & EoutsideMustache)
00027 {
00028
00029 nclusters = 0;
00030 EoutsideMustache = 0;
00031
00032 unsigned int ncl = clusters.size();
00033 if(!ncl) return;
00034
00035
00036 float emax = 0;
00037 int imax = -1;
00038 for(unsigned int i=0; i<ncl; ++i){
00039 float e = (*clusters[i]).energy();
00040 if(e > emax){
00041 emax = e;
00042 imax = i;
00043 }
00044 }
00045
00046 if(imax<0) return;
00047 float eta0 = (*clusters[imax]).eta();
00048 float phi0 = (*clusters[imax]).phi();
00049
00050
00051 float p00 = -0.107537;
00052 float p01 = 0.590969;
00053 float p02 = -0.076494;
00054 float p10 = -0.0268843;
00055 float p11 = 0.147742;
00056 float p12 = -0.0191235;
00057
00058 float w00 = -0.00571429;
00059 float w01 = -0.002;
00060 float w10 = 0.0135714;
00061 float w11 = 0.001;
00062
00063 float deta, dphi;
00064 float upper_cut, lower_cut;
00065 float b_upper, b_lower;
00066 float a_upper, a_lower;
00067 float curv_low, curv_up;
00068 float midpoint;
00069
00070 for(unsigned int k=0; k<ncl; k++){
00071 deta = 0.0;
00072 dphi = 0.0;
00073 upper_cut = 0.0;
00074 lower_cut = 0.0;
00075 b_upper = 0.0;
00076 b_lower = 0.0;
00077 a_upper = 0.0;
00078 a_lower = 0.0;
00079 curv_low = 0.0;
00080 curv_up = 0.0;
00081 midpoint = 0.0;
00082
00083 deta = sin(phi0)*((*clusters[k]).eta()-eta0);
00084 dphi = (*clusters[k]).phi()-phi0;
00085
00086 if(dphi> TMath::Pi()) dphi -= 2* TMath::Pi();
00087 if(dphi<-1* TMath::Pi()) dphi +=2* TMath::Pi();
00088
00089
00090
00091
00092
00093
00094 b_lower = w00*sin(eta0)*eta0 + w01 / sqrt(log10((*clusters[k]).energy())+1.1);
00095 b_upper = w10*sin(eta0)*eta0 + w11 / sqrt(log10((*clusters[k]).energy())+1.1);
00096
00097
00098 midpoint = b_upper - (b_upper-b_lower)/2.;
00099 b_lower = b_lower - midpoint;
00100 b_upper = b_upper - midpoint;
00101
00102
00103
00104
00105 curv_up = p00*pow(eta0*sin(eta0),2)+p01*eta0*sin(eta0)+p02;
00106 curv_low = p10*pow(eta0*sin(eta0),2)+p11*eta0*sin(eta0)+p12;
00107
00108
00109 a_lower = (1/(4*curv_low))-fabs(b_lower);
00110 a_upper = (1/(4*curv_up))-fabs(b_upper);
00111
00112 upper_cut =(1./(4.*a_upper))*pow(dphi,2)+b_upper;
00113 lower_cut =(1./(4.*a_lower))*pow(dphi,2)+b_lower;
00114
00115
00116 if (!(deta < upper_cut && deta > lower_cut)){
00117 nclusters++;
00118 EoutsideMustache += (*clusters[k]).energy();
00119 }
00120
00121 }
00122 }
00123
00124 void Mustache::MustacheClust(std::vector<CaloCluster> clusters, std::vector<unsigned int>& insideMust, std::vector<unsigned int>& outsideMust){
00125 unsigned int ncl = clusters.size();
00126 if(!ncl) return;
00127
00128
00129 float emax = 0;
00130 int imax = -1;
00131 for(unsigned int i=0; i<ncl; ++i){
00132 float e = (clusters[i]).energy();
00133 if(e > emax){
00134 emax = e;
00135 imax = i;
00136 }
00137 }
00138
00139 if(imax<0) return;
00140 float eta0 = (clusters[imax]).eta();
00141 float phi0 = (clusters[imax]).phi();
00142
00143
00144 float p00 = -0.107537;
00145 float p01 = 0.590969;
00146 float p02 = -0.076494;
00147 float p10 = -0.0268843;
00148 float p11 = 0.147742;
00149 float p12 = -0.0191235;
00150
00151 float w00 = -0.00571429;
00152 float w01 = -0.002;
00153 float w10 = 0.0135714;
00154 float w11 = 0.001;
00155
00156 float deta, dphi;
00157 float upper_cut, lower_cut;
00158 float b_upper, b_lower;
00159 float a_upper, a_lower;
00160 float curv_low, curv_up;
00161 float midpoint;
00162
00163 for(unsigned int k=0; k<ncl; k++){
00164 deta = 0.0;
00165 dphi = 0.0;
00166 upper_cut = 0.0;
00167 lower_cut = 0.0;
00168 b_upper = 0.0;
00169 b_lower = 0.0;
00170 a_upper = 0.0;
00171 a_lower = 0.0;
00172 curv_low = 0.0;
00173 curv_up = 0.0;
00174 midpoint = 0.0;
00175
00176 deta = sin(phi0)*((clusters[k]).eta()-eta0);
00177 dphi = (clusters[k]).phi()-phi0;
00178
00179 if(dphi> TMath::Pi()) dphi -= 2* TMath::Pi();
00180 if(dphi<-1* TMath::Pi()) dphi +=2* TMath::Pi();
00181
00182
00183
00184
00185
00186
00187 b_lower = w00*sin(eta0)*eta0 + w01 / sqrt(log10((clusters[k]).energy())+1.1);
00188 b_upper = w10*sin(eta0)*eta0 + w11 / sqrt(log10((clusters[k]).energy())+1.1);
00189
00190
00191 midpoint = b_upper - (b_upper-b_lower)/2.;
00192 b_lower = b_lower - midpoint;
00193 b_upper = b_upper - midpoint;
00194
00195
00196
00197
00198 curv_up = p00*pow(eta0*sin(eta0),2)+p01*eta0*sin(eta0)+p02;
00199 curv_low = p10*pow(eta0*sin(eta0),2)+p11*eta0*sin(eta0)+p12;
00200
00201
00202 a_lower = (1/(4*curv_low))-fabs(b_lower);
00203 a_upper = (1/(4*curv_up))-fabs(b_upper);
00204
00205 upper_cut =(1./(4.*a_upper))*pow(dphi,2)+b_upper;
00206 lower_cut =(1./(4.*a_lower))*pow(dphi,2)+b_lower;
00207
00208
00209 if (!(deta < upper_cut && deta > lower_cut)){
00210 outsideMust.push_back(k);
00211 }
00212 else{
00213 insideMust.push_back(k);
00214 }
00215 }
00216 }
00217
00218 void Mustache::FillMustacheVar(std::vector<CaloCluster>clusters){
00219 Energy_In_Mustache_=0;
00220 Energy_Outside_Mustache_=0;
00221 LowestClusterEInMustache_=0;
00222 excluded_=0;
00223 included_=0;
00224 std::multimap<float, unsigned int>OrderedClust;
00225 std::vector<unsigned int> insideMust;
00226 std::vector<unsigned int> outsideMust;
00227 MustacheClust(clusters, insideMust, outsideMust);
00228 included_=insideMust.size(); excluded_=outsideMust.size();
00229 for(unsigned int i=0; i<insideMust.size(); ++i){
00230 unsigned int index=insideMust[i];
00231 Energy_In_Mustache_=clusters[index].energy()+Energy_In_Mustache_;
00232 OrderedClust.insert(make_pair(clusters[index].energy(), index));
00233 }
00234 for(unsigned int i=0; i<outsideMust.size(); ++i){
00235 unsigned int index=outsideMust[i];
00236 Energy_Outside_Mustache_=clusters[index].energy()+Energy_Outside_Mustache_;
00237 Et_Outside_Mustache_=clusters[index].energy()*sin(clusters[index].position().theta())
00238 +Et_Outside_Mustache_;
00239 }
00240 std::multimap<float, unsigned int>::iterator it;
00241 it=OrderedClust.begin();
00242 unsigned int lowEindex=(*it).second;
00243 LowestClusterEInMustache_=clusters[lowEindex].energy();
00244
00245 }