ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/yangyong/combineICEB/makeDeadCrystalFlag.C
Revision: 1.2
Committed: Tue Apr 10 19:41:10 2012 UTC (13 years, 1 month ago) by yangyong
Content type: text/plain
Branch: MAIN
CVS Tags: V2012combv2c, V2012combv2b, V2012combv2a, V2012combv2, V2012combv1, V2011combv1, pi0etaeb_laser20111122, HEAD
Changes since 1.1: +208 -0 lines
Error occurred while calculating annotation data.
Log Message:
LaserTag:
EcalLaserAPDPNRatios_data_20111122_158851_180363

and alpha Tag ( for Endcap Only)
EcalLaserAlphas_lto420-620_progr_data_20111122

File Contents

# Content
1 #include <iomanip>
2 #include <fstream>
3 #include "TH1.h"
4 #include "TH2.h"
5 #include "TString.h"
6 #include "TFile.h"
7 #include "TMath.h"
8 #include "TBranch.h"
9 #include "TChain.h"
10 #include <iostream>
11 #include <algorithm>
12 #include <map>
13 #include "TLorentzVector.h"
14 #include "TVector3.h"
15 #include "TApplication.h"
16 #include "TSystem.h"
17 #include "TF1.h"
18 #include "TGraphErrors.h"
19 #include "TCanvas.h"
20 #include "TH1F.h"
21 #include "TH2F.h"
22 #include "TRandom.h"
23 #include "TRandom3.h"
24 #include "TMultiLayerPerceptron.h"
25 #include "TMLPAnalyzer.h"
26 #include "TMatrixD.h"
27 #include "TMatrix.h"
28 #include "TMatrixDSymEigen.h"
29 #include "TMatrixDSym.h"
30 #include "TMatrixTSym.h"
31 #include <vector>
32 #include "TArrow.h"
33 #include "TLegend.h"
34 #include "TROOT.h"
35 #include <stdlib.h>
36 #include "TStyle.h"
37 #include "TLatex.h"
38 #include "TGraphAsymmErrors.h"
39 #include "TLegendEntry.h"
40 #include "THStack.h"
41
42 using namespace std;
43
44 #include "common_functions.cc"
45 #include "physUtils.cc"
46
47
48 void checkHowManyDeadCrystalNext(int j, int k, int flagmap_ietaiphi[170][360],int &ncorner, int &nside, int &nflagdeadNextTo){
49
50 ///input i, j after convxvalid
51
52 if( !( j>=0 && j<= 169 && k>=0 && k<= 359)){
53 cout<<"input checkHowManyDeadCrystalNext j/k: "<< j<<" "<<k<<endl;
54 exit(1);
55 }
56
57
58 int nbad = 0;
59 nside = 0;
60 ncorner = 0;
61
62
63
64
65
66 for(int nieta = -1; nieta <=1; nieta++){
67 int jj= j+ nieta;
68 if( jj <0 || jj >=170) continue;
69
70 for(int niphi = -1; niphi <=1; niphi++){
71
72 if(nieta==0 && niphi==0) continue; //itself
73
74
75 int kk = k + niphi;
76 if( kk == -1) kk = 359;
77 if( kk == 360) kk = 0;
78
79
80 if(flagmap_ietaiphi[jj][kk]>0 ){
81 nbad ++;
82 int deta = diff_neta(j,jj);
83 int dphi = diff_nphi(k,kk);
84
85 if( deta ==1 && dphi ==1) ncorner ++;
86 else nside ++;
87
88 }
89 }
90
91 }
92
93 nflagdeadNextTo = 0;
94
95 if(nbad==0){
96 nflagdeadNextTo = 0;
97 }
98 else if(nbad==1){
99 if(ncorner ==1) {
100 nflagdeadNextTo = 1;
101 }else{
102 nflagdeadNextTo = 2;
103 }
104 }else if(nbad==2){
105 if(ncorner ==2) {
106 nflagdeadNextTo = 3;
107 }else if( nside ==2) {
108 nflagdeadNextTo = 4;
109 }else {
110 nflagdeadNextTo = 5;
111 }
112 }else if(nbad==3){
113 if(ncorner ==3) {
114 nflagdeadNextTo = 6;
115 }else if( nside ==3) {
116 nflagdeadNextTo = 7;
117 }else if( ncorner ==1 && nside ==2) {
118 nflagdeadNextTo = 8;
119 }else if( ncorner ==2 && nside ==1) {
120 nflagdeadNextTo = 9;
121 }
122 }else if( nbad==4){
123 if(ncorner ==4 ) {
124 nflagdeadNextTo = 10;
125 }else if( nside ==4) {
126 nflagdeadNextTo = 11;
127 }else if( ncorner ==2 && nside ==2) {
128 nflagdeadNextTo = 12;
129 }else if( ncorner ==1 && nside ==3) {
130 nflagdeadNextTo = 13;
131 }else if( ncorner ==3 && nside ==1) {
132 nflagdeadNextTo = 14;
133 }
134 }else{
135 cout<<"nbad? "<< nbad <<" "<< j<<" "<<k<<endl;
136 exit(1);
137 }
138
139
140 }
141
142
143 /// code to make deadflag map for each crystal in the Barrel
144 /// simply to check the count of n.b. of pi0/eta candidates seeded in each crystal.
145 /// should work OK when use all statistics for a given calibration period.
146 /// makeDeadCrystalFlag("calibres/deriveCalibConst.testCalibv1.dflag72.pe1.cut0.rmOvlap0.step11.method1.corrEta21.corrPhi10.corrSM1.corrDead-1.precalib1.vtx1.encorr0.evtNot-1.trig0.root",72);
147
148 void makeDeadCrystalFlag(char *inputfile, int dataflag){
149
150 TFile *ff = new TFile(inputfile,"read");
151
152 TString output = TString(Form("deadflag/crystal_deadflag_eb_dflag%d.txt",dataflag));
153 cout<<output<<endl;
154 ofstream txtout(output,ios::out);
155
156
157 TH2F *hhtmp = (TH2F*)ff->Get("hh_res_count_0");
158 int flagmap_ietaiphi[170][360];
159
160 for(int j=0; j<170; j++){
161 int bx = j-85;
162 if( bx>=0) bx +=1;
163 for(int k=0; k< 360; k++){
164
165 int by = k;
166 if( k== 0) by = 360;
167
168 int count = hhtmp->GetBinContent(bx+85+1,by);
169
170 if( count >0 && count < 50) {
171 cout<<"pls check small count!!! " << bx <<" "<<by <<" "<< count <<endl;
172 }
173
174 if( count >10){
175 flagmap_ietaiphi[j][k] = 0;
176 }else{
177 flagmap_ietaiphi[j][k] = 1;
178 }
179
180
181 }
182 }
183
184 int ncorner;
185 int nside;
186 int nflagdeadNextTo;
187
188
189 for(int ieta=-85; ieta<=85; ieta++){
190 if( ieta == 0) continue;
191 for(int iphi=1; iphi<=360; iphi++){
192 int j = ieta;
193 int k = iphi;
194 convxtalid(k,j);
195 j += 85;
196
197 if(flagmap_ietaiphi[j][k] <1){
198 checkHowManyDeadCrystalNext(j,k, flagmap_ietaiphi, ncorner, nside, nflagdeadNextTo);
199 txtout<<j<<" "<<k<<" "<< flagmap_ietaiphi[j][k] <<" "<< ncorner <<" "<< nside << " "<< nflagdeadNextTo <<endl;
200 }else{
201 txtout<<j<<" "<<k<<" "<< flagmap_ietaiphi[j][k] <<" "<< -1 <<" "<< -1 <<" "<< -1 <<endl;
202 }
203 }
204 }
205
206
207
208 }