CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

TShapeAnalysis Class Reference

#include <TShapeAnalysis.h>

List of all members.

Public Member Functions

void assignChannel (int, int)
void computeShape (std::string namefile, TTree *)
void computetmaxVal (int, double *)
void getDateStart ()
void getDateStop ()
std::vector< double > getInitVals (int)
std::vector< double > getVals (int)
void printshapeData (int)
void putAllVals (int, double *, int, int)
void putAllVals (int, double *, int, int, int, int, int, int)
void putalphaInit (int, double)
void putalphaVal (int, double)
void putbetaInit (int, double)
void putbetaVal (int, double)
void putchi2Init (int, double)
void putchi2Val (int, double)
void putDateStart (long int)
void putDateStop (long int)
void putetaInit (int, int)
void putflagInit (int, int)
void putflagVal (int, int)
void putphiInit (int, int)
void putwidthInit (int, double)
void putwidthVal (int, double)
void set_const (int, int, int, int, int, double, double)
void set_nch (int)
void set_presample (int)
 TShapeAnalysis (TTree *tAB, double, double, double, double)
 TShapeAnalysis (double, double, double, double)
virtual ~TShapeAnalysis ()

Private Member Functions

void init (double, double, double, double)
void init (TTree *tAB, double, double, double, double)

Private Attributes

double alpha0
double alpha_init [fNchsel]
double alpha_val [fNchsel]
double beta0
double beta_init [fNchsel]
double beta_val [fNchsel]
int ch_init [fNchsel]
double chi2_init [fNchsel]
double chi2_val [fNchsel]
double chi2cut
int dcc_init [fNchsel]
int eta_init [fNchsel]
char filename [80]
int flag_init [fNchsel]
int flag_val [fNchsel]
int index [fNchsel]
int nchsel
int nevt
double noise
int npass [fNchsel]
double npassok [fNchsel]
int nsamplecristal
int phi_init [fNchsel]
int presample
double rawsglu [fNchsel][200][10]
int sampamax
int sampbmax
int side_init [fNchsel]
TTree * tABinit
TTree * tABout
long int timestart
long int timestop
int tower_init [fNchsel]
double width_init [fNchsel]
double width_val [fNchsel]

Detailed Description

Definition at line 10 of file TShapeAnalysis.h.


Constructor & Destructor Documentation

TShapeAnalysis::TShapeAnalysis ( double  alpha0,
double  beta0,
double  width0,
double  chi20 
)

Definition at line 26 of file TShapeAnalysis.cc.

References init.

{
  init(alpha0, beta0, width0, chi20);
}
TShapeAnalysis::TShapeAnalysis ( TTree *  tAB,
double  alpha0,
double  beta0,
double  width0,
double  chi20 
)

Definition at line 31 of file TShapeAnalysis.cc.

References init.

{
  init(tAB, alpha0, beta0, width0, chi20);
}
TShapeAnalysis::~TShapeAnalysis ( ) [virtual]

Definition at line 37 of file TShapeAnalysis.cc.

{
}

Member Function Documentation

void TShapeAnalysis::assignChannel ( int  n,
int  ch 
)

Definition at line 170 of file TShapeAnalysis.cc.

References getHLTprescales::index, and n.

{
    if(n >= nchsel)
         printf(" number of channels exceed maximum allowed\n");

    index[n]=ch;
}
void TShapeAnalysis::computeShape ( std::string  namefile,
TTree *   
)
void TShapeAnalysis::computetmaxVal ( int  i,
double *  tm_val 
)

Definition at line 434 of file TShapeAnalysis.cc.

References i, gen::k, runTheMatrix::npass, and mathSSE::sqrt().

