ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/yangyong/combineICEB/combineCalibConstantv2.C
(Generate patch)

Comparing UserCode/yangyong/combineICEB/combineCalibConstantv2.C (file contents):
Revision 1.2 by yangyong, Tue Apr 10 19:41:08 2012 UTC vs.
Revision 1.3 by yangyong, Fri Aug 10 14:54:03 2012 UTC

# Line 9 | Line 9 | TRandom3 *rgen_;
9   #include "usefullcode.cc"
10  
11   float interCalib_preCalib[170][360];
12 float interCalib_preCalibTrue[170][360];
12   float interCalibEndcap_preCalib[2][101][101];
13  
14   void copyConstant(float c1[170][360], float c2[170][360]){
# Line 200 | Line 199 | void combineCalibConstantv2(){
199    
200    
201  
202 <  readInterCalibConstEBSimple("interCalibEB_GR_R_42_V13.txt",interCalib_preCalib); ///2010IC
202 >  readInterCalibConstEBSimple("interCalibEB_GR_P_V39.txt",interCalib_preCalib);
203    
204  
206  ///pre-calibration constants
207  readInterCalibConstEBSimple("interCalib_GR09_H_V6OFF_barrel.txt",interCalib_preCalibTrue);
205    
209
206    map<int, string> smScaleFiles;
207  
208 <  //7 Sets IC
213 <  /// 160404to166923
214 <  /// 166946to167913
215 <  /// 169985to172630
216 <  /// 172635to172791
217 <  /// 175832to176929
218 <  /// 176933to177878
219 <  /// 178003to180252
208 >
209    
210    
211    //SM-scale files Pi0
223  smScaleFiles[0] = "calibres/deriveCalibConst.testCalibv1.dflag60.pe1.cut0.rmOvlap0.step1.method1.corrEta-1.corrPhi-1.corrSM0.corrDead-1.precalib1.vtx1.encorr0.evtNot-1.trig0.root";
224  smScaleFiles[1] = "calibres/deriveCalibConst.testCalibv1.dflag61.pe1.cut0.rmOvlap0.step1.method1.corrEta-1.corrPhi-1.corrSM0.corrDead-1.precalib1.vtx1.encorr0.evtNot-1.trig0.root";
225  smScaleFiles[2] = "calibres/deriveCalibConst.testCalibv1.dflag62.pe1.cut0.rmOvlap0.step1.method1.corrEta-1.corrPhi-1.corrSM0.corrDead-1.precalib1.vtx1.encorr0.evtNot-1.trig0.root";
226  smScaleFiles[3] = "calibres/deriveCalibConst.testCalibv1.dflag63.pe1.cut0.rmOvlap0.step1.method1.corrEta-1.corrPhi-1.corrSM0.corrDead-1.precalib1.vtx1.encorr0.evtNot-1.trig0.root";
227  smScaleFiles[4] = "calibres/deriveCalibConst.testCalibv1.dflag72.pe1.cut0.rmOvlap0.step1.method1.corrEta-1.corrPhi-1.corrSM0.corrDead-1.precalib1.vtx1.encorr0.evtNot-1.trig0.root";
228  smScaleFiles[5] = "calibres/deriveCalibConst.testCalibv1.dflag73.pe1.cut0.rmOvlap0.step1.method1.corrEta-1.corrPhi-1.corrSM0.corrDead-1.precalib1.vtx1.encorr0.evtNot-1.trig0.root";
229  smScaleFiles[6] = "calibres/deriveCalibConst.testCalibv1.dflag64.pe1.cut0.rmOvlap0.step1.method1.corrEta-1.corrPhi-1.corrSM0.corrDead-1.precalib1.vtx1.encorr0.evtNot-1.trig0.root";
230  
231  //SM-scale files Eta
232  smScaleFiles[7] = "calibres/deriveCalibConst.testCalibv1.dflag250.pe2.cut0.rmOvlap0.step1.method1.corrEta-1.corrPhi-1.corrSM0.corrDead-1.precalib1.vtx1.encorr0.evtNot-1.trig0.root";
233  smScaleFiles[8] = "calibres/deriveCalibConst.testCalibv1.dflag251.pe2.cut0.rmOvlap0.step1.method1.corrEta-1.corrPhi-1.corrSM0.corrDead-1.precalib1.vtx1.encorr0.evtNot-1.trig0.root";
234  smScaleFiles[9] = "calibres/deriveCalibConst.testCalibv1.dflag252.pe2.cut0.rmOvlap0.step1.method1.corrEta-1.corrPhi-1.corrSM0.corrDead-1.precalib1.vtx1.encorr0.evtNot-1.trig0.root";
235  smScaleFiles[10] = "calibres/deriveCalibConst.testCalibv1.dflag253.pe2.cut0.rmOvlap0.step1.method1.corrEta-1.corrPhi-1.corrSM0.corrDead-1.precalib1.vtx1.encorr0.evtNot-1.trig0.root";
236  smScaleFiles[11] = "calibres/deriveCalibConst.testCalibv1.dflag227.pe2.cut0.rmOvlap0.step1.method1.corrEta-1.corrPhi-1.corrSM0.corrDead-1.precalib1.vtx1.encorr0.evtNot-1.trig0.root";
237  smScaleFiles[12] = "calibres/deriveCalibConst.testCalibv1.dflag228.pe2.cut0.rmOvlap0.step1.method1.corrEta-1.corrPhi-1.corrSM0.corrDead-1.precalib1.vtx1.encorr0.evtNot-1.trig0.root";
238  smScaleFiles[13] = "calibres/deriveCalibConst.testCalibv1.dflag254.pe2.cut0.rmOvlap0.step1.method1.corrEta-1.corrPhi-1.corrSM0.corrDead-1.precalib1.vtx1.encorr0.evtNot-1.trig0.root";
212    
213 <
214 <  // number of ICs
215 <  int nIC = 7;
213 >  smScaleFiles[0] = "../Pi0Calibration/Barrel/calibres/deriveCalibConst.dflag2.pe1.step1.iter1.root";
214 >  smScaleFiles[1] = "../Pi0Calibration/Barrel/calibres/deriveCalibConst.dflag3.pe2.step1.iter1.root";
215 >
216 >  // number of IC periods
217 >  int nIC = 1;
218    
219  
220  
221    map<int,string> icFiles;
222    
223    //IC Pi0
224 <  icFiles[0] = "calibres/deriveCalibConst.testCalibv1.dflag60.pe1.cut0.rmOvlap0.step25.method2.corrEta21.corrPhi11.corrSM1.corrDead1.precalib1.vtx1.encorr0.evtNot-1.trig0.txt";
250 <  icFiles[1] = "calibres/deriveCalibConst.testCalibv1.dflag61.pe1.cut0.rmOvlap0.step25.method2.corrEta21.corrPhi11.corrSM1.corrDead1.precalib1.vtx1.encorr0.evtNot-1.trig0.txt";
251 <  icFiles[2] = "calibres/deriveCalibConst.testCalibv1.dflag62.pe1.cut0.rmOvlap0.step25.method2.corrEta21.corrPhi11.corrSM1.corrDead1.precalib1.vtx1.encorr0.evtNot-1.trig0.txt";
252 <  icFiles[3] = "calibres/deriveCalibConst.testCalibv1.dflag63.pe1.cut0.rmOvlap0.step25.method2.corrEta21.corrPhi11.corrSM1.corrDead1.precalib1.vtx1.encorr0.evtNot-1.trig0.txt";
253 <  icFiles[4] = "calibres/deriveCalibConst.testCalibv1.dflag72.pe1.cut0.rmOvlap0.step25.method2.corrEta21.corrPhi11.corrSM1.corrDead1.precalib1.vtx1.encorr0.evtNot-1.trig0.txt";
254 <  icFiles[5] = "calibres/deriveCalibConst.testCalibv1.dflag73.pe1.cut0.rmOvlap0.step25.method2.corrEta21.corrPhi11.corrSM1.corrDead1.precalib1.vtx1.encorr0.evtNot-1.trig0.txt";
255 <  icFiles[6] = "calibres/deriveCalibConst.testCalibv1.dflag64.pe1.cut0.rmOvlap0.step25.method2.corrEta21.corrPhi11.corrSM1.corrDead1.precalib1.vtx1.encorr0.evtNot-1.trig0.txt";
256 <  
224 >  icFiles[0] = "../Pi0Calibration/Barrel/calibres/deriveCalibConst.dflag2.pe1.step4.iter30.txt";
225    //IC Eta
226 <  icFiles[7] = "calibres/deriveCalibConst.testCalibv1.dflag250.pe2.cut0.rmOvlap0.step45.method2.corrEta21.corrPhi11.corrSM1.corrDead1.precalib1.vtx1.encorr0.evtNot-1.trig0.txt";
259 <  icFiles[8] = "calibres/deriveCalibConst.testCalibv1.dflag251.pe2.cut0.rmOvlap0.step45.method2.corrEta21.corrPhi11.corrSM1.corrDead1.precalib1.vtx1.encorr0.evtNot-1.trig0.txt";
260 <  icFiles[9] = "calibres/deriveCalibConst.testCalibv1.dflag252.pe2.cut0.rmOvlap0.step45.method2.corrEta21.corrPhi11.corrSM1.corrDead1.precalib1.vtx1.encorr0.evtNot-1.trig0.txt";
261 <  icFiles[10] = "calibres/deriveCalibConst.testCalibv1.dflag253.pe2.cut0.rmOvlap0.step45.method2.corrEta21.corrPhi11.corrSM1.corrDead1.precalib1.vtx1.encorr0.evtNot-1.trig0.txt";
262 <  icFiles[11] = "calibres/deriveCalibConst.testCalibv1.dflag227.pe2.cut0.rmOvlap0.step45.method2.corrEta21.corrPhi11.corrSM1.corrDead1.precalib1.vtx1.encorr0.evtNot-1.trig0.txt";
263 <  icFiles[12] = "calibres/deriveCalibConst.testCalibv1.dflag228.pe2.cut0.rmOvlap0.step45.method2.corrEta21.corrPhi11.corrSM1.corrDead1.precalib1.vtx1.encorr0.evtNot-1.trig0.txt";
264 <  icFiles[13] = "calibres/deriveCalibConst.testCalibv1.dflag254.pe2.cut0.rmOvlap0.step45.method2.corrEta21.corrPhi11.corrSM1.corrDead1.precalib1.vtx1.encorr0.evtNot-1.trig0.txt";
265 <  
226 >  icFiles[1] = "../Pi0Calibration/Barrel/calibres/deriveCalibConst.dflag3.pe2.step4.iter30.txt";
227    
228    //crystal dead flag
229 <  getCrystaldeadflagBarrel_v1("deadflag/crystal_deadflag_eb_dflag60.txt",ndeadflagietaiphi_ic[0]);
230 <  getCrystaldeadflagBarrel_v1("deadflag/crystal_deadflag_eb_dflag61.txt",ndeadflagietaiphi_ic[1]);
231 <  getCrystaldeadflagBarrel_v1("deadflag/crystal_deadflag_eb_dflag62.txt",ndeadflagietaiphi_ic[2]);
271 <  getCrystaldeadflagBarrel_v1("deadflag/crystal_deadflag_eb_dflag63.txt",ndeadflagietaiphi_ic[3]);
272 <  getCrystaldeadflagBarrel_v1("deadflag/crystal_deadflag_eb_dflag72.txt",ndeadflagietaiphi_ic[4]);
273 <  getCrystaldeadflagBarrel_v1("deadflag/crystal_deadflag_eb_dflag73.txt",ndeadflagietaiphi_ic[5]);
274 <  getCrystaldeadflagBarrel_v1("deadflag/crystal_deadflag_eb_dflag64.txt",ndeadflagietaiphi_ic[6]);
275 <  
276 <  getCrystaldeadflagBarrel_v1("deadflag/crystal_deadflag_eb_dflag250.txt",ndeadflagietaiphi_ic[7]);
277 <  getCrystaldeadflagBarrel_v1("deadflag/crystal_deadflag_eb_dflag251.txt",ndeadflagietaiphi_ic[8]);
278 <  getCrystaldeadflagBarrel_v1("deadflag/crystal_deadflag_eb_dflag252.txt",ndeadflagietaiphi_ic[9]);
279 <  getCrystaldeadflagBarrel_v1("deadflag/crystal_deadflag_eb_dflag253.txt",ndeadflagietaiphi_ic[10]);
280 <  getCrystaldeadflagBarrel_v1("deadflag/crystal_deadflag_eb_dflag227.txt",ndeadflagietaiphi_ic[11]);
281 <  getCrystaldeadflagBarrel_v1("deadflag/crystal_deadflag_eb_dflag228.txt",ndeadflagietaiphi_ic[12]);
282 <  getCrystaldeadflagBarrel_v1("deadflag/crystal_deadflag_eb_dflag254.txt",ndeadflagietaiphi_ic[13]);
283 <  
284 <  
229 >  getCrystaldeadflagBarrel_v1("../Pi0Calibration/Barrel/crystal_deadflag_eb_dflag2.txt",ndeadflagietaiphi_ic[0]);
230 >  getCrystaldeadflagBarrel_v1("../Pi0Calibration/Barrel/crystal_deadflag_eb_dflag3.txt",ndeadflagietaiphi_ic[1]);
231 >
232    ofstream txtoutTocheck("combinedCalibConstantv2.txt");
233      
234    
# Line 311 | Line 258 | void combineCalibConstantv2(){
258    //   float icwt2[170][360];
259    
260    
261 <  /// ieta -21 to -15 iph 280 to 290
315 <  bool fixTempTT = true;  ///this is a fix-me by hand, not elegant, be careful!
316 <  
317 <  // ieta -30 to -25, iphi  165 to 171
318 <  // ieta -81 to -75, iphi  300 to 310
319 <    
320 <  
261 >
262    for(int n=0; n< nConstantSet; n++){
263      string filename = smScaleFiles[n];
264      TFile *ff = new TFile(filename.c_str(),"read");
265 <    TH1F *hhtmp = (TH1F*)ff->Get("hh_corr_smv2");
265 >    TH1F *hhtmp = (TH1F*)ff->Get("hh_corr_sm");
266      hh_smscales[n] = hhtmp;
267      
268      filename = icFiles[n];
269  
270      readInterCalibConstEBSimplev1(filename.c_str(),cc);
330    
331    
332    if( fixTempTT){
333      
334      float meanTemp = 0;
335      int nTemp = 0;
336      float meanTemp2 =0;
337      int nTemp2 = 0;
338            
339      
340      float meanTemp3=0;
341      int nTemp3 = 0;
342      float meanTemp4=0;
343      int nTemp4 = 0;
344      
345      
346      float meanTemp5=0;
347      int nTemp5 = 0;
348      float meanTemp6=0;
349      int nTemp6 = 0;
350            
351      
352      float meanTemp7=0;
353      int nTemp7 = 0;
354      float meanTemp8=0;
355      int nTemp8 = 0;
356
357      
358      for(int j=0; j< 170; j++){
359        for(int k=0; k< 360; k++){
360          int ieta = j-85;
361          if( ieta >=0) ieta += 1;
362          int iphi = k;
363          if( k==0) iphi = 360;
364                  
365
366          ////<<<<<<<
367          if( (ieta == 35 && iphi >= 311 && iphi <= 315) ||
368              (ieta == 41 && iphi >= 311 && iphi <= 315) ||
369              (ieta >= 36 && ieta <= 40 && iphi == 310 ) ||
370              (ieta >= 36 && ieta <= 40 && iphi == 316 )
371              ){
372            if( cc[j][k] >0){
373              meanTemp7 += cc[j][k];
374              nTemp7 ++;
375            }
376          }
377          if( (ieta== 35 &&  iphi == 310) ||
378              (ieta== 35 &&  iphi == 316) ||
379              (ieta== 41 &&  iphi == 310) ||
380              (ieta== 41 &&  iphi == 316) ){
381            if( cc[j][k] >0){
382              meanTemp8 += cc[j][k];
383              nTemp8 ++;
384            }
385          }
386          ////>>>>>>>
387          
388          
389          ////<<<<<<<
390          if( (ieta == -81 && iphi >= 301 && iphi <= 310) ||
391              (ieta == -75 && iphi >= 301 && iphi <= 310) ||
392              (ieta >= -80 && ieta <= -76 && iphi == 300 ) ||
393              (ieta >= -80 && ieta <= -76 && iphi == 311 )
394              ){
395            if( cc[j][k] >0){
396              meanTemp5 += cc[j][k];
397              nTemp5 ++;
398            }
399          }
400          if( (ieta== -81 &&  iphi == 300) ||
401              (ieta== -81 &&  iphi == 311) ||
402              (ieta== -75 &&  iphi == 300) ||
403              (ieta== -75 &&  iphi == 311) ){
404            if( cc[j][k] >0){
405              meanTemp6 += cc[j][k];
406              nTemp6 ++;
407            }
408          }
409          ////>>>>>>>
410                  
411          
412          ////<<<<<<<
413          if( (ieta == -31 && iphi >= 166 && iphi <= 170) ||
414              (ieta == -25 && iphi >= 166 && iphi <= 170) ||
415              (ieta >= -30 && ieta <= -26 && iphi == 165 ) ||
416              (ieta >= -30 && ieta <= -26 && iphi == 171 )
417              ){
418            if( cc[j][k] >0){
419              meanTemp3 += cc[j][k];
420              nTemp3 ++;
421            }
422          }
423          if( (ieta== -31 &&  iphi == 165) ||
424              (ieta== -31 &&  iphi == 171) ||
425              (ieta== -25 &&  iphi == 165) ||
426              (ieta== -25 &&  iphi == 171) ){
427            if( cc[j][k] >0){
428              meanTemp4 += cc[j][k];
429              nTemp4 ++;
430            }
431          }
432          ////>>>>>>>
433          
434  
435          ////<<<<<<<
436          if( (ieta == -21 && iphi >= 281 && iphi <= 290) ||
437              (ieta == -15 && iphi >= 281 && iphi <= 290) ||
438              (ieta >= -20 && ieta <= -16 && iphi == 280 ) ||
439              (ieta >= -20 && ieta <= -16 && iphi == 291 )
440              ){
441            if( cc[j][k] >0){
442              meanTemp += cc[j][k];
443              nTemp ++;
444            }
445            
446          }
447
448          if( (ieta== -21 &&  iphi == 291) ||
449              (ieta== -21 &&  iphi == 280) ||
450              (ieta== -15 &&  iphi == 280) ||
451              (ieta== -15 &&  iphi == 291) ){
452            
453            if( cc[j][k] > 0){
454              meanTemp2 += cc[j][k];
455              nTemp2 ++;
456            }
457          }
458          ////>>>>>>>
459          
460          
461        }
462      }
463            
464      
465      
466      if( n==2 || n==3 || n==9 || n==10){
467        meanTemp5 /= nTemp5;
468        meanTemp6 /= nTemp6;
469        cout<<" meanTemp5 6 " << meanTemp5 <<" "<<meanTemp6 <<endl;
470        
471        for(int j=0; j< 170; j++){
472          for(int k=0; k< 360; k++){
473            int ieta = j-85;
474            if( ieta >=0) ieta += 1;
475            int iphi = k;
476            if( k==0) iphi = 360;
477            
478            if( (ieta == -81 && iphi >= 301 && iphi <= 310) ||
479                (ieta == -75 && iphi >= 301 && iphi <= 310) ||
480                (ieta >= -80 && ieta <= -76 && iphi == 300 ) ||
481                (ieta >= -80 && ieta <= -76 && iphi == 311 )
482                ){
483              if( cc[j][k] >0){
484                cc[j][k] /= meanTemp5;
485              }
486            }
487            if( (ieta== -81 &&  iphi == 300) ||
488                (ieta== -81 &&  iphi == 311) ||
489                (ieta== -75 &&  iphi == 300) ||
490                (ieta== -75 &&  iphi == 311) ){
491              if( cc[j][k] >0){
492                cc[j][k] /= meanTemp6;
493              }
494            }
495          }
496        }
497      }
498      
499      
500      if( n==0 || n==1  || n==2 || n==3 || n ==4 || n==5  || n==6 || n==7 || n==8 || n==9 || n==10|| n== 11 || n== 12 || n== 13){
501        meanTemp3 /= nTemp3;
502        meanTemp4 /= nTemp4;
503        cout<<" meanTemp3 4 " << meanTemp3 <<" "<<meanTemp4 <<endl;
504
505        for(int j=0; j< 170; j++){
506          for(int k=0; k< 360; k++){
507            int ieta = j-85;
508            if( ieta >=0) ieta += 1;
509            int iphi = k;
510            if( k==0) iphi = 360;
511            
512            if( (ieta == -31 && iphi >= 166 && iphi <= 170) ||
513                (ieta == -25 && iphi >= 166 && iphi <= 170) ||
514                (ieta >= -30 && ieta <= -26 && iphi == 165 ) ||
515                (ieta >= -30 && ieta <= -26 && iphi == 171 )
516                ){
517              if( cc[j][k] >0){
518                cc[j][k] /= meanTemp3;
519              }
520            }
521            if( (ieta== -31 &&  iphi == 165) ||
522                (ieta== -31 &&  iphi == 171) ||
523                (ieta== -25 &&  iphi == 165) ||
524                (ieta== -25 &&  iphi == 171) ){
525              if( cc[j][k] >0){
526                cc[j][k] /= meanTemp4;
527              }
528            }
529          }
530        }
531      }
532      
533
534
535      if( n==4 || n==5 || n== 11 || n==12){ ///September
536        meanTemp /= nTemp;
537        meanTemp2 /=nTemp2;
538        meanTemp7 /= nTemp7;
539        meanTemp8 /= nTemp8;
540        cout<<" meanTemp " << meanTemp <<" "<<meanTemp2 <<" "<< meanTemp7 <<" "<< meanTemp8<<endl;
541        
542        
543        for(int j=0; j< 170; j++){
544          for(int k=0; k< 360; k++){
545            int ieta = j-85;
546            if( ieta >=0) ieta += 1;
547            int iphi = k;
548            if( k==0) iphi = 360;
549          
550            if( (ieta == -21 && iphi >= 281 && iphi <= 290) ||
551                (ieta == -15 && iphi >= 281 && iphi <= 290) ||
552                (ieta >= -20 && ieta <= -16 && iphi == 280 ) ||
553                (ieta >= -20 && ieta <= -16 && iphi == 291 )
554                ){
555              if( cc[j][k] >0){
556                cc[j][k] /= meanTemp;
557              }
558            }
559            
560            if( (ieta== -21 &&  iphi == 291) ||
561                (ieta== -21 &&  iphi == 280) ||
562                (ieta== -15 &&  iphi == 280) ||
563                (ieta== -15 &&  iphi == 291) ){
564              if( cc[j][k] > 0){
565                cc[j][k] /= meanTemp2;
566              }
567            }
568            
569            if( (ieta == 35 && iphi >= 311 && iphi <= 315) ||
570                (ieta == 41 && iphi >= 311 && iphi <= 315) ||
571                (ieta >= 36 && ieta <= 40 && iphi == 310 ) ||
572                (ieta >= 36 && ieta <= 40 && iphi == 316 )
573                ){
574              if( cc[j][k] >0){
575                cc[j][k] /= meanTemp7;
576              }
577            }
578            if( (ieta== 35 &&  iphi == 310) ||
579                (ieta== 35 &&  iphi == 316) ||
580                (ieta== 41 &&  iphi == 310) ||
581                (ieta== 41 &&  iphi == 316) ){
582              if( cc[j][k] >0){
583                cc[j][k] /= meanTemp8;
584              }
585            }
586            
587          }
588        }
589        
590      }
591      
592    }
593    
594    
271    
272      for(int j=0; j< 170; j++){
273        for(int k=0; k< 360; k++){
# Line 637 | Line 313 | void combineCalibConstantv2(){
313      }
314    }
315    
316 +  cout<<"sddd" <<endl;
317 +
318    
319    TH1F *hh_c_ieta[50][170];
320    TH1F *hh_c_ietaAbs[50][85];
# Line 647 | Line 325 | void combineCalibConstantv2(){
325    TH1F *hh_csmtb_ietaTT[50][34];
326    TH1F *hh_csmtb_ietaTTAbs[50][17];
327    TH1F *hh_csmco_ietaTTAbs[50][17];
328 +
329    TH1F *hh_csmco_ietaTT[50][34];
330  
331    TH1F *hh_csmall_ietaTTAbs[50][17];
# Line 727 | Line 406 | void combineCalibConstantv2(){
406      }
407    }
408  
409 <  
409 >  cout<<"sdddd" <<endl;
410      
411    
412    TH1F *hh_res_cietaAbs_period[50][3];
# Line 840 | Line 519 | void combineCalibConstantv2(){
519      }
520    }
521    
522 <  
522 >  cout<<"sddda" <<endl;
523    
524  
525    for(int j=0; j< nConstantSet; j++){
# Line 850 | Line 529 | void combineCalibConstantv2(){
529        hh_res_csmtbietaTT[j][k] = new TH1F(histname,histname,34,xbinLow);
530        histname = TString(Form("hh_res_csmtbietaTTAbs_%d_%d",j,k));
531        hh_res_csmtbietaTTAbs[j][k] = new TH1F(histname,histname,17,xbinLow1);
532 +
533 +      
534 +      histname = TString(Form("hh_res_csmallietaTTAbs_%d_%d",j,k));
535 +      hh_res_csmallietaTTAbs[j][k] = new TH1F(histname,histname,17,xbinLow1);
536 +      
537        
538        histname = TString(Form("hh_res_csmcoietaTT_%d_%d",j,k));
539        hh_res_csmcoietaTT[j][k] = new TH1F(histname,histname,34,xbinLow);
# Line 883 | Line 567 | void combineCalibConstantv2(){
567    TH1F *hh_res_diff_csmallietaTT[50][50][3];
568    TH1F *hh_res_diff_csmallietaTTAbs[50][50][3];
569    
570 +  cout<<"sdddb" <<endl;
571 +
572    for(int n=0; n< nConstantSet; n++){
573      for(int k=n+1; k< nConstantSet; k++){
574        TString histname = TString (Form("hh2_diff_%dand%d",n,k));
# Line 932 | Line 618 | void combineCalibConstantv2(){
618        
619      }
620    }
621 <  
621 >
622 >  cout<<"sddde" <<endl;
623  
624    TH2F *hh2_largeICdiff[50][50];
625    for(int n=0; n< nIC; n++){
# Line 944 | Line 631 | void combineCalibConstantv2(){
631    TH2F *hh2_largeICdiff_all =new TH2F("hh2_largeICdiff_all","hh2_largeICdiff_all",171,-85,86,360,1,361);
632    
633    vector<string> inputfileStat;
634 <
635 <  inputfileStat.push_back("calibres/deriveCalibConst.testCalibv1.dflag60.pe1.cut0.rmOvlap0.step11.method1.corrEta21.corrPhi10.corrSM1.corrDead-1.precalib1.vtx1.encorr0.evtNot-1.trig0.root");
949 <  inputfileStat.push_back("calibres/deriveCalibConst.testCalibv1.dflag61.pe1.cut0.rmOvlap0.step11.method1.corrEta21.corrPhi10.corrSM1.corrDead-1.precalib1.vtx1.encorr0.evtNot-1.trig0.root");
950 <  inputfileStat.push_back("calibres/deriveCalibConst.testCalibv1.dflag62.pe1.cut0.rmOvlap0.step11.method1.corrEta21.corrPhi10.corrSM1.corrDead-1.precalib1.vtx1.encorr0.evtNot-1.trig0.root");
951 <  inputfileStat.push_back("calibres/deriveCalibConst.testCalibv1.dflag63.pe1.cut0.rmOvlap0.step11.method1.corrEta21.corrPhi10.corrSM1.corrDead-1.precalib1.vtx1.encorr0.evtNot-1.trig0.root");
952 <  inputfileStat.push_back("calibres/deriveCalibConst.testCalibv1.dflag72.pe1.cut0.rmOvlap0.step11.method1.corrEta21.corrPhi10.corrSM1.corrDead-1.precalib1.vtx1.encorr0.evtNot-1.trig0.root");
953 <  inputfileStat.push_back("calibres/deriveCalibConst.testCalibv1.dflag73.pe1.cut0.rmOvlap0.step11.method1.corrEta21.corrPhi10.corrSM1.corrDead-1.precalib1.vtx1.encorr0.evtNot-1.trig0.root");
954 <  inputfileStat.push_back("calibres/deriveCalibConst.testCalibv1.dflag64.pe1.cut0.rmOvlap0.step11.method1.corrEta21.corrPhi10.corrSM1.corrDead-1.precalib1.vtx1.encorr0.evtNot-1.trig0.root");
955 <  
956 <  inputfileStat.push_back("calibres/deriveCalibConst.testCalibv1.dflag250.pe2.cut0.rmOvlap0.step11.method1.corrEta21.corrPhi10.corrSM1.corrDead-1.precalib1.vtx1.encorr0.evtNot-1.trig0.root");
957 <  inputfileStat.push_back("calibres/deriveCalibConst.testCalibv1.dflag251.pe2.cut0.rmOvlap0.step11.method1.corrEta21.corrPhi10.corrSM1.corrDead-1.precalib1.vtx1.encorr0.evtNot-1.trig0.root");
958 <  inputfileStat.push_back("calibres/deriveCalibConst.testCalibv1.dflag252.pe2.cut0.rmOvlap0.step11.method1.corrEta21.corrPhi10.corrSM1.corrDead-1.precalib1.vtx1.encorr0.evtNot-1.trig0.root");
959 <  inputfileStat.push_back("calibres/deriveCalibConst.testCalibv1.dflag253.pe2.cut0.rmOvlap0.step11.method1.corrEta21.corrPhi10.corrSM1.corrDead-1.precalib1.vtx1.encorr0.evtNot-1.trig0.root");
960 <  inputfileStat.push_back("calibres/deriveCalibConst.testCalibv1.dflag227.pe2.cut0.rmOvlap0.step11.method1.corrEta21.corrPhi10.corrSM1.corrDead-1.precalib1.vtx1.encorr0.evtNot-1.trig0.root");
961 <  inputfileStat.push_back("calibres/deriveCalibConst.testCalibv1.dflag228.pe2.cut0.rmOvlap0.step11.method1.corrEta21.corrPhi10.corrSM1.corrDead-1.precalib1.vtx1.encorr0.evtNot-1.trig0.root");
962 <  inputfileStat.push_back("calibres/deriveCalibConst.testCalibv1.dflag254.pe2.cut0.rmOvlap0.step11.method1.corrEta21.corrPhi10.corrSM1.corrDead-1.precalib1.vtx1.encorr0.evtNot-1.trig0.root");
634 >  inputfileStat.push_back("calibres1/deriveCalibConst.dflag2.pe1.step3.iter11.root");
635 >  inputfileStat.push_back("calibres1/deriveCalibConst.dflag3.pe2.step3.iter11.root");
636    
637    
638 <  TH1F *hh_res_ietaTTAbs[50][5];////[4] means the stat error.
638 >  TH1F *hh_res_ieta[50][4];////[4] means the stat error.
639    
640    for(int n=0; n< int(inputfileStat.size()); n++){
641      for(int k=0;k<5;k++){
642 <      string filename = string(Form("hh_res_ietaTTAbs_%d_%d",n,k));
643 <      hh_res_ietaTTAbs[n][k] =new TH1F(filename.c_str(),filename.c_str(),17,xbinLow1);
642 >      string filename = string(Form("hh_res_ieta_%d_%d",n,k));
643 >      hh_res_ieta[n][k] =new TH1F(filename.c_str(),filename.c_str(),171,-85,86);
644      }
645    }
646 +  TH1F *hh_statErr_ietaAbs[50];
647 +  for(int n=0; n< int(inputfileStat.size()); n++){
648 +    string filename = string(Form("hh_statErr_ietaAbs_%d",n));
649 +    hh_statErr_ietaAbs[n] =new TH1F(filename.c_str(),filename.c_str(),85,1,86);
650 +  }
651 +  
652  
653 <  TH1F *hh_statErr_ietaTTAbs_period[50]; //pi0&eta combined for each period
653 >  TH1F *hh_statErr_ietaAbs_period[50]; //pi0&eta combined for each period
654    for(int j=0; j< nIC; j++){
655 <    string filename = string(Form("hh_statErr_ietaTTAbs_period_%d",j));
656 <    hh_statErr_ietaTTAbs_period[j]=new TH1F(filename.c_str(),filename.c_str(),17,xbinLow1);
655 >    string filename = string(Form("hh_statErr_ietaAbs_period_%d",j));
656 >    hh_statErr_ietaAbs_period[j]=new TH1F(filename.c_str(),filename.c_str(),85,1,86);
657    }
658    
659 +  cout<<"sddf" <<endl;
660    
661    ///using MC-based forumula + 0.5/1 % sys.
662    // 7.4/resolution * 17 /sqrt(N) * sqrt( 1+ 1.8/sob) + 0.5/1%
# Line 986 | Line 666 | void combineCalibConstantv2(){
666      string filename = inputfileStat[j];
667      TFile *f1 = new TFile(filename.c_str(),"read");
668      for(int k=0;k<4;k++){
669 <      string histname = string (Form("hh_res_ietaTTAbs_%d",k));
669 >      string histname = string (Form("hh_res_ieta_%d",k));
670        TH1F *hhtmp = (TH1F*)f1->Get(histname.c_str());
671 <      hh_res_ietaTTAbs[j][k]->Add(hhtmp);
671 >      if(hhtmp==0){
672 >        cout<<"empty hh_res_ieta_ ! "<<endl;
673 >        return;
674 >      }
675 >      
676 >      hh_res_ieta[j][k]->Add(hhtmp);
677      }
678    }
679    
680 +  cout<<"calc stat err " <<endl;
681 +  
682    for(int j=0; j< int(inputfileStat.size());j++){
683  
684 <    for(int n=0; n< 17; n++){
685 <      float npiz = hh_res_ietaTTAbs[j][1]->GetBinContent(n+1)*0.5/(360*10) ;
686 <      float sob = hh_res_ietaTTAbs[j][2]->GetBinContent(n+1);
687 <      float reso = hh_res_ietaTTAbs[j][3]->GetBinContent(n+1)/hh_res_ietaTTAbs[j][0]->GetBinContent(n+1) * 100;
684 >    for(int n=1; n<=85 ; n++){
685 >      float npiz = 0.5*(hh_res_ieta[j][1]->GetBinContent(87+n-1) + hh_res_ieta[j][1]->GetBinContent(85-(n-1)) ) /(360*2) ;
686 >      float sob = 0.5*(hh_res_ieta[j][3]->GetBinContent(87+n-1) + hh_res_ieta[j][3]->GetBinContent(85-(n-1)) );
687 >      float reso = 0.5*(hh_res_ieta[j][2]->GetBinContent(87+n-1) + hh_res_ieta[j][2]->GetBinContent(85-(n-1)) )/hh_res_ieta[j][0]->GetBinContent(87+n-1);
688 >
689 >      if(npiz<=0){
690 >        cout<<"empty histogram!!" <<endl;
691 >        return;
692 >      }
693 >      
694        float statErr = reso/7.4 * 17/sqrt(npiz) * sqrt( 1+ 1.8/sob);
695 <      hh_res_ietaTTAbs[j][4]->SetBinContent(n+1,statErr);
695 >      hh_statErr_ietaAbs[j]->SetBinContent(n,statErr);
696      }
697    }
698    
699 +  
700    ///the combined IC from all ICs
701    ofstream txtout("interCalibConstants.combinedPi0EtaAllPeriod.EcalBarrel.txt",ios::out);
702    
# Line 1022 | Line 716 | void combineCalibConstantv2(){
716  
717    cout<<"fill" <<endl;
718  
719 <
719 >  
720    
721  
722    for(int n=0; n< nConstantSet; n++){
# Line 1079 | Line 773 | void combineCalibConstantv2(){
773              hh_csmco_ietaTTAbs[n][ietaTTAbs]->Fill(c);
774              hh_csmco_ietaTT[n][j/5]->Fill(c);
775            }
776 +          
777 +          hh_csmall_ietaTTAbs[n][ietaTTAbs]->Fill(c);
778 +
779          }else{
780            hh2_c[n]->SetBinContent(beta,bphi,-1);
781          }
# Line 1201 | Line 898 | void combineCalibConstantv2(){
898        }
899      }
900      
901 +    for(int j=0;j<17; j++){
902 +      fitHistogram(hh_csmall_ietaTTAbs[k][j],resfit);
903 +      for(int n=0;n<3; n++){
904 +        hh_res_csmallietaTTAbs[k][n]->SetBinContent(j+1,resfit[2*n]);
905 +        hh_res_csmallietaTTAbs[k][n]->SetBinError(j+1,resfit[2*n+1]);
906 +      }
907 +    }
908 +    
909 +    
910 +
911      for(int j=0;j<34; j++){
912        fitHistogram(hh_csmco_ietaTT[k][j],resfit);
913        for(int n=0;n<3; n++){
# Line 1271 | Line 978 | void combineCalibConstantv2(){
978          
979  
980          //now use MC-predicted precision
981 <        statErr = hh_res_ietaTTAbs[n][4]->GetBinContent(ietaTTAbs+1);
981 >        statErr = hh_res_ieta[n][4]->GetBinContent(87+abs(ieta)-1);
982          
983          float sigma = sqrt( statErr * statErr + sysErr * sysErr);
984          
# Line 1286 | Line 993 | void combineCalibConstantv2(){
993            wtSumC_period[nperiod] += tmp1;
994            wtSumS_period[nperiod] += tmp2;
995            
1289          
1290          ////// Set by hand, for some crystals'IC, not used for combination
1291          if( n==4 || n==11 || n==5 || n== 12){ ////  fix by hand September 's IC  in a region ( deadflag txt file was wrong  )
1292            //set by hand those to be -1 for combination, including +2 crystals next to the "dead region"
1293            if( (ieta >=-22 && ieta <= -12) &&
1294                (iphi >=279 && iphi <= 292 )
1295                ){
1296              c = -1;
1297            }
1298          }
1299          if( n==4 || n==11 || n==5 || n== 12){  ///one more TT
1300            if( (ieta >=35 && ieta <= 41) &&
1301                (iphi >=310 && iphi <= 316 )
1302                ){
1303              c = -1;
1304            }
1305          }
1306          if( n==0 || n==1  || n==2 || n==3 || n ==4 || n==6 || n==7 || n==8 || n==9 || n==10|| n== 11 || n== 13){ //using only 5 and 12 for combination
1307            if( ieta >= -31 && ieta <= -25 && iphi >= 165 && iphi <= 171){
1308              c = -1;
1309            }
1310          }
1311          if( n==2  || n==3 || n==9 || n==10){
1312            if( ieta >= -81 && ieta <= -75 && iphi >= 300 && iphi <= 311){
1313              c = -1;
1314            }
1315          }
1316          
996            if( c> 0){ //all combined
997              wtSumC += tmp1;
998              wtSumS += tmp2;
# Line 1347 | Line 1026 | void combineCalibConstantv2(){
1026  
1027    float statErr_allCombined[85] = {0} ;
1028    
1029 <  for(int b=1; b<= hh_res_ietaTTAbs[0][4]->GetNbinsX(); b++){
1029 >  for(int b=1; b<= hh_statErr_ietaAbs[0]->GetNbinsX(); b++){
1030      float sumStatErr2 = 0;
1031      for(int n=0; n< nConstantSet; n++){
1032 <      float statErr = hh_res_ietaTTAbs[n][4]->GetBinContent(b);
1032 >      float statErr = hh_statErr_ietaAbs[n]->GetBinContent(b);
1033        sumStatErr2 += 1./ ( statErr * statErr );
1034      }
1035      float statErr = sqrt( 1./ sumStatErr2 );
1036      statErr_allCombined[b-1] = statErr;
1037      
1038 <    cout<<" statErr_allCombined " << b <<" "<< statErr_allCombined[b-1] << " % "<<endl;
1038 >    cout<<" statErr_allCombined " << b <<" "<< statErr_allCombined[b-1]*100 << " % "<<endl;
1039  
1040    }
1041    
1042  
1043    ///Stat error for each period
1044    for(int j=0; j< nIC; j++){
1045 <    for(int b=1; b<= hh_res_ietaTTAbs[j][4]->GetNbinsX();b++){
1046 <      float statErrPi0 = hh_res_ietaTTAbs[j][4]->GetBinContent(b);
1047 <      float statErrEta = hh_res_ietaTTAbs[j+nIC][4]->GetBinContent(b);
1045 >    for(int b=1; b<= hh_statErr_ietaAbs[0]->GetNbinsX();b++){
1046 >      float statErrPi0 =  hh_statErr_ietaAbs[j]->GetBinContent(b);
1047 >      float statErrEta =  hh_statErr_ietaAbs[j+nIC]->GetBinContent(b);
1048        float statErr = 1/(statErrPi0*statErrPi0) + 1./(statErrEta*statErrEta);
1049        statErr = sqrt(1/statErr);
1050 <      hh_statErr_ietaTTAbs_period[j]->SetBinContent(b,statErr);
1050 >      hh_statErr_ietaAbs_period[j]->SetBinContent(b,statErr);
1051      }
1052    }
1053    
# Line 1380 | Line 1059 | void combineCalibConstantv2(){
1059      int ieta = j-85;
1060      if( ieta >=0) ieta += 1;
1061      
1062 +  
1063 +    int absieta = abs(ieta);
1064 +    
1065      for(int k=0; k<360; k++){
1066        int iphi = k;
1067        if( k==0) iphi = 360;
# Line 1408 | Line 1090 | void combineCalibConstantv2(){
1090            if( icwt_period[n1][j][k]>0 && icwt_period[n2][j][k]>0){
1091              float reldiff = fabs( icwt_period[n1][j][k] - icwt_period[n2][j][k] )/ ( 0.5* (icwt_period[n1][j][k] + icwt_period[n2][j][k]));
1092  
1093 <            float statErr1 = hh_statErr_ietaTTAbs_period[n1]->GetBinContent(ietaTTAbs+1)/100;
1094 <            float statErr2 = hh_statErr_ietaTTAbs_period[n2]->GetBinContent(ietaTTAbs+1)/100;
1093 >            float statErr1 = hh_statErr_ietaAbs_period[n1]->GetBinContent(absieta)/100;
1094 >            float statErr2 = hh_statErr_ietaAbs_period[n2]->GetBinContent(absieta)/100;
1095              
1096              ////assuming same sys.
1097              float diff_statErr = sqrt( statErr1*statErr1 + statErr2*statErr2);
# Line 1512 | Line 1194 | void combineCalibConstantv2(){
1194                exit(1);
1195              }
1196              hh_c_deadflag_period[n][deadflag]->Fill(icwt_period[n][j][k]);
1197 <            hh_cc_deadflag_period[n][deadflag]->Fill(icwt_period[n][j][k] * interCalib_preCalibTrue[j][k]);
1516 <            hh_cc1_deadflag_period[n][deadflag]->Fill(interCalib_preCalibTrue[j][k]);
1197 >
1198              if(deadflag>0){
1199                hh_c_deadflag_period[n][19]->Fill(icwt_period[n][j][k]);
1200                hh_cc_deadflag_period[n][19]->Fill( interCalib_preCalib[j][k] * icwt_period[n][j][k]);
1520              hh_cc1_deadflag_period[n][19]->Fill( interCalib_preCalibTrue[j][k]);
1201              }
1202              
1203            }
# Line 1546 | Line 1226 | void combineCalibConstantv2(){
1226              
1227  
1228        for(int n=0; n< nIC; n++){ ///for each period
1229 <        statErr = hh_statErr_ietaTTAbs_period[n]->GetBinContent(ietaTTAbs+1);
1229 >        statErr = hh_statErr_ietaAbs_period[n]->GetBinContent(absieta);
1230          icErr = sqrt( statErr * statErr + sysErr * sysErr);
1231          icErr /= 100;
1232          

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines