26 double sig[4][10][10];
27 double c[4][10][10], cikik[4], cikjk[4];
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++){
67 tempmatrix[
m][
i][
j] = 0;
75 for(
int m = 0;
m != 4;
m++){
76 for(
int i = 0;
i != 10;
i++){
89 for(
int m = 0;
m != 4;
m++){
90 for(
int i = 0;
i != 10;
i++){
91 for(
int j =
i;
j != 10;
j++){ sig[
m][
j][
i] = sig[
m][
i][
j];}
96 for(
int m = 0;
m!=4;
m++)
101 for(
int m = 0;
m!=4;
m++)
103 for(
int i = 1;
i != 10;
i++)
105 c[
m][
i][0] = (sig[
m][0][
i] /
c[
m][0][0]);
110 for(
int m = 0;
m!=4;
m++)
112 c[
m][1][1] =
sqrt(sig[
m][1][1] - (
c[
m][1][0]*
c[
m][1][0]));
113 if (((sig[
m][1][1]) - (
c[m][1][0]*
c[m][1][0]))<=0)
continue;
114 for(
int i = 2;
i !=10;
i++)
117 for(
int j=1;
j!=
i;
j++)
120 for(
int k=0;
k !=
j;
k++)
127 for(
int k = 0;
k !=
i;
k++)
131 double test = (sig[
m][
i][
i] - cikik[
m]);
164 for(
int m = 0; m != 4; m++){
165 for(
int i = 0;
i != 10;
i++){
166 for(
int j =
i;
j != 10;
j++){
168 tempmatrix[
m][
j][
i] =
c[
m][
j][
i];
173 if(hcalid.subdet()==1)
175 for(
int m = 0; m != 4; m++)
176 for(
int i = 0;
i != 10;
i++)
177 for(
int j = 0;
j != 10;
j++)
178 HBmatrix[m][
i][
j] += tempmatrix[m][
i][
j];
181 if(hcalid.subdet()==2)
183 for(
int m = 0; m != 4; m++)
184 for(
int i = 0;
i != 10;
i++)
185 for(
int j = 0;
j != 10;
j++)
186 HEmatrix[m][
i][
j] += tempmatrix[m][
i][
j];
189 if(hcalid.subdet()==3)
191 for(
int m = 0; m != 4; m++)
192 for(
int i = 0;
i != 10;
i++)
193 for(
int j = 0;
j != 10;
j++)
194 HOmatrix[m][
i][
j] += tempmatrix[m][
i][
j];
197 if(hcalid.subdet()==4)
199 for(
int m = 0; m != 4; m++)
200 for(
int i = 0;
i != 10;
i++)
201 for(
int j = 0;
j != 10;
j++)
202 HFmatrix[m][
i][
j] += tempmatrix[m][
i][
j];
208 outMatrices->addValues(*item);
212 for(
int m = 0; m != 4; m++)
214 for(
int i = 0;
i != 10;
i++)
216 for(
int j = 0;
j != 10;
j++)
218 HBmatrix [
m][
i][
j] /= HBcount;
219 HEmatrix [
m][
i][
j] /= HEcount;
220 HFmatrix [
m][
i][
j] /= HFcount;
221 HOmatrix [
m][
i][
j] /= HOcount;
226 std::vector<DetId> listResult = outMatrices->getAllChannels();
234 std::vector<HcalGenericDetId> listEMap = myRefEMap->
allPrecisionId();
236 for (std::vector<HcalGenericDetId>::const_iterator it = listEMap.begin(); it != listEMap.end(); it++)
239 if (
std::find(listResult.begin(), listResult.end(), mydetid ) == listResult.end() )
242 if(it->isHcalDetId())
247 for(
int m = 0; m != 4; m++)
249 for(
int i = 0;
i != 10;
i++)
251 for(
int j = 0;
j != 10;
j++)
254 if(hcalid2.subdet()==1) item->
setValue(m,
i,
j,HBmatrix [m][
i][
j]);
255 if(hcalid2.subdet()==2) item->setValue(m,
i,j,HEmatrix [m][
i][j]);
256 if(hcalid2.subdet()==3) item->setValue(m,
i,j,HFmatrix [m][
i][j]);
257 if(hcalid2.subdet()==4) item->setValue(m,
i,j,HOmatrix [m][
i][j]);
259 if(hcalid2.subdet()==1) item->setValue(m,
i,j,0);
260 if(hcalid2.subdet()==2) item->setValue(m,
i,j,0);
261 if(hcalid2.subdet()==3) item->setValue(m,
i,j,0);
262 if(hcalid2.subdet()==4) item->setValue(m,
i,j,0);
267 outMatrices->addValues(*item);
268 std::cout <<
"... Average Matrix used\n";
274 std::vector<DetId> checkResult = outMatrices->getAllChannels();
276 for(std::vector<DetId>::const_iterator it = checkResult.begin(); it != checkResult.end(); it++)
count ++;
278 std::cout <<
"There are " <<
count <<
" channels with Cholesky matrices.\n" <<
"Used " << n_avg <<
" average values.\n";
280 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)
std::vector< DetId > getAllChannels() const
float getValue(int capid, int i, int j) const
std::vector< HcalGenericDetId > allPrecisionId() const
bool dumpObject(std::ostream &fOutput, const HcalPedestals &fObject)