Skip to content
Snippets Groups Projects
THcShowerArray.cxx 31 KiB
Newer Older
  • Learn to ignore specific revisions
  • //_____________________________________________________________________________
    void THcShowerArray::CalculatePedestals( )
    {
    
      // Use the accumulated pedestal data to calculate pedestals.
    
      for(Int_t i=0; i<fNelem;i++) {
    
        fPed[i] = ((Float_t) fPedSum[i]) / TMath::Max(1, fPedCount[i]);
        fSig[i] = sqrt(((Float_t)fPedSum2[i])/TMath::Max(1, fPedCount[i])
    		   - fPed[i]*fPed[i]);
        fThresh[i] = fPed[i] + TMath::Min(50., TMath::Max(10., 3.*fSig[i]));
    
      }
    
      // Debug output.
    
      if ( ((THcShower*) GetParent())->fdbg_raw_cal ) {
    
        cout << "---------------------------------------------------------------\n";
    
        cout << "Debug output from THcShowerArray::CalculatePedestals for "
    
        	 << GetParent()->GetPrefix() << ":" << endl;
    
        cout << "  ADC pedestals and thresholds for calorimeter plane "
    	 << GetName() << endl;
        for(Int_t i=0; i<fNelem;i++) {
          cout << "  element " << i << ": "
    	   << "  Pedestal = " << fPed[i]
    
    	   << "  threshold = " << fThresh[i]
    
    	   << endl;
        }
        cout << "---------------------------------------------------------------\n";
    
      }
    
    }
    //_____________________________________________________________________________
    void THcShowerArray::InitializePedestals( )
    {
      fNPedestalEvents = 0;
    
    
      fPedSum = new Int_t [fNelem];
      fPedSum2 = new Int_t [fNelem];
      fPedCount = new Int_t [fNelem];
    
      fSig = new Float_t [fNelem];
      fPed = new Float_t [fNelem];
      fThresh = new Float_t [fNelem];
    
      for(Int_t i=0;i<fNelem;i++) {
        fPedSum[i] = 0;
        fPedSum2[i] = 0;
        fPedCount[i] = 0;
      }
    
    
    //------------------------------------------------------------------------------
    
    // Fiducial volume limits.
    
    Double_t THcShowerArray::fvXmin() {
      THcShower* fParent;
      fParent = (THcShower*) GetParent();
      return fXPos[0][0] - fXStep/2 + fParent->fvDelta;
    }
    
    Double_t THcShowerArray::fvYmax() {
      THcShower* fParent;
      fParent = (THcShower*) GetParent();
      return fYPos[0][0] + fYStep/2 - fParent->fvDelta;
    }
    
    Double_t THcShowerArray::fvXmax() {
      THcShower* fParent;
      fParent = (THcShower*) GetParent();
      return fXPos[fNRows-1][fNColumns-1] + fXStep/2 - fParent->fvDelta;
    }
    
    Double_t THcShowerArray::fvYmin() {
      THcShower* fParent;
      fParent = (THcShower*) GetParent();
      return fYPos[fNRows-1][fNColumns-1] - fYStep/2 + fParent->fvDelta;
    }
    
    Double_t THcShowerArray::clMaxEnergyBlock(THcShowerCluster* cluster) {
      Double_t max_energy=-1.;
      Double_t max_block=-1.;
      for (THcShowerClusterIt it=(*cluster).begin(); it!=(*cluster).end(); ++it) {
        if ( (**it).hitE() > max_energy )   {
           max_energy = (**it).hitE();
           max_block = ((**it).hitColumn())*fNRows + (**it).hitRow()+1;
        }
      }
      return max_block;
    }