<commit_before>/**************************************************************************
 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
 *                                                                        *
 * Author: The ALICE Off-line Project.                                    *
 * Contributors are mentioned in the code where appropriate.              *
 *                                                                        *
 * Permission to use, copy, modify and distribute this software and its   *
 * documentation strictly for non-commercial purposes is hereby granted   *
 * without fee, provided that the above copyright notice appears in all   *
 * copies and that both the copyright notice and this permission notice   *
 * appear in the supporting documentation. The authors make no claims     *
 * about the suitability of this software for any purpose. It is          *
 * provided "as is" without express or implied warranty.                  *
 **************************************************************************/

/* $Id$ */

/* History of cvs commits:
 *
 * $Log$
 * Revision 1.81  2005/09/02 14:32:07  kharlov
 * Calibration of raw data
 *
 * Revision 1.80  2005/08/24 15:31:36  kharlov
 * Setting raw digits flag
 *
 * Revision 1.79  2005/07/25 15:53:53  kharlov
 * Read raw data
 *
 * Revision 1.78  2005/05/28 14:19:04  schutz
 * Compilation warnings fixed by T.P.
 *
 */

//*-- Author: <NAME> (SUBATECH)  & <NAME> (SUBATECH & Kurchatov Institute)
//////////////////////////////////////////////////////////////////////////////
//  Clusterization class. Performs clusterization (collects neighbouring active cells) and 
//  unfolds the clusters having several local maxima.  
//  Results are stored in TreeR#, branches PHOSEmcRP (EMC recPoints),
//  PHOSCpvRP (CPV RecPoints) and AliPHOSClusterizer (Clusterizer with all 
//  parameters including input digits branch title, thresholds etc.)
//  This TTask is normally called from Reconstructioner, but can as well be used in 
//  standalone mode.
// Use Case:
//  root [0] AliPHOSClusterizerv1 * cl = new AliPHOSClusterizerv1("galice.root", "recpointsname", "digitsname")  
//  Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated
//               // reads gAlice from header file "galice.root", uses digits stored in the branch names "digitsname" (default = "Default")
//               // and saves recpoints in branch named "recpointsname" (default = "digitsname")                       
//  root [1] cl->ExecuteTask()  
//               //finds RecPoints in all events stored in galice.root
//  root [2] cl->SetDigitsBranch("digits2") 
//               //sets another title for Digitis (input) branch
//  root [3] cl->SetRecPointsBranch("recp2")  
//               //sets another title four output branches
//  root [4] cl->SetEmcLocalMaxCut(0.03)  
//               //set clusterization parameters
//  root [5] cl->ExecuteTask("deb all time")  
//               //once more finds RecPoints options are 
//               // deb - print number of found rec points
//               // deb all - print number of found RecPoints and some their characteristics 
//               // time - print benchmarking results

// --- ROOT system ---

#include "TMath.h" 
#include "TMinuit.h"
#include "TTree.h" 
#include "TBenchmark.h"

// --- Standard library ---

// --- AliRoot header files ---
#include "AliLog.h"
#include "AliPHOSGetter.h"
#include "AliPHOSGeometry.h" 
#include "AliPHOSClusterizerv1.h"
#include "AliPHOSEmcRecPoint.h"
#include "AliPHOSCpvRecPoint.h"
#include "AliPHOSDigit.h"
#include "AliPHOSDigitizer.h"
#include "AliPHOSCalibrationDB.h"

ClassImp(AliPHOSClusterizerv1)
  
//____________________________________________________________________________
  AliPHOSClusterizerv1::AliPHOSClusterizerv1() : AliPHOSClusterizer()
{
  // default ctor (to be used mainly by Streamer)
  
  InitParameters() ; 
  fDefaultInit = kTRUE ; 
}

//____________________________________________________________________________
AliPHOSClusterizerv1::AliPHOSClusterizerv1(const TString alirunFileName, const TString eventFolderName)
:AliPHOSClusterizer(alirunFileName, eventFolderName)
{
  // ctor with the indication of the file where header Tree and digits Tree are stored
  
  InitParameters() ;
  Init() ;
  fDefaultInit = kFALSE ; 
}

