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

// LHC10x multiplicity config for protons and deuterons
// author: Eulogio Serradilla <eulogio.serradilla@cern.ch>

#if !defined(__CINT__) || defined(__MAKECINT__)
#include <TSystem.h>
#include <TROOT.h>
#include <TString.h>
#include <TFileMerger.h>
#include "AliLnDriver.h"
#endif

#include "Config.h"

Int_t LHC10xMult(  const TString& species   = "Deuteron"
                 , const TString& inputDir  = "~/alice/input"
                 , const TString& outputDir = "~/alice/output"
                 , const TString& period    = "lhc10d"
                 , const TString& otag      = "lhc10d"
                 , const TString& trkselTag = "-tpc3-nsd-moc"
                 , Double_t       ymax      = 0.5
                 , Int_t          option    = 2)
{
//
// lhc10x multiplicity config
// call Config_XXX for each multiplicity class
//
// if option = 0 then use Config_XXX_TPC
// if option = 1 then use Config_XXX_TOF
// if option = 2 then use Config_TPCTOF
//
	using namespace B2mult;
	using namespace std;
	
	const Bool_t  kINEL[kNmult] = { 0 };
	
	Double_t ptmin   = (species=="Proton") ? 0.4 : 0.7;
	Double_t ptjoint = (species=="Proton") ? 1.0 : 1.0;
	Double_t ptmax   = (species=="Proton") ? 2.0 : 2.5;
	Double_t ptpid   = (species=="Proton") ? 0.4 : 1.3;
	
	if( (option<0) || (option>2) || ((species != "Proton") && (species != "Deuteron")))
	{
		cerr << "unknown species/option: " << species << "/" << option << endl;
		cerr << "species: Proton or Deuteron, options: 0 (TPC), 1 (TOF), 2 (TPCTOF)" << endl;
		exit(1);
	}
	
	TFileMerger m1,m2;
	
	TString ratio[kNmult];
	TString spectra[kNmult];
	
	for(Int_t i=0; i<kNmult; ++i)
	{
		// limit the ptmax value for deuterons
		if(species == "Deuteron") ptmax = kDtrPtMax[i];
		
		cout << endl;
		cout << "Multiplicity class : " << kMultTag[i] << endl;
		cout << "Period             : " << period << endl;
		
		TString outputTag = otag + kMultTag[i];
		
		TString arg =          inputDir    + "\","
			      + "\"" + outputDir   + "\","
			      + "\"" + period      + "\","
			      + "\"" + outputTag   + "\","
		              + "\"" + trkselTag   + "\","
			      + "\"" + kMultTag[i] + "\"," // data
			      + "\"" + "";          // same simulations for all mult
			
		switch(option)
		{
			case 0:
				cout << "Config_" << species << "_TPC_LHC10x.C" << endl << endl;
				gROOT->ProcessLine(Form(".x Config_%s_TPC_LHC10x.C+g(\"%s\", %f, %d, 0, %f, %f)", species.Data(), arg.Data(), ymax, kINEL[i], ptmin, ptmax));
				break;
			case 1:
				cout << "Config_" << species << "_LHC10x.C" << endl << endl;
				gROOT->ProcessLine(Form(".x Config_%s_TOF_LHC10x.C+g(\"%s\", %f, %d, 0, %f, %f, %f)", species.Data(), arg.Data(), ymax, kINEL[i], ptmin, ptmax, ptpid));
				break;
			case 2:
				cout << "Config_TPCTOF_LHC10x.C" << endl << endl;
				gROOT->ProcessLine(Form(".x Config_TPCTOF_LHC10x.C+g(\"%s\", %f, %d, 0, \"%s\", %f, %f, %f, %f)", arg.Data(), ymax, kINEL[i], species.Data(), ptmin, ptjoint, ptmax, ptpid));
				break;
		}
		
		ratio[i]   = outputDir + "/" + species + "-" + outputTag + "-Ratio.root";
		spectra[i] = outputDir + "/" + species + "-" + outputTag + "-Spectra.root";
		
		m1.AddFile(ratio[i].Data(),0);
		m2.AddFile(spectra[i].Data(),0);
	}
	
	// merge
	
	TString allRatios  = outputDir + "/" + species + "-" + otag + "-Mult-Ratio.root";
	TString allSpectra = outputDir + "/" + species + "-" + otag + "-Mult-Spectra.root";
	
	m1.OutputFile(allRatios.Data());
	m2.OutputFile(allSpectra.Data());
	
	m1.Merge();
	m2.Merge();
	
	// delete tmp files
	
	for(Int_t i=0; i<kNmult; ++i)
	{
		gSystem->Exec(Form("rm -f %s", ratio[i].Data()));
		gSystem->Exec(Form("rm -f %s", spectra[i].Data()));
	}
	
	// draw output
	
	gROOT->ProcessLine(Form(".x DrawDir.C+g(\"%s\",\"Anti%s%s_Ratio_Pt\",\"\",0,4.5, 0., 1.8, \"#it{p}_{T} (GeV/c)\", \"#bar{p}/p\", 0, \"cRatio\",\"Particle ratio\")", allRatios.Data(),species.Data(),species.Data()));
	
	Double_t minYield = (species=="Proton") ? 1.1e-6 : 1.1e-8;
	Double_t maxYield = (species=="Proton") ? 4.e-1  : 7.e-4;
	
	DrawOutputSpectraMult(allSpectra, species, minYield, maxYield);
	
	return 0;
}
 LHC10xMult.C:1
 LHC10xMult.C:2
 LHC10xMult.C:3
 LHC10xMult.C:4
 LHC10xMult.C:5
 LHC10xMult.C:6
 LHC10xMult.C:7
 LHC10xMult.C:8
 LHC10xMult.C:9
 LHC10xMult.C:10
 LHC10xMult.C:11
 LHC10xMult.C:12
 LHC10xMult.C:13
 LHC10xMult.C:14
 LHC10xMult.C:15
 LHC10xMult.C:16
 LHC10xMult.C:17
 LHC10xMult.C:18
 LHC10xMult.C:19
 LHC10xMult.C:20
 LHC10xMult.C:21
 LHC10xMult.C:22
 LHC10xMult.C:23
 LHC10xMult.C:24
 LHC10xMult.C:25
 LHC10xMult.C:26
 LHC10xMult.C:27
 LHC10xMult.C:28
 LHC10xMult.C:29
 LHC10xMult.C:30
 LHC10xMult.C:31
 LHC10xMult.C:32
 LHC10xMult.C:33
 LHC10xMult.C:34
 LHC10xMult.C:35
 LHC10xMult.C:36
 LHC10xMult.C:37
 LHC10xMult.C:38
 LHC10xMult.C:39
 LHC10xMult.C:40
 LHC10xMult.C:41
 LHC10xMult.C:42
 LHC10xMult.C:43
 LHC10xMult.C:44
 LHC10xMult.C:45
 LHC10xMult.C:46
 LHC10xMult.C:47
 LHC10xMult.C:48
 LHC10xMult.C:49
 LHC10xMult.C:50
 LHC10xMult.C:51
 LHC10xMult.C:52
 LHC10xMult.C:53
 LHC10xMult.C:54
 LHC10xMult.C:55
 LHC10xMult.C:56
 LHC10xMult.C:57
 LHC10xMult.C:58
 LHC10xMult.C:59
 LHC10xMult.C:60
 LHC10xMult.C:61
 LHC10xMult.C:62
 LHC10xMult.C:63
 LHC10xMult.C:64
 LHC10xMult.C:65
 LHC10xMult.C:66
 LHC10xMult.C:67
 LHC10xMult.C:68
 LHC10xMult.C:69
 LHC10xMult.C:70
 LHC10xMult.C:71
 LHC10xMult.C:72
 LHC10xMult.C:73
 LHC10xMult.C:74
 LHC10xMult.C:75
 LHC10xMult.C:76
 LHC10xMult.C:77
 LHC10xMult.C:78
 LHC10xMult.C:79
 LHC10xMult.C:80
 LHC10xMult.C:81
 LHC10xMult.C:82
 LHC10xMult.C:83
 LHC10xMult.C:84
 LHC10xMult.C:85
 LHC10xMult.C:86
 LHC10xMult.C:87
 LHC10xMult.C:88
 LHC10xMult.C:89
 LHC10xMult.C:90
 LHC10xMult.C:91
 LHC10xMult.C:92
 LHC10xMult.C:93
 LHC10xMult.C:94
 LHC10xMult.C:95
 LHC10xMult.C:96
 LHC10xMult.C:97
 LHC10xMult.C:98
 LHC10xMult.C:99
 LHC10xMult.C:100
 LHC10xMult.C:101
 LHC10xMult.C:102
 LHC10xMult.C:103
 LHC10xMult.C:104
 LHC10xMult.C:105
 LHC10xMult.C:106
 LHC10xMult.C:107
 LHC10xMult.C:108
 LHC10xMult.C:109
 LHC10xMult.C:110
 LHC10xMult.C:111
 LHC10xMult.C:112
 LHC10xMult.C:113
 LHC10xMult.C:114
 LHC10xMult.C:115
 LHC10xMult.C:116
 LHC10xMult.C:117
 LHC10xMult.C:118
 LHC10xMult.C:119
 LHC10xMult.C:120
 LHC10xMult.C:121
 LHC10xMult.C:122
 LHC10xMult.C:123
 LHC10xMult.C:124
 LHC10xMult.C:125
 LHC10xMult.C:126
 LHC10xMult.C:127
 LHC10xMult.C:128
 LHC10xMult.C:129
 LHC10xMult.C:130
 LHC10xMult.C:131
 LHC10xMult.C:132
 LHC10xMult.C:133
 LHC10xMult.C:134
 LHC10xMult.C:135
 LHC10xMult.C:136
 LHC10xMult.C:137
 LHC10xMult.C:138
 LHC10xMult.C:139
 LHC10xMult.C:140