{
  double tm_mean=0;double tm_sig=0;

        double tm=0.; double sigtm=0.;
        for(int k=0;k<npass[i]-1;k++) {
                if(1. < tm_val[k] && tm_val[k] < 10.) {
                   npassok[i]++;
                   tm+= tm_val[k];
                   sigtm+= tm_val[k]*tm_val[k];
                }
        }
        if(npassok[i] <= 0) {
              tm_mean=0.; tm_sig=0.;
        } else {
              for(int k=0;k<npass[i]-1;k++) {
                    if(1. < tm_val[k] && tm_val[k] < 10.) {
                         double ss= (sigtm/npassok[i]-tm/npassok[i]*tm/npassok[i]);
                         if(ss < 0.) ss=0.;
                         tm_sig=sqrt(ss);
                         tm_mean= tm/npassok[i];
                    }
              }
        }
        //printf("npassok[%d]=%f tm_mean=%f tm_sig=%f\n",i,npassok[i],tm_mean,tm_sig);
        putwidthVal(i,tm_mean);
        
}
void TShapeAnalysis::getDateStart ( )

Definition at line 188 of file TShapeAnalysis.cc.

References matplotRender::t, and cond::rpcobgas::time.

{
    time_t t,timecur;
    timecur= time(&t);
    timestart= ((long int) timecur);
}
void TShapeAnalysis::getDateStop ( )

Definition at line 195 of file TShapeAnalysis.cc.

References matplotRender::t, and cond::rpcobgas::time.

{
    time_t t,timecur;
    timecur= time(&t);
    timestop= ((long int) timecur);
}
std::vector< double > TShapeAnalysis::getInitVals ( int  n)

Definition at line 533 of file TShapeAnalysis.cc.

References v.

{

  std::vector<double> v;
  
  v.push_back(alpha_init[n]);
  v.push_back(beta_init[n]);
  v.push_back(width_init[n]);
  v.push_back(chi2_init[n]);
  v.push_back(flag_init[n]);
  
  return v;
}
std::vector< double > TShapeAnalysis::getVals ( int  n)

Definition at line 520 of file TShapeAnalysis.cc.

References v.

Referenced by EcalLaserAnalyzer::endJob().

{

  std::vector<double> v;
  
  v.push_back(alpha_val[n]);
  v.push_back(beta_val[n]);
  v.push_back(width_val[n]);
  v.push_back(chi2_val[n]);
  v.push_back(flag_val[n]);
  
  return v;
}
void TShapeAnalysis::init ( TTree *  tAB,
double  alpha0,
double  beta0,
double  width0,
double  chi20 
) [private]

Definition at line 74 of file TShapeAnalysis.cc.

References fNchsel, and init.

{
  init( alpha0, beta0, width0, chi20 );
  
  tABinit=tAB->CloneTree();

  // Declaration of leaf types
  Int_t           sidei;
  Int_t           iphii;
  Int_t           ietai;
  Int_t           dccIDi;
  Int_t           towerIDi;
  Int_t           channelIDi;
  Double_t        alphai;
  Double_t        betai;
  Double_t        widthi;
  Double_t        chi2i;
  Int_t           flagi;
  
  // List of branches
  TBranch        *b_iphi;   
  TBranch        *b_ieta;   
  TBranch        *b_side;   
  TBranch        *b_dccID;   
  TBranch        *b_towerID;   
  TBranch        *b_channelID;   
  TBranch        *b_alpha;   
  TBranch        *b_beta;   
  TBranch        *b_width;   
  TBranch        *b_chi2;   
  TBranch        *b_flag;   
  
  if(tABinit){

    tABinit->SetBranchAddress("iphi", &iphii, &b_iphi);
    tABinit->SetBranchAddress("ieta", &ietai, &b_ieta);
    tABinit->SetBranchAddress("side", &sidei, &b_side);
    tABinit->SetBranchAddress("dccID", &dccIDi, &b_dccID);
    tABinit->SetBranchAddress("towerID", &towerIDi, &b_towerID);
    tABinit->SetBranchAddress("channelID", &channelIDi, &b_channelID);
    tABinit->SetBranchAddress("alpha", &alphai, &b_alpha);
    tABinit->SetBranchAddress("beta", &betai, &b_beta);
    tABinit->SetBranchAddress("width", &widthi, &b_width);
    tABinit->SetBranchAddress("chi2", &chi2i, &b_chi2);
    tABinit->SetBranchAddress("flag", &flagi, &b_flag);
    
    nchsel=tABinit->GetEntries();
    assert(nchsel<=fNchsel);
    
    for(int cris=0;cris<nchsel;cris++){
      
      tABinit->GetEntry(cris);
      
      //      std::cout<< "Loop 1 "<< cris<<" "<<alphai<< std::endl;

      putalphaVal(cris,alphai);
      putchi2Val(cris,chi2i);
      putbetaVal(cris,betai);
      putwidthVal(cris,widthi);
      putflagVal(cris,flagi);
      
      putalphaInit(cris,alphai);
      putchi2Init(cris,chi2i);
      putbetaInit(cris,betai);
      putwidthInit(cris,widthi);
      putflagInit(cris,flagi);
      putetaInit(cris,ietai);
      putphiInit(cris,iphii);
 
    }
  }
}
void TShapeAnalysis::init ( double  alpha0,
double  beta0,
double  width0,
double  chi20 
) [private]