//____________________________________________________________________________
  AliPHOSClusterizerv1::~AliPHOSClusterizerv1()
{
  // dtor

}
//____________________________________________________________________________
const TString AliPHOSClusterizerv1::BranchName() const 
{  
  return GetName();
}
 
//____________________________________________________________________________
Float_t  AliPHOSClusterizerv1::Calibrate(Int_t amp, Int_t absId)
{  
  // Convert digitized amplitude into energy.
  // Calibration parameters are taken from calibration data base for raw data,
  // or from digitizer parameters for simulated data.

  if(fCalibData){
    Int_t relId[4];
    AliPHOSGetter *gime = AliPHOSGetter::Instance();
    gime->PHOSGeometry()->AbsToRelNumbering(absId,relId) ;
    Int_t   module = relId[0];
    Int_t   column = relId[2];
    Int_t   row    = relId[3];
    if(absId <= fEmcCrystals) { //calibrate as EMC 
      fADCchanelEmc   = fCalibData->GetADCchannelEmc (module,column,row);
      fADCpedestalEmc = fCalibData->GetADCpedestalEmc(module,column,row);
      return fADCpedestalEmc + amp*fADCchanelEmc ;        
    }
    else //calibrate as CPV, not implemented yet
      return 0;
  }
  else{ //simulation
    if(absId <= fEmcCrystals) //calibrate as EMC 
      return fADCpedestalEmc + amp*fADCchanelEmc ;        
    else //calibrate as CPV
      return fADCpedestalCpv+ amp*fADCchanelCpv ;       
  }
}

