26 double sig[4][10][10];
27 double c[4][10][10], cikik[4], cikjk[4], ct[4][10][10];
31 std::vector<DetId> listChan = myCov->getAllChannels();
32 std::vector<DetId>::iterator cell;
39 double HBmatrix[4][10][10];
40 double HEmatrix[4][10][10];
41 double HFmatrix[4][10][10];
42 double HOmatrix[4][10][10];
44 double tempmatrix[4][10][10] ;
47 for(
int m= 0;
m != 4;
m++){
48 for(
int i = 0;
i != 10;
i++){
49 for(
int j = 0;
j!=10;
j++){
50 HBmatrix[
m][
i][
j] = 0;
51 HEmatrix[
m][
i][
j] = 0;
52 HFmatrix[
m][
i][
j] = 0;
53 HOmatrix[
m][
i][
j] = 0;
58 for (std::vector<DetId>::iterator it = listChan.begin(); it != listChan.end(); it++)
60 for(
int m= 0;
m != 4;
m++){
61 for(
int i = 0;
i != 10;
i++){
62 for(
int j = 0;
j!=10;
j++){
68 tempmatrix[
m][
i][
j] = 0;
76 for(
int m = 0;
m != 4;
m++){
77 for(
int i = 0;
i != 10;
i++){
90 for(
int m = 0;
m != 4;
m++){
91 for(
int i = 0;
i != 10;
i++){
92 for(
int j =
i;
j != 10;
j++){ sig[
m][
j][
i] = sig[
m][
i][
j];}
97 for(
int m = 0;
m!=4;
m++)
102 for(
int m = 0;
m!=4;
m++)
104 for(
int i = 1;
i != 10;
i++)
106 c[
m][
i][0] = (sig[
m][0][
i] /
c[
m][0][0]);
111 for(
int m = 0;
m!=4;
m++)
113 c[
m][1][1] =
sqrt(sig[
m][1][1] - (
c[
m][1][0]*
c[
m][1][0]));
114 if (((sig[
m][1][1]) - (
c[m][1][0]*
c[m][1][0]))<=0)
continue;
115 for(
int i = 2;
i !=10;
i++)
118 for(
int j=1;
j!=
i;
j++)
121 for(
int k=0;
k !=
j;
k++)
128 for(
int k = 0;
k !=
i;
k++)
132 double test = (sig[
m][
i][
i] - cikik[
m]);
165 for(
int m = 0; m != 4; m++){
166 for(
int i = 0;
i != 10;
i++){
167 for(
int j =
i;
j != 10;
j++){
169 tempmatrix[
m][
j][
i] =
c[
m][
j][
i];
174 if(hcalid.subdet()==1)
176 for(
int m = 0; m != 4; m++)
177 for(
int i = 0;
i != 10;
i++)
178 for(
int j = 0;
j != 10;
j++)
179 HBmatrix[m][
i][
j] += tempmatrix[m][
i][
j];
182 if(hcalid.subdet()==2)
184 for(
int m = 0; m != 4; m++)
185 for(
int i = 0;
i != 10;
i++)
186 for(
int j = 0;
j != 10;
j++)
187 HEmatrix[m][
i][
j] += tempmatrix[m][
i][
j];
190 if(hcalid.subdet()==3)
192 for(
int m = 0; m != 4; m++)
193 for(
int i = 0;
i != 10;
i++)
194 for(
int j = 0;
j != 10;
j++)
195 HOmatrix[m][
i][
j] += tempmatrix[m][
i][
j];
198 if(hcalid.subdet()==4)
200 for(
int m = 0; m != 4; m++)
201 for(
int i = 0;
i != 10;
i++)
202 for(
int j = 0;
j != 10;
j++)
203 HFmatrix[m][
i][
j] += tempmatrix[m][
i][
j];
209 outMatrices->addValues(*item);
213 for(
int m = 0; m != 4; m++)
215 for(
int i = 0;
i != 10;
i++)
217 for(
int j = 0;
j != 10;
j++)
219 HBmatrix [
m][
i][
j] /= HBcount;
220 HEmatrix [
m][
i][
j] /= HEcount;
221 HFmatrix [
m][
i][
j] /= HFcount;
222 HOmatrix [
m][
i][
j] /= HOcount;
227 std::vector<DetId> listResult = outMatrices->getAllChannels();
235 std::vector<HcalGenericDetId> listEMap = myRefEMap->
allPrecisionId();
237 for (std::vector<HcalGenericDetId>::const_iterator it = listEMap.begin(); it != listEMap.end(); it++)
240 if (
std::find(listResult.begin(), listResult.end(), mydetid ) == listResult.end() )
243 if(it->isHcalDetId())
248 for(
int m = 0; m != 4; m++)
250 for(
int i = 0;
i != 10;
i++)
252 for(
int j = 0;
j != 10;
j++)
255 if(hcalid2.subdet()==1) item->
setValue(m,
i,
j,HBmatrix [m][
i][
j]);
256 if(hcalid2.subdet()==2) item->setValue(m,
i,j,HEmatrix [m][
i][j]);
257 if(hcalid2.subdet()==3) item->setValue(m,
i,j,HFmatrix [m][
i][j]);
258 if(hcalid2.subdet()==4) item->setValue(m,
i,j,HOmatrix [m][
i][j]);
260 if(hcalid2.subdet()==1) item->setValue(m,
i,j,0);
261 if(hcalid2.subdet()==2) item->setValue(m,
i,j,0);
262 if(hcalid2.subdet()==3) item->setValue(m,
i,j,0);
263 if(hcalid2.subdet()==4) item->setValue(m,
i,j,0);
268 outMatrices->addValues(*item);
269 std::cout <<
"... Average Matrix used\n";
275 std::vector<DetId> checkResult = outMatrices->getAllChannels();
277 for(std::vector<DetId>::const_iterator it = checkResult.begin(); it != checkResult.end(); it++)
count ++;
279 std::cout <<
"There are " <<
count <<
" channels with Cholesky matrices.\n" <<
"Used " << n_avg <<
" average values.\n";
281 ofstream cmatout(
outfile.c_str());
void setValue(int capid, int i, int j, float val)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
float getValue(int capid, int i, int j) const
std::vector< HcalGenericDetId > allPrecisionId() const
bool dumpObject(std::ostream &fOutput, const HcalPedestals &fObject)