ROOT logo
#if !defined (__CINT__) || (defined(__MAKECINT__))
#include <iostream>
#include "TClonesArray.h"
#include "AliParticleYield.h"

#endif
TClonesArray * arr =0;

void InterpolateRatios(Int_t pdg1, Int_t pdg2, TString centr1="V0M0005", TString centr2="V0M0510", TString centrfinal="V0M0010") ;
void Interpolate0010(Int_t pdg) ;
void Interpolate2040(Int_t pdg) ;
void Interpolate6080(Int_t pdg) ;

void ExtrapolateWithConstantRatioToPions(Int_t pdg, TString centrOrigin, TString centrDest);
Int_t collSystem = -1;
Float_t energy = -1;

void InterpolateRatiosAndYields() {
#if !(!defined (__CINT__) || (defined(__MAKECINT__)))
  LoadLibs();
#endif
  collSystem = 2; energy =2760;
  // *************** pi, K, pr *****************
  arr=   AliParticleYield::ReadFromASCIIFile("PbPb_2760_PiKaPr.txt");
  // Interpolate0010(211);
  // Interpolate0010(-211);
  // Interpolate0010(321);
  // Interpolate0010(-321);
  // Interpolate0010(2212);
  // Interpolate0010(-2212);
  // InterpolateRatios(2212,211, "V0M0005", "V0M0510", "V0M0010");  
  // InterpolateRatios(321,211 , "V0M0005", "V0M0510", "V0M0010");  
  // Interpolate6080(211);
  // Interpolate6080(-211);
  // Interpolate6080(2212);
  // Interpolate6080(-2212);
  // Interpolate6080(321);
  // Interpolate6080(-321);
  // InterpolateRatios(2212,211, "V0M6070", "V0M7080", "V0M6080");  
  //  InterpolateRatios(321,211, "V0M6070", "V0M7080", "V0M6080");    

  Interpolate2040(211);
  Interpolate2040(-211);
  Interpolate2040(2212);
  Interpolate2040(-2212);
  Interpolate2040(321);
  Interpolate2040(-321);

  // *************** Lambda and K0 *****************
  // arr=   AliParticleYield::ReadFromASCIIFile("PbPb_2760_LambdaK0.txt");
  // Interpolate0010(3122);
  // Interpolate0010(310);
  // *************** Helium 3 *****************
  // arr = AliParticleYield::ReadFromASCIIFile("PbPb_2760_DeuHelium3.txt");
  // arr->AbsorbObjects(AliParticleYield::ReadFromASCIIFile("./PbPb_2760_AveragedNumbers.txt"));
  // ExtrapolateWithConstantRatioToPions(1000020030, "V0M0020", "V0M0010");
  // *************** Kstar *****************
  // arr = AliParticleYield::ReadFromASCIIFile("PbPb_2760_Kstar892.txt");
  // arr->AbsorbObjects(AliParticleYield::ReadFromASCIIFile("./PbPb_2760_AveragedNumbers.txt"));
  // ExtrapolateWithConstantRatioToPions(313, "V0M0020", "V0M0010");

  // *************** pPb, deuteron *********************
  //  collSystem = 1; energy = 5020;
  // 1. Average pions
  //arr = AliParticleYield::ReadFromASCIIFile("pPb_5020_PiKaPrLamndaK0.txt");
  //  Interpolate0010(211);
  //  Interpolate0010(-211);
  // 2. Extrapolate the deuteron
  // arr = AliParticleYield::ReadFromASCIIFile("pPb_5020_deuteron.txt");
  // arr->AbsorbObjects(AliParticleYield::ReadFromASCIIFile("pPb_5020_PiKaPrLamndaK0.txt"));
  //  ExtrapolateWithConstantRatioToPions(1000010020, "V0A0010", "V0A0005");
  // ExtrapolateWithConstantRatioToPions(-1000010020, "V0A0010", "V0A0005");
  // ExtrapolateWithConstantRatioToPions(1000010020, "V0A6000", "V0A6080");
  // ExtrapolateWithConstantRatioToPions(-1000010020, "V0A6000", "V0A6080");


}

void DUMP(){
  AliParticleYield * p0 = AliParticleYield::FindParticle(arr, 211,  2, 2760., "V0M0005");
  //  p0 = AliParticleYield::Add(p0, AliParticleYield::FindParticle(arr, -211,  2, 2760., "V0M0005"));
  AliParticleYield * p2 = AliParticleYield::FindParticle(arr, 2212, 2, 2760., "V0M0005");
  //  p2 = AliParticleYield::Add(p2,AliParticleYield::FindParticle(arr, -2212, 2, 2760., "V0M0005"));
  AliParticleYield *pratio = AliParticleYield::Divide(p2,p0);
  pratio->Print();
  AliParticleYield::FindRatio(arr, 2212, 211, 2, 2760, "V0M0005")->Print();

}

void Interpolate0010(Int_t pdg) {

  TString centrPrefix = collSystem == 2 ? "V0M" : "V0A";

  AliParticleYield * p0 = AliParticleYield::FindParticle(arr, pdg, collSystem, energy, centrPrefix+"0005");
  AliParticleYield * p1 = AliParticleYield::FindParticle(arr, pdg, collSystem, energy, centrPrefix+"0510");
  p0->Scale(0.5);
  p1->Scale(0.5);
  AliParticleYield * pav = AliParticleYield::Add(p0,p1);
  std::cout << pav->GetYield() << ", " << pav->GetStatError() << ", "<< pav->GetSystError() << std::endl;


} 
void Interpolate6080(Int_t pdg) {

  TString centrPrefix = collSystem == 2 ? "V0M" : "V0A";

  AliParticleYield * p0 = AliParticleYield::FindParticle(arr, pdg, collSystem, energy, centrPrefix+"6070");
  AliParticleYield * p1 = AliParticleYield::FindParticle(arr, pdg, collSystem, energy, centrPrefix+"7080");
  p0->Scale(0.5);
  p1->Scale(0.5);
  AliParticleYield * pav = AliParticleYield::Add(p0,p1);
  std::cout << pav->GetYield() << ", " << pav->GetStatError() << ", "<< pav->GetSystError() << std::endl;


} 

void Interpolate2040(Int_t pdg) {

  TString centrPrefix = collSystem == 2 ? "V0M" : "V0A";

  AliParticleYield * p0 = AliParticleYield::FindParticle(arr, pdg, collSystem, energy, centrPrefix+"2030");
  AliParticleYield * p1 = AliParticleYield::FindParticle(arr, pdg, collSystem, energy, centrPrefix+"3040");
  p0->Scale(0.5);
  p1->Scale(0.5);
  AliParticleYield * pav = AliParticleYield::Add(p0,p1);
  std::cout << pav->GetYield() << ", " << pav->GetStatError() << ", "<< pav->GetSystError() << std::endl;


} 

void InterpolateRatios(Int_t pdg1, Int_t pdg2, TString centr1, TString centr2, TString centrfinal) {

  // Get the ratios from the DB for the correct centralities
  AliParticleYield * ratio[2];
  ratio[0] = AliParticleYield::FindRatio(arr, pdg1, pdg2, 2, 2760., centr1, 1);
  ratio[1] = AliParticleYield::FindRatio(arr, pdg1, pdg2, 2, 2760., centr2, 1);

  AliParticleYield * average = AliParticleYield::Add(ratio[0], ratio[1]);
  average->Scale(0.5);

  AliParticleYield * pi[2];
  pi[0] = AliParticleYield::FindParticle(arr, pdg2, 2, 2760., centr1, 0);
  pi[0] = AliParticleYield::Add(pi[0],AliParticleYield::FindParticle(arr, -pdg2, 2, 2760., centr1, 0));
  pi[1] = AliParticleYield::FindParticle(arr, pdg2, 2, 2760., centr2, 0);
  pi[1] = AliParticleYield::Add(pi[1],AliParticleYield::FindParticle(arr, -pdg2, 2, 2760., centr2, 0));
  

  // Scale to get protons with errors corresponding to the ratio
  ratio[0]->Scale(pi[0]->GetYield()) ;
  ratio[1]->Scale(pi[1]->GetYield()) ;

  ratio[0] = AliParticleYield::Add(ratio[0], ratio[1]);
  pi[0]    = AliParticleYield::Add(pi[0],pi[1]);
  pi[0]->SetNormError(0);
  pi[0]->SetStatError(0);
  pi[0]->SetSystError(0);
  
  ratio[0]->Scale(1./pi[0]->GetYield());
  ratio[0]->SetCentr(centrfinal);
  cout << "*** "<< ratio[0]->GetPartName() << " " <<  centrfinal << " ***"<< std::endl;
  std::cout << "RATIO OF AVERAGE: " ;
  ratio[0]->Print("justvalue");
  //  average->Dump();
  std::cout << "AVERAGE OF RATIO: " ;
  average->Print("justvalue");

    
}

void ExtrapolateWithConstantRatioToPions(Int_t pdg, TString centrOrigin, TString centrDest) {

  AliParticleYield * part       =  AliParticleYield::FindParticle(arr, pdg,collSystem, energy, centrOrigin);
  AliParticleYield * pionOrigin =  AliParticleYield::FindParticle(arr, 211,collSystem, energy, centrOrigin);
  AliParticleYield * pionDest   =  AliParticleYield::FindParticle(arr, 211,collSystem, energy, centrDest);
  if(!part || !pionOrigin | !pionDest) {
    return;
  }
  // The pion yield is takes
  part->Scale (1./pionOrigin->GetYield());
  part->Scale (pionDest->GetYield());
  part->SetCentr(centrDest);
  part->SetMeasurementType(part->GetMeasurementType() | AliParticleYield::kTypeExtrPionRatio);
  part->Print();
  //  std::cout << "1" << std::endl;
  TClonesArray * arrOut = new TClonesArray("AliParticleYield");
  //  std::cout << "2" << std::endl;
  new((*arrOut)[0]) AliParticleYield(*part) ;

  //  std::cout << "3" << std::endl;
  //  std::cout << "4" << std::endl;
  AliParticleYield::SaveAsASCIIFile(arrOut, "temp.txt");
}
 InterpolateRatiosAndYields.C:1
 InterpolateRatiosAndYields.C:2
 InterpolateRatiosAndYields.C:3
 InterpolateRatiosAndYields.C:4
 InterpolateRatiosAndYields.C:5
 InterpolateRatiosAndYields.C:6
 InterpolateRatiosAndYields.C:7
 InterpolateRatiosAndYields.C:8
 InterpolateRatiosAndYields.C:9
 InterpolateRatiosAndYields.C:10
 InterpolateRatiosAndYields.C:11
 InterpolateRatiosAndYields.C:12
 InterpolateRatiosAndYields.C:13
 InterpolateRatiosAndYields.C:14
 InterpolateRatiosAndYields.C:15
 InterpolateRatiosAndYields.C:16
 InterpolateRatiosAndYields.C:17
 InterpolateRatiosAndYields.C:18
 InterpolateRatiosAndYields.C:19
 InterpolateRatiosAndYields.C:20
 InterpolateRatiosAndYields.C:21
 InterpolateRatiosAndYields.C:22
 InterpolateRatiosAndYields.C:23
 InterpolateRatiosAndYields.C:24
 InterpolateRatiosAndYields.C:25
 InterpolateRatiosAndYields.C:26
 InterpolateRatiosAndYields.C:27
 InterpolateRatiosAndYields.C:28
 InterpolateRatiosAndYields.C:29
 InterpolateRatiosAndYields.C:30
 InterpolateRatiosAndYields.C:31
 InterpolateRatiosAndYields.C:32
 InterpolateRatiosAndYields.C:33
 InterpolateRatiosAndYields.C:34
 InterpolateRatiosAndYields.C:35
 InterpolateRatiosAndYields.C:36
 InterpolateRatiosAndYields.C:37
 InterpolateRatiosAndYields.C:38
 InterpolateRatiosAndYields.C:39
 InterpolateRatiosAndYields.C:40
 InterpolateRatiosAndYields.C:41
 InterpolateRatiosAndYields.C:42
 InterpolateRatiosAndYields.C:43
 InterpolateRatiosAndYields.C:44
 InterpolateRatiosAndYields.C:45
 InterpolateRatiosAndYields.C:46
 InterpolateRatiosAndYields.C:47
 InterpolateRatiosAndYields.C:48
 InterpolateRatiosAndYields.C:49
 InterpolateRatiosAndYields.C:50
 InterpolateRatiosAndYields.C:51
 InterpolateRatiosAndYields.C:52
 InterpolateRatiosAndYields.C:53
 InterpolateRatiosAndYields.C:54
 InterpolateRatiosAndYields.C:55
 InterpolateRatiosAndYields.C:56
 InterpolateRatiosAndYields.C:57
 InterpolateRatiosAndYields.C:58
 InterpolateRatiosAndYields.C:59
 InterpolateRatiosAndYields.C:60
 InterpolateRatiosAndYields.C:61
 InterpolateRatiosAndYields.C:62
 InterpolateRatiosAndYields.C:63
 InterpolateRatiosAndYields.C:64
 InterpolateRatiosAndYields.C:65
 InterpolateRatiosAndYields.C:66
 InterpolateRatiosAndYields.C:67
 InterpolateRatiosAndYields.C:68
 InterpolateRatiosAndYields.C:69
 InterpolateRatiosAndYields.C:70
 InterpolateRatiosAndYields.C:71
 InterpolateRatiosAndYields.C:72
 InterpolateRatiosAndYields.C:73
 InterpolateRatiosAndYields.C:74
 InterpolateRatiosAndYields.C:75
 InterpolateRatiosAndYields.C:76
 InterpolateRatiosAndYields.C:77
 InterpolateRatiosAndYields.C:78
 InterpolateRatiosAndYields.C:79
 InterpolateRatiosAndYields.C:80
 InterpolateRatiosAndYields.C:81
 InterpolateRatiosAndYields.C:82
 InterpolateRatiosAndYields.C:83
 InterpolateRatiosAndYields.C:84
 InterpolateRatiosAndYields.C:85
 InterpolateRatiosAndYields.C:86
 InterpolateRatiosAndYields.C:87
 InterpolateRatiosAndYields.C:88
 InterpolateRatiosAndYields.C:89
 InterpolateRatiosAndYields.C:90
 InterpolateRatiosAndYields.C:91
 InterpolateRatiosAndYields.C:92
 InterpolateRatiosAndYields.C:93
 InterpolateRatiosAndYields.C:94
 InterpolateRatiosAndYields.C:95
 InterpolateRatiosAndYields.C:96
 InterpolateRatiosAndYields.C:97
 InterpolateRatiosAndYields.C:98
 InterpolateRatiosAndYields.C:99
 InterpolateRatiosAndYields.C:100
 InterpolateRatiosAndYields.C:101
 InterpolateRatiosAndYields.C:102
 InterpolateRatiosAndYields.C:103
 InterpolateRatiosAndYields.C:104
 InterpolateRatiosAndYields.C:105
 InterpolateRatiosAndYields.C:106
 InterpolateRatiosAndYields.C:107
 InterpolateRatiosAndYields.C:108
 InterpolateRatiosAndYields.C:109
 InterpolateRatiosAndYields.C:110
 InterpolateRatiosAndYields.C:111
 InterpolateRatiosAndYields.C:112
 InterpolateRatiosAndYields.C:113
 InterpolateRatiosAndYields.C:114
 InterpolateRatiosAndYields.C:115
 InterpolateRatiosAndYields.C:116
 InterpolateRatiosAndYields.C:117
 InterpolateRatiosAndYields.C:118
 InterpolateRatiosAndYields.C:119
 InterpolateRatiosAndYields.C:120
 InterpolateRatiosAndYields.C:121
 InterpolateRatiosAndYields.C:122
 InterpolateRatiosAndYields.C:123
 InterpolateRatiosAndYields.C:124
 InterpolateRatiosAndYields.C:125
 InterpolateRatiosAndYields.C:126
 InterpolateRatiosAndYields.C:127
 InterpolateRatiosAndYields.C:128
 InterpolateRatiosAndYields.C:129
 InterpolateRatiosAndYields.C:130
 InterpolateRatiosAndYields.C:131
 InterpolateRatiosAndYields.C:132
 InterpolateRatiosAndYields.C:133
 InterpolateRatiosAndYields.C:134
 InterpolateRatiosAndYields.C:135
 InterpolateRatiosAndYields.C:136
 InterpolateRatiosAndYields.C:137
 InterpolateRatiosAndYields.C:138
 InterpolateRatiosAndYields.C:139
 InterpolateRatiosAndYields.C:140
 InterpolateRatiosAndYields.C:141
 InterpolateRatiosAndYields.C:142
 InterpolateRatiosAndYields.C:143
 InterpolateRatiosAndYields.C:144
 InterpolateRatiosAndYields.C:145
 InterpolateRatiosAndYields.C:146
 InterpolateRatiosAndYields.C:147
 InterpolateRatiosAndYields.C:148
 InterpolateRatiosAndYields.C:149
 InterpolateRatiosAndYields.C:150
 InterpolateRatiosAndYields.C:151
 InterpolateRatiosAndYields.C:152
 InterpolateRatiosAndYields.C:153
 InterpolateRatiosAndYields.C:154
 InterpolateRatiosAndYields.C:155
 InterpolateRatiosAndYields.C:156
 InterpolateRatiosAndYields.C:157
 InterpolateRatiosAndYields.C:158
 InterpolateRatiosAndYields.C:159
 InterpolateRatiosAndYields.C:160
 InterpolateRatiosAndYields.C:161
 InterpolateRatiosAndYields.C:162
 InterpolateRatiosAndYields.C:163
 InterpolateRatiosAndYields.C:164
 InterpolateRatiosAndYields.C:165
 InterpolateRatiosAndYields.C:166
 InterpolateRatiosAndYields.C:167
 InterpolateRatiosAndYields.C:168
 InterpolateRatiosAndYields.C:169
 InterpolateRatiosAndYields.C:170
 InterpolateRatiosAndYields.C:171
 InterpolateRatiosAndYields.C:172
 InterpolateRatiosAndYields.C:173
 InterpolateRatiosAndYields.C:174
 InterpolateRatiosAndYields.C:175
 InterpolateRatiosAndYields.C:176
 InterpolateRatiosAndYields.C:177
 InterpolateRatiosAndYields.C:178
 InterpolateRatiosAndYields.C:179
 InterpolateRatiosAndYields.C:180
 InterpolateRatiosAndYields.C:181
 InterpolateRatiosAndYields.C:182
 InterpolateRatiosAndYields.C:183
 InterpolateRatiosAndYields.C:184
 InterpolateRatiosAndYields.C:185
 InterpolateRatiosAndYields.C:186
 InterpolateRatiosAndYields.C:187
 InterpolateRatiosAndYields.C:188
 InterpolateRatiosAndYields.C:189
 InterpolateRatiosAndYields.C:190
 InterpolateRatiosAndYields.C:191
 InterpolateRatiosAndYields.C:192
 InterpolateRatiosAndYields.C:193