<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.                  *
 **************************************************************************/

/*
Comments to be written here:

1. What do we calibrate.

  Time dependence of gain and drift velocity in order to account for changes in: temperature, pressure, gas composition.

  AliTPCcalibTime *calibTime = new AliTPCcalibTime("cosmicTime","cosmicTime",0, 1213.9e+06, 1213.96e+06, 0.04e+04, 0.04e+04);

*/

#include "Riostream.h"
#include "TDatabasePDG.h"
#include "TGraphErrors.h"
#include "TH1F.h"
#include "THnSparse.h"
#include "TList.h"
#include "TMath.h"
#include "TTimeStamp.h"
#include "TTree.h"
#include "TVectorD.h"
//#include "TChain.h"
//#include "TFile.h"

#include "AliDCSSensor.h"
#include "AliDCSSensorArray.h"
#include "AliESDEvent.h"
#include "AliESDInputHandler.h"
#include "AliESDVertex.h"
#include "AliESDfriend.h"
#include "AliLog.h"
#include "AliRelAlignerKalman.h"
#include "AliTPCCalROC.h"
#include "AliTPCParam.h"
#include "AliTPCreco.h"
#include "AliTPCTracklet.h"
#include "AliTPCcalibDB.h"
#include "AliTPCcalibLaser.h"
#include "AliTPCcalibTime.h"
#include "AliTPCclusterMI.h"
#include "AliTPCseed.h"
#include "AliTrackPointArray.h"
#include "AliTracker.h"
#include "AliKFVertex.h"
#include <AliLog.h>

ClassImp(AliTPCcalibTime)

Double_t AliTPCcalibTime::fgResHistoMergeCut = 20000000.;

AliTPCcalibTime::AliTPCcalibTime() 
  :AliTPCcalibBase(),  
   fMemoryMode(1), // 0 -do not fill THnSparse with residuals  1- fill only important QA THn 2 - Fill all THnsparse for calibration
   fLaser(0),       // pointer to laser calibration
   fDz(0),          // current delta z
   fCutMaxD(3),        // maximal distance in rfi ditection
   fCutMaxDz(25),      // maximal distance in rfi ditection
   fCutTheta(0.03),    // maximal distan theta
   fCutMinDir(-0.99),  // direction vector products
   fCutTracks(2500),
   fArrayLaserA(0),      //laser  fit parameters C
   fArrayLaserC(0),      //laser  fit parameters A
   fArrayDz(0),          //NEW! Tmap of V drifts for different triggers
   fAlignITSTPC(0),      //alignemnt array ITS TPC match
   fAlignTRDTPC(0),      //alignemnt array TRD TPC match 
   fAlignTOFTPC(0),      //alignemnt array TOF TPC match
   fTimeKalmanBin(60*15), //time bin width for kalman - 15 minutes default
   fTimeBins(0),
   fTimeStart(0),
   fTimeEnd(0),
   fPtBins(0),
   fPtStart(0),
   fPtEnd(0),
   fVdriftBins(0),
   fVdriftStart(0),
   fVdriftEnd(0),
   fRunBins(0),
   fRunStart(0),
   fRunEnd(0)
{  
  //
  // default constructor
  //
  AliDebug(5,"Default Constructor");  
  for (Int_t i=0;i<3;i++) {
    fHistVdriftLaserA[i]=0;
    fHistVdriftLaserC[i]=0;
  }
  for (Int_t i=0;i<10;i++) {
    fCosmiMatchingHisto[i]=0;
  }
  //
  for (Int_t i=0;i<5;i++) {
    fResHistoTPCCE[i]=0;
    fResHistoTPCITS[i]=0;
    fResHistoTPCTRD[i]=0;
    fResHistoTPCTOF[i]=0;
    fResHistoTPCvertex[i]=0;
    fTPCVertex[i]=0;
  }
  for (Int_t i=0;i<12;i++) {
    fTPCVertex[i]=0;
  }
  for (Int_t i=0;i<5;i++) {
    fTPCVertexCorrelation[i]=0;
  }
  static Int_t counter=0;
  if (1) {
    TTimeStamp s;
    Int_t time=s;
    AliDebug(5,Form("Counter Constructor\t%d\t%d",counter,time));
    counter++;
  }

}

AliTPCcalibTime::AliTPCcalibTime(const Text_t *name, const Text_t *title, UInt_t StartTime, UInt_t EndTime, Int_t deltaIntegrationTimeVdrift, Int_t memoryMode)
  :AliTPCcalibBase(),
   fMemoryMode(memoryMode), // 0 -do not fill THnSparse with residuals  1- fill only important QA THn 2 - Fill all THnsparse for calibration
   fLaser(0),            // pointer to laser calibration
   fDz(0),               // current delta z
   fCutMaxD(5*0.5356),   // maximal distance in rfi ditection
   fCutMaxDz(40),   // maximal distance in rfi ditection
   fCutTheta(5*0.004644),// maximal distan theta
   fCutMinDir(-0.99),    // direction vector products
   fCutTracks(2500),
   fArrayLaserA(new TObjArray(1000)),      //laser  fit parameters C
   fArrayLaserC(new TObjArray(1000)),      //laser  fit parameters A
   fArrayDz(0),            //Tmap of V drifts for different triggers
   fAlignITSTPC(0),      //alignemnt array ITS TPC match
   fAlignTRDTPC(0),      //alignemnt array TRD TPC match 
   fAlignTOFTPC(0),      //alignemnt array TOF TPC match
   fTimeKalmanBin(60*15), //time bin width for kalman - 15 minutes default
   fTimeBins(0),
   fTimeStart(0),
   fTimeEnd(0),
   fPtBins(0),
   fPtStart(0),
   fPtEnd(0),
   fVdriftBins(0),
   fVdriftStart(0),
   fVdriftEnd(0),
   fRunBins(0),
   fRunStart(0),
   fRunEnd(0)
{
  //
  // Non deafaul constructor - to be used in the Calibration setups 
  //

  SetName(name);
  SetTitle(title);
  for (Int_t i=0;i<3;i++) {
    fHistVdriftLaserA[i]=0;
    fHistVdriftLaserC[i]=0;
  }

  for (Int_t i=0;i<5;i++) {
    fResHistoTPCCE[i]=0;
    fResHistoTPCITS[i]=0;
    fResHistoTPCTRD[i]=0;
    fResHistoTPCTOF[i]=0;
    fResHistoTPCvertex[i]=0;
  }


  AliDebug(5,"Non Default Constructor");
  fTimeBins   =(EndTime-StartTime)/deltaIntegrationTimeVdrift;
  fTimeStart  =StartTime; //(((TObjString*)(mapGRP->GetValue("fAliceStartTime")))->GetString()).Atoi();
  fTimeEnd    =EndTime;   //(((TObjString*)(mapGRP->GetValue("fAliceStopTime")))->GetString()).Atoi();
  fPtBins     = 400;
  fPtStart    = -0.04;
  fPtEnd      =  0.04;
  fVdriftBins = 500;
  fVdriftStart= -0.1;
  fVdriftEnd  =  0.1;
  fRunBins    = 1000001;
  fRunStart   = -1.5;
  fRunEnd     = 999999.5;

  Int_t    binsVdriftLaser[4] = {fTimeBins , fPtBins , fVdriftBins*20, fRunBins };
  Double_t xminVdriftLaser[4] = {fTimeStart, fPtStart, fVdriftStart  , fRunStart};
  Double_t xmaxVdriftLaser[4] = {fTimeEnd  , fPtEnd  , fVdriftEnd    , fRunEnd  };
  TString axisTitle[4]={
    "T",
    "#delta_{P/T}",
    "value",
    "run"
  };
  TString histoName[3]={
    "Loffset",
    "Lcorr",
    "Lgy"
  };

  
  for (Int_t i=0;i<3;i++) {
    fHistVdriftLaserA[i] = new THnSparseF("HistVdriftLaser","HistVdriftLaser;time;p/T ratio;Vdrift;run",4,binsVdriftLaser,xminVdriftLaser,xmaxVdriftLaser);
    fHistVdriftLaserC[i] = new THnSparseF("HistVdriftLaser","HistVdriftLaser;time;p/T ratio;Vdrift;run",4,binsVdriftLaser,xminVdriftLaser,xmaxVdriftLaser);
    fHistVdriftLaserA[i]->SetName(histoName[i]);
    fHistVdriftLaserC[i]->SetName(histoName[i]);
    for (Int_t iaxis=0; iaxis<4;iaxis++){
      fHistVdriftLaserA[i]->GetAxis(iaxis)->SetName(axisTitle[iaxis]);
      fHistVdriftLaserC[i]->GetAxis(iaxis)->SetName(axisTitle[iaxis]);
    }
  }
  fBinsVdrift[0] = fTimeBins;
  fBinsVdrift[1] = fPtBins;
  fBinsVdrift[2] = fVdriftBins;
  fBinsVdrift[3] = fRunBins;
  fXminVdrift[0] = fTimeStart;
  fXminVdrift[1] = fPtStart;
  fXminVdrift[2] = fVdriftStart;
  fXminVdrift[3] = fRunStart;
  fXmaxVdrift[0] = fTimeEnd;
  fXmaxVdrift[1] = fPtEnd;
  fXmaxVdrift[2] = fVdriftEnd;
  fXmaxVdrift[3] = fRunEnd;

  fArrayDz=new TObjArray();
  fAlignITSTPC = new TObjArray;      //alignemnt array ITS TPC match
  fAlignTRDTPC = new TObjArray;      //alignemnt array ITS TPC match
  fAlignTOFTPC = new TObjArray;      //alignemnt array ITS TPC match
  fAlignITSTPC->SetOwner(kTRUE);
  fAlignTRDTPC->SetOwner(kTRUE);
  fAlignTOFTPC->SetOwner(kTRUE);
  

  fCosmiMatchingHisto[0]=new TH1F("Cosmics matching","p0-all"   ,100,-10*0.5356  ,10*0.5356  );
  fCosmiMatchingHisto[1]=new TH1F("Cosmics matching","p1-all"   ,100,-10*4.541   ,10*4.541   );
  fCosmiMatchingHisto[2]=new TH1F("Cosmics matching","p2-all"   ,100,-10*0.01134 ,10*0.01134 );
  fCosmiMatchingHisto[3]=new TH1F("Cosmics matching","p3-all"   ,100,-10*0.004644,10*0.004644);
  fCosmiMatchingHisto[4]=new TH1F("Cosmics matching","p4-all"   ,100,-10*0.03773 ,10*0.03773 );
  fCosmiMatchingHisto[5]=new TH1F("Cosmics matching","p0-isPair",100,-10*0.5356  ,10*0.5356  );
  fCosmiMatchingHisto[6]=new TH1F("Cosmics matching","p1-isPair",100,-10*4.541   ,10*4.541   );
  fCosmiMatchingHisto[7]=new TH1F("Cosmics matching","p2-isPair",100,-10*0.01134 ,10*0.01134 );
  fCosmiMatchingHisto[8]=new TH1F("Cosmics matching","p3-isPair",100,-10*0.004644,10*0.004644);
  fCosmiMatchingHisto[9]=new TH1F("Cosmics matching","p4-isPair",100,-10*0.03773 ,10*0.03773 );
  for (Int_t i=0;i<12;i++) {
    fTPCVertex[i]=0;
  }
  for (Int_t i=0;i<5;i++) {
    fTPCVertexCorrelation[i]=0;
  }<commit_msg>Different histograms should have different names (i think)<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.                  *
 **************************************************************************/

/*
Comments to be written here:

1. What do we calibrate.

  Time dependence of gain and drift velocity in order to account for changes in: temperature, pressure, gas composition.

  AliTPCcalibTime *calibTime = new AliTPCcalibTime("cosmicTime","cosmicTime",0, 1213.9e+06, 1213.96e+06, 0.04e+04, 0.04e+04);

*/

#include "Riostream.h"
#include "TDatabasePDG.h"
#include "TGraphErrors.h"
#include "TH1F.h"
#include "THnSparse.h"
#include "TList.h"
#include "TMath.h"
#include "TTimeStamp.h"
#include "TTree.h"
#include "TVectorD.h"
//#include "TChain.h"
//#include "TFile.h"

#include "AliDCSSensor.h"
#include "AliDCSSensorArray.h"
#include "AliESDEvent.h"
#include "AliESDInputHandler.h"
#include "AliESDVertex.h"
#include "AliESDfriend.h"
#include "AliLog.h"
#include "AliRelAlignerKalman.h"
#include "AliTPCCalROC.h"
#include "AliTPCParam.h"
#include "AliTPCreco.h"
#include "AliTPCTracklet.h"
#include "AliTPCcalibDB.h"
#include "AliTPCcalibLaser.h"
#include "AliTPCcalibTime.h"
#include "AliTPCclusterMI.h"
#include "AliTPCseed.h"
#include "AliTrackPointArray.h"
#include "AliTracker.h"
#include "AliKFVertex.h"
#include <AliLog.h>

ClassImp(AliTPCcalibTime)

Double_t AliTPCcalibTime::fgResHistoMergeCut = 20000000.;

AliTPCcalibTime::AliTPCcalibTime() 
  :AliTPCcalibBase(),  
   fMemoryMode(1), // 0 -do not fill THnSparse with residuals  1- fill only important QA THn 2 - Fill all THnsparse for calibration
   fLaser(0),       // pointer to laser calibration
   fDz(0),          // current delta z
   fCutMaxD(3),        // maximal distance in rfi ditection
   fCutMaxDz(25),      // maximal distance in rfi ditection
   fCutTheta(0.03),    // maximal distan theta
   fCutMinDir(-0.99),  // direction vector products
   fCutTracks(2500),
   fArrayLaserA(0),      //laser  fit parameters C
   fArrayLaserC(0),      //laser  fit parameters A
   fArrayDz(0),          //NEW! Tmap of V drifts for different triggers
   fAlignITSTPC(0),      //alignemnt array ITS TPC match
   fAlignTRDTPC(0),      //alignemnt array TRD TPC match 
   fAlignTOFTPC(0),      //alignemnt array TOF TPC match
   fTimeKalmanBin(60*15), //time bin width for kalman - 15 minutes default
   fTimeBins(0),
   fTimeStart(0),
   fTimeEnd(0),
   fPtBins(0),
   fPtStart(0),
   fPtEnd(0),
   fVdriftBins(0),
   fVdriftStart(0),
   fVdriftEnd(0),
   fRunBins(0),
   fRunStart(0),
   fRunEnd(0)
{  
  //
  // default constructor
  //
  AliDebug(5,"Default Constructor");  
  for (Int_t i=0;i<3;i++) {
    fHistVdriftLaserA[i]=0;
    fHistVdriftLaserC[i]=0;
  }
  for (Int_t i=0;i<10;i++) {
    fCosmiMatchingHisto[i]=0;
  }
  //
  for (Int_t i=0;i<5;i++) {
    fResHistoTPCCE[i]=0;
    fResHistoTPCITS[i]=0;
    fResHistoTPCTRD[i]=0;
    fResHistoTPCTOF[i]=0;
    fResHistoTPCvertex[i]=0;
    fTPCVertex[i]=0;
  }
  for (Int_t i=0;i<12;i++) {
    fTPCVertex[i]=0;
  }
  for (Int_t i=0;i<5;i++) {
    fTPCVertexCorrelation[i]=0;
  }
  static Int_t counter=0;
  if (1) {
    TTimeStamp s;
    Int_t time=s;
    AliDebug(5,Form("Counter Constructor\t%d\t%d",counter,time));
    counter++;
  }

}

AliTPCcalibTime::AliTPCcalibTime(const Text_t *name, const Text_t *title, UInt_t StartTime, UInt_t EndTime, Int_t deltaIntegrationTimeVdrift, Int_t memoryMode)
  :AliTPCcalibBase(),
   fMemoryMode(memoryMode), // 0 -do not fill THnSparse with residuals  1- fill only important QA THn 2 - Fill all THnsparse for calibration
   fLaser(0),            // pointer to laser calibration
   fDz(0),               // current delta z
   fCutMaxD(5*0.5356),   // maximal distance in rfi ditection
   fCutMaxDz(40),   // maximal distance in rfi ditection
   fCutTheta(5*0.004644),// maximal distan theta
   fCutMinDir(-0.99),    // direction vector products
   fCutTracks(2500),
   fArrayLaserA(new TObjArray(1000)),      //laser  fit parameters C
   fArrayLaserC(new TObjArray(1000)),      //laser  fit parameters A
   fArrayDz(0),            //Tmap of V drifts for different triggers
   fAlignITSTPC(0),      //alignemnt array ITS TPC match
   fAlignTRDTPC(0),      //alignemnt array TRD TPC match 
   fAlignTOFTPC(0),      //alignemnt array TOF TPC match
   fTimeKalmanBin(60*15), //time bin width for kalman - 15 minutes default
   fTimeBins(0),
   fTimeStart(0),
   fTimeEnd(0),
   fPtBins(0),
   fPtStart(0),
   fPtEnd(0),
   fVdriftBins(0),
   fVdriftStart(0),
   fVdriftEnd(0),
   fRunBins(0),
   fRunStart(0),
   fRunEnd(0)
{
  //
  // Non deafaul constructor - to be used in the Calibration setups 
  //

  SetName(name);
  SetTitle(title);
  for (Int_t i=0;i<3;i++) {
    fHistVdriftLaserA[i]=0;
    fHistVdriftLaserC[i]=0;
  }

  for (Int_t i=0;i<5;i++) {
    fResHistoTPCCE[i]=0;
    fResHistoTPCITS[i]=0;
    fResHistoTPCTRD[i]=0;
    fResHistoTPCTOF[i]=0;
    fResHistoTPCvertex[i]=0;
  }


  AliDebug(5,"Non Default Constructor");
  fTimeBins   =(EndTime-StartTime)/deltaIntegrationTimeVdrift;
  fTimeStart  =StartTime; //(((TObjString*)(mapGRP->GetValue("fAliceStartTime")))->GetString()).Atoi();
  fTimeEnd    =EndTime;   //(((TObjString*)(mapGRP->GetValue("fAliceStopTime")))->GetString()).Atoi();
  fPtBins     = 400;
  fPtStart    = -0.04;
  fPtEnd      =  0.04;
  fVdriftBins = 500;
  fVdriftStart= -0.1;
  fVdriftEnd  =  0.1;
  fRunBins    = 1000001;
  fRunStart   = -1.5;
  fRunEnd     = 999999.5;

  Int_t    binsVdriftLaser[4] = {fTimeBins , fPtBins , fVdriftBins*20, fRunBins };
  Double_t xminVdriftLaser[4] = {fTimeStart, fPtStart, fVdriftStart  , fRunStart};
  Double_t xmaxVdriftLaser[4] = {fTimeEnd  , fPtEnd  , fVdriftEnd    , fRunEnd  };
  TString axisTitle[4]={
    "T",
    "#delta_{P/T}",
    "value",
    "run"
  };
  TString histoName[3]={
    "Loffset",
    "Lcorr",
    "Lgy"
  };

  
  for (Int_t i=0;i<3;i++) {
    fHistVdriftLaserA[i] = new THnSparseF("HistVdriftLaser","HistVdriftLaser;time;p/T ratio;Vdrift;run",4,binsVdriftLaser,xminVdriftLaser,xmaxVdriftLaser);
    fHistVdriftLaserC[i] = new THnSparseF("HistVdriftLaser","HistVdriftLaser;time;p/T ratio;Vdrift;run",4,binsVdriftLaser,xminVdriftLaser,xmaxVdriftLaser);
    fHistVdriftLaserA[i]->SetName(histoName[i]);
    fHistVdriftLaserC[i]->SetName(histoName[i]);
    for (Int_t iaxis=0; iaxis<4;iaxis++){
      fHistVdriftLaserA[i]->GetAxis(iaxis)->SetName(axisTitle[iaxis]);
      fHistVdriftLaserC[i]->GetAxis(iaxis)->SetName(axisTitle[iaxis]);
    }
  }
  fBinsVdrift[0] = fTimeBins;
  fBinsVdrift[1] = fPtBins;
  fBinsVdrift[2] = fVdriftBins;
  fBinsVdrift[3] = fRunBins;
  fXminVdrift[0] = fTimeStart;
  fXminVdrift[1] = fPtStart;
  fXminVdrift[2] = fVdriftStart;
  fXminVdrift[3] = fRunStart;
  fXmaxVdrift[0] = fTimeEnd;
  fXmaxVdrift[1] = fPtEnd;
  fXmaxVdrift[2] = fVdriftEnd;
  fXmaxVdrift[3] = fRunEnd;

  fArrayDz=new TObjArray();
  fAlignITSTPC = new TObjArray;      //alignemnt array ITS TPC match
  fAlignTRDTPC = new TObjArray;      //alignemnt array ITS TPC match
  fAlignTOFTPC = new TObjArray;      //alignemnt array ITS TPC match
  fAlignITSTPC->SetOwner(kTRUE);
  fAlignTRDTPC->SetOwner(kTRUE);
  fAlignTOFTPC->SetOwner(kTRUE);
  

  fCosmiMatchingHisto[0]=new TH1F("Cosmics matching p0a","p0-all"   ,100,-10*0.5356  ,10*0.5356  );
  fCosmiMatchingHisto[1]=new TH1F("Cosmics matching p1a","p1-all"   ,100,-10*4.541   ,10*4.541   );
  fCosmiMatchingHisto[2]=new TH1F("Cosmics matching p2a","p2-all"   ,100,-10*0.01134 ,10*0.01134 );
  fCosmiMatchingHisto[3]=new TH1F("Cosmics matching p3a","p3-all"   ,100,-10*0.004644,10*0.004644);
  fCosmiMatchingHisto[4]=new TH1F("Cosmics matching p4a","p4-all"   ,100,-10*0.03773 ,10*0.03773 );
  fCosmiMatchingHisto[5]=new TH1F("Cosmics matching p0p","p0-isPair",100,-10*0.5356  ,10*0.5356  );
  fCosmiMatchingHisto[6]=new TH1F("Cosmics matching p1p","p1-isPair",100,-10*4.541   ,10*4.541   );
  fCosmiMatchingHisto[7]=new TH1F("Cosmics matching p2p","p2-isPair",100,-10*0.01134 ,10*0.01134 );
  fCosmiMatchingHisto[8]=new TH1F("Cosmics matching p3p","p3-isPair",100,-10*0.004644,10*0.004644);
  fCosmiMatchingHisto[9]=new TH1F("Cosmics matching p4p","p4-isPair",100,-10*0.03773 ,10*0.03773 );
  for (Int_t i=0;i<12;i++) {
    fTPCVertex[i]=0;
  }
  for (Int_t i=0;i<5;i++) {
    fTPCVertexCorrelation[i]=0;
  }
{'fraction_non_alphanumeric': 0.15203600281949792, 'fraction_numerical': 0.05042563574255815, 'mean_word_length': 3.5450961064563824, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '7226284', 'n_tokens_mistral': 7887, 'n_tokens_neox': 7395, 'n_words': 1379}