//____________________________________________________________________________
void AliPHOSClusterizerv1::Exec(Option_t *option)
{
  // Steering method to perform clusterization for events
  // in the range from fFirstEvent to fLastEvent.
  // This range is optionally set by SetEventRange().
  // if fLastEvent=-1 (by default), then process events until the end.

  if(strstr(option,"tim"))
    gBenchmark->Start("PHOSClusterizer"); 
  
  if(strstr(option,"print")) {<commit_msg>Swap row and columns in Calibrate()<commit_after>/**************************************************************************
 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
 *                                                                        *
 * Author: The ALICE Off-line Project.                                    *
 * Contributors are mentioned in the code where appropriate.              *
 *                                                                        *
 * Permission to use, copy, modify and distribute this software and its   *
 * documentation strictly for non-commercial purposes is hereby granted   *
 * without fee, provided that the above copyright notice appears in all   *
 * copies and that both the copyright notice and this permission notice   *
 * appear in the supporting documentation. The authors make no claims     *
 * about the suitability of this software for any purpose. It is          *
 * provided "as is" without express or implied warranty.                  *
 **************************************************************************/

/* $Id$ */

/* History of cvs commits:
 *
 * $Log$
 * Revision 1.82  2005/09/02 15:43:13  kharlov
 * Add comments in GetCalibrationParameters and Calibrate
 *
 * Revision 1.81  2005/09/02 14:32:07  kharlov
 * Calibration of raw data
 *
 * Revision 1.80  2005/08/24 15:31:36  kharlov
 * Setting raw digits flag
 *
 * Revision 1.79  2005/07/25 15:53:53  kharlov
 * Read raw data
 *
 * Revision 1.78  2005/05/28 14:19:04  schutz
 * Compilation warnings fixed by T.P.
 *
 */

//*-- Author: <NAME> (SUBATECH)  & <NAME> (SUBATECH & Kurchatov Institute)
//////////////////////////////////////////////////////////////////////////////
//  Clusterization class. Performs clusterization (collects neighbouring active cells) and 
//  unfolds the clusters having several local maxima.  
//  Results are stored in TreeR#, branches PHOSEmcRP (EMC recPoints),
//  PHOSCpvRP (CPV RecPoints) and AliPHOSClusterizer (Clusterizer with all 
//  parameters including input digits branch title, thresholds etc.)
//  This TTask is normally called from Reconstructioner, but can as well be used in 
//  standalone mode.
// Use Case:
//  root [0] AliPHOSClusterizerv1 * cl = new AliPHOSClusterizerv1("galice.root", "recpointsname", "digitsname")  
//  Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated
//               // reads gAlice from header file "galice.root", uses digits stored in the branch names "digitsname" (default = "Default")
//               // and saves recpoints in branch named "recpointsname" (default = "digitsname")                       
//  root [1] cl->ExecuteTask()  
//               //finds RecPoints in all events stored in galice.root
//  root [2] cl->SetDigitsBranch("digits2") 
//               //sets another title for Digitis (input) branch
//  root [3] cl->SetRecPointsBranch("recp2")  
//               //sets another title four output branches
//  root [4] cl->SetEmcLocalMaxCut(0.03)  
//               //set clusterization parameters
//  root [5] cl->ExecuteTask("deb all time")  
//               //once more finds RecPoints options are 
//               // deb - print number of found rec points
//               // deb all - print number of found RecPoints and some their characteristics 
//               // time - print benchmarking results

// --- ROOT system ---

#include "TMath.h" 
#include "TMinuit.h"
#include "TTree.h" 
#include "TBenchmark.h"

// --- Standard library ---

// --- AliRoot header files ---
#include "AliLog.h"
#include "AliPHOSGetter.h"
#include "AliPHOSGeometry.h" 
#include "AliPHOSClusterizerv1.h"
#include "AliPHOSEmcRecPoint.h"
#include "AliPHOSCpvRecPoint.h"
#include "AliPHOSDigit.h"
#include "AliPHOSDigitizer.h"
#include "AliPHOSCalibrationDB.h"

ClassImp(AliPHOSClusterizerv1)
  
//____________________________________________________________________________
  AliPHOSClusterizerv1::AliPHOSClusterizerv1() : AliPHOSClusterizer()
{
  // default ctor (to be used mainly by Streamer)
  
  InitParameters() ; 
  fDefaultInit = kTRUE ; 
}

//____________________________________________________________________________
AliPHOSClusterizerv1::AliPHOSClusterizerv1(const TString alirunFileName, const TString eventFolderName)
:AliPHOSClusterizer(alirunFileName, eventFolderName)
{
  // ctor with the indication of the file where header Tree and digits Tree are stored
  
  InitParameters() ;
  Init() ;
  fDefaultInit = kFALSE ; 
}

//____________________________________________________________________________
  AliPHOSClusterizerv1::~AliPHOSClusterizerv1()
{
  // dtor

}
//____________________________________________________________________________
const TString AliPHOSClusterizerv1::BranchName() const 
{  
  return GetName();
}
 
//____________________________________________________________________________
Float_t  AliPHOSClusterizerv1::Calibrate(Int_t amp, Int_t absId)
{  
  // Convert digitized amplitude into energy.
  // Calibration parameters are taken from calibration data base for raw data,
  // or from digitizer parameters for simulated data.

  if(fCalibData){
    Int_t relId[4];
    AliPHOSGetter *gime = AliPHOSGetter::Instance();
    gime->PHOSGeometry()->AbsToRelNumbering(absId,relId) ;
    Int_t   module = relId[0];
    Int_t   row    = relId[2];
    Int_t   column = relId[3];
    if(absId <= fEmcCrystals) { //calibrate as EMC 
      fADCchanelEmc   = fCalibData->GetADCchannelEmc (module,column,row);
      fADCpedestalEmc = fCalibData->GetADCpedestalEmc(module,column,row);
      return fADCpedestalEmc + amp*fADCchanelEmc ;        
    }
    else //calibrate as CPV, not implemented yet
      return 0;
  }
  else{ //simulation
    if(absId <= fEmcCrystals) //calibrate as EMC 
      return fADCpedestalEmc + amp*fADCchanelEmc ;        
    else //calibrate as CPV
      return fADCpedestalCpv+ amp*fADCchanelCpv ;       
  }
}

//____________________________________________________________________________
void AliPHOSClusterizerv1::Exec(Option_t *option)
{
  // Steering method to perform clusterization for events
  // in the range from fFirstEvent to fLastEvent.
  // This range is optionally set by SetEventRange().
  // if fLastEvent=-1 (by default), then process events until the end.

  if(strstr(option,"tim"))
    gBenchmark->Start("PHOSClusterizer"); 
  
  if(strstr(option,"print")) {
{'fraction_non_alphanumeric': 0.1271867612293144, 'fraction_numerical': 0.01804570527974783, 'mean_word_length': 2.900122925629994, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5911026', 'n_tokens_mistral': 3715, 'n_tokens_neox': 3506, 'n_words': 1038}