Definition at line 41 of file TShapeAnalysis.cc.

References fNchsel, getHLTprescales::index, runTheMatrix::npass, and NULL.

{
  tABinit=NULL;
  nchsel=fNchsel;
  for(int cris=0;cris<fNchsel;cris++){

    index[cris]=-1;
    npass[cris]=0;
    npassok[cris]=0.;
    
    alpha_val[cris]=alpha0;
    beta_val[cris]=beta0;
    width_val[cris]=width0;
    chi2_val[cris]=chi20;
    flag_val[cris]=0;
    
    alpha_init[cris]=alpha0;
    beta_init[cris]=beta0;
    width_init[cris]=width0;
    chi2_init[cris]=chi20;
    flag_init[cris]=0;

    phi_init[cris]=0;
    eta_init[cris]=0;
    side_init[cris]=0;
    dcc_init[cris]=0;
    tower_init[cris]=0;
    ch_init[cris]=0;
    assignChannel(cris,cris);
    
  }
}
void TShapeAnalysis::printshapeData ( int  gRunNumber)

Definition at line 547 of file TShapeAnalysis.cc.

References lut2db_cfg::filename, i, getHLTprescales::index, and NULL.

{
     FILE *fd;
     int nev;
     sprintf(filename,"runABW%d.pedestal",gRunNumber); 
     fd = fopen(filename, "w");                                
     if(fd == NULL) printf("Error while opening file : %s\n",filename);

     for(int i=0; i<nchsel;i++) {
        if(index[i] >= 0) {
          nev= (int) npassok[i];
          double trise= alpha_val[i]*beta_val[i];
          fprintf( fd, "%d %d 1 %ld %ld %f %f %f %f\n",
                index[i],nev,timestart,timestop,alpha_val[i],beta_val[i],trise,width_val[i]);
        }
     }
     int iret=fclose(fd);
     printf(" Closing file : %d\n",iret);

}
void TShapeAnalysis::putAllVals ( int  ch,
double *  sampl,
int  ieta,
int  iphi 
)

Definition at line 214 of file TShapeAnalysis.cc.

References i, getHLTprescales::index, gen::k, n, and runTheMatrix::npass.

{

  int i,k;
  int n=-1;
  for(i=0;i<nchsel;i++)
    if(index[i] == ch) n=i;
  
  if(n >= 0) {
    if(npass[n] < nevt) {
      
      for(k=0;k<nsamplecristal;k++) {
        rawsglu[n][npass[n]][k] = sampl[k];
      }
      
      npass[n]++;
    }
  } else {
    printf("no index found for ch=%d\n",ch);
  }
}
void TShapeAnalysis::putAllVals ( int  ch,
double *  sampl,
int  ieta,
int  iphi,
int  dcc,
int  side,
int  tower,
int  chid 
)

Definition at line 202 of file TShapeAnalysis.cc.

