BinCorrelationEM Class Reference

#include <BinCorrelationEM.h>

List of all members.

Public Member Functions

 BinCorrelationEM (Double_t *inputs=0)
 ~BinCorrelationEM ()
void ReInit (Double_t *)
double CalcCorrelation (Double_t, Double_t)
double * GetErrArray (Int_t, Int_t, Int_t, Int_t)

Private Member Functions

void Init ()

Private Attributes

Double_t * fErrArray
Double_t * fCovMat
Double_t * fInputParams

Detailed Description

Definition at line 7 of file BinCorrelationEM.h.


Constructor & Destructor Documentation

BinCorrelationEM::BinCorrelationEM ( Double_t *  inputs = 0  ) 

Definition at line 9 of file BinCorrelationEM.cxx.

References fCovMat, fErrArray, fInputParams, and Init().

00009                                                   {
00010 
00011   fErrArray = NULL;
00012   fCovMat = NULL;
00013   
00014   if(inputs){
00015     fInputParams = new Double_t[6];
00016     for(Int_t i=0;i<6;i++){
00017       fInputParams[i] = inputs[i];
00018     }
00019     Init();
00020   }
00021   else fInputParams = NULL;
00022 
00023 }

BinCorrelationEM::~BinCorrelationEM (  ) 

Definition at line 25 of file BinCorrelationEM.cxx.

References fCovMat, fErrArray, and fInputParams.

00025                                    {
00026   if(fErrArray) delete [] fErrArray;
00027   if(fCovMat) delete [] fCovMat;
00028   if(fInputParams) delete [] fInputParams;
00029 }


Member Function Documentation

Double_t BinCorrelationEM::CalcCorrelation ( Double_t  ,
Double_t   
)

Definition at line 66 of file BinCorrelationEM.cxx.

00066                                                                         {
00067   
00068   return 1;
00069 
00070 }

Double_t * BinCorrelationEM::GetErrArray ( Int_t  LowBin_pl,
Int_t  HighBin_pl,
Int_t  LowBin_st,
Int_t  HighBin_st 
)

Vertex for MC always (u,v,z)=(11.5,11.5,0.5) for CalDet No XTalk Sim CovMat generated over 30planes x 24strips (Actually correlation matrix) Read in all values then truncate according to event histogram size

Definition at line 72 of file BinCorrelationEM.cxx.

References MuELoss::a, fCovMat, fErrArray, fInputParams, infile, Msg::kDebug, Msg::kVerbose, and MSG.

Referenced by FitterEM::CalculateChi2().

