ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/yangyong/combineICEE/make_deadflagEE.C
Revision: 1.2
Committed: Thu Aug 30 11:03:29 2012 UTC (12 years, 8 months ago) by yangyong
Content type: text/plain
Branch: MAIN
CVS Tags: V2012comb, HEAD
Changes since 1.1: +36 -3 lines
Error occurred while calculating annotation data.
Log Message:
*** empty log message ***

File Contents

# Content
1 #include "rootheader.h"
2 #include "testSelection_cluster.h"
3
4 #include "common_functions.cc"
5
6
7 float interCalib_preCalib[170][360];
8 float interCalibEndcap_preCalib[2][101][101];
9
10
11 bool isTestBeamSM(int iSM){
12
13
14
15 //if( iSM == 1 || iSM == 2 || iSM == 11 || iSM == 15 || iSM == 21 || iSM == 24) return true;
16
17 if( iSM == 1 || iSM == 11 || iSM == 15 || iSM == 24) return true;
18
19
20 else return false;
21
22 }
23
24 #include "effSigma.C"
25
26 #include "gausfit.cc"
27
28
29
30 #include "foldEndcap.cc"
31
32
33 #include "getCalibConstants.cc"
34
35
36
37
38 void checkHowManyDeadCrystalNext(int iz, int j, int k, int flagmap_ietaiphi[2][101][101],int &ncorner, int &nside, int &nflagdeadNextTo){
39
40
41 ///input i, j after convxvalid
42
43 if( ! (iz >=0 && iz<=1) ){
44 cout<<"iz 0/1 ? " << iz <<endl;
45 return;
46 }
47
48
49
50 int nbad = 0;
51 nside = 0;
52 ncorner = 0;
53
54
55
56
57 for(int nieta = -1; nieta <=1; nieta++){
58 int jj= j+ nieta;
59 if( jj <=0 || jj >=101) continue;
60
61 for(int niphi = -1; niphi <=1; niphi++){
62
63 if(nieta==0 && niphi==0) continue; //itself
64 int kk = k + niphi;
65
66 if( validRecHitEndCap[iz][jj][kk] ==0) continue;
67
68 if(flagmap_ietaiphi[iz][jj][kk]>0 ){
69 nbad ++;
70 int deta = diff_neta(j,jj);
71 int dphi = diff_nphi(k,kk);
72
73 if( deta ==1 && dphi ==1) ncorner ++;
74 else nside ++;
75
76 }
77 }
78
79 }
80
81 nflagdeadNextTo = 0;
82
83 if(nbad==0){
84 nflagdeadNextTo = 0;
85 }
86 else if(nbad==1){
87 if(ncorner ==1) {
88 nflagdeadNextTo = 1;
89 }else{
90 nflagdeadNextTo = 2;
91 }
92 }else if(nbad==2){
93 if(ncorner ==2) {
94 nflagdeadNextTo = 3;
95 }else if( nside ==2) { //
96 nflagdeadNextTo = 4;
97 }else { //NZ
98 nflagdeadNextTo = 5;
99 }
100 }else if(nbad==3){
101 if(ncorner ==3) {
102 nflagdeadNextTo = 6;
103 }else if( nside ==3) { ///NZ
104 nflagdeadNextTo = 7;
105 }else if( ncorner ==1 && nside ==2) {
106 nflagdeadNextTo = 8;
107 }else if( ncorner ==2 && nside ==1) { //NZ
108 nflagdeadNextTo = 9;
109 }
110 }else if( nbad==4){
111 if(ncorner ==4 ) {
112 nflagdeadNextTo = 10;
113 }else if( nside ==4) {
114 nflagdeadNextTo = 11;
115 }else if( ncorner ==2 && nside ==2) { //NZ
116 nflagdeadNextTo = 12;
117 }else if( ncorner ==1 && nside ==3) {
118 nflagdeadNextTo = 13;
119 }else if( ncorner ==3 && nside ==1) { //NZ
120 nflagdeadNextTo = 14;
121 }
122 } else if( nbad ==5){
123 if( ncorner ==4 ) {
124 nflagdeadNextTo = 15;
125 }
126 else if( nside ==4 ) {
127 nflagdeadNextTo = 16;
128 }
129 else if( nside ==3 && ncorner ==2 ) {
130 nflagdeadNextTo = 17;
131 }
132 else if( nside ==2 && ncorner ==3 ) {
133 nflagdeadNextTo = 18;
134 }
135
136 else{
137 cout<<"? " << nbad <<" "<< nside <<" "<< ncorner <<endl;
138 }
139 }
140
141 else if(nbad == 6){
142 if( ncorner ==4 && nside ==2 ) {
143 nflagdeadNextTo = 19;
144 }
145
146 else{
147 cout<<"? " << nbad <<" "<< nside <<" "<< ncorner <<endl;
148 }
149
150 }
151
152 else{
153 cout<<"nbad? "<< nbad <<" "<< iz <<" "<< j<<" "<<k<<" "<< ncorner <<" "<< nside <<endl;
154 exit(1);
155 }
156
157 }
158
159 ///input the IC file in calibres/
160 void make_deadflagEE(char *inputfile, int dataflag ){
161
162 for(int j=0; j<2; j++){
163 for(int x =0; x<101; x++){
164 for(int y=0; y<101; y++){
165 validRecHitEndCap[j][x][y] = 0;
166 }
167 }
168 }
169 get_xyzEBrechits();
170 setEtaRingBoundaryEndcap();
171
172
173
174 readInterCalibEndcap_GR09_V8();
175
176 ifstream txtin(inputfile,ios::in);
177
178 string sinput = inputfile;
179
180 int pizEta = 1;
181 if( sinput.find("pe2") != string::npos){
182 pizEta = 2;
183 }
184
185
186 cout<<"pizEta " << pizEta <<endl;
187 int nMaxRingIC = 20;
188 if( pizEta==2){
189 nMaxRingIC = 30;
190 }
191
192
193 int iz;
194 int ix;
195 int iy;
196 int flag;
197 float cc;
198 int flagEE[2][101][101];
199 while (txtin.good()){
200 txtin>> iz >> ix >> iy >> cc;
201
202 flag = cc <0 ; //-1 means dead xtal
203
204 int iring = iRingEndCap(2*iz-1,ix,iy); ///input -1/1,
205
206 ///if(iring > nMaxRingIC ) flag = 0; //always good for those rings...
207
208 flagEE[iz][ix][iy]= flag;
209 }
210
211
212 TString output = TString(Form("crystal_deadflag_ee_dflag%d.txt",dataflag));
213 cout<<output<<endl;
214 ofstream txtout(output,ios::out);
215
216 for(int iz=0; iz<2; iz++){
217 for(int j=0; j<101; j++){
218 for(int k=0; k< 101; k++){
219 if( validRecHitEndCap[iz][j][k] <1) continue;
220
221 int ncorner;
222 int nside;
223 int nflagdead;
224
225 if( flagEE[iz][j][k] ==0){
226 checkHowManyDeadCrystalNext(iz,j,k,flagEE,ncorner,nside,nflagdead);
227 txtout<<2*iz-1 <<" "<< j<<" "<<k<<" "<< flagEE[iz][j][k] <<" "<< ncorner <<" "<<nside <<" "<< nflagdead <<endl;
228 }else{
229 txtout<<2*iz-1 <<" "<< j<<" "<<k<<" "<< flagEE[iz][j][k]<<" "<< -1<<" "<< -1 <<" "<<-1 <<endl;
230 }
231
232 }
233 }
234 }
235
236
237
238 }