{
  dcc_init[ch]=dcc;
  tower_init[ch]=side;
  ch_init[ch]=chid;
  side_init[ch]=side;
  eta_init[ch]=ieta;
  phi_init[ch]=iphi;
  putAllVals(ch, sampl, ieta, iphi);
  
}
void TShapeAnalysis::putalphaInit ( int  n,
double  val 
)

Definition at line 487 of file TShapeAnalysis.cc.

References n.

{
    alpha_init[n]= val;
}
void TShapeAnalysis::putalphaVal ( int  n,
double  val 
)

Definition at line 463 of file TShapeAnalysis.cc.

References n.

{
    alpha_val[n]= val;
}
void TShapeAnalysis::putbetaInit ( int  n,
double  val 
)

Definition at line 496 of file TShapeAnalysis.cc.

References n.

{
    beta_init[n]= val;
}
void TShapeAnalysis::putbetaVal ( int  n,
double  val 
)

Definition at line 472 of file TShapeAnalysis.cc.

References n.

{
    beta_val[n]= val;
}
void TShapeAnalysis::putchi2Init ( int  n,
double  val 
)

Definition at line 492 of file TShapeAnalysis.cc.

References n.

{
    chi2_init[n]= val;
}
void TShapeAnalysis::putchi2Val ( int  n,
double  val 
)

Definition at line 468 of file TShapeAnalysis.cc.

References n.

{
    chi2_val[n]= val;
}
void TShapeAnalysis::putDateStart ( long int  timecur)

Definition at line 178 of file TShapeAnalysis.cc.

{
    timestart=timecur;
}
void TShapeAnalysis::putDateStop ( long int  timecur)

Definition at line 183 of file TShapeAnalysis.cc.

{
    timestop=timecur;
}
void TShapeAnalysis::putetaInit ( int  n,
int  val 
)

Definition at line 506 of file TShapeAnalysis.cc.

References n.

{
    eta_init[n]= val;
}
void TShapeAnalysis::putflagInit ( int  n,
int  val 
)

Definition at line 516 of file TShapeAnalysis.cc.

References n.

{
    flag_init[n]= val;
}
void TShapeAnalysis::putflagVal ( int  n,
int  val 
)

Definition at line 482 of file TShapeAnalysis.cc.

References n.

{
    flag_val[n]= val;
}
void TShapeAnalysis::putphiInit ( int  n,
int  val 
)

Definition at line 511 of file TShapeAnalysis.cc.

References n.

{
    phi_init[n]= val;
}
void TShapeAnalysis::putwidthInit ( int  n,
double  val 
)

Definition at line 501 of file TShapeAnalysis.cc.

References n.

{
    width_init[n]= val;
}
void TShapeAnalysis::putwidthVal ( int  n,
double  val 
)

Definition at line 477 of file TShapeAnalysis.cc.

References n.

{
    width_val[n]= val;
}
void TShapeAnalysis::set_const ( int  ns,
int  ns1,
int  ns2,
int  ps,
int  nevtmax,
double  noise_val,
double  chi2_cut 
)

Definition at line 147 of file TShapeAnalysis.cc.

{
  nsamplecristal= ns;
  presample=ps;
  sampbmax= ns1;
  sampamax= ns2;
  nevt= nevtmax;
  noise= noise_val;
  chi2cut=chi2_cut;
}
void TShapeAnalysis::set_nch ( int  nch)

Definition at line 163 of file TShapeAnalysis.cc.

References fNchsel.

Referenced by EcalLaserAnalyzer::endJob(), and EcalABAnalyzer::endJob().

                                   {

  assert (nch<=fNchsel);
  if(tABinit) assert(nch==nchsel);
  nchsel=nch;

}
void TShapeAnalysis::set_presample ( int  ps)

Definition at line 159 of file TShapeAnalysis.cc.

Referenced by EcalLaserAnalyzer::endJob(), and EcalABAnalyzer::endJob().

{
  presample=ps;
}

Member Data Documentation