00073                                                                          {
00074 
00075   if(fErrArray) return fErrArray;
00076   
00077   int nplane = int(HighBin_pl-LowBin_pl+1);
00078   int nstrip = int(HighBin_st-LowBin_st+1);
00079   int totstp = nplane*nstrip;
00080   
00081   fErrArray = new double[totstp*totstp];
00082 
00086 
00087   if(!fCovMat){ //if it doesn't exist, make it and fill it    
00088     MSG("FitShowerEM",Msg::kDebug) << "Setting up Correlation Matrix" << endl;
00089     
00090     fCovMat = new double[720*720];
00091     ifstream infile;
00092     char name[256];
00093     sprintf(name,"BinErrors/CovMat_%iGeV_NoXTalk.dat",int(fInputParams[0]));
00094     infile.open(name);
00095     if(!infile.is_open()) {
00096       //open default
00097       sprintf(name,"BinErrors/CovMat_3GeV_NoXTalk.dat");
00098       infile.open(name);
00099     }
00100     
00101     if(!infile.is_open()) {
00102       MSG("FitShowerEM",Msg::kDebug) 
00103         << "No txt file for correlations found - using identity matrix" << endl;
00104       for(int i=0;i<720;i++){
00105         for(int j=0;j<720;j++) {
00106           if(i==j) fCovMat[i*720+j] = 1;
00107           else fCovMat[i*720+j] = 0;
00108         }
00109       }
00110     }
00111     else {
00112       int a,b;
00113       double c;
00114       while(infile>>a>>b>>c) {
00115         if(c>1e6) fCovMat[a*720+b]=c;
00116         else fCovMat[a*720+b]=0;
00117       }
00118       infile.close();    
00119       MSG("FitShowerEM",Msg::kDebug) << "Read in file " << name << endl;
00120     }
00121   }
00122   
00123 
00124   Double_t SimVtx[3] = {11.5,11.5,0.5};
00125   //fill fErrArray
00126   for(int i=0;i<totstp;i++){
00127     int plane_i = int(LowBin_pl) + i/nstrip;
00128     int strip_i = int(LowBin_st) + i%nstrip;
00129     if(plane_i%2==0) {
00130       strip_i += int(-fInputParams[1] + SimVtx[0]);      
00131     }
00132     else {
00133       strip_i += int(-fInputParams[2] + SimVtx[1]);
00134     }
00135     plane_i += int(-fInputParams[3] + SimVtx[2]);
00136     for(int j=0;j<totstp;j++){
00137       int plane_j = int(LowBin_pl) + j/nstrip;
00138       int strip_j = int(LowBin_st) + j%nstrip;      
00139       if(plane_j%2==0) {
00140         strip_j = int(-fInputParams[1] + SimVtx[0]) + strip_j;
00141       }
00142       else {
00143         strip_j = int(-fInputParams[2] + SimVtx[1]) + strip_j;
00144       }
00145       plane_j += int(-fInputParams[3] + SimVtx[2]);
00146             
00147       if(plane_i>=0&&plane_i<30&&plane_j>=0&&plane_j<30
00148          &&strip_i>=0&&strip_i<24&&strip_j>=0&&strip_j<24){
00149         fErrArray[i*totstp+j] = fCovMat[(plane_i*24+strip_i)*720 + 
00150                                         plane_j*24+strip_j];
00151       }
00152       else { //out of defined region
00153         if(i==j) fErrArray[i*totstp+j] = 1.;  //diagonal terms
00154         else fErrArray[i*totstp+j] = 0;       //off-diagonal
00155       }
00156 
00157       MSG("FitShowerEM",Msg::kVerbose) << "Plane_i: " << plane_i 
00158                                        << " Strip_i: " << strip_i 
00159                                        << "\nPlane_j: " << plane_j 
00160                                        << " Strip_j: " << strip_j
00161                                        << "\nErrArray_ij: " 
00162                                        << fErrArray[i*totstp+j]
00163                                        << endl;
00164     }
00165   }
00166 
00167   return fErrArray;
00168 
00169 }

void BinCorrelationEM::Init ( void   )  [private]

Definition at line 62 of file BinCorrelationEM.cxx.

Referenced by BinCorrelationEM(), and ReInit().

00062                            {
00063 
00064 }

void BinCorrelationEM::ReInit ( Double_t *  inputs  ) 

Definition at line 31 of file BinCorrelationEM.cxx.

References fCovMat, fErrArray, fInputParams, Init(), Msg::kWarning, and MSG.

Referenced by FitterEM::CalculateChi2().

00031                                              {
00032 
00033   //delete old inputs
00034   Double_t CurrentEnergy = -1;
00035   if(fInputParams) {
00036     CurrentEnergy = fInputParams[0];
00037     delete [] fInputParams;
00038   }
00039   
00040   //read in new ones
00041   fInputParams = new Double_t[6];
00042   for(Int_t i=0;i<6;i++){
00043     fInputParams[i] = inputs[i];
00044   }
00045   
00046   //delete fErrArray whatever happens
00047   //only delete fCovMat if the energy has changed
00048   if(fInputParams[0]>0){
00049     Init();
00050     delete [] fErrArray;
00051     fErrArray = NULL;
00052     if(CurrentEnergy!=fInputParams[0]) {
00053       delete [] fCovMat;
00054       fCovMat = NULL;
00055     }
00056   }
00057   else MSG("FitShowerEM",Msg::kWarning)
00058     <<"Trying to ReInit with energy <=0 ... Probably everything will break..." 
00059     << endl;
00060 }


Member Data Documentation

Double_t* BinCorrelationEM::fCovMat [private]

Definition at line 20 of file BinCorrelationEM.h.

Referenced by BinCorrelationEM(), GetErrArray(), ReInit(), and ~BinCorrelationEM().

Double_t* BinCorrelationEM::fErrArray [private]

Definition at line 19 of file BinCorrelationEM.h.

Referenced by BinCorrelationEM(), GetErrArray(), ReInit(), and ~BinCorrelationEM().

Double_t* BinCorrelationEM::fInputParams [private]

Definition at line 22 of file BinCorrelationEM.h.

Referenced by BinCorrelationEM(), GetErrArray(), ReInit(), and ~BinCorrelationEM().


The documentation for this class was generated from the following files:

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1