ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/yangyong/combineICEE/make_deadflagEE.C
Revision: 1.1
Committed: Tue Apr 10 20:03:11 2012 UTC (13 years, 1 month ago) by yangyong
Content type: text/plain
Branch: MAIN
CVS Tags: pi0etaee_laser20111122_eefloatalpha
Log Message:
LaserTag:
EcalLaserAPDPNRatios_data_20111122_158851_180363
and alpha Tag ( for Endcap Only)
EcalLaserAlphas_lto420-620_progr_data_20111122

File Contents

# User Rev Content
1 yangyong 1.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    
142     else{
143     cout<<"nbad? "<< nbad <<" "<< iz <<" "<< j<<" "<<k<<endl;
144     exit(1);
145     }
146    
147     }
148    
149     ///input the IC file in calibres/
150     void make_deadflagEE(char *inputfile, int dataflag ){
151    
152     for(int j=0; j<2; j++){
153     for(int x =0; x<101; x++){
154     for(int y=0; y<101; y++){
155     validRecHitEndCap[j][x][y] = 0;
156     }
157     }
158     }
159    
160     readInterCalibEndcap_GR09_V8();
161    
162     ifstream txtin(inputfile,ios::in);
163    
164    
165    
166     int iz;
167     int ix;
168     int iy;
169     int flag;
170     float cc;
171     int flagEE[2][101][101];
172     while (txtin.good()){
173     txtin>> iz >> ix >> iy >> cc;
174     flag = cc <0 ; //-1 means dead xtal
175     flagEE[iz][ix][iy]= flag;
176     }
177    
178    
179     TString output = TString(Form("deadflag/crystal_deadflag_ee_dflag%d.txt",dataflag));
180     cout<<output<<endl;
181     ofstream txtout(output,ios::out);
182    
183     for(int iz=0; iz<2; iz++){
184     for(int j=0; j<101; j++){
185     for(int k=0; k< 101; k++){
186     if( validRecHitEndCap[iz][j][k] <1) continue;
187    
188     int ncorner;
189     int nside;
190     int nflagdead;
191    
192     if( flagEE[iz][j][k] ==0){
193     checkHowManyDeadCrystalNext(iz,j,k,flagEE,ncorner,nside,nflagdead);
194     txtout<<2*iz-1 <<" "<< j<<" "<<k<<" "<< flagEE[iz][j][k] <<" "<< ncorner <<" "<<nside <<" "<< nflagdead <<endl;
195     }else{
196     txtout<<2*iz-1 <<" "<< j<<" "<<k<<" "<< flagEE[iz][j][k]<<" "<< -1<<" "<< -1 <<" "<<-1 <<endl;
197     }
198    
199     }
200     }
201     }
202    
203    
204    
205     }