double TShapeAnalysis::alpha0 [private]

Definition at line 21 of file TShapeAnalysis.h.

double TShapeAnalysis::alpha_init[fNchsel] [private]

Definition at line 24 of file TShapeAnalysis.h.

double TShapeAnalysis::alpha_val[fNchsel] [private]

Definition at line 22 of file TShapeAnalysis.h.

double TShapeAnalysis::beta0 [private]

Definition at line 21 of file TShapeAnalysis.h.

double TShapeAnalysis::beta_init[fNchsel] [private]

Definition at line 24 of file TShapeAnalysis.h.

double TShapeAnalysis::beta_val[fNchsel] [private]

Definition at line 22 of file TShapeAnalysis.h.

int TShapeAnalysis::ch_init[fNchsel] [private]

Definition at line 27 of file TShapeAnalysis.h.

double TShapeAnalysis::chi2_init[fNchsel] [private]

Definition at line 24 of file TShapeAnalysis.h.

double TShapeAnalysis::chi2_val[fNchsel] [private]

Definition at line 22 of file TShapeAnalysis.h.

double TShapeAnalysis::chi2cut [private]

Definition at line 35 of file TShapeAnalysis.h.

int TShapeAnalysis::dcc_init[fNchsel] [private]

Definition at line 27 of file TShapeAnalysis.h.

int TShapeAnalysis::eta_init[fNchsel] [private]

Definition at line 25 of file TShapeAnalysis.h.

char TShapeAnalysis::filename[80] [private]

Definition at line 15 of file TShapeAnalysis.h.

int TShapeAnalysis::flag_init[fNchsel] [private]

Definition at line 25 of file TShapeAnalysis.h.

int TShapeAnalysis::flag_val[fNchsel] [private]

Definition at line 23 of file TShapeAnalysis.h.

int TShapeAnalysis::index[fNchsel] [private]

Definition at line 17 of file TShapeAnalysis.h.

int TShapeAnalysis::nchsel [private]

Definition at line 36 of file TShapeAnalysis.h.

int TShapeAnalysis::nevt [private]

Definition at line 18 of file TShapeAnalysis.h.

double TShapeAnalysis::noise [private]

Definition at line 20 of file TShapeAnalysis.h.

int TShapeAnalysis::npass[fNchsel] [private]

Definition at line 17 of file TShapeAnalysis.h.

double TShapeAnalysis::npassok[fNchsel] [private]

Definition at line 30 of file TShapeAnalysis.h.

Definition at line 18 of file TShapeAnalysis.h.

int TShapeAnalysis::phi_init[fNchsel] [private]

Definition at line 25 of file TShapeAnalysis.h.

Definition at line 19 of file TShapeAnalysis.h.

double TShapeAnalysis::rawsglu[fNchsel][200][10] [private]

Definition at line 29 of file TShapeAnalysis.h.

int TShapeAnalysis::sampamax [private]

Definition at line 18 of file TShapeAnalysis.h.

int TShapeAnalysis::sampbmax [private]

Definition at line 18 of file TShapeAnalysis.h.

int TShapeAnalysis::side_init[fNchsel] [private]

Definition at line 27 of file TShapeAnalysis.h.

TTree* TShapeAnalysis::tABinit [private]

Definition at line 32 of file TShapeAnalysis.h.

TTree* TShapeAnalysis::tABout [private]

Definition at line 33 of file TShapeAnalysis.h.

long int TShapeAnalysis::timestart [private]

Definition at line 16 of file TShapeAnalysis.h.

long int TShapeAnalysis::timestop [private]

Definition at line 16 of file TShapeAnalysis.h.

int TShapeAnalysis::tower_init[fNchsel] [private]

Definition at line 27 of file TShapeAnalysis.h.

double TShapeAnalysis::width_init[fNchsel] [private]

Definition at line 24 of file TShapeAnalysis.h.

double TShapeAnalysis::width_val[fNchsel] [private]

Definition at line 22 of file TShapeAnalysis.h.