fillChain.C

event selection (run h5_14) - Ivan Muzalevsky, 08/20/2018 02:29 AM

Download (16.5 KB)

 
1
void fillChain() { 
2
        
3
    // Reading cal parameters 
4
  Float_t parXL1[32],parXL2[32],parYL1[16],parYL2[16],parXR1[32], parXR2[32],parYR1[16],parYR2[16],par201[16],par202[16],parCsR1[16],parCsR2[16];
5
  //------------------------------------------------------------------------------ 
6
  // for 1 mm Si detector
7
  TString line1;
8
  ifstream myfile1;
9
  Int_t count=-2;
10
  myfile1.open("/media/user/work/data/analysisexp1804/presentPars/SQX_R.cal");
11
  while (! myfile1.eof() ){
12
    line1.ReadLine(myfile1);
13
    if(count < 0){
14
      count++;
15
      continue;
16
    }
17
    if(line1.IsNull()) break;
18
    sscanf(line1.Data(),"%g %g", parXR1+count,parXR2+count);
19
    count++;
20
  }
21
  cout << endl << " pars for XR strips" << endl;
22
  for(Int_t i=0;i<32;i++) cout << parXR1[i] << " " << parXR2[i] << endl;  
23

    
24
  ifstream myfile2;
25
  TString line2;
26
  count=-2;
27
  myfile2.open("/media/user/work/data/analysisexp1804/presentPars/SQY_R.cal");
28
  while (! myfile2.eof() ){
29
    line2.ReadLine(myfile2);
30
    if(count < 0){
31
      count++;
32
      continue;
33
    }
34
    if(line2.IsNull()) break;
35
    sscanf(line2.Data(),"%g %g", parYR1+count,parYR2+count);
36
    count++;
37
  }
38

    
39
  cout << endl << " pars for YR strips" << endl;
40
  for(Int_t i=0;i<16;i++) cout << parYR1[i] << " " << parYR2[i] << endl;   
41

    
42
  ifstream myfile3;
43
  TString line3;
44
  count=-2;
45
  myfile3.open("/media/user/work/data/analysisexp1804/presentPars/SQX_L.cal");
46
  while (! myfile3.eof() ){
47
    line3.ReadLine(myfile3);
48
    if(count < 0){
49
      count++;
50
      continue;
51
    }
52
    if(line3.IsNull()) break;
53
    sscanf(line3.Data(),"%g %g", parXL1+count,parXL2+count);
54
    count++;
55
  }
56

    
57
  cout << endl << " pars for XL strips" << endl;
58
  for(Int_t i=0;i<32;i++) cout << parXL1[i] << " " << parXL2[i] << endl;   
59

    
60
  ifstream myfile4;
61
  TString line4;
62
  count=-2;
63
  myfile4.open("/media/user/work/data/analysisexp1804/presentPars/SQY_L.cal");
64
  while (! myfile4.eof() ){
65
    line4.ReadLine(myfile4);
66
    if(count < 0){
67
      count++;
68
      continue;
69
    }
70
    if(line4.IsNull()) break;
71
    sscanf(line4.Data(),"%g %g", parYL1+count,parYL2+count);
72
    count++;
73
  }
74

    
75
  cout << endl << " pars for YL strips" << endl;
76
  for(Int_t i=0;i<16;i++) cout << parYL1[i] << " " << parYL2[i] << endl;     
77

    
78
  ifstream myfile5;
79
  TString line5;
80
  count=-2;
81
  myfile5.open("/media/user/work/data/analysisexp1804/presentPars/SQ20.cal");
82
  while (! myfile5.eof() ){
83
    line5.ReadLine(myfile5);
84
    if(count < 0){
85
      count++;
86
      continue;
87
    }
88
    if(line5.IsNull()) break;
89
    sscanf(line5.Data(),"%g %g", par201+count,par202+count);
90
    count++;
91
  }
92

    
93
  cout << endl << " pars for 20um strips" << endl;
94
  for(Int_t i=0;i<16;i++) cout << par201[i] << " " << par202[i] << endl; 
95

    
96
  ifstream myfile7;
97
  TString line7;
98
  count=-2;
99
  myfile7.open("/media/user/work/data/analysisexp1804/presentPars/csi_r_ec.clb");
100
  while (! myfile7.eof() ) {
101
    line7.ReadLine(myfile7);
102
    if(count < 0){
103
      count++;
104
      continue;
105
    }
106
    if(line7.IsNull()) break;
107
    sscanf(line7.Data(),"%g %g", parCsR1+count,parCsR2+count);
108
    count++;
109
  }  
110

    
111
  cout << endl << " pars for CsR strips" << endl;
112
  for(Int_t i=0;i<16;i++) cout << parCsR1[i] << " " << parCsR2[i] << endl; 
113

    
114
  Float_t tAngle = 12.;
115
  //------------------------------------------------------------------------------ 
116
  TChain *t = new TChain("AnalysisxTree");
117

    
118
  Float_t tF5[4],tF3[4],CsI_L[16],tCsI_L[16],CsI_R[16],tCsI_R[16],SQX_L[32],SQY_L[16],tSQX_L[32],tSQY_L[16],SQX_R[32],SQY_R[16],tSQX_R[32],tSQY_R[16],SQ20[16],tSQ20[16],
119
          x1,x2,y1,y2,x1n,x2n,y1n,y2n,ToF,deBeam,zt,yt,xt,CsI,tCsI;
120

    
121
  UShort_t   NeEvent_CsI_L[16],NeEvent_tCsI_L[16],NeEvent_CsI_R[16],NeEvent_tCsI_R[16],NeEvent_SQX_L[32],NeEvent_SQY_L[16],NeEvent_tSQX_L[32],NeEvent_tSQY_L[16],
122
             NeEvent_SQX_R[32],NeEvent_SQY_R[16],NeEvent_tSQX_R[32],NeEvent_tSQY_R[16],NeEvent_SQ20[16],NeEvent_tSQ20[16],
123
             NeEvent_F3[4],NeEvent_tF3[4],NeEvent_F5[4],NeEvent_tF5[4],NeEvent_nx1,NeEvent_nx2,NeEvent_ny1,NeEvent_ny2,NeEvent_x1[32],NeEvent_x2[32],NeEvent_y1[32],NeEvent_y2[32];
124

    
125
  TBranch *b_NeEvent_CsI_L,*b_NeEvent_tCsI_L,*b_NeEvent_CsI_R,*b_NeEvent_tCsI_R,*b_NeEvent_SQX_L,*b_NeEvent_SQY_L,*b_NeEvent_tSQX_L,*b_NeEvent_tSQY_L,*b_NeEvent_SQX_R,*b_NeEvent_SQY_R,
126
          *b_NeEvent_tSQX_R,*b_NeEvent_tSQY_R,*b_NeEvent_SQ20,*b_NeEvent_tSQ20,*b_NeEvent_F3,*b_NeEvent_F5,*b_NeEvent_tF3,*b_NeEvent_tF5,
127
          *b_NeEvent_nx1,*b_NeEvent_nx2,*b_NeEvent_ny1,*b_NeEvent_ny2,*b_NeEvent_x1,*b_NeEvent_x2,*b_NeEvent_y1,*b_NeEvent_y2,*b_NeEvent_trigger;
128

    
129
  Int_t NeEvent_trigger,trigger,nx1,nx2,ny1,ny2,nCsI;
130

    
131
  Long64_t nentries1;
132
  Int_t maxE,multY_L,multX_L,multY_R,multX_R,mult20,multY_Lt,multX_Lt,multY_Rt,multX_Rt,mult20t,multCsi_R,multCsi_L,timeF5,thresh_X,thresh_Y,thresh_CsI,nCh_L,nCh_R;
133

    
134
  Int_t ToFflag,Csi_Rflag,MWPCflag,SQRflag,SQLflag,SQ20flag,flag,flagR,flagL; //! flags
135

    
136
  Float_t maxCsI_R,maxCsI_L;
137

    
138
  Float_t tx1,tx2,ty1,ty2,tyt,txt,tzt;
139

    
140
  const Float_t    MWPC1_X_displacement  = -1.0;
141
  const Float_t    MWPC1_Y_displacement  = -2.1375;
142
  const Float_t    MWPC2_X_displacement  = 0.2;
143
  const Float_t    MWPC2_Y_displacement  = -1.125;
144

    
145
  const Float_t    MWPC1_X_zero_position = -15.5*1.25;
146
  const Float_t    MWPC1_Y_zero_position = -15.5*1.25;
147
  const Float_t    MWPC2_X_zero_position = -15.5*1.25;
148
  const Float_t    MWPC2_Y_zero_position = -15.5*1.25;
149

    
150
 // Creating outfile,outtree
151
  TFile *fw = new TFile("/media/user/work/data/analysisexp1804/h5_14_3.root", "RECREATE");
152
  TTree *tw = new TTree("tree", "data");
153

    
154
  //tw->Branch("CsI_L",&CsI_L,"CsI_L[16]/F");
155
  //tw->Branch("tCsI_L",&tCsI_L,"tCsI_L[16]/F");
156
  tw->Branch("CsI_R",&CsI_R,"CsI_R[16]/F");
157
  tw->Branch("tCsI_R",&tCsI_R,"tCsI_R[16]/F");
158

    
159
  tw->Branch("CsI",&CsI_R,"CsI_R/F");
160
  tw->Branch("tCsI",&tCsI_R,"tCsI_R/F");
161
  tw->Branch("nCsI",&nCsI,"nCsI/I");
162

    
163

    
164
  tw->Branch("SQX_L",&SQX_L,"SQX_L[32]/F");
165
  tw->Branch("tSQX_L",&tSQX_L,"tSQX_L[32]/F");
166
  tw->Branch("SQY_L",&SQY_L,"SQY_L[16]/F");
167
  tw->Branch("tSQY_L",&tSQY_L,"tSQY_L[16]/F");
168
  tw->Branch("SQ20",&SQ20,"SQ20[16]/F");
169
  tw->Branch("tSQ20",&tSQ20,"tSQ20[16]/F");
170

    
171
  tw->Branch("SQX_R",&SQX_R,"SQX_R[32]/F");
172
  tw->Branch("tSQX_R",&tSQX_R,"tSQX_R[32]/F");
173
  tw->Branch("SQY_R",&SQY_R,"SQY_R[16]/F");
174
  tw->Branch("tSQY_R",&tSQY_R,"tSQY_R[16]/F");
175

    
176
  tw->Branch("ToF",&ToF,"ToF/F");
177
  tw->Branch("deBeam",&deBeam,"deBeam/F");
178

    
179
  tw->Branch("nx1",&nx1,"nx1/I");
180
  tw->Branch("ny1",&ny1,"ny1/I");
181
  tw->Branch("nx2",&nx2,"nx2/I");
182
  tw->Branch("ny2",&ny2,"ny2/I");
183

    
184
  tw->Branch("x1",&x1,"x1/F");
185
  tw->Branch("x2",&x2,"x2/F");
186
  tw->Branch("y1",&y1,"y1/F");
187
  tw->Branch("y2",&y2,"y2/F");
188
  tw->Branch("yt",&yt,"yt/F");
189
  tw->Branch("xt",&xt,"xt/F");  
190

    
191
  tw->Branch("trigger",&trigger,"trigger/I");
192

    
193
  tw->Branch("flagR",&flagR,"flagR/I");
194
  tw->Branch("flagL",&flagL,"flagL/I");
195

    
196
        t->Add("/media/user/work/data/exp1804/h5_14_00*.root");
197
  nentries1 = t->GetEntries();
198
  cout << " Number of InPut entries: "<< nentries1 << endl;
199

    
200
  t->SetMakeClass(1);
201

    
202
  t->SetBranchAddress("NeEvent.CsI_L[16]", NeEvent_CsI_L, &b_NeEvent_CsI_L);
203
  t->SetBranchAddress("NeEvent.tCsI_L[16]", NeEvent_tCsI_L, &b_NeEvent_tCsI_L);
204
  t->SetBranchAddress("NeEvent.CsI_R[16]", NeEvent_CsI_R, &b_NeEvent_CsI_R);
205
  t->SetBranchAddress("NeEvent.tCsI_R[16]", NeEvent_tCsI_R, &b_NeEvent_tCsI_R);
206
  t->SetBranchAddress("NeEvent.SQX_L[32]", NeEvent_SQX_L, &b_NeEvent_SQX_L);
207
  t->SetBranchAddress("NeEvent.SQY_L[16]", NeEvent_SQY_L, &b_NeEvent_SQY_L); 
208
  t->SetBranchAddress("NeEvent.tSQX_L[32]", NeEvent_tSQX_L, &b_NeEvent_tSQX_L);
209
  t->SetBranchAddress("NeEvent.tSQY_L[16]", NeEvent_tSQY_L, &b_NeEvent_tSQY_L);
210
  t->SetBranchAddress("NeEvent.SQX_R[32]", NeEvent_SQX_R, &b_NeEvent_SQX_R);
211
  t->SetBranchAddress("NeEvent.SQY_R[16]", NeEvent_SQY_R, &b_NeEvent_SQY_R);
212
  t->SetBranchAddress("NeEvent.tSQX_R[32]", NeEvent_tSQX_R, &b_NeEvent_tSQX_R);
213
  t->SetBranchAddress("NeEvent.tSQY_R[16]", NeEvent_tSQY_R, &b_NeEvent_tSQY_R);
214
  t->SetBranchAddress("NeEvent.SQ20[16]", NeEvent_SQ20, &b_NeEvent_SQ20);
215
  t->SetBranchAddress("NeEvent.tSQ20[16]", NeEvent_tSQ20, &b_NeEvent_tSQ20);
216
  t->SetBranchAddress("NeEvent.F3[4]", NeEvent_F3, &b_NeEvent_F3);
217
  t->SetBranchAddress("NeEvent.tF3[4]", NeEvent_tF3, &b_NeEvent_tF3);
218
  t->SetBranchAddress("NeEvent.F5[4]", NeEvent_F5, &b_NeEvent_F5);
219
  t->SetBranchAddress("NeEvent.tF5[4]", NeEvent_tF5, &b_NeEvent_tF5);
220
  t->SetBranchAddress("NeEvent.nx1", &NeEvent_nx1, &b_NeEvent_nx1);
221
  t->SetBranchAddress("NeEvent.ny1", &NeEvent_ny1, &b_NeEvent_ny1);
222
  t->SetBranchAddress("NeEvent.nx2", &NeEvent_nx2, &b_NeEvent_nx2);
223
  t->SetBranchAddress("NeEvent.ny2", &NeEvent_ny2, &b_NeEvent_ny2);
224
  t->SetBranchAddress("NeEvent.x1[32]", NeEvent_x1, &b_NeEvent_x1);
225
  t->SetBranchAddress("NeEvent.y1[32]", NeEvent_y1, &b_NeEvent_y1);
226
  t->SetBranchAddress("NeEvent.x2[32]", NeEvent_x2, &b_NeEvent_x2);
227
  t->SetBranchAddress("NeEvent.y2[32]", NeEvent_y2, &b_NeEvent_y2);
228
  t->SetBranchAddress("NeEvent.trigger", &NeEvent_trigger, &b_NeEvent_trigger);
229

    
230
  maxE = nentries1;
231
  cout<<">>> filling TREE up to "<<maxE<< " event"<<endl;
232
  for (Long64_t jentry=0; jentry<maxE;jentry++) {
233
          t->GetEntry(jentry);
234
    if(jentry%10000000==0) cout << "######## " << jentry << endl;
235
    // обнуление
236
    trigger = NeEvent_trigger;
237
    flag=0;
238
    flagR = 0;
239
    flagL = 0;
240

    
241
    //----------------------------- CsI module
242
    for(Int_t i=0;i<16;i++) { // обнуление
243
      CsI_R[i] = 0;
244
      tCsI_R[i] = 0;
245
    }
246
    CsI = 0;
247
    tCsI = 0;
248
    nCsI = -10;
249

    
250
    multCsi_R = 0;
251
    Csi_Rflag = 0;    
252
    //searching for maxAmp of CsI_R and CsI_L, time selection NeEvent_tCsI_R[i]>0
253

    
254
    maxCsI_R = 0; nCh_R = -10;
255
    for(Int_t i=0;i<16;i++) {
256
      if(maxCsI_R<NeEvent_CsI_R[i] && NeEvent_tCsI_R[i]>0) {
257
        maxCsI_R = NeEvent_CsI_R[i];
258
        nCh_R = i;
259

    
260
        nCsI = i;
261
        CsI = NeEvent_CsI_R[i];  
262
        tCsI = NeEvent_tCsI_R[i];
263
      }
264
    }
265
 
266
    // calculation of the multiplicity
267
    for(Int_t i=0;i<16;i++){
268
      if(NeEvent_CsI_R[i]==maxCsI_R && maxCsI_R>0) multCsi_R++;
269
    }
270
    
271
    // Csi_R energy threshold
272
    if(maxCsI_R<200) Csi_Rflag--;
273
    //multiplicity selection
274
    if(multCsi_R!=1) Csi_Rflag--;   
275
  
276
    //Fill
277
    CsI_R[nCh_R] = NeEvent_CsI_R[nCh_R]*parCsR2[nCh_R] + parCsR1[nCh_R];
278
    tCsI_R[nCh_R] = NeEvent_tCsI_R[nCh_R]*0.3; 
279

    
280
    CsI = CsI*parCsR2[nCsI] + parCsR1[nCsI];
281
    tCsI = tCsI*0.3;
282

    
283
    // amp-time cut (340,430)
284
    if((tCsI - NeEvent_tF5[0]*0.125)<365 || (tCsI - NeEvent_tF5[0]*0.125)>460) Csi_Rflag--;
285

    
286

    
287
    //Csi_Rflag MUST BE = 0 !!!
288
    //----------------------------- endl of CsI module
289

    
290
    //----------------------------- ToF module
291
    // обнуление
292
    ToF=0;
293
    deBeam=0;
294
    ToFflag = 0;
295

    
296
    // for(Int_t i=0;i<4;i++) {
297
    //  // if(tF5[i]-tF3[i]<100 || tF5[i]-tF3[i]>200) ToFflag--;
298
    //   for(Int_t j=i;j<4;j++) {
299
    //     if(NeEvent_tF5[i]-NeEvent_tF5[j]<-20 || NeEvent_tF5[i]-NeEvent_tF5[j]>20) ToFflag--;
300
    //     if(NeEvent_tF3[i]-NeEvent_tF3[j]<-20 || NeEvent_tF3[i]-NeEvent_tF3[j]>20) ToFflag--;
301
    //     if(NeEvent_F5[i]+NeEvent_F3[j]<10) ToFflag--;
302

    
303
    //   }
304
    // }
305
    //fill
306
    deBeam = (NeEvent_F5[0]+NeEvent_F5[1]+NeEvent_F5[2]+NeEvent_F5[3]+NeEvent_F3[0]+NeEvent_F3[1]+NeEvent_F3[2]+NeEvent_F3[3]);
307
    ToF = (NeEvent_tF5[0]+NeEvent_tF5[1]+NeEvent_tF5[2]+NeEvent_tF5[3] - NeEvent_tF3[0]-NeEvent_tF3[1]-NeEvent_tF3[2]-NeEvent_tF3[3])*0.25*0.125 + 89.165;
308
    if(ToF<100 || ToF>200) ToFflag--; 
309
    if(ToFflag!=0) continue;
310
    //TOFFLAG MUST BE = 0!!
311
    //----------------------------- end of ToF module
312

    
313

    
314
    //----------------------------- MWPC
315
    // обнуление 
316
    MWPCflag = 1;
317

    
318
    x1 = -100.;
319
    y1 = -100.;
320
    x2 = -100.;
321
    y2 = -100.;
322
    xt = -100.;
323
    yt = -100.;
324
   
325

    
326
    nx1 = NeEvent_nx1;
327
    ny1 = NeEvent_ny1;
328
    nx2 = NeEvent_nx2;
329
    ny2 = NeEvent_ny2;
330

    
331
    if(nx1>10 || ny1>10 || nx2>10 || ny2>10) continue;
332

    
333
    if(nx1==0) {MWPCflag = MWPCflag*0;}
334
    if(nx1==1) {
335
      MWPCflag = MWPCflag*1;
336
      x1n = NeEvent_x1[0];
337
    }
338
    if(nx1>1) {
339
      for(Int_t i=0;i<nx1-1;i++) {
340
        if((NeEvent_x1[i+1]-NeEvent_x1[i])!=1) {
341
          MWPCflag = MWPCflag*0;
342
        }
343
      }
344

    
345
      if(MWPCflag==1) {
346
        x1n = (NeEvent_x1[0]+NeEvent_x1[nx1-1])/2.;
347
      }
348
    }    
349

    
350
    if(nx2==0) {MWPCflag = MWPCflag*0;}
351
    if(nx2==1) {
352
      MWPCflag = MWPCflag*1;
353
      x2n = NeEvent_x2[0];
354
    }
355
    if(nx2>1) {
356
      for(Int_t i=0;i<nx2-1;i++) {
357
        if((NeEvent_x2[i+1]-NeEvent_x2[i])!=1) {
358
          MWPCflag = MWPCflag*0;
359
        }
360
      }
361
      if(MWPCflag==1) {
362
        x2n = (NeEvent_x2[0]+NeEvent_x2[nx2-1])/2.;
363
      }
364
    } 
365

    
366
    if(ny1==0) {MWPCflag = MWPCflag*0;}
367
    if(ny1==1) {
368
      MWPCflag = MWPCflag*1;
369
      y1n=NeEvent_y1[0];
370
    }
371
    if(ny1>1) {
372
      for(Int_t i=0;i<ny1-1;i++) {
373
        if((NeEvent_y1[i+1]-NeEvent_y1[i])!=1) {
374
          MWPCflag = MWPCflag*0;
375
        }
376
      }
377
      if(MWPCflag==1) {
378
        y1n = (NeEvent_y1[0]+NeEvent_y1[ny1-1])/2.;
379
      }
380
    }  
381

    
382
    if(ny2==0) {MWPCflag = MWPCflag*0;}
383
    if(ny2==1) {
384
      MWPCflag = MWPCflag*1;
385
      y2n = NeEvent_y2[0];
386
    }
387
    if(ny2>1) {
388
      for(Int_t i=0;i<ny2-1;i++) {
389
        if((NeEvent_y2[i+1]-NeEvent_y2[i])!=1) {
390
          MWPCflag = MWPCflag*0;
391
        }
392
      }
393
      if(MWPCflag==1) {
394
        y2n = (NeEvent_y2[0]+NeEvent_y2[ny2-1])/2.;
395
      }
396
    } 
397

    
398

    
399
    if(MWPCflag==1) { // рассматриваем события с множественностью 1 в MWPC или кластером БОГУМИЛ
400

    
401
      x1 = MWPC1_X_zero_position + MWPC1_X_displacement+x1n*1.25;
402
      y1 = MWPC1_Y_zero_position + MWPC1_Y_displacement + y1n*1.25;
403

    
404
      x2 = MWPC2_X_zero_position + MWPC2_X_displacement + x2n*1.25;
405
      y2 = MWPC2_Y_zero_position + MWPC2_Y_displacement + y2n*1.25;
406

    
407
      xt = (546*x1 + 816*(x2-x1))/(546 - (x2-x1)*tan(TMath::DegToRad()*tAngle));
408
      yt = (y2-y1)*(xt-x1)/(x2-x1) + y1;
409
      zt = 546.*(xt-x1)/(x2-x1) - 816;
410
    }
411

    
412
    if(MWPCflag!=1) continue;
413
    //----------------------------- MWPC
414

    
415

    
416
//----------------------------- SQ_R module
417

    
418
    // обнуление 
419
    for(Int_t i = 0; i<32;i++) {
420
      SQX_R[i]=0.;
421
      tSQX_R[i]=0.;
422
      if(i<16) {
423
        SQY_R[i]=0.;
424
        tSQY_R[i]=0.;
425
      }
426
    }
427
    SQRflag = 0;
428

    
429
    //fill
430
    for(Int_t i=0; i<32; i++) {
431
      SQX_R[i] = NeEvent_SQX_R[i]*parXR2[i] + parXR1[i];
432
      tSQX_R[i] = NeEvent_tSQX_R[i]*0.3;
433
      if(i<16){
434
        SQY_R[i] = NeEvent_SQY_R[i]*parYR2[i] + parYR1[i];
435
        tSQY_R[i] = NeEvent_tSQY_R[i]*0.3;
436
      }
437
    }
438

    
439
    for(Int_t i=0;i<32;i++){ 
440
      if(i<16){ // CFD LED times (walk)
441
        if(tSQX_R[i] - NeEvent_tF5[0]*0.125 > -70 && tSQX_R[i] - NeEvent_tF5[0]*0.125<0 && tSQX_R[i]>0 && SQX_R[i]>1.) SQRflag++;
442
        if(tSQY_R[i] - NeEvent_tF5[0]*0.125 > -70 && tSQY_R[i] - NeEvent_tF5[0]*0.125<0 && tSQY_R[i]>0 && SQY_R[i]>1.) SQRflag++;
443
      }
444
      if(i>15){ // both times by CFD 
445
        if(tSQX_R[i] - NeEvent_tF5[0]*0.125 > 40 && tSQX_R[i] - NeEvent_tF5[0]*0.125<90 && tSQX_R[i]>0 && SQX_R[i]>1.) SQRflag++;
446
      }
447
    }
448
    //----------------------------- end of SQ_R module
449

    
450

    
451
    //----------------------------- SQ_L module
452

    
453
    // обнуление 
454
    for(Int_t i = 0; i<32;i++) {
455
      SQX_L[i]=0.;
456
      tSQX_L[i]=0.;
457
      if(i<16) {
458
        SQY_L[i]=0.;
459
        tSQY_L[i]=0.;
460
      }
461
    }
462
    SQLflag = 0;
463

    
464
    //fill
465
    for(Int_t i=0; i<32; i++) {
466
      SQX_L[i] = NeEvent_SQX_L[i]*parXL2[i] + parXL1[i];
467
      tSQX_L[i] = NeEvent_tSQX_L[i]*0.3;
468
      if(i<16){
469
        SQY_L[i] = NeEvent_SQY_L[i]*parYL2[i] + parYL1[i];
470
        tSQY_L[i] = NeEvent_tSQY_L[i]*0.3;
471
      }
472
    }
473

    
474
    for(Int_t i=0;i<32;i++){ 
475
      if(i<16){ // CFD LED times (walk)
476
        if(tSQX_L[i] - NeEvent_tF5[0]*0.125 > -70 && tSQX_L[i] - NeEvent_tF5[0]*0.125<0 && tSQX_L[i]>0 && SQX_L[i]>1.) SQLflag++;
477
        if(tSQY_L[i] - NeEvent_tF5[0]*0.125 > -70 && tSQY_L[i] - NeEvent_tF5[0]*0.125<0 && tSQY_L[i]>0 && SQY_L[i]>1.) SQLflag++;
478
      }
479
      if(i>15){ // both times by CFD 
480
        if(tSQX_L[i] - NeEvent_tF5[0]*0.125 > 40 && tSQX_L[i] - NeEvent_tF5[0]*0.125<90 && tSQX_L[i]>0 && SQX_L[i]>1.) SQLflag++;
481
      }
482
    }
483
    //----------------------------- end of SQ_L module
484

    
485
    //----------------------------- SQ20 module
486

    
487
    // обнуление 
488
    for(Int_t i = 0; i<16;i++) {
489
      SQ20[i]=0.;
490
      tSQ20[i]=0.;
491
    }
492
    SQ20flag = 0;
493
    mult20 = 0;
494

    
495
    //fill
496
    for(Int_t i=0; i<16; i++) {
497
      SQ20[i] = NeEvent_SQ20[i]*par202[i] + par201[i]; 
498
      tSQ20[i] = NeEvent_tSQ20[i]*0.3;
499
    }
500

    
501
    for(Int_t i=0;i<16;i++){ 
502
      if(SQ20[i]>0.9 && tSQ20[i] - NeEvent_tF5[0]*0.125 > 30 && tSQ20[i] - NeEvent_tF5[0]*0.125<170 && tSQ20[i]>0) SQ20flag++;
503
    }
504

    
505
    //----------------------------- en of SQ20 module 
506

    
507
    if(Csi_Rflag==0 && SQRflag>1) flagR = 1;
508
    if(SQ20flag>0 && SQLflag>1) flagL = 1;
509
    if(flagL==0 && flagR==0) continue;
510
    tw->Fill();
511
   // }                        
512
  }//entries
513
  fw->cd();
514
        tw->Write();
515
        fw->Close();
516
}