ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/yangyong/combineICEE/getCalibConstants.cc
(Generate patch)

Comparing UserCode/yangyong/combineICEE/getCalibConstants.cc (file contents):
Revision 1.1 by yangyong, Tue Apr 10 20:03:11 2012 UTC vs.
Revision 1.2 by yangyong, Thu Aug 30 11:03:29 2012 UTC

# Line 30 | Line 30 | void scaleMeanToUnit(float C[170][360]){
30  
31  
32  
33 // void scaleMeanToUnitEndcap(float C[2][101][101]){
34
35  
36 //   double mean = 0;
37 //   int n = 0;
38 //   for(int j=0; j< 170; j++){
39 //     for(int k=0; k< 360; k++){
40      
41 //       if( C[j][k] >0){
42 //      mean += C[j][k];
43 //      n ++;
44 //       }      
45 //     }
46 //   }
47 //   mean /= n;
48 //   cout<<"mean " << mean<<" "<<n<<endl;
49
50 //   for(int j=0; j< 170; j++){
51 //     for(int k=0; k< 360; k++){
52 //       if(C[j][k] >0){
53 //      C[j][k] /= mean;
54 //       }
55 //     }
56 //   }
57  
58 // }
59
60
61
62
33   void NormIetaToUnitTestBeamSMOnly(float C[170][360]){
34    
35    float mean_ieta[170] = {0};
# Line 459 | Line 429 | void readInterCalibConstEBSimplev1(const
429    
430   }
431  
462
463
464 void readInterCalibBarre_Phiv1new(){
465  
466  char *file_input = new char[500];
467  sprintf(file_input,"phisym_EcalIntercalib-160M-corrected.txt");
468  
469  sprintf(file_input,"EcalIntercalibConstants_Run2010A_corr.xml.txt");
470  
471  cout<<"READING fro inter-calib file "<<file_input<<endl;
472  ifstream inputcc(file_input,ios::in);
473  if (inputcc.fail()){
474    cout<<"error open file barrel.. " << file_input<<endl;
475    exit(1);
476  }
477  
478  float c1;
479  for(int ieta=-85; ieta <= 85; ieta++){
480    if( ieta==0) continue;
481    for(int iphi=1; iphi <= 360; iphi++){
482      inputcc >> c1;
483      
484      int eta = ieta;
485      int phi = iphi;
486      convxtalid(phi,eta);
487      
488      if( c1 <=0){
489        c1 =1;
490      }
491      
492      if( c1 == 1 ){
493        c1 = - 1;
494      }
495      if( c1 <0.6 || c1 >2.5){
496        c1 = -1;
497      }
498      
499      
500      CphiCorr[eta+85][phi] = c1;
501    }
502  }
503    
504 }
505
506
507 void readInterCalibBarre_Phi2011a(){
508  
509  char *file_input = new char[500];
510
511  
512  sprintf(file_input,"EcalIntercalib-2011A-corrected.xmlv1");
513  
514  cout<<"READING fro inter-calib file "<<file_input<<endl;
515  ifstream inputcc(file_input,ios::in);
516  if (inputcc.fail()){
517    cout<<"error open file barrel.. " << file_input<<endl;
518    exit(1);
519  }
520  
521  float c1;
522  for(int ieta=-85; ieta <= 85; ieta++){
523    if( ieta==0) continue;
524    for(int iphi=1; iphi <= 360; iphi++){
525      inputcc >> c1;
526      
527      int eta = ieta;
528      int phi = iphi;
529      convxtalid(phi,eta);
530      
531      if( c1 <=0){
532        c1 =1;
533      }
534      
535      if( c1 == 1 ){
536        c1 = - 1;
537      }
538      if( c1 <0.6 || c1 >2.5){
539        c1 = -1;
540      }
541      
542      
543      CphiCorr[eta+85][phi] = c1;
544    }
545  }
546  
547
548
549 }
550
551
552
553
554 void readInterCalibBarre_Phiv1(){
555    
556  char *file_input = new char[500];
557  sprintf(file_input,"phisym_EcalIntercalib-160M-corrected.txt");
558  
559  
560  cout<<"READING fro inter-calib file "<<file_input<<endl;
561  ifstream inputcc(file_input,ios::in);
562  if (inputcc.fail()){
563    cout<<"error open file barrel.. " << file_input<<endl;
564    exit(1);
565  }
566  
567  int eta;
568  int phi;
569  float c = 1;
570  float c1 = 1;
571  
572  int n = 0;
573
574  eta  = -85;
575  phi = 0;
576  
577  float mean = 0;
578  
579  int cureta = -85;
580  
581  int ngood = 0;
582  
583  
584  
585  while (inputcc.good()){
586
587    inputcc >> c1;
588
589    if(c1==1) c1 = -1;
590    
591    
592    if(  n% 360 ==0 && n>0 ) {
593      eta++;
594      if(eta==0) eta = 1;  
595    }
596    
597    if( eta == cureta){
598      phi ++;
599    }else{
600      cureta = eta;
601      phi = 1;
602      
603    }
604    
605    
606    n++;
607    
608    
609    int iSM = (phi-1)/20+1;
610    if( eta<0) iSM += 18;
611        
612    
613    int ieta = eta;
614    int iphi = phi;
615    
616    
617    convxtalid(iphi,ieta);
618    
619    ///txtout<<eta<<" "<<phi<<endl;
620    
621    CphiCorr[ieta+85][iphi] = c1;  
622    
623    
624    if(c1 >0 ){
625      mean += c1;
626      ngood ++;
627    }
628    
629    
630    if(n >= 360*170) break;
631    
632  }
633  
634  
635  mean /=  ngood;
636  cout<<n<<" phi  constants read. "<< mean <<endl;
637  
638  
639 //   for(int j=0; j< 170; j++){
640 //     mean_ieta[j] /= nmean_ieta[j];
641 //     txtout<<"mean_ieta_phisym "<< j<<" "<< mean_ieta[j] <<" "<< nmean_ieta[j] <<endl;
642 //   }
643  
644  
645 //   for(int j=0; j< 170; j++){
646 //     for(int k=0; k< 360; k++){
647      
648 //       if(  CphiCorr[j][k] >0 ){
649 //      CphiCorr[j][k] /=  mean_ieta[j] ;
650        
651 //       }
652 //       Cphi[j][k] =   CphiCorr[j][k] *  iCalConst_data[j][k];
653 //     }
654 //   }
655  
656 //   NormSMScaleToUnit(CphiCorr);
657  
658 }
659
660
661 ///read initi calibration constants for each crystal
662 void readInterCalibBarre_BSv1(){
663  
664  
665  char *file_input = new char[500];
666  sprintf(file_input,"IC_barrel_splash09_AllRuns.txt");
667  
668  
669  cout<<"READING fro inter-calib bsfile "<<file_input<<endl;
670  txtout<<"READING fro inter-calib bsfile "<<file_input<<endl;
671  ifstream inputcc(file_input,ios::in);
672  if (inputcc.fail()){
673    cout<<"error open file barrel.. " << file_input<<endl;
674    exit(1);
675  }
676  
677  int eta;
678  int phi;
679  float c = 1;
680  float c1 = 1;
681  
682  int n = 0;
683  int ngood = 0;
684  
685
686  float mean = 0;
687  
688  
689  
690  
691  float mean_ieta[170] = {0};
692  int nmean_ieta[170] = {0};
693  
694
695  while (inputcc.good()){
696
697    inputcc >> eta >> phi >>c1;
698    
699    //  cout<<phi<<" "<<eta<<" "<<c<<endl;
700    
701    convxtalid(phi,eta);
702    
703    eta += 85;
704    
705    if( c1 == 1){
706      c1 = -1;
707    }
708    
709    if( c1 <0.6 || c1 >2.5){
710      c1 = -1;
711    }
712    
713    
714    ///iCalConstPi0[eta][phi] = c1 ;
715    
716    CBSCorr[eta][phi] = c1;  
717    
718    if(c1 >0 ){
719      mean += c1;
720      ngood ++;
721    }
722
723    if(c1 >0 ){
724      mean_ieta[eta] += c1;
725      nmean_ieta[eta] ++;
726    }
727    
728    n++;
729    
730    /// hh_imcEB->Fill(c);
731    if(n >= 360*170) break;
732    
733  }
734  
735  
736  
737  mean /= ngood;
738  
739  
740    
741  cout<<n<<" bs  constants read. "<< mean << endl;
742  
743    
744  
745 //   for(int j=0; j< 170; j++){
746 //     for(int k=0; k< 360; k++){
747      
748 //       if(  CBSCorr[j][k] >0 ){
749 //      CBSCorr[j][k] /=  mean_ieta[j];
750 //       }
751      
752 //       CBS[j][k] = CBSCorr[j][k] * iCalConst_data[j][k];
753      
754      
755 //     }
756 //   }
757 //   NormSMScaleToUnit(CBSCorr);
758  
759  
760  
761 }
762
763
764
765
766
767 ///read initi calibration constants for each crystal
768 void readInterCalibBarre_GR09_V8(){
769
770
771  
772  char *file_input = new char[500];
773  file_input = "interCalib_GR09_R_V6A_barrel.txt";
774  cout<<"READING fro inter-calib file "<<file_input<<endl;
775  ifstream inputcc(file_input,ios::in);
776  if (inputcc.fail()){
777    cout<<"error open file barrel.. " << file_input<<endl;
778    exit(1);
779  }
780  
781  int eta;
782  int phi;
783  float c = 1;
784  float c1 = 1;
785  
786  int n = 0;
787  
788  double mean = 0;
789  
790
791  while (inputcc.good()){
792
793    inputcc >> eta >> phi >>c1;
794    
795    //  cout<<phi<<" "<<eta<<" "<<c<<endl;
796    
797    convxtalid(phi,eta);
798    
799    eta += 85;
800    
801    ///iCalConst[eta][phi] = c;
802    
803    //iCalConst_data[eta][phi] = c1 * 0.038012/ 0.038;  ///Now this is exactly the same as the inter-calibration used in data.
804    
805    interCalib_preCalib[eta][phi] = c1 ; /// now OK iN MC startupv8p.
806    
807    
808    n++;
809    //  cout<<phi<<" "<<eta<<" "<<c<<endl;
810    mean += c1;
811    
812    /// hh_imcEB->Fill(c);
813    if(n >= 360*170) break;
814    
815  }
816  
817
818  mean /= 61200;
819    
820  cout<<n<<" constants read. "<< mean <<endl;
821  
822  
823 }
824
432  
433  
434  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines