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.5 by yangyong, Mon Aug 27 21:37:39 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] = "calibres/deriveCalibConst.dflag2.pe1.step1.iter1.root";
214 >  smScaleFiles[1] = "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] = "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] = "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]);
232 <  getCrystaldeadflagBarrel_v1("deadflag/crystal_deadflag_eb_dflag63.txt",ndeadflagietaiphi_ic[3]);
233 <  getCrystaldeadflagBarrel_v1("deadflag/crystal_deadflag_eb_dflag72.txt",ndeadflagietaiphi_ic[4]);
234 <  getCrystaldeadflagBarrel_v1("deadflag/crystal_deadflag_eb_dflag73.txt",ndeadflagietaiphi_ic[5]);
235 <  getCrystaldeadflagBarrel_v1("deadflag/crystal_deadflag_eb_dflag64.txt",ndeadflagietaiphi_ic[6]);
236 <  
237 <  getCrystaldeadflagBarrel_v1("deadflag/crystal_deadflag_eb_dflag250.txt",ndeadflagietaiphi_ic[7]);
238 <  getCrystaldeadflagBarrel_v1("deadflag/crystal_deadflag_eb_dflag251.txt",ndeadflagietaiphi_ic[8]);
239 <  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("crystal_deadflag_eb_dflag2.txt",ndeadflagietaiphi_ic[0]);
230 >  getCrystaldeadflagBarrel_v1("crystal_deadflag_eb_dflag3.txt",ndeadflagietaiphi_ic[1]);
231 >
232 >
233 >    
234 >  vector<string> inputfileStat;
235 >  inputfileStat.push_back("calibres/deriveCalibConst.dflag2.pe1.step3.iter11.root");
236 >  inputfileStat.push_back("calibres/deriveCalibConst.dflag3.pe2.step3.iter11.root");
237 >
238 >
239 >
240    ofstream txtoutTocheck("combinedCalibConstantv2.txt");
241      
242    
# Line 311 | Line 266 | void combineCalibConstantv2(){
266    //   float icwt2[170][360];
267    
268    
269 <  /// 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 <  
269 >
270    for(int n=0; n< nConstantSet; n++){
271      string filename = smScaleFiles[n];
272      TFile *ff = new TFile(filename.c_str(),"read");
273 <    TH1F *hhtmp = (TH1F*)ff->Get("hh_corr_smv2");
273 >    TH1F *hhtmp = (TH1F*)ff->Get("hh_corr_sm");
274      hh_smscales[n] = hhtmp;
275      
276      filename = icFiles[n];
277  
278      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    
279    
280      for(int j=0; j< 170; j++){
281        for(int k=0; k< 360; k++){
# Line 637 | Line 321 | void combineCalibConstantv2(){
321      }
322    }
323    
324 +
325    
326    TH1F *hh_c_ieta[50][170];
327    TH1F *hh_c_ietaAbs[50][85];
# Line 647 | Line 332 | void combineCalibConstantv2(){
332    TH1F *hh_csmtb_ietaTT[50][34];
333    TH1F *hh_csmtb_ietaTTAbs[50][17];
334    TH1F *hh_csmco_ietaTTAbs[50][17];
335 +
336    TH1F *hh_csmco_ietaTT[50][34];
337  
338    TH1F *hh_csmall_ietaTTAbs[50][17];
# Line 727 | Line 413 | void combineCalibConstantv2(){
413      }
414    }
415  
730  
416      
417    
418    TH1F *hh_res_cietaAbs_period[50][3];
# Line 840 | Line 525 | void combineCalibConstantv2(){
525      }
526    }
527    
843  
844  
528  
529    for(int j=0; j< nConstantSet; j++){
530      for(int k=0; k<3; k++){
# Line 850 | Line 533 | void combineCalibConstantv2(){
533        hh_res_csmtbietaTT[j][k] = new TH1F(histname,histname,34,xbinLow);
534        histname = TString(Form("hh_res_csmtbietaTTAbs_%d_%d",j,k));
535        hh_res_csmtbietaTTAbs[j][k] = new TH1F(histname,histname,17,xbinLow1);
536 +
537 +      
538 +      histname = TString(Form("hh_res_csmallietaTTAbs_%d_%d",j,k));
539 +      hh_res_csmallietaTTAbs[j][k] = new TH1F(histname,histname,17,xbinLow1);
540 +      
541        
542        histname = TString(Form("hh_res_csmcoietaTT_%d_%d",j,k));
543        hh_res_csmcoietaTT[j][k] = new TH1F(histname,histname,34,xbinLow);
# Line 883 | Line 571 | void combineCalibConstantv2(){
571    TH1F *hh_res_diff_csmallietaTT[50][50][3];
572    TH1F *hh_res_diff_csmallietaTTAbs[50][50][3];
573    
574 +
575    for(int n=0; n< nConstantSet; n++){
576      for(int k=n+1; k< nConstantSet; k++){
577        TString histname = TString (Form("hh2_diff_%dand%d",n,k));
# Line 932 | Line 621 | void combineCalibConstantv2(){
621        
622      }
623    }
624 <  
624 >
625  
626    TH2F *hh2_largeICdiff[50][50];
627    for(int n=0; n< nIC; n++){
# Line 942 | Line 631 | void combineCalibConstantv2(){
631      }
632    }
633    TH2F *hh2_largeICdiff_all =new TH2F("hh2_largeICdiff_all","hh2_largeICdiff_all",171,-85,86,360,1,361);
945  
946  vector<string> inputfileStat;
634  
948  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");
635    
636    
637 <  TH1F *hh_res_ietaTTAbs[50][5];////[4] means the stat error.
637 >  TH1F *hh_res_ieta[50][4];////[4] means the stat error.
638    
639    for(int n=0; n< int(inputfileStat.size()); n++){
640 <    for(int k=0;k<5;k++){
641 <      string filename = string(Form("hh_res_ietaTTAbs_%d_%d",n,k));
642 <      hh_res_ietaTTAbs[n][k] =new TH1F(filename.c_str(),filename.c_str(),17,xbinLow1);
640 >    for(int k=0;k<4;k++){
641 >      string filename = string(Form("hh_res_ieta_%d_%d",n,k));
642 >      hh_res_ieta[n][k] =new TH1F(filename.c_str(),filename.c_str(),171,-85,86);
643      }
644    }
645 +  TH1F *hh_statErr_ietaAbs[50];
646 +  for(int n=0; n< int(inputfileStat.size()); n++){
647 +    string filename = string(Form("hh_statErr_ietaAbs_%d",n));
648 +    hh_statErr_ietaAbs[n] =new TH1F(filename.c_str(),filename.c_str(),85,1,86);
649 +  }
650 +  TH1F *hh_statErr_ietaTTAbs[50];
651 +  for(int n=0; n< int(inputfileStat.size()); n++){
652 +    string filename = string(Form("hh_statErr_ietaTTAbs_%d",n));
653 +    hh_statErr_ietaTTAbs[n] =new TH1F(filename.c_str(),filename.c_str(),17,xbinLow1);
654 +  }
655  
656 <  TH1F *hh_statErr_ietaTTAbs_period[50]; //pi0&eta combined for each period
656 >  TH1F *hh_statErr_ietaAbs_period[50]; //pi0&eta combined for each period
657    for(int j=0; j< nIC; j++){
658 <    string filename = string(Form("hh_statErr_ietaTTAbs_period_%d",j));
659 <    hh_statErr_ietaTTAbs_period[j]=new TH1F(filename.c_str(),filename.c_str(),17,xbinLow1);
658 >    string filename = string(Form("hh_statErr_ietaAbs_period_%d",j));
659 >    hh_statErr_ietaAbs_period[j]=new TH1F(filename.c_str(),filename.c_str(),85,1,86);
660    }
661    
662    
663    ///using MC-based forumula + 0.5/1 % sys.
664    // 7.4/resolution * 17 /sqrt(N) * sqrt( 1+ 1.8/sob) + 0.5/1%
665    
666 <
985 <  for(int j=0; j< int(inputfileStat.size());j++){
666 > for(int j=0; j< int(inputfileStat.size());j++){
667      string filename = inputfileStat[j];
668      TFile *f1 = new TFile(filename.c_str(),"read");
669      for(int k=0;k<4;k++){
670 <      string histname = string (Form("hh_res_ietaTTAbs_%d",k));
670 >      string histname = string (Form("hh_res_ieta_%d",k));
671        TH1F *hhtmp = (TH1F*)f1->Get(histname.c_str());
672 <      hh_res_ietaTTAbs[j][k]->Add(hhtmp);
672 >      if(hhtmp==0){
673 >        cout<<"empty hh_res_ieta_ ! "<<endl;
674 >        return;
675 >      }
676 >      
677 >      hh_res_ieta[j][k]->Add(hhtmp);
678 >    }
679 >
680 >    if( f1->Get("hh_res_ietaTTAbs_0") !=0){
681 >      TH1F *htmp1 = (TH1F*)f1->Get("hh_res_ietaTTAbs_0");
682 >      TH1F *htmp2 = (TH1F*)f1->Get("hh_res_ietaTTAbs_1");
683 >      TH1F *htmp3 = (TH1F*)f1->Get("hh_res_ietaTTAbs_2");
684 >      TH1F *htmp4 = (TH1F*)f1->Get("hh_res_ietaTTAbs_3");
685 >      for(int b=1; b<= 17; b++){
686 >        float m0 = htmp1->GetBinContent(b);
687 >        float sig = htmp3->GetBinContent(b);
688 >        float sb = htmp4->GetBinContent(b);
689 >        float n = htmp2->GetBinContent(b)/ (360*5*2*2);
690 >        float statErr = (sig/m0*100)/7.4 * 17/sqrt(n) * sqrt( 1+ 1.8/sb);
691 >        hh_statErr_ietaTTAbs[j]->SetBinContent(b,statErr);
692 >      }
693      }
694 +    
695    }
696 +
697 +
698 +  
699    
700    for(int j=0; j< int(inputfileStat.size());j++){
701  
702 <    for(int n=0; n< 17; n++){
703 <      float npiz = hh_res_ietaTTAbs[j][1]->GetBinContent(n+1)*0.5/(360*10) ;
704 <      float sob = hh_res_ietaTTAbs[j][2]->GetBinContent(n+1);
705 <      float reso = hh_res_ietaTTAbs[j][3]->GetBinContent(n+1)/hh_res_ietaTTAbs[j][0]->GetBinContent(n+1) * 100;
706 <      float statErr = reso/7.4 * 17/sqrt(npiz) * sqrt( 1+ 1.8/sob);
707 <      hh_res_ietaTTAbs[j][4]->SetBinContent(n+1,statErr);
702 >    for(int n=1; n<=85 ; n++){
703 >      float npiz = 0.5*(hh_res_ieta[j][1]->GetBinContent(87+n-1) + hh_res_ieta[j][1]->GetBinContent(85-(n-1)) ) /(360*2) ;
704 >      float sob = 0.5*(hh_res_ieta[j][3]->GetBinContent(87+n-1) + hh_res_ieta[j][3]->GetBinContent(85-(n-1)) );
705 >      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);
706 >
707 >      if(npiz<=0){
708 >        cout<<"empty histogram!!" <<endl;
709 >        return;
710 >      }
711 >      
712 >      float statErr = (reso*100)/7.4 * 17/sqrt(npiz) * sqrt( 1+ 1.8/sob);
713 >
714 >      cout<<"statErr " << reso <<" "<< npiz <<" "<< sob <<" "<< statErr <<endl;
715 >
716 >      hh_statErr_ietaAbs[j]->SetBinContent(n,statErr);
717      }
718    }
719    
720 +  //return;
721 +
722 +  
723    ///the combined IC from all ICs
724    ofstream txtout("interCalibConstants.combinedPi0EtaAllPeriod.EcalBarrel.txt",ios::out);
725    
# Line 1022 | Line 739 | void combineCalibConstantv2(){
739  
740    cout<<"fill" <<endl;
741  
742 <
742 >  
743    
744  
745    for(int n=0; n< nConstantSet; n++){
# Line 1079 | Line 796 | void combineCalibConstantv2(){
796              hh_csmco_ietaTTAbs[n][ietaTTAbs]->Fill(c);
797              hh_csmco_ietaTT[n][j/5]->Fill(c);
798            }
799 +          
800 +          hh_csmall_ietaTTAbs[n][ietaTTAbs]->Fill(c);
801 +
802          }else{
803            hh2_c[n]->SetBinContent(beta,bphi,-1);
804          }
# Line 1201 | Line 921 | void combineCalibConstantv2(){
921        }
922      }
923      
924 +    for(int j=0;j<17; j++){
925 +      fitHistogram(hh_csmall_ietaTTAbs[k][j],resfit);
926 +      for(int n=0;n<3; n++){
927 +        hh_res_csmallietaTTAbs[k][n]->SetBinContent(j+1,resfit[2*n]);
928 +        hh_res_csmallietaTTAbs[k][n]->SetBinError(j+1,resfit[2*n+1]);
929 +      }
930 +    }
931 +    
932 +    
933 +
934      for(int j=0;j<34; j++){
935        fitHistogram(hh_csmco_ietaTT[k][j],resfit);
936        for(int n=0;n<3; n++){
# Line 1271 | Line 1001 | void combineCalibConstantv2(){
1001          
1002  
1003          //now use MC-predicted precision
1004 <        statErr = hh_res_ietaTTAbs[n][4]->GetBinContent(ietaTTAbs+1);
1004 >        statErr = hh_statErr_ietaAbs[n]->GetBinContent(abs(ieta));
1005          
1006          float sigma = sqrt( statErr * statErr + sysErr * sysErr);
1007          
# Line 1286 | Line 1016 | void combineCalibConstantv2(){
1016            wtSumC_period[nperiod] += tmp1;
1017            wtSumS_period[nperiod] += tmp2;
1018            
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          
1019            if( c> 0){ //all combined
1020              wtSumC += tmp1;
1021              wtSumS += tmp2;
# Line 1347 | Line 1049 | void combineCalibConstantv2(){
1049  
1050    float statErr_allCombined[85] = {0} ;
1051    
1052 <  for(int b=1; b<= hh_res_ietaTTAbs[0][4]->GetNbinsX(); b++){
1052 >  for(int b=1; b<= hh_statErr_ietaAbs[0]->GetNbinsX(); b++){
1053      float sumStatErr2 = 0;
1054      for(int n=0; n< nConstantSet; n++){
1055 <      float statErr = hh_res_ietaTTAbs[n][4]->GetBinContent(b);
1055 >      float statErr = hh_statErr_ietaAbs[n]->GetBinContent(b);
1056        sumStatErr2 += 1./ ( statErr * statErr );
1057      }
1058      float statErr = sqrt( 1./ sumStatErr2 );
# Line 1363 | Line 1065 | void combineCalibConstantv2(){
1065  
1066    ///Stat error for each period
1067    for(int j=0; j< nIC; j++){
1068 <    for(int b=1; b<= hh_res_ietaTTAbs[j][4]->GetNbinsX();b++){
1069 <      float statErrPi0 = hh_res_ietaTTAbs[j][4]->GetBinContent(b);
1070 <      float statErrEta = hh_res_ietaTTAbs[j+nIC][4]->GetBinContent(b);
1068 >    for(int b=1; b<= hh_statErr_ietaAbs[0]->GetNbinsX();b++){
1069 >      float statErrPi0 =  hh_statErr_ietaAbs[j]->GetBinContent(b);
1070 >      float statErrEta =  hh_statErr_ietaAbs[j+nIC]->GetBinContent(b);
1071        float statErr = 1/(statErrPi0*statErrPi0) + 1./(statErrEta*statErrEta);
1072        statErr = sqrt(1/statErr);
1073 <      hh_statErr_ietaTTAbs_period[j]->SetBinContent(b,statErr);
1073 >      hh_statErr_ietaAbs_period[j]->SetBinContent(b,statErr);
1074      }
1075    }
1076    
# Line 1380 | Line 1082 | void combineCalibConstantv2(){
1082      int ieta = j-85;
1083      if( ieta >=0) ieta += 1;
1084      
1085 +  
1086 +    int absieta = abs(ieta);
1087 +    
1088      for(int k=0; k<360; k++){
1089        int iphi = k;
1090        if( k==0) iphi = 360;
# Line 1408 | Line 1113 | void combineCalibConstantv2(){
1113            if( icwt_period[n1][j][k]>0 && icwt_period[n2][j][k]>0){
1114              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]));
1115  
1116 <            float statErr1 = hh_statErr_ietaTTAbs_period[n1]->GetBinContent(ietaTTAbs+1)/100;
1117 <            float statErr2 = hh_statErr_ietaTTAbs_period[n2]->GetBinContent(ietaTTAbs+1)/100;
1116 >            float statErr1 = hh_statErr_ietaAbs_period[n1]->GetBinContent(absieta)/100;
1117 >            float statErr2 = hh_statErr_ietaAbs_period[n2]->GetBinContent(absieta)/100;
1118              
1119              ////assuming same sys.
1120              float diff_statErr = sqrt( statErr1*statErr1 + statErr2*statErr2);
# Line 1477 | Line 1182 | void combineCalibConstantv2(){
1182        if(abs(ieta)>=60) sysErr = 1;
1183        
1184        float icErr = sysErr;
1185 <      float statErr = statErr_allCombined[ietaTTAbs];
1185 >      float statErr = statErr_allCombined[abs(ieta)-1];
1186        icErr = sqrt(sysErr *sysErr + statErr * statErr);
1187        icErr /=100;
1188        
# Line 1512 | Line 1217 | void combineCalibConstantv2(){
1217                exit(1);
1218              }
1219              hh_c_deadflag_period[n][deadflag]->Fill(icwt_period[n][j][k]);
1220 <            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]);
1220 >
1221              if(deadflag>0){
1222                hh_c_deadflag_period[n][19]->Fill(icwt_period[n][j][k]);
1223                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]);
1224              }
1225              
1226            }
# Line 1546 | Line 1249 | void combineCalibConstantv2(){
1249              
1250  
1251        for(int n=0; n< nIC; n++){ ///for each period
1252 <        statErr = hh_statErr_ietaTTAbs_period[n]->GetBinContent(ietaTTAbs+1);
1252 >        statErr = hh_statErr_ietaAbs_period[n]->GetBinContent(absieta);
1253          icErr = sqrt( statErr * statErr + sysErr * sysErr);
1254          icErr /= 100;
1255          

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines