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.3 by yangyong, Fri Aug 10 14:54:03 2012 UTC vs.
Revision 1.5 by yangyong, Mon Aug 27 21:37:39 2012 UTC

# Line 210 | Line 210 | void combineCalibConstantv2(){
210    
211    //SM-scale files Pi0
212    
213 <  smScaleFiles[0] = "../Pi0Calibration/Barrel/calibres/deriveCalibConst.dflag2.pe1.step1.iter1.root";
214 <  smScaleFiles[1] = "../Pi0Calibration/Barrel/calibres/deriveCalibConst.dflag3.pe2.step1.iter1.root";
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;
# Line 221 | Line 221 | void combineCalibConstantv2(){
221    map<int,string> icFiles;
222    
223    //IC Pi0
224 <  icFiles[0] = "../Pi0Calibration/Barrel/calibres/deriveCalibConst.dflag2.pe1.step4.iter30.txt";
224 >  icFiles[0] = "calibres/deriveCalibConst.dflag2.pe1.step4.iter30.txt";
225    //IC Eta
226 <  icFiles[1] = "../Pi0Calibration/Barrel/calibres/deriveCalibConst.dflag3.pe2.step4.iter30.txt";
226 >  icFiles[1] = "calibres/deriveCalibConst.dflag3.pe2.step4.iter30.txt";
227    
228    //crystal dead flag
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]);
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      
# Line 313 | Line 321 | void combineCalibConstantv2(){
321      }
322    }
323    
316  cout<<"sddd" <<endl;
324  
325    
326    TH1F *hh_c_ieta[50][170];
# Line 406 | Line 413 | void combineCalibConstantv2(){
413      }
414    }
415  
409  cout<<"sdddd" <<endl;
416      
417    
418    TH1F *hh_res_cietaAbs_period[50][3];
# Line 519 | Line 525 | void combineCalibConstantv2(){
525      }
526    }
527    
522  cout<<"sddda" <<endl;
523  
528  
529    for(int j=0; j< nConstantSet; j++){
530      for(int k=0; k<3; k++){
# Line 567 | Line 571 | void combineCalibConstantv2(){
571    TH1F *hh_res_diff_csmallietaTT[50][50][3];
572    TH1F *hh_res_diff_csmallietaTTAbs[50][50][3];
573    
570  cout<<"sdddb" <<endl;
574  
575    for(int n=0; n< nConstantSet; n++){
576      for(int k=n+1; k< nConstantSet; k++){
# Line 619 | Line 622 | void combineCalibConstantv2(){
622      }
623    }
624  
622  cout<<"sddde" <<endl;
625  
626    TH2F *hh2_largeICdiff[50][50];
627    for(int n=0; n< nIC; n++){
# Line 629 | 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);
634 <  
633 <  vector<string> inputfileStat;
634 <  inputfileStat.push_back("calibres1/deriveCalibConst.dflag2.pe1.step3.iter11.root");
635 <  inputfileStat.push_back("calibres1/deriveCalibConst.dflag3.pe2.step3.iter11.root");
634 >
635    
636    
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++){
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      }
# Line 648 | Line 647 | void combineCalibConstantv2(){
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 <  
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_ietaAbs_period[50]; //pi0&eta combined for each period
657    for(int j=0; j< nIC; j++){
# Line 656 | Line 659 | void combineCalibConstantv2(){
659      hh_statErr_ietaAbs_period[j]=new TH1F(filename.c_str(),filename.c_str(),85,1,86);
660    }
661    
659  cout<<"sddf" <<endl;
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 <
665 <  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++){
# Line 675 | Line 676 | void combineCalibConstantv2(){
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    
680  cout<<"calc stat err " <<endl;
699    
700    for(int j=0; j< int(inputfileStat.size());j++){
701  
# Line 691 | Line 709 | void combineCalibConstantv2(){
709          return;
710        }
711        
712 <      float statErr = reso/7.4 * 17/sqrt(npiz) * sqrt( 1+ 1.8/sob);
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);
# Line 978 | Line 1001 | void combineCalibConstantv2(){
1001          
1002  
1003          //now use MC-predicted precision
1004 <        statErr = hh_res_ieta[n][4]->GetBinContent(87+abs(ieta)-1);
1004 >        statErr = hh_statErr_ietaAbs[n]->GetBinContent(abs(ieta));
1005          
1006          float sigma = sqrt( statErr * statErr + sysErr * sysErr);
1007          
# Line 1035 | Line 1058 | void combineCalibConstantv2(){
1058      float statErr = sqrt( 1./ sumStatErr2 );
1059      statErr_allCombined[b-1] = statErr;
1060      
1061 <    cout<<" statErr_allCombined " << b <<" "<< statErr_allCombined[b-1]*100 << " % "<<endl;
1061 >    cout<<" statErr_allCombined " << b <<" "<< statErr_allCombined[b-1] << " % "<<endl;
1062  
1063    }
1064    
# Line 1159 | 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        

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines