text:
<?php

namespace Magento\Weee\Test\Unit\Model;

use Magento\Weee\Model\Tax;

/**
 * Class TaxTest
 */
class TaxTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @var \Magento\Weee\Model\Tax
     */
    protected $model;

    /**
     * @var \PHPUnit_Framework_MockObject_MockObject
     */
    protected $context;

    /**
     * @var \PHPUnit_Framework_MockObject_MockObject
     */
    protected $registry;

    /**
     * @var \PHPUnit_Framework_MockObject_MockObject
     */
    protected $attributeFactory;

    /**
     * @var \PHPUnit_Framework_MockObject_MockObject
     */
    protected $storeManager;

    /**
     * @var \PHPUnit_Framework_MockObject_MockObject
     */
    protected $calculationFactory;

    /**
     * @var \PHPUnit_Framework_MockObject_MockObject
     */
    protected $customerSession;

    /**
     * @var \PHPUnit_Framework_MockObject_MockObject
     */
    protected $accountManagement;

    /**
     * @var \PHPUnit_Framework_MockObject_MockObject
     */
    protected $taxData;

    /**
     * @var \PHPUnit_Framework_MockObject_MockObject
     */
    protected $resource;

    /**
     * @var \PHPUnit_Framework_MockObject_MockObject
     */
    protected $weeeConfig;

    /**
     * @var \PHPUnit_Framework_MockObject_MockObject
     */
    protected $priceCurrency;

    /**
     * @var \PHPUnit_Framework_MockObject_MockObject
     */
    protected $resourceCollection;

    /**
     * @var \PHPUnit_Framework_MockObject_MockObject
     */
    protected $data;

    /**
     * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
     */
    protected $objectManager;

    /**
     * Setup the test
     */
    protected function setUp()
    {
        $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);

        $className = '\Magento\Framework\Model\Context';
        $this->context = $this->getMock($className, [], [], '', false);

        $className = '\Magento\Framework\Registry';
        $this->registry = $this->getMock($className, [], [], '', false);

        $className = '\Magento\Eav\Model\Entity\AttributeFactory';
        $this->attributeFactory = $this->getMock($className, ['create'], [], '', false);

        $className = '\Magento\Store\Model\StoreManagerInterface';
        $this->storeManager = $this->getMock($className, [], [], '', false);

        $className = '\Magento\Tax\Model\CalculationFactory';
        $this->calculationFactory = $this->getMock($className, ['create'], [], '', false);

        $className = '\Magento\Customer\Model\Session';
        $this->customerSession = $this->getMock(
            $className,
            ['getCustomerId', 'getDefaultTaxShippingAddress', 'getDefaultTaxBillingAddress', 'getCustomerTaxClassId'],
            [],
            '',
            false
        );
        $this->customerSession->expects($this->any())->method('getCustomerId')->willReturn(null);
        $this->customerSession->expects($this->any())->method('getDefaultTaxShippingAddress')->willReturn(null);
        $this->customerSession->expects($this->any())->method('getDefaultTaxBillingAddress')->willReturn(null);
        $this->customerSession->expects($this->any())->method('getCustomerTaxClassId')->willReturn(null);

        $className = '\Magento\Customer\Api\AccountManagementInterface';
        $this->accountManagement = $this->getMock($className, [], [], '', false);

        $className = '\Magento\Tax\Helper\Data';
        $this->taxData = $this->getMock($className, [], [], '', false);

        $className = '\Magento\Weee\Model\ResourceModel\Tax';
        $this->resource = $this->getMock($className, [], [], '', false);

        $className = '\Magento\Weee\Model\Config';
        $this->weeeConfig = $this->getMock($className, [], [], '', false);

        $className = '\Magento\Framework\Pricing\PriceCurrencyInterface';
        $this->priceCurrency = $this->getMock($className, [], [], '', false);

        $className = '\Magento\Framework\Data\Collection\AbstractDb';
        $this->resourceCollection = $this->getMock($className, [], [], '', false);

        $this->model = $this->objectManager->getObject(
            '\Magento\Weee\Model\Tax',
            [
                'context' => $this->context,
                'registry' => $this->registry,
                'attributeFactory' => $this->attributeFactory,
                'storeManager' => $this->storeManager,
                'calculationFactory' => $this->calculationFactory,
                'customerSession' => $this->customerSession,
                'accountManagement' => $this->accountManagement,
                'taxData' => $this->taxData,
                'resource' => $this->resource,
                'weeeConfig' => $this->weeeConfig,
                'priceCurrency' => $this->priceCurrency,
                'resourceCollection' => $this->resourceCollection,
            ]
        );
    }

    /**
     * test GetProductWeeeAttributes
     * @dataProvider getProductWeeeAttributesDataProvider
     * @param array $weeeTaxCalculationsByEntity
     * @param array $expectedFptLabel
     */
    public function testGetProductWeeeAttributes($weeeTaxCalculationsByEntity, $expectedFptLabel)
    {
        $product = $this->getMock('\Magento\Catalog\Model\Product', [], [], '', false);
        $website = $this->getMock('\Magento\Store\Model\Website', [], [], '', false);
        $store = $this->getMock('\Magento\Store\Model\Store', [], [], '', false);
        $group = $this->getMock('\Magento\Store\Model\Group', [], [], '', false);

        $attribute = $this->getMock('\Magento\Eav\Model\Entity\Attribute', [], [], '', false);
        $calculation = $this->getMock('Magento\Tax\Model\Calculation', [], [], '', false);

        $obj = new \Magento\Framework\DataObject(['country' => 'US', 'region' => 'TX']);
        $calculation->expects($this->once())
            ->method('getRateRequest')
            ->willReturn($obj);
        $calculation->expects($this->once())
            ->method('getDefaultRateRequest')
            ->willReturn($obj);
        $calculation->expects($this->any())
            ->method('getRate')
            ->willReturn('10');

        $attribute->expects($this->once())
            ->method('getAttributeCodesByFrontendType')
            ->willReturn(['0'=>'fpt']);

        $store->expects($this->any())
            ->method('getId')
            ->willReturn(1);

        $product->expects($this->any())
            ->method('getId')
            ->willReturn(1);

        $website->expects($this->any())
            ->method('getId')
            ->willReturn(1);
        $website->expects($this->any())
            ->method('getDefaultGroup')
            ->willReturn($group);

        $group->expects($this->any())
            ->method('getDefaultStore')
            ->willReturn($store);

        $this->storeManager->expects($this->any())
            ->method('getWebsite')
            ->willReturn($website);

        $this->weeeConfig->expects($this->any())
            ->method('isEnabled')
            ->willReturn(true);

        $this->weeeConfig->expects($this->any())
            ->method('isTaxable')
            ->willReturn(true);

        $this->attributeFactory->expects($this->any())
            ->method('create')
            ->willReturn($attribute);

        $this->calculationFactory->expects($this->any())
            ->method('create')
            ->willReturn($calculation);

        $this->priceCurrency->expects($this->any())
            ->method('round')
            ->with(0.1)
            ->willReturn(0.25);

        $this->resource->expects($this->any())
            ->method('fetchWeeeTaxCalculationsByEntity')
            ->willReturn([
                0 => $weeeTaxCalculationsByEntity
            ]);

        $result = $this->model->getProductWeeeAttributes($product, null, null, null, true);
        $this->assertTrue(is_array($result));
        $this->assertArrayHasKey(0, $result);
        $obj = $result[0];
        $this->assertEquals(1, $obj->getAmount());
        $this->assertEquals(0.25, $obj->getTaxAmount());
        $this->assertEquals($weeeTaxCalculationsByEntity['attribute_code'], $obj->getCode());
        $this->assertEquals(__($expectedFptLabel), $obj->getName());
    }

    /**
     * @return array
     */
    public function getProductWeeeAttributesDataProvider()
    {
        return [
            'store_label_defined' => [
                'weeeTaxCalculationsByEntity' => [
                    'weee_value' => 1,
                    'label_value' => 'fpt_label',
                    'frontend_label' => 'fpt_label_frontend',
                    'attribute_code' => 'fpt_code',
                ],
                'expectedFptLabel' => 'fpt_label'
            ],
            'store_label_not_defined' => [
                'weeeTaxCalculationsByEntity' => [
                    'weee_value' => 1,
                    'label_value' => '',
                    'frontend_label' => 'fpt_label_frontend',
                    'attribute_code' => 'fpt_code',
                ],
                'expectedFptLabel' => 'fpt_label_frontend'
            ]
        ];
    }
}


text:
package com.google.googleidentity.oauth2.endpoint;

import com.google.common.base.Preconditions;
import com.google.googleidentity.oauth2.exception.OAuth2ServerException;
import com.google.googleidentity.oauth2.request.OAuth2Request;
import com.google.googleidentity.oauth2.util.OAuth2Utils;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.TemplateException;
import freemarker.template.Version;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;

/** Approval endpoint, used for user approval */
@Singleton
public class ConsentEndpoint extends HttpServlet {

  private static final long serialVersionUID = 7L;

  private static final Logger log = Logger.getLogger("ConsentEndpoint");

  private Configuration configuration;

  @Inject
  public ConsentEndpoint() {}

  public void init() throws ServletException {

    // FreeMaker's version
    Version version = new Version("2.3.30");
    configuration = new Configuration(version);
    configuration.setServletContextForTemplateLoading(getServletContext(), "template");
  }

  protected void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    try {
      toConsentPage(request, response);
    } catch (TemplateException e) {
      throw new OAuth2ServerException("Display consent page error", e);
    }
  }

  private void toConsentPage(HttpServletRequest request, HttpServletResponse response)
      throws IOException, TemplateException {

    Preconditions.checkArgument(
        OAuth2Utils.getClientSession(request).getRequest().isPresent(),
        "Request should have been set");

    OAuth2Request oauth2Request = OAuth2Utils.getClientSession(request).getRequest().get();

    Map<String, Object> information = new HashMap<>();
    information.put("clientID", oauth2Request.getRequestAuth().getClientId());

    List<String> scopes = oauth2Request.getRequestBody().getScopesList();

    StringBuilder sb = new StringBuilder();
    for (String scope : scopes) {
      sb.append(scope).append(" ");
    }

    information.put("scopes", sb.toString());

    Template template = configuration.getTemplate("ConsentPage.ftl");

    response.setCharacterEncoding("utf-8");
    PrintWriter printWriter = response.getWriter();

    template.process(information, printWriter);

    printWriter.flush();
  }
}

redpajama_set_name: RedPajamaGithub


text:
int
strsplit (const char *, char *[], const char *);

#endif


text:
© Copyright 2015
			BINAMTECH


text:
<project xmlns="http://maven.apache.org/POM/4.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>uk.gov.dstl.baleen</groupId>
    <artifactId>baleen</artifactId>
    <version>2.8.0-SNAPSHOT</version>
  </parent>
  <artifactId>baleen-annotators</artifactId>
  <name>Baleen Annotators</name>
  <description>Annotators for Baleen</description>
  <dependencies>
    <dependency>
      <groupId>uk.gov.dstl.baleen</groupId>
      <artifactId>baleen-core</artifactId>
      <version>${baleen.version}</version>
    </dependency>
    <dependency>
      <groupId>uk.gov.dstl.baleen</groupId>
      <artifactId>baleen-uima</artifactId>
      <version>${baleen.version}</version>
    </dependency>
    <dependency>
      <groupId>uk.gov.dstl.baleen</groupId>
      <artifactId>baleen-resources</artifactId>
      <version>${baleen.version}</version>
    </dependency>
    <dependency>
      <groupId>uk.gov.dstl.geo</groupId>
      <artifactId>osgb</artifactId>
      <version>${osgb.version}</version>
    </dependency>
    <dependency>
      <groupId>com.opencsv</groupId>
      <artifactId>opencsv</artifactId>
      <version>${opencsv.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.opennlp</groupId>
      <artifactId>opennlp-tools</artifactId>
      <version>${opennlp.version}</version>
    </dependency>
    <dependency>
      <groupId>de.bwaldvogel</groupId>
      <artifactId>liblinear</artifactId>
      <version>${liblinear.version}</version>
    </dependency>
    <dependency>
      <groupId>org.maltparser</groupId>
      <artifactId>maltparser</artifactId>
      <version>${maltparser.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-lang3</artifactId>
      <version>${commonslang3.version}</version>
    </dependency>
    <dependency>
      <groupId>net.arnx</groupId>
      <artifactId>jsonic</artifactId>
      <version>${jsonic.version}</version>
    </dependency>
    <dependency>
      <groupId>com.optimaize.languagedetector</groupId>
      <artifactId>language-detector</artifactId>
      <version>${languagedetector.version}</version>
    </dependency>
    <dependency>
      <groupId>org.ahocorasick</groupId>
      <artifactId>ahocorasick</artifactId>
      <version>${ahocorasick.version}</version>
    </dependency>
    <dependency>
      <groupId>org.atteo</groupId>
      <artifactId>evo-inflector</artifactId>
      <version>${evoinflector.version}</version>
    </dependency>
    <dependency>
      <groupId>com.samskivert</groupId>
      <artifactId>jmustache</artifactId>
      <version>${jmustache.version}</version>
    </dependency>
    <dependency>
      <groupId>org.jsoup</groupId>
      <artifactId>jsoup</artifactId>
      <version>${jsoup.version}</version>
    </dependency>
    <dependency>
      <groupId>org.opensextant</groupId>
      <artifactId>geodesy</artifactId>
      <version>${geodesy.version}</version>
      <exclusions>
        <exclusion>
          <groupId>org.slf4j</groupId>
          <artifactId>slf4j-simple</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>uk.gov.dstl.baleen</groupId>
      <artifactId>baleen-resources</artifactId>
      <version>${baleen.version}</version>
      <type>test-jar</type>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>uk.gov.dstl.baleen</groupId>
      <artifactId>baleen-uima</artifactId>
      <version>${baleen.version}</version>
      <type>test-jar</type>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.github.fakemongo</groupId>
      <artifactId>fongo</artifactId>
      <version>${fongo.version}</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <version>${maven-jar-plugin.version}</version>
        <executions>
          <execution>
            <goals>
              <goal>test-jar</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <excludes>
            <exclude>logback-test.xml</exclude>
          </excludes>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>


text:
require "vcr"
require "yaml"
require "Garnet"

RSpec.configure do |config|
  config.filter_run :focus
  config.run_all_when_everything_filtered = true

  if config.files_to_run.one?
    config.default_formatter = "doc"
  end

  config.order = :random
  Kernel.srand config.seed

  config.expect_with :rspec do |expectations|
    expectations.syntax = :expect
  end

  config.mock_with :rspec do |mocks|
    mocks.syntax = :expect
    mocks.verify_partial_doubles = true
  end
end

Garnet.configure do |config|
  settings = YAML::load_file(File.join(__dir__, "..", "config", "settings.yml"))
  config.api_key = settings["api_key"]
  config.api_url = settings["api_url"]
end

VCR.configure do |c|
  c.cassette_library_dir = "fixtures/vcr_cassettes"
  c.filter_sensitive_data("<REDMINE_API_KEY>") { Garnet.configuration.api_key }
  c.filter_sensitive_data("<REDMINE_API_URL>") { Garnet.configuration.api_url }
  c.hook_into :webmock
end


text:
package com.lynx.fqb.find;

import java.util.Optional;

import javax.persistence.EntityManager;

import org.junit.Assert;
import org.junit.Test;

import com.lynx.fqb.Find;
import com.lynx.fqb.Find.InterceptingFind;
import com.lynx.fqb.IntegrationTestBase;
import com.lynx.fqb.entity.SellOrder;
import com.lynx.fqb.intercept.EntityInterceptor;

public class FindITest extends IntegrationTestBase {

    @Test
    public void shouldGetById() {
        Optional<SellOrder> entity = Find.entity(SellOrder.class).byId(ORDER_ONE_ID).apply(em);

        Assert.assertEquals(ORDER_ONE_ID, entity.get().getId());
    }

    @Test
    public void shouldReturnEmpty() {
        Optional<SellOrder> entity = Find.entity(SellOrder.class).byId(-1l).apply(em);

        Assert.assertFalse(entity.isPresent());
    }

    @Test
    public void shouldInterceptAndReturnEntity() {
        Optional<SellOrder> result = new InterceptingFind<>(new OnlyFirstFindInterceptor()).entity(SellOrder.class).byId(ORDER_ONE_ID).apply(em);

        Assert.assertTrue(result.isPresent());
    }

    @Test
    public void shouldInterceptAndReturnEmpty() {
        Long id = ORDER_TWO_ID;

        Assert.assertTrue(Find.entity(SellOrder.class).byId(id).apply(em).isPresent());

        Optional<SellOrder> result = new InterceptingFind<>(new OnlyFirstFindInterceptor()).entity(SellOrder.class).byId(id).apply(em);

        Assert.assertFalse(result.isPresent());
    }

    @Test
    public void shouldIdentityInterceptOnExistingResult() {
        Optional<SellOrder> result = new InterceptingFind<SellOrder>(EntityInterceptor.noOp()).entity(SellOrder.class).byId(ORDER_ONE_ID).apply(em);

        Assert.assertTrue(result.isPresent());
    }

    @Test
    public void shouldIdentityInterceptOnEmptyResult() {
        Optional<SellOrder> result = new InterceptingFind<SellOrder>(EntityInterceptor.noOp()).entity(SellOrder.class).byId(-1l).apply(em);

        Assert.assertFalse(result.isPresent());
    }

    private static class OnlyFirstFindInterceptor implements EntityInterceptor<SellOrder> {

        @Override
        public Optional<SellOrder> apply(EntityManager em, SellOrder entity) {
            if (entity.getId().equals(ORDER_ONE_ID)) {
                return Optional.of(entity);
            }

            return Optional.empty();
        }

    }
}


text:
package org.act.tstream.task.execute;

import java.util.Map;
import java.util.Map.Entry;

import org.apache.log4j.Logger;

import backtype.storm.Config;
import backtype.storm.task.IBolt;
import backtype.storm.task.IOutputCollector;
import backtype.storm.task.OutputCollector;
import backtype.storm.task.TopologyContext;
import backtype.storm.tuple.Tuple;
import backtype.storm.utils.DisruptorQueue;
import backtype.storm.utils.WorkerClassLoader;

import org.act.tstream.daemon.worker.TimeTick;
import org.act.tstream.metric.MetricDef;
import org.act.tstream.metric.JStormTimer;
import org.act.tstream.metric.Metrics;
import org.act.tstream.stats.CommonStatsRolling;
import org.act.tstream.task.TaskStatus;
import org.act.tstream.task.TaskTransfer;
import org.act.tstream.task.acker.Acker;
import org.act.tstream.task.comm.TaskSendTargets;
import org.act.tstream.task.error.ITaskReportErr;
import org.act.tstream.utils.JStormUtils;
import org.act.tstream.utils.RotatingMap;
import org.act.tstream.utils.TimeUtils;
import com.lmax.disruptor.EventHandler;

/**
 *
 * BoltExecutor
 *
 * @author yannian/Longda
 *
 */
public class BoltExecutors extends BaseExecutors implements EventHandler {
	private static Logger LOG = Logger.getLogger(BoltExecutors.class);

	protected IBolt bolt;

	protected RotatingMap<Tuple, Long> tuple_start_times;

	private int ackerNum = 0;

	// internal outputCollector is BoltCollector
	private OutputCollector outputCollector;

	private JStormTimer boltExeTimer;

	public BoltExecutors(IBolt _bolt, TaskTransfer _transfer_fn,
			Map<Integer, DisruptorQueue> innerTaskTransfer, Map storm_conf,
			DisruptorQueue deserializeQueue, TaskSendTargets _send_fn,
			TaskStatus taskStatus, TopologyContext sysTopologyCxt,
			TopologyContext userTopologyCxt, CommonStatsRolling _task_stats,
			ITaskReportErr _report_error) {

		super(_transfer_fn, storm_conf, deserializeQueue, innerTaskTransfer,
				sysTopologyCxt, userTopologyCxt, _task_stats, taskStatus,
				_report_error);

		this.bolt = _bolt;

		// create TimeCacheMap

		this.tuple_start_times = new RotatingMap<Tuple, Long>(
				Acker.TIMEOUT_BUCKET_NUM);

		this.ackerNum = JStormUtils.parseInt(storm_conf
				.get(Config.TOPOLOGY_ACKER_EXECUTORS));

		// don't use TimeoutQueue for recv_tuple_queue,
		// then other place should check the queue size
		// TimeCacheQueue.DefaultExpiredCallback<Tuple> logExpireCb = new
		// TimeCacheQueue.DefaultExpiredCallback<Tuple>(
		// idStr);
		// this.recv_tuple_queue = new
		// TimeCacheQueue<Tuple>(message_timeout_secs,
		// TimeCacheQueue.DEFAULT_NUM_BUCKETS, logExpireCb);

		// create BoltCollector
		IOutputCollector output_collector = new BoltCollector(
				message_timeout_secs, _report_error, _send_fn, storm_conf,
				_transfer_fn, sysTopologyCxt, taskId, tuple_start_times,
				_task_stats);

		outputCollector = new OutputCollector(output_collector);

		boltExeTimer = Metrics.registerTimer(idStr, MetricDef.EXECUTE_TIME,
				String.valueOf(taskId), Metrics.MetricType.TASK);
		TimeTick.registerTimer(idStr + "-sampling-tick", exeQueue);

		try {
			// do prepare
			WorkerClassLoader.switchThreadContext();
			bolt.prepare(storm_conf, userTopologyCxt, outputCollector);

		} catch (Throwable e) {
			error = e;
			LOG.error("bolt prepare error ", e);
			report_error.report(e);
		} finally {
			WorkerClassLoader.restoreThreadContext();
		}

		LOG.info("Successfully create BoltExecutors " + idStr);

	}

	@Override
	public String getThreadName() {
		return idStr + "-" + BoltExecutors.class.getSimpleName();
	}

	@Override
	public void run() {

		WorkerClassLoader.switchThreadContext();
		while (taskStatus.isShutdown() == false) {
			try {

				exeQueue.consumeBatchWhenAvailable(this);

			} catch (Throwable e) {
				if (taskStatus.isShutdown() == false) {
					LOG.error(idStr + " bolt exeutor  error", e);
				}
			}
		}
		WorkerClassLoader.restoreThreadContext();

	}

	@Override
	public void onEvent(Object event, long sequence, boolean endOfBatch)
			throws Exception {

		if (event == null) {
			return;
		}

		boltExeTimer.start();

		try {

			if (event instanceof TimeTick.Tick) {
				// don't check the timetick name to improve performance

				Map<Tuple, Long> timeoutMap = tuple_start_times.rotate();

				if (ackerNum > 0) {
					// only when acker is enable
					for (Entry<Tuple, Long> entry : timeoutMap.entrySet()) {
						Tuple input = entry.getKey();
						task_stats.bolt_failed_tuple(
								input.getSourceComponent(),
								input.getSourceStreamId());
					}
				}

				return;
			}

			Tuple tuple = (Tuple) event;

			task_stats.recv_tuple(tuple.getSourceComponent(),
					tuple.getSourceStreamId());

			tuple_start_times.put(tuple, System.currentTimeMillis());

			try {
				bolt.execute(tuple);
			} catch (Throwable e) {
				error = e;
				LOG.error("bolt execute error ", e);
				report_error.report(e);
			}

			if (ackerNum == 0) {
				// only when acker is disable
				// get tuple process latency
				Long start_time = (Long) tuple_start_times.remove(tuple);
				if (start_time != null) {
					Long delta = TimeUtils.time_delta_ms(start_time);
					task_stats.bolt_acked_tuple(tuple.getSourceComponent(),
							tuple.getSourceStreamId(), delta);
				}
			}
		} finally {
			boltExeTimer.stop();
		}
	}

}


text:
% SOMA - Self-Organizing Migration Algorithm
% visit http://www.ft.utb.cz/people/zelinka/soma/
% written by ibisek, MMV
%
% STRATEGY "ALL-TO-ONE (LEADER)", the basic version

function [retVal] = soma_all_to_one(optimizedFunction, GenerateRandSchemeFunc, CheckSchemeInBoundFunc, migrations, popSize, nV, ProtRef)

hfig=gca;

%%
% optimization parameter (recommanded values : step = 0.11; pathLength =3; prt = 0.1; minDiv = 0;)
opt.step       = 0.11;
opt.pathLength = 3;
opt.prt        = 0.1;
opt.nV = nV;

% create "instance" of optimized function
opt.costFunctionHandle = optimizedFunction;
opt.CheckSchemeInBoundFunc = CheckSchemeInBoundFunc;
RefCost = optimizedFunction(ProtRef);

% random population within borders and cost values
costValues = zeros(1,popSize);
population = zeros(nV,size(GenerateRandSchemeFunc(),2),popSize);
j_progress('Generate Random Protocols...')
for i=1:popSize
    j_progress(i/popSize)
    population(:,:,i) = GenerateRandSchemeFunc();
    individual = population(:,:,i);
    costValues(1,i) = opt.costFunctionHandle( individual);
end
j_progress('...done')

% find the leader ( individual with the lowest cost value )
[~,indexOfLeader] = min(costValues);

globalErrorHistory = zeros(migrations,1);

%%
% Create Wait Bar
h = waitbar(0, sprintf('Migration 0/%0.0f',migrations), 'Name', 'Optimizing CRLB',...
            'CreateCancelBtn','if ~strcmp(get(gcbf,''Name''),''Canceling...''), set(gcbf,''Name'',''Canceling...''), setappdata(gcbf,''canceling'',1), else, delete(gcbf); end');
setappdata(h,'canceling',0);
j_progress('MIGRATIONS IN PROCESS...\n')

% Migrate
for mig = 1:migrations

    j_progress((mig-1)/migrations)
    % migrate individuals to the leader (except leader to himself, of course)
    Leader = population(:,:,indexOfLeader);
    for i = 1:popSize
        if indexOfLeader ~=i
            [costValues(i), population(:,:,i)] = migrationfun(population(:,:,i),Leader,costValues(i),opt);
        end
    end % for i

    % find the leader (individual with the lowest cost value)
    [~,indexOfLeader] = min(costValues);
    globalErrorHistory(mig) = costValues(indexOfLeader);

    schemeLEADER = population(:,:,indexOfLeader);

    LEADER_hist(:,:,mig)=schemeLEADER;
    plot(hfig,linspace(1,mig,mig), globalErrorHistory(1:mig),'-*')
    hold(hfig,'on') ; plot(hfig,[1 mig],[RefCost RefCost],'--r')
    hold(hfig,'off');
    xlabel(hfig,'migrations') ; ylabel(hfig,'CRLB') ; title(hfig,'optimization history : SOMA All to One CRLB')
    legend(hfig,{'Optimized Protocol','Original Protocol'})
    drawnow

    if ishandle(h)
        waitbar((mig-1)/migrations,h,sprintf('Migration %0.0f/%0.0f',mig-1,migrations));
        if getappdata(h,'canceling')
            break
        end
    end
end
delete(h)       % DELETE the waitbar; don't try to CLOSE it.

% return values:
retVal.schemeLEADER = schemeLEADER;
retVal.costValue = costValues(1,indexOfLeader);
retVal.history = globalErrorHistory;
retVal.history_scheme = LEADER_hist;

function [costValues, Individual] = migrationfun(Individual,leaderPosition,costValues,opt)
% Check if this individual is not leader. If true, skip it.

% store the individual's start position
startPositionOfIndividual = Individual;

% Let's migrate!
for t=0:opt.step:opt.pathLength

    % Generate new PRTVector for each step of this individual
    PRTVector = zeros(opt.nV,size(Individual,2));
    prtVectorContainOnlyZeros = true;
    while(prtVectorContainOnlyZeros)
        for j=1:opt.nV*size(Individual,2)
            if rand<opt.prt
                PRTVector(j) = 1;
                prtVectorContainOnlyZeros = false;
            else
                PRTVector(j) = 0;
            end
        end
    end

    %new position for all dimensions:
    tmpIndividual = startPositionOfIndividual + (leaderPosition - startPositionOfIndividual ) .* t .* PRTVector;

    %check boundaries
    newtmpIndividual = opt.CheckSchemeInBoundFunc(tmpIndividual);
    tmpIndividual = newtmpIndividual;

    tmpCostValue = feval(opt.costFunctionHandle, tmpIndividual);

    if tmpCostValue<costValues
        costValues = tmpCostValue;   % store better CV and position
        Individual = tmpIndividual;
    end

end % for t


text:
//Int_t nhistos=6;
const Int_t ncollsyst=1;
const Int_t nbinDpt=4;
const Int_t nbinAssocpt=3;
Int_t firstDpt=0;
Double_t canvasheight=1000;
Double_t ratioForCanvasWidth=4./3.;
Double_t resizeTextFactor=0.9*900./1000.;//canvasheight/1800.; // size was tuned for canvasheight =1800.
Double_t markersize=1.*resizeTextFactor;
Int_t style=1;
// FOR ELENA: HERE THERE ARE JUST STRINGS AND NAMES/LEGENDS
TString collsyst[ncollsyst]={"pp, #sqrt{s} = 5.02 TeV"};
TString pthadron[nbinAssocpt]={"1.0to99.0","1.0to2.0","2.0to3.0"};
TString strmesonpt[nbinDpt]={"3to5","5to8","8to16","16to24"};
TString strPtAssocText[nbinAssocpt]={"#it{p}_{T}^{assoc} > 1 GeV/#it{c}","1 < #it{p}_{T}^{assoc} < 2 GeV/#it{c}","2 < #it{p}_{T}^{assoc} < 3 GeV/#it{c}"};
TString strPtMesonText[nbinDpt]={ "3 < #it{p}_{T}^{D} < 5 GeV/#it{c}", "5 < #it{p}_{T}^{D} < 8 GeV/#it{c}", "8 < #it{p}_{T}^{D} < 16 GeV/#it{c}", "16 < #it{p}_{T}^{D} < 24 GeV/#it{c}"};
TString strDeltaEta="|#Delta#eta| < 1";
Double_t minYaxis[nbinAssocpt]={-0.6,-0.3,-0.2}; // or -0.6 for all
Double_t maxYaxis[nbinAssocpt]={3.4,1.4,1.1};// or 4.1 for the first , 2.9 for the middle and 1.9 for the last
Double_t mesonptcenter[nbinDpt]={4.,6.5,12.,20.};// needed for getting the baseline
Color_t colourSystem[ncollsyst]={kBlack};
Color_t colourSystemBaseUnc[ncollsyst]={kGray+2};//was {kBlack,kRed-7};
Int_t fillColourBaselineStyle=1001;
Int_t markerstyle[1]={20};// pp, p-Pb
Double_t innerPadHeight;// not touch, set internally
Double_t innerPadWidth;// not touch, set internally
Int_t rebin =1;
Double_t **ptbinsD;
Int_t ndesiredbins=3;
TString inputdatadirectory[ncollsyst] = {"./ScriptOutput/ReflectedPlots/StdRebin/AllPlots/Averages"};
TString baselinedirectory[ncollsyst]={"./ScriptOutput/ReflectedPlots/StdRebin/AllPlots/Averages/FitResults/Trends_pp"};
TString avType="Weighted";
TString filenames[ncollsyst][nbinAssocpt][nbinDpt];// [coll syst][ptassoc][ptmes]
TString pedestalfilenames[ncollsyst][nbinAssocpt];// [coll syst][ptassoc]
TString basicdir="$PWD";
TH1D ****histo;
TGraphAsymmErrors ****err;
TLatex ****ltscale;
TH1D ****subtractedhisto;
TH1D ***histopPbSuperimp;
TGraphAsymmErrors ****suberr;
TGraphAsymmErrors ****grbase;
TGraphAsymmErrors ****grv2;

Bool_t skip3to5=kFALSE;
Int_t ihskip=0;
TString fitplotmacrodir=gSystem->ExpandPathName("$ALICE_PHYSICS/../src/PWGHF/correlationHF/macros/");
Bool_t isReflected=kTRUE;
//Double_t leftMarginCanvas=0.17;
//Double_t rightMarginCanvas=0.055;
//Double_t bottomMarginCanvas=0.1;
//Double_t topMarginCanvas=0.1;

Double_t scaleHeightPads=1;// do not touch this, it is regulated automatically in the macro
Double_t scaleWidthPads=1;// do not touch this, it is regulated automatically in the macro
Double_t ytitleoffset=7.5,xtitleoffset=6.;// was 4.8(y) and 3.45(x)
Double_t referencePadHeight=0.2933; // Do not touch unless the canvas division is changed from 2x3, change canvasheight and resizeTextFactor instead
Double_t referencePadHeight=0.44; // Do not touch unless the canvas division is changed from 2x3, change canvasheight and resizeTextFactor instead

void SetBasicDir(TString dir){
  basicdir=dir;
}

void SetSkip3to5pPb(Bool_t skip){
  skip3to5=skip;
}

void SetIsReflected(Bool_t isrefl){
  isReflected=isrefl;
}

void SetBaselineDirectory(TString dirbase){
  baselinedirectory[0]=dirbase;
}

void SetInputDataDirectory(TString inputdir){
  inputdatadirectory[0]=inputdir;
}

void SetAverageMode(Int_t avmode){
  if(avmode==0)avType="Weighted";
  else if(avmode==1)avType="Arithmetic";
  else Printf("DO COMPARISON WITH MC: WRONGE AVERAGE METHOD SET");
}

void SetPaveStyle(TPaveText *pv){
  pv->SetFillColor(0);
  pv->SetFillStyle(0);
  //  pv->SetBorderStyle(0);
  pv->SetBorderSize(0);
  pv->SetTextFont(43);
  //  pv->SetTextSize(20);
  pv->SetTextAlign(12);

}

void SetPadStyle(TPad *p){
  p->SetTicky();
  p->SetTickx();
  //  p->SetFrameBorderMode(0);
  p->SetFillStyle(0);
  p->SetFrameFillStyle(4000);
  //  p->SetBottomMargin(0);
  //  p->SetTopMargin(0);
  //  p->Range(-2.6,-1.5,5.4,4.4);
  //  p->SetLeftMargin(leftMarginCanvas);
  //  p->SetRightMargin(rightMarginCanvas);
  //  p->SetBottomMargin(bottomMarginCanvas);
  //  p->SetTopMargin(topMarginCanvas);
}

void LoadFileNamesppVspPb(){

  for(Int_t icoll=0;icoll<ncollsyst;icoll++){
    for(Int_t kassoc=0;kassoc<nbinAssocpt;kassoc++){
      for(Int_t jmes=0;jmes<nbinDpt;jmes++){
	       if(icoll==0) filenames[icoll][kassoc][jmes]=Form("%s/%sAverageppDzeroDstarDplus%s_assoc%s.root",inputdatadirectory[icoll].Data(),avType.Data(),strmesonpt[jmes].Data(),pthadron[kassoc].Data());
      }
        pedestalfilenames[icoll][kassoc]=Form("%s/CanvasBaselineVariationTrendPedestal_pthad%s.root",baselinedirectory[icoll].Data(),pthadron[kassoc].Data());
    }
  }
}

void Init(){
  if(skip3to5)firstDpt=1;

  histo=new TH1D***[ncollsyst];
  err=new TGraphAsymmErrors***[ncollsyst];
  ltscale = new TLatex ***[ncollsyst];
  subtractedhisto=new TH1D***[ncollsyst];
  suberr=new TGraphAsymmErrors***[ncollsyst];
  grbase=new TGraphAsymmErrors***[ncollsyst];
  grv2=new TGraphAsymmErrors***[ncollsyst];
  for(Int_t icoll=0;icoll<ncollsyst;icoll++){
    histo[icoll]=new TH1D**[nbinAssocpt];
    err[icoll]= new TGraphAsymmErrors**[nbinAssocpt];
    ltscale[icoll] = new TLatex **[nbinAssocpt];
    subtractedhisto[icoll]=new TH1D**[nbinAssocpt];
    histopPbSuperimp=new TH1D**[nbinAssocpt];
    suberr[icoll]=new TGraphAsymmErrors**[nbinAssocpt];
    grbase[icoll]=new TGraphAsymmErrors**[nbinAssocpt];
    grv2[icoll]=new TGraphAsymmErrors**[nbinAssocpt];
    for(Int_t kassoc=0;kassoc<nbinAssocpt;kassoc++){
      histo[icoll][kassoc]=new TH1D*[nbinDpt];
      subtractedhisto[icoll][kassoc]=new TH1D*[nbinDpt];
      histopPbSuperimp[kassoc]=new TH1D*[nbinDpt];
      err[icoll][kassoc]= new TGraphAsymmErrors*[nbinDpt];
      ltscale[icoll][kassoc] = new TLatex*[nbinDpt];
      suberr[icoll][kassoc]=new TGraphAsymmErrors*[nbinDpt];
      grbase[icoll][kassoc]=new TGraphAsymmErrors*[nbinDpt];
      grv2[icoll][kassoc]=new TGraphAsymmErrors*[nbinDpt];
      for(Int_t jmes=0;jmes<nbinDpt;jmes++){
      histo[icoll][kassoc][jmes]=0x0;
      subtractedhisto[icoll][kassoc][jmes]=0x0;
      histopPbSuperimp[kassoc][jmes]=0x0;
      err[icoll][kassoc][jmes]=0x0;
      ltscale[icoll][kassoc][jmes] =0x0;
      suberr[icoll][kassoc][jmes]=0x0;
      grbase[icoll][kassoc][jmes]=0x0;
      grv2[icoll][kassoc][jmes]=0x0;
      }
    }
  }
}

Int_t rebin =1;

//_______________________________________________________________________
TH1D * GetHistoAndSyst(TString path, Int_t collsyst,TString hname, TString hnamesyst,TGraphAsymmErrors *&gr2, TLatex *&tUncertainty){

  Printf("Opening file: %s",path.Data());
  TFile *f=TFile::Open(path.Data(),"READ");
  TH1D *hFDsub=(TH1D*)f->Get(hname.Data());
  AliHFDhadronCorrSystUnc *syst=(AliHFDhadronCorrSystUnc*)f->Get(hnamesyst.Data());
  TH1D *hUncCorrMin=syst->GetHistoTotFlatMin();
  TH1D *hUncCorrMax=syst->GetHistoTotFlatMax();

  gr2=syst->GetTotNonFlatUncGraph();
  gr2->SetLineColor(kBlack);
  gr2->SetMarkerColor(kBlack);
  gr2->SetFillStyle(0);

  if(collsyst==0){
    if(TMath::Abs(hUncCorrMin->GetBinContent(1)-hUncCorrMax->GetBinContent(1))<0.001)tUncertainty=new TLatex(0.55,0.49,Form("%.0f#% scale uncertainty pp",hUncCorrMin->GetBinContent(1)*100.));
    else tUncertainty=new TLatex(0.55,0.49,Form("{}^{#plus%.0f%s}_{#minus%.0f%s} scale unc.","%","%",TMath::Abs(hUncCorrMax->GetBinContent(1))*100.,TMath::Abs(hUncCorrMin->GetBinContent(1)*100.)));
  }

  tUncertainty->SetNDC();
  tUncertainty->SetTextSize(0.025);
  tUncertainty->SetTextFont(62);

  return hFDsub;

}

//_______________________________________________________________________
TH1D * GetPedestalHistoAndSystAndSubtractPedpPb(Int_t binSystem, Int_t binAssoc,Int_t binMeson,TH1D *histo, TGraphAsymmErrors* gr,TGraphAsymmErrors *&grout, TString canvasname,TGraphAsymmErrors *&grbaseOut,TGraphAsymmErrors *&grv2Out){

  Double_t value = 0, pedestal=0;
  TGraphAsymmErrors *grBaseHelp,*grV2;
  grbaseOut=new TGraphAsymmErrors();
  grbaseOut->SetName(Form("grbaselineUncFull_%s_%s_%s",collsyst[binSystem].Data(),strmesonpt[binMeson].Data(),pthadron[binAssoc].Data()));

  Double_t xuncFull,errxuncFull;
  Double_t xuncv2,errxuncv2;
  Int_t bin,bingr;
  TString path = pedestalfilenames[binSystem][binAssoc];//pPb, proper bin assoc

  if(binSystem>=0){
    // get pedestal from fit outputs
    grV2=0x0;
    cout << "pPb -->  Reading File from path: " << path << endl;

    TFile * file = TFile::Open(path.Data(),"READ");
    TCanvas* c=(TCanvas*)file->Get(canvasname.Data());
    TH1D* h = (TH1D*)c->GetListOfPrimitives()->FindObject("FinalTrendPedestal");
    grBaseHelp=(TGraphAsymmErrors*)c->GetListOfPrimitives()->FindObject("fBaselineVariationSystematicsPedestal");

    /*grv2Out=new TGraphAsymmErrors();
    grv2Out->SetName(Form("grbaselineUncV2_%s_%s_%s",collsyst[binSystem].Data(),strmesonpt[binMeson].Data(),pthadron[binAssoc].Data()));

    grV2=(TGraphAsymmErrors*)c->GetListOfPrimitives()->FindObject("fv2SystematicsPedestal");
    */ //removed for now, it seems useless andd breaks (I don't know why) the retrieval of the baseline-subtr uncertainty

    if(isReflected){
      xuncFull=3.25+0.1*binSystem;
      errxuncFull=0.05;
      xuncv2=-0.3;
      errxuncv2=0.075;
    }
    else{
      xuncFull=4.98+0.1*binSystem;
      errxuncFull=0.05;
      xuncv2=-1.85;
      errxuncv2=0.075;
    }

    bin=h->FindBin(mesonptcenter[binMeson]);
    bingr=GetBinGraph(mesonptcenter[binMeson],grBaseHelp);

    pedestal=h->GetBinContent(bin);
    Double_t x,y,erryl,erryh;
    grBaseHelp->GetPoint(bingr,x,y);
    Printf("histo: x=%f, graph: %f",h->GetBinCenter(bin),x);
    erryl=grBaseHelp->GetErrorYlow(bingr);
    erryh=grBaseHelp->GetErrorYhigh(bingr);

    grbaseOut->SetPoint(0,xuncFull,0);
    grbaseOut->SetPointError(0,errxuncFull,errxuncFull,erryl,erryh);

    if(grV2){
      grV2->GetPoint(bingr,x,y);
      erryl=grV2->GetErrorYlow(bingr);
      erryh=grV2->GetErrorYhigh(bingr);
      grv2Out->SetPoint(0,xuncFull,0);
      grv2Out->SetPointError(0,errxuncFull,errxuncFull,erryl,erryh);
    }
  }

/*
  if(binSystem==0){
    grV2=0x0;
    cout << "pp -->  Reading File from path: " << path << endl;

    TFile * file = TFile::Open(path.Data(),"READ");
    TCanvas* c=(TCanvas*)file->Get(canvasname.Data());
    TH1D* h = (TH1D*)c->GetListOfPrimitives()->FindObject("FinalTrendPedestal");
    grBaseHelp=(TGraphAsymmErrors*)c->GetListOfPrimitives()->FindObject("fBaselineVariationSystematicsPedestal");

    if(isReflected){
      xuncFull=3.25;
      errxuncFull=0.075;
      xuncv2=-0.15;
      errxuncv2=0.075;
    }
    else{
      xuncFull=4.83;
      errxuncFull=0.075;
      xuncv2=-1.7;
      errxuncv2=0.075;
    }

    bin=h->FindBin(mesonptcenter[binMeson]);
    bingr=GetBinGraph(mesonptcenter[binMeson],grBaseHelp);

    pedestal=h->GetBinContent(bin);
    Double_t x,y,erryl,erryh;
    grBaseHelp->GetPoint(bingr,x,y);
    Printf("histo: x=%f, graph: %f",h->GetBinCenter(bin),x);
    erryl=grBaseHelp->GetErrorYlow(bingr);
    erryh=grBaseHelp->GetErrorYhigh(bingr);

    grbaseOut->SetPoint(0,xuncFull,0);
    grbaseOut->SetPointError(0,errxuncFull,errxuncFull,erryl,erryh);
    if(grV2){
      grV2->GetPoint(bingr,x,y);
      erryl=grV2->GetErrorYlow(bingr);
      erryh=grV2->GetErrorYhigh(bingr);
      grv2Out->SetPoint(0,xuncFull,0);
      grv2Out->SetPointError(0,errxuncFull,errxuncFull,erryl,erryh);
    }
  }
*/
  cout<<"Baseline being subtracted for: "<<collsyst[binSystem].Data()<< " "<<strmesonpt[binMeson].Data()<< " "<<pthadron[binAssoc].Data()<<" - with uncertainty: "<<erryl<<endl;

  grout=(TGraphAsymmErrors*)gr->Clone(Form("grSub_%s_%s_%s",collsyst[binSystem].Data(),strmesonpt[binMeson].Data(),pthadron[binAssoc].Data()));

  TString nameoutput = histo->GetName();
  nameoutput += "_subtr_";
  nameoutput += "pedestal";
  nameoutput += Form("_%s_%s_%s",collsyst[binSystem].Data(),strmesonpt[binMeson].Data(),pthadron[binAssoc].Data());

  TH1D * outputhisto = (TH1D*)histo->Clone(nameoutput.Data());
  outputhisto->Reset();
  outputhisto->SetStats(kFALSE);

  for(Int_t iBin = 1; iBin <= histo->GetNbinsX();iBin++){

    value = histo->GetBinContent(iBin);
    value -= pedestal;

    outputhisto->SetBinContent(iBin,value);

    outputhisto->SetBinError(iBin,histo->GetBinError(iBin));
    Double_t x,y,eyl,eyh;
    gr->GetPoint(iBin-1,x,y);
    eyl=gr->GetErrorYlow(iBin-1);
    eyh=gr->GetErrorYhigh(iBin-1);
    //cout<<x<<"  "<<y<<"  "<<eyl<<"  "<<eyh<<endl;
    grout->SetPoint(iBin-1,x,y-pedestal);

  }
  cout<<"sub -> "<<outputhisto->GetBinContent(5)<<endl;

  outputhisto->SetXTitle("#Delta#varphi (rad)");
  outputhisto->SetYTitle("#frac{1}{#it{N}_{D}} #frac{d#it{N}^{assoc}}{d#Delta#varphi} - baseline (rad^{-1})");
  //  outputhisto->GetYaxis()->SetTitleOffset(1.5);
  //  outputhisto->GetYaxis()->SetTitleFont(42);
  //  outputhisto->GetXaxis()->SetTitleFont(42);
  //  outputhisto->GetYaxis()->SetTitleSize(25);
  //  outputhisto->GetXaxis()->SetTitleSize(25);
  //  outputhisto->GetYaxis()->SetLabelSize(0.04);
  //  outputhisto->GetXaxis()->SetLabelSize(0.04);

  cout<<"now return histogram"<<endl;

  return outputhisto;

}

Int_t GetBinGraph(Double_t xbincenter, TGraph *gr,Double_t tolerance=0.1){// works only if the bin center is passed (or a value within tolerance). In other cases might not giving back what is expected
  Int_t size=gr->GetN();
  Double_t xg,yg;
  for(Int_t j=0;j<size;j++){
    gr->GetPoint(j,xg,yg);
    if(j==0){
      if(xbincenter<xg&&TMath::Abs(xg-xbincenter)>tolerance)return -1;
    }

    if(TMath::Abs(xg-xbincenter)<tolerance)return j;

  }
  return -1;
}

void Set3x2PadPositions(TCanvas* c){

  TPad * pd1 = (TPad*)c->GetPad(1);
    TPad * pd2 =(TPad*) c->GetPad(2);
    TPad * pd3 =(TPad*) c->GetPad(3);
    TPad * pd4 =(TPad*) c->GetPad(4);
    TPad * pd5 =(TPad*) c->GetPad(5);
    TPad * pd6 =(TPad*) c->GetPad(6);

    SetPadStyle(pd1);

    Double_t xl,xu,yl,yu;
    Double_t marginLeft=0.1;
    Double_t marginRight=0.02;
    Double_t marginTop=0.04;
    Double_t marginBottom=0.08;
    innerPadWidth=(1-marginLeft-marginRight)/2.;// this is the width w/o margin, not the real pad width!!
    innerPadHeight=(1-marginTop-marginBottom)/3.;// this is the height w/o margin, not the real pad height, which differs between inner pads and pads at the "boarders"!!
    Printf("innerPadHeight: %f",innerPadHeight);
    Printf("innerPadWidth: %f",innerPadWidth);
    Double_t marginLeftForXAxis=0.02;
    Double_t marginBottomForYAxis=0.02;

    // Bottom row
    pd5->GetPadPar(xl,yl,xu,yu);
    Printf("Original values: xl %f  xu %f  yl  %f  yu %f",xl,xu,yl,yu);
    pd5->SetPad(0.,0.,innerPadWidth+marginLeft,innerPadHeight+marginBottom);
    pd5->SetLeftMargin(marginLeft/(marginLeft+innerPadWidth));
    pd5->SetRightMargin(0.);
    pd5->SetBottomMargin(marginBottom/(marginBottom+innerPadHeight));
    pd5->SetTopMargin(0.);

        pd5->Modified();
        pd5->Update();

    pd6->GetPadPar(xl,yl,xu,yu);
    Printf("Original values: xl %f  xu %f  yl  %f  yu %f",xl,xu,yl,yu);
    pd6->SetPad(innerPadWidth+marginLeft-marginLeftForXAxis,0,1.,innerPadHeight+marginBottom);
    pd6->SetLeftMargin(marginLeftForXAxis/(innerPadWidth+marginLeftForXAxis+marginRight));//0.02/(1.-innerPadWidth-marginLeft));
    pd6->SetRightMargin(marginRight/(innerPadWidth+marginRight+marginLeftForXAxis));
    pd6->SetBottomMargin(marginBottom/(marginBottom+innerPadHeight));
    pd6->SetTopMargin(0.);

        pd6->Modified();
        pd6->Update();

    // Middle Row
    pd3->GetPadPar(xl,yl,xu,yu);
    Printf("Original values: xl %f  xu %f  yl  %f  yu %f",xl,xu,yl,yu);
    pd3->SetPad(0.,innerPadHeight+marginBottom-marginBottomForYAxis,innerPadWidth+marginLeft,2.*innerPadHeight+marginBottom);
    pd3->SetLeftMargin(marginLeft/(marginLeft+innerPadWidth));
    pd3->SetRightMargin(0.);
    pd3->SetBottomMargin(marginBottomForYAxis/(innerPadHeight+marginBottomForYAxis));
    pd3->SetTopMargin(0.);

        pd3->Modified();
        pd3->Update();

    pd4->GetPadPar(xl,yl,xu,yu);
    Printf("Original values: xl %f  xu %f  yl  %f  yu %f",xl,xu,yl,yu);
    pd4->SetPad(innerPadWidth+marginLeft-marginLeftForXAxis,innerPadHeight+marginBottom-marginBottomForYAxis,1.,2.*innerPadHeight+marginBottom);
    pd4->SetLeftMargin(marginLeftForXAxis/(innerPadWidth+marginLeftForXAxis+marginRight));//0.02/(1.-innerPadWidth-marginLeft));
    pd4->SetRightMargin(marginRight/(innerPadWidth+marginRight+marginLeftForXAxis));
    pd4->SetBottomMargin(marginBottomForYAxis/(innerPadHeight+marginBottomForYAxis));
    pd4->SetTopMargin(0.);

        pd4->Modified();
        pd4->Update();

    // Top Row
    pd1->GetPadPar(xl,yl,xu,yu);
    Printf("Original values: xl %f  xu %f  yl  %f  yu %f",xl,xu,yl,yu);
    pd1->SetPad(0,2.*innerPadHeight+marginBottom-marginBottomForYAxis,innerPadWidth+marginLeft,1.);
    pd1->SetLeftMargin(marginLeft/(marginLeft+innerPadWidth));
    pd1->SetRightMargin(0.);
    pd1->SetBottomMargin(marginBottomForYAxis/(innerPadHeight+marginBottomForYAxis+marginTop));
    pd1->SetTopMargin(marginTop/(innerPadHeight+marginTop+marginBottomForYAxis));

    pd1->Modified();
    pd1->Update();

    scaleHeightPads=pd1->GetHNDC();
    scaleWidthPads=pd1->GetWNDC();

    pd2->GetPadPar(xl,yl,xu,yu);
    Printf("Original values: xl %f  xu %f  yl  %f  yu %f",xl,xu,yl,yu);
    pd2->SetPad(innerPadWidth+marginLeft-marginLeftForXAxis,2.*innerPadHeight+marginBottom-marginBottomForYAxis,1,1);
    pd2->SetLeftMargin(marginLeftForXAxis/(innerPadWidth+marginLeftForXAxis+marginRight));//0.02/(1.-innerPadWidth-marginLeft));
    pd2->SetRightMargin(marginRight/(innerPadWidth+marginRight+marginLeftForXAxis));
    pd2->SetBottomMargin(marginBottomForYAxis/(innerPadHeight+marginBottomForYAxis+marginTop));
    pd2->SetTopMargin(marginTop/(innerPadHeight+marginTop+marginBottomForYAxis));

}

void SetColorGraphs(Int_t system,TGraph* gr,Color_t color=-1){
  if(color==-1){
    gr->SetLineColor(colourSystem[system]);
    gr->SetFillColor(colourSystem[system]);
    gr->SetMarkerColor(colourSystem[system]);
  }
  else{
    gr->SetLineColor(color);
    gr->SetFillColor(color);
    gr->SetMarkerColor(color);
  }

}

void SetScaleUncertaintyPositionAndSize(TLatex *tl1){
  tl1->SetTextFont(43);
  tl1->SetX(0.077/gPad->GetWNDC()+gPad->GetLeftMargin());
  tl1->SetY(0.22/gPad->GetHNDC()+gPad->GetBottomMargin());
  tl1->SetTextSize(27*innerPadHeight/referencePadHeight*resizeTextFactor);// old settings with font 42: 0.07/(gPad->GetHNDC())*scaleHeightPads*resizeTextFactor);
  tl1->SetTextAlign(12);
  return;
}

TLegend *GetLegendDataPoints(TH1D *h1,Int_t identifier){

  TLegend * legend = new TLegend(0.035/gPad->GetWNDC()+gPad->GetLeftMargin(),0.165/gPad->GetHNDC()+gPad->GetBottomMargin(),0.155/gPad->GetWNDC()+gPad->GetLeftMargin(),0.195/gPad->GetHNDC()+gPad->GetBottomMargin());
    //new TLegend(0.011/gPad->GetWNDC()+gPad->GetLeftMargin(),0.14/gPad->GetHNDC()+gPad->GetBottomMargin(),0.2/gPad->GetWNDC()+gPad->GetLeftMargin(),0.2/gPad->GetHNDC()+gPad->GetBottomMargin());
  //previous settings: (0.011/gPad->GetWNDC()+gPad->GetLeftMargin(),0.16/gPad->GetHNDC()+gPad->GetBottomMargin(),0.2/gPad->GetWNDC()+gPad->GetLeftMargin(),0.22/gPad->GetHNDC()+gPad->GetBottomMargin());
    legend->SetFillColor(0);
    legend->SetFillStyle(0);
    legend->SetBorderSize(0);
    legend->SetTextFont(43);
    legend->SetTextSize(25*innerPadHeight/referencePadHeight*resizeTextFactor);
      // old settings with font 42, still good (0.07/(gPad->GetHNDC())*scaleHeightPads*resizeTextFactor);
    legend->AddEntry(h1,"pp, #sqrt{s} = 5.02 TeV","lep");
    legend->SetName(Form("LegendDataPPandpPb_%d",identifier));
    return legend;
  }

TLegend *GetLegendDataPointsFake(TH1D *hpp,Int_t identifier){

  TLegend * legend = new TLegend(0.035/gPad->GetWNDC()+gPad->GetLeftMargin(),0.165/gPad->GetHNDC()+gPad->GetBottomMargin(),0.155/gPad->GetWNDC()+gPad->GetLeftMargin(),0.195/gPad->GetHNDC()+gPad->GetBottomMargin());
    //new TLegend(0.011/gPad->GetWNDC()+gPad->GetLeftMargin(),0.14/gPad->GetHNDC()+gPad->GetBottomMargin(),0.2/gPad->GetWNDC()+gPad->GetLeftMargin(),0.2/gPad->GetHNDC()+gPad->GetBottomMargin());
  //previous settings: (0.011/gPad->GetWNDC()+gPad->GetLeftMargin(),0.16/gPad->GetHNDC()+gPad->GetBottomMargin(),0.2/gPad->GetWNDC()+gPad->GetLeftMargin(),0.22/gPad->GetHNDC()+gPad->GetBottomMargin());
    legend->SetFillColor(0);
    legend->SetFillStyle(0);
    legend->SetBorderSize(0);
    legend->SetTextFont(43);
    legend->SetTextSize(25*innerPadHeight/referencePadHeight*resizeTextFactor);
      // old settings with font 42, still good (0.07/(gPad->GetHNDC())*scaleHeightPads*resizeTextFactor);
    legend->AddEntry(hpp,"","lep");
    legend->AddEntry((TObject*)0,"","");
    legend->SetName(Form("LegendDataPPandpPb_%d",identifier));
    return legend;
  }

TLegend *GetLegendBaselines(TGraphAsymmErrors *g1,Int_t identifier,Int_t positionOption=1){
  TLegend * legend;
  if(positionOption==0){
    legend=new TLegend(0.011/gPad->GetWNDC()+gPad->GetLeftMargin(),0.21/gPad->GetHNDC()+gPad->GetBottomMargin(),0.10/gPad->GetWNDC()+gPad->GetLeftMargin(),0.275/gPad->GetHNDC()+gPad->GetBottomMargin());
  }
  else if(positionOption==1){
    legend= new TLegend(0.20/gPad->GetWNDC()+gPad->GetLeftMargin(),0.21/gPad->GetHNDC()+gPad->GetBottomMargin(),0.31/gPad->GetWNDC()+gPad->GetLeftMargin(),0.275/gPad->GetHNDC()+gPad->GetBottomMargin());
  }
  else if(positionOption==2){// standard
    legend= new TLegend(0.13/gPad->GetWNDC()+gPad->GetLeftMargin(),0.17/gPad->GetHNDC()+gPad->GetBottomMargin(),0.23/gPad->GetWNDC()+gPad->GetLeftMargin(),0.235/gPad->GetHNDC()+gPad->GetBottomMargin());
  }
  else if(positionOption==3){
    legend= new TLegend(0.035/gPad->GetWNDC()+gPad->GetLeftMargin(),0.135/gPad->GetHNDC()+gPad->GetBottomMargin(),0.155/gPad->GetWNDC()+gPad->GetLeftMargin(),0.165/gPad->GetHNDC()+gPad->GetBottomMargin());
  }
  else return 0x0;
  legend->SetFillColor(0);
  legend->SetFillStyle(0);
  legend->SetBorderSize(0);
  legend->SetTextFont(43);
  legend->SetTextAlign(12);
  legend->SetTextSize(23*innerPadHeight/referencePadHeight*resizeTextFactor);// old settings with font 42, 0.07/(gPad->GetHNDC())*scaleHeightPads*resizeTextFactor);
  legend->AddEntry(g1,"baseline-subtraction uncertainty","f");
  // legend->AddEntry(box2[4],"v2 subtr p-Pb","f");
  legend->SetName(Form("LegendBaselineUncPPandpPb_%d",identifier));
  return legend;
}

TPaveText *GetALICEpavetext(Int_t identifier){
  TPaveText *alice = new TPaveText(0.33/gPad->GetWNDC()+gPad->GetLeftMargin(),0.255/gPad->GetHNDC()+gPad->GetBottomMargin(),0.37/gPad->GetWNDC()+gPad->GetLeftMargin(),0.275/gPad->GetHNDC()+gPad->GetBottomMargin(),"NDC");
  //  TPaveText *alice = new TPaveText(0.012/gPad->GetWNDC()+gPad->GetLeftMargin(),0.26/gPad->GetHNDC()+gPad->GetBottomMargin(),0.3/gPad->GetWNDC()+gPad->GetLeftMargin(),0.28/gPad->GetHNDC()+gPad->GetBottomMargin(),"NDC");
  SetPaveStyle(alice);
  alice->SetTextFont(43);
  alice->SetTextSize(32*innerPadHeight/referencePadHeight*resizeTextFactor);//old settings with font 42 : 0.08/(gPad->GetHNDC())*scaleHeightPads*resizeTextFactor);
  alice->AddText("ALICE");//commented
  // fitvalueslow->AddText("D meson (average D^{0},D^{+},D^{*+}) - charged particle correlation");
  alice->SetName(Form("paveALICE_%d",identifier));
  return alice;
}

TPaveText *GetAveragepavetext(Int_t identifier){
  TPaveText* pvAverage = new TPaveText(0.004/gPad->GetWNDC()+gPad->GetLeftMargin(),0.255/gPad->GetHNDC()+gPad->GetBottomMargin(),0.3/gPad->GetWNDC()+gPad->GetLeftMargin(),0.275/gPad->GetHNDC()+gPad->GetBottomMargin(),"NDC");
  //  TPaveText* pvAverage = new TPaveText(0.012/gPad->GetWNDC()+gPad->GetLeftMargin(),0.23/gPad->GetHNDC()+gPad->GetBottomMargin(),0.3/gPad->GetWNDC()+gPad->GetLeftMargin(),0.25/gPad->GetHNDC()+gPad->GetBottomMargin(),"NDC");
  //0.21,0.83,0.5,0.863,"NDC");
  SetPaveStyle(pvAverage);
  pvAverage->SetTextFont(43);
  pvAverage->SetTextSize(32*innerPadHeight/referencePadHeight*resizeTextFactor);//old settings with font 42: 0.08/(gPad->GetHNDC())*scaleHeightPads*resizeTextFactor);
  pvAverage->AddText("Average D^{0}, D^{+}, D^{*+}");
  pvAverage->SetName(Form("paveAverage_%d",identifier));
  return pvAverage;
}

TPaveText *GetPaveKineInfo(TString strPtMeson,TString strPtAssoc,Int_t identifier,Int_t mode=10/* mode: alignment * 10 + 0,1,2,3 (two rows, two rows + include DeltaEta, single row, single row + included delta eta, with alignment=0 -> align left, 1->align right*/){
  TPaveText *pvKineInfo;
  Double_t extraSize=0.;
  if(mode%10==1){
    extraSize=0.02;
  }
  if(mode%10==1){
    extraSize=0.02;
  }
  if(mode%10==2){
    extraSize=0.218;
  }
  if(mode%10==3){
    extraSize=0.238;
  }

  if(mode/10==0){
    pvKineInfo= new TPaveText(0.009/gPad->GetWNDC()+gPad->GetLeftMargin(),0.215/gPad->GetHNDC()+gPad->GetBottomMargin(),0.23/gPad->GetWNDC()+gPad->GetLeftMargin()+extraSize,0.28/gPad->GetHNDC()+gPad->GetBottomMargin(),"NDC");
    SetPaveStyle(pvKineInfo);
    pvKineInfo->SetTextAlign(12);
  }
  else if(mode/10==2){
    pvKineInfo= new TPaveText(0.025/gPad->GetWNDC()+gPad->GetLeftMargin(),0.215/gPad->GetHNDC()+gPad->GetBottomMargin(),0.42/gPad->GetWNDC()+gPad->GetLeftMargin(),0.28/gPad->GetHNDC()+gPad->GetBottomMargin(),"NDC");
    SetPaveStyle(pvKineInfo);
    pvKineInfo->SetTextAlign(22);
  }
  else if(mode/10==1){
    pvKineInfo= new TPaveText(0.32/gPad->GetWNDC()+gPad->GetLeftMargin()-extraSize,0.215/gPad->GetHNDC()+gPad->GetBottomMargin(),0.42/gPad->GetWNDC()+gPad->GetLeftMargin(),0.28/gPad->GetHNDC()+gPad->GetBottomMargin(),"NDC");
    SetPaveStyle(pvKineInfo);
    pvKineInfo->SetTextAlign(32);
  }
  else return 0x0;
  TString strname=Form("pvKineInfo");
  TString strall;
  pvKineInfo->SetTextFont(43);
  pvKineInfo->SetTextSize(26.*innerPadHeight/referencePadHeight*resizeTextFactor);// settings for font 42: 0.07/(gPad->GetHNDC())*scaleHeightPads*resizeTextFactor);
  if(!strPtMeson.IsNull()){
    if(mode%10<2)pvKineInfo->AddText(strPtMeson.Data());
    else {
      strall=strPtMeson;
      if(strPtAssoc.IsNull()){
  pvKineInfo->AddText(strall.Data());
      }
    }
    strname.Append("Dpt");
  }
  if(!strPtAssoc.IsNull()){
    strname.Append("AssocPt");
    if(mode%10==1||mode%10==3){
      strPtAssoc.Append(Form(", %s",strDeltaEta.Data()));
      strname.Append("DeltaEta");
    }
    if(mode%10<2){
      pvKineInfo->AddText(strPtAssoc.Data());
    }
    else{
      strall.Append(Form(", %s",strPtAssoc.Data()));
      pvKineInfo->AddText(strall.Data());
    }
  }
  else if(strPtMeson.IsNull()&&(mode%10==1||mode%10==3)){
    strname.Append("DeltaEta");
    pvKineInfo->AddText(strDeltaEta.Data());
  }
  pvKineInfo->SetName(Form("%s_%d",strname.Data(),identifier));
  return pvKineInfo;
}

void DrawSinglePanel_CorrelationDistributions_2(){
  gStyle->SetOptStat(0000);
  Init();
  LoadFileNamesppVspPb();

  for(Int_t icoll=0;icoll<ncollsyst;icoll++){
    for(Int_t kassoc=0;kassoc<nbinAssocpt;kassoc++){
      for(Int_t jmes=firstDpt;jmes<nbinDpt;jmes++){
  //  if(skip3to5&&jmes==0)continue;
  //  TH1D * GetHistoAndSyst(TString path, Int_t collsyst,TString hname, TString hnamesyst,TGraphAsymmErrors *&gr2, TLatex *&tUncertainty){
  histo[icoll][kassoc][jmes]=GetHistoAndSyst(filenames[icoll][kassoc][jmes],icoll,"fhDaverage","AverageSystematicUncertainty",err[icoll][kassoc][jmes],ltscale[icoll][kassoc][jmes]);

        histo[icoll][kassoc][jmes]->SetMarkerColor(colourSystem[icoll]);
  histo[icoll][kassoc][jmes]->SetLineColor(colourSystem[icoll]);
  histo[icoll][kassoc][jmes]->SetLineWidth(1);
  histo[icoll][kassoc][jmes]->SetMarkerStyle(markerstyle[icoll]);
  histo[icoll][kassoc][jmes]->SetMarkerSize(markersize);

  subtractedhisto[icoll][kassoc][jmes] = GetPedestalHistoAndSystAndSubtractPedpPb(icoll,kassoc,jmes,histo[icoll][kassoc][jmes],err[icoll][kassoc][jmes],suberr[icoll][kassoc][jmes],"CanvasBaselineVariationTrendPedestal",grbase[icoll][kassoc][jmes],grv2[icoll][kassoc][jmes]);
  cout<<"sub -> "<<subtractedhisto[icoll][kassoc][jmes]->GetBinContent(5)<<endl;
  subtractedhisto[icoll][kassoc][jmes]->GetYaxis()->SetRangeUser(-0.8,3*subtractedhisto[icoll][kassoc][jmes]->GetBinContent(subtractedhisto[icoll][kassoc][jmes]->GetMaximumBin()));
  grbase[icoll][kassoc][jmes]->SetFillStyle(fillColourBaselineStyle);
  grbase[icoll][kassoc][jmes]->SetFillColor(colourSystemBaseUnc[icoll]);// was kRed-7
  grbase[icoll][kassoc][jmes]->SetLineColor(colourSystemBaseUnc[icoll]);//was kRed-7
  grbase[icoll][kassoc][jmes]->SetLineWidth(1);

        if(grv2[icoll][kassoc][jmes]){
    grv2[icoll][kassoc][jmes]->SetFillStyle(3002);
    grv2[icoll][kassoc][jmes]->SetFillColor(kMagenta);
  }
  suberr[icoll][kassoc][jmes]->SetLineColor(colourSystem[icoll]);

  subtractedhisto[icoll][kassoc][jmes]->SetMinimum(minYaxis[kassoc]);
  subtractedhisto[icoll][kassoc][jmes]->SetMaximum(maxYaxis[kassoc]);

      }
    }
  }

  Printf("All Histos and Graphs created");
  // UP TO HERE SHOULD BE OK

  TCanvas *cFinalPaperStyle;
  if(skip3to5){
    cFinalPaperStyle=new TCanvas("cFinalPaperStyle","cFinalPaperStyle",ratioForCanvasWidth*canvasheight,canvasheight);
    //SetPadStyle(cFinalPaperStyle);
    //    cFinalPaperStyle->SetBottomMargin(0);
    //    cFinalPaperStyle->SetTopMargin(0);
  cFinalPaperStyle->Divide(3,3,0.0,0.0,0);
  Set3x3PadPositions(cFinalPaperStyle);
  cFinalPaperStyle->Modified();
  cFinalPaperStyle->Update();
    //    Convert3x2Matrix(cFinalPaperStyle,kTRUE);
  }
  else{
    cFinalPaperStyle=new TCanvas("cFinalPaperStyle","cFinalPaperStyle",ratioForCanvasWidth*canvasheight,canvasheight);
    SetPadStyle(cFinalPaperStyle);
    cFinalPaperStyle->Divide(4,3,0,0);
    Set4x3PadPositions(cFinalPaperStyle);
    cFinalPaperStyle->Modified();
    cFinalPaperStyle->Update();
  }

  for(Int_t iassoc=0;iassoc<nbinAssocpt;iassoc++){
    for(Int_t jDpt=firstDpt;jDpt<nbinDpt;jDpt++){
      TPad *pd=(TPad*)cFinalPaperStyle->cd((nbinDpt-firstDpt)*iassoc+jDpt-firstDpt+1);
      SetPadStyle(pd);
      //    gPad->SetLeftMargin(0.3);
      //    gPad->SetRightMargin(0.);
      //    gPad->SetTopMargin(0.3);
      //    gPad->SetBottomMargin(0.3);

      Double_t startline,endline,wi;
      wi=subtractedhisto[0][iassoc][jDpt]->GetBinWidth(1);
      startline=subtractedhisto[0][iassoc][jDpt]->GetBinLowEdge(1);
      endline=subtractedhisto[0][iassoc][jDpt]->GetBinLowEdge(subtractedhisto[0][iassoc][jDpt]->GetNbinsX())+wi+0.15;// 0.15
      // cout<<"******************* "<<startline<<"  "<<endline<<endl;
      TLine* line=new TLine(startline, 0, endline, 0);
      line->SetLineStyle(2);

      TH1D* h=new TH1D(*subtractedhisto[0][iassoc][jDpt]);
      h->Reset();
      h->GetXaxis()->SetLimits(startline,endline);
      h->SetLineColor(0);
      h->GetYaxis()->SetNdivisions(505,kTRUE);
      h->GetXaxis()->CenterTitle();
      h->GetYaxis()->CenterTitle();
      /*
  // older settings, still valid
  h->GetYaxis()->SetTitleFont(42);
  h->GetXaxis()->SetTitleFont(42);
  h->GetYaxis()->SetLabelFont(42);
  h->GetXaxis()->SetLabelFont(42);
  h->GetYaxis()->SetTitleSize(0.07/(gPad->GetHNDC())*scaleHeightPads*resizeTextFactor);
  h->GetXaxis()->SetTitleSize(0.07/(gPad->GetHNDC())*scaleHeightPads*resizeTextFactor);
  h->GetYaxis()->SetLabelSize(0.07/(gPad->GetHNDC())*scaleHeightPads*resizeTextFactor);
  h->GetXaxis()->SetLabelSize(0.07/(gPad->GetHNDC())*scaleHeightPads*resizeTextFactor);

*/

      h->GetYaxis()->SetTitleFont(43);
      h->GetXaxis()->SetTitleFont(43);
      h->GetYaxis()->SetLabelFont(43);
      h->GetXaxis()->SetLabelFont(43);
      h->GetYaxis()->SetTitleSize(28*innerPadHeight/referencePadHeight*resizeTextFactor);
      h->GetXaxis()->SetTitleSize(28*innerPadHeight/referencePadHeight*resizeTextFactor);
      h->GetYaxis()->SetLabelSize(28*innerPadHeight/referencePadHeight*resizeTextFactor);
      h->GetXaxis()->SetLabelSize(28*innerPadHeight/referencePadHeight*resizeTextFactor);

      h->GetYaxis()->SetTitleOffset(ytitleoffset*innerPadHeight/referencePadHeight*resizeTextFactor);//0.95*(gPad->GetHNDC())/scaleHeightPads/resizeTextFactor);
      h->GetXaxis()->SetTitleOffset(xtitleoffset*innerPadHeight/referencePadHeight*resizeTextFactor);// not number before, no number was optimized before font 43 was introduced
      if(jDpt-firstDpt!=0){
  h->GetYaxis()->SetTitleSize(0);
  h->GetYaxis()->SetLabelSize(0);
      }

      if(iassoc!=nbinAssocpt-1){
  h->GetXaxis()->SetTitleSize(0);
  h->GetXaxis()->SetLabelSize(0);
      }

      //      h->GetXaxis()->Delete();
      //      h->GetYaxis()->Delete();
      h->Draw();

      //  box2[4]->Draw("same");
      SetColorGraphs(0,grbase[0][iassoc][jDpt],colourSystemBaseUnc[0]);// redundant...
      grbase[0][iassoc][jDpt]->SetFillStyle(fillColourBaselineStyle);
      grbase[0][iassoc][jDpt]->SetLineWidth(1);
      grbase[0][iassoc][jDpt]->Draw("E2");

      line->Draw();
      Printf("Setting scale unc text pos and size");
      SetScaleUncertaintyPositionAndSize(ltscale[0][iassoc][jDpt]);

      if((nbinDpt-firstDpt)*iassoc+jDpt-firstDpt+1==1){
        ltscale[0][iassoc][jDpt]->SetY(0.15/gPad->GetHNDC()+gPad->GetBottomMargin());// older settings 0.135/gPad->GetHNDC()+gPad->GetBottomMargin());
        ltscale[0][iassoc][jDpt]->SetX(0.077/gPad->GetWNDC()+gPad->GetLeftMargin());
      }

      suberr[0][iassoc][jDpt]->SetLineWidth(1);
      suberr[0][iassoc][jDpt]->Draw("E2");
      subtractedhisto[0][iassoc][jDpt]->Draw("same");
      ltscale[0][iassoc][jDpt]->Draw();//commented
      Printf("Getting data legend");
      TLegend *legend=GetLegendDataPoints(histo[0][iassoc][firstDpt],(nbinDpt-firstDpt)*iassoc+jDpt-firstDpt+1);
      //TLegend *legendSuperimp=GetLegendDataPointsFake(histo[0][iassoc][firstDpt],histopPbSuperimp[iassoc][firstDpt],(nbinDpt-firstDpt)*iassoc+jDpt-firstDpt+1);
      Printf("Getting baseline unc legend");
      TLegend *legend2;
      if(style==0)legend2=GetLegendBaselines(grbase[0][iassoc][firstDpt],(nbinDpt-firstDpt)*iassoc+jDpt-firstDpt+1,0);
      else if(style==1)legend2=GetLegendBaselines(grbase[0][iassoc][firstDpt],(nbinDpt-firstDpt)*iassoc+jDpt-firstDpt+1,3); // default option was 1 in older settings; 2 for draft 1 version;
      else legend2=GetLegendBaselines(grbase[0][iassoc][firstDpt],(nbinDpt-firstDpt)*iassoc+jDpt-firstDpt+1,1);
      if((nbinDpt-firstDpt)*iassoc+jDpt-firstDpt+1==2){legend->Draw(); /*legendSuperimp->Draw();*/}
      if((nbinDpt-firstDpt)*iassoc+jDpt-firstDpt+1==2)legend2->Draw();// was in pad 3 before
      Printf("Getting average pave text");
      TPaveText *pvAverage=GetAveragepavetext((nbinDpt-firstDpt)*iassoc+jDpt-firstDpt+1);
      Printf("Getting ALICE pave text");
      TPaveText *alice=GetALICEpavetext((nbinDpt-firstDpt)*iassoc+jDpt-firstDpt+1);
      alice->SetX1(0.8);
      TPaveText *pvKineInfo;

      if((nbinDpt-firstDpt)*iassoc+jDpt-firstDpt+1==1){
  Printf("Getting Pave Kine infos in bin main, aligning left");
  pvKineInfo=GetPaveKineInfo(strPtMesonText[jDpt],strPtAssocText[iassoc],(nbinDpt-firstDpt)*iassoc+jDpt-firstDpt+1,22);
  pvKineInfo->SetY1(0.22/gPad->GetHNDC()+gPad->GetBottomMargin());
  pvKineInfo->SetY2(0.245/gPad->GetHNDC()+gPad->GetBottomMargin());
  pvKineInfo->SetX1(0.008/gPad->GetWNDC()+gPad->GetLeftMargin());
  pvKineInfo->SetX2(0.23/gPad->GetWNDC()+gPad->GetLeftMargin());
  pvKineInfo->SetTextAlign(12);
  pvKineInfo->Draw("same");
  Printf("Getting Pave Kine infos (DeltaEta) in bin main, aligning left");
  pvKineInfo=GetPaveKineInfo(0x0,0x0,(nbinDpt-firstDpt)*iassoc+jDpt-firstDpt+1,1);// just a trick to get DeltaEta
  Printf("Delta Eta pave obtained");
  pvKineInfo->SetY1(0.195/gPad->GetHNDC()+gPad->GetBottomMargin());
  pvKineInfo->SetY2(0.21/gPad->GetHNDC()+gPad->GetBottomMargin());
        pvKineInfo->SetX1(0.01/gPad->GetWNDC()+gPad->GetLeftMargin());
        pvKineInfo->SetX2(0.18/gPad->GetWNDC()+gPad->GetLeftMargin());
  pvKineInfo->SetTextAlign(12);
  pvKineInfo->Draw("same");
        pvKineInfo=GetPaveKineInfo(strPtMesonText[jDpt],strPtAssocText[iassoc],(nbinDpt-firstDpt)*iassoc+jDpt-firstDpt+1,22);
      }
      else{
  Printf("Getting Pave Kine infos (style %d)",style);
  if(style==0){
    pvKineInfo=GetPaveKineInfo(strPtMesonText[jDpt],strPtAssocText[iassoc],(nbinDpt-firstDpt)*iassoc+jDpt-firstDpt+1,10);
  }
  else if(style==1){
    pvKineInfo=GetPaveKineInfo(strPtMesonText[jDpt],strPtAssocText[iassoc],(nbinDpt-firstDpt)*iassoc+jDpt-firstDpt+1,22);
  }
  else {// very old default
    pvKineInfo=GetPaveKineInfo(strPtMesonText[jDpt],strPtAssocText[iassoc],(nbinDpt-firstDpt)*iassoc+jDpt-firstDpt+1,0);
  }
  pvKineInfo->SetX1(0.2);
  pvKineInfo->SetX2(0.8);

  pvKineInfo->Draw("same");
      }
      if(jDpt==0)  {
        pvKineInfo->SetX1(0.47);
  pvKineInfo->SetX2(0.85);
      } else if(jDpt==1||jDpt==2) {
        pvKineInfo->SetX1(0.22);
        pvKineInfo->SetX2(0.85);
}

      if((nbinDpt-firstDpt)*iassoc+jDpt-firstDpt+1==1) alice->Draw("same");
      if((nbinDpt-firstDpt)*iassoc+jDpt-firstDpt+1==1) pvAverage->Draw("same");

      Printf("Bin D :%d, bin assoc %d done",jDpt,iassoc);
    }
  }

  TString outdir = Form("%s/ScriptOutput/ReflectedPlots/StdRebin/AllPlots/Averages/MultiPanelAverages",basicdir.Data());
  //gSystem->Exec(Form("mkdir %s",outdir.Data()));

  for(Int_t j=6;j>=1;j--){
    Printf("IN THE LOOP WHERE PADS ARE DRAWN, JUST BEFORE SAVING");
    TPad *pd=(TPad*)cFinalPaperStyle->cd(j);
    pd->Draw();
  }
  cFinalPaperStyle->SaveAs(Form("%s/DrawSinglePanel_CorrelationDistributions_%sAverage_2.root",outdir.Data(),avType.Data()));
  cFinalPaperStyle->SaveAs(Form("%s/DrawSinglePanel_CorrelationDistributions_%sAverage_2.png",outdir.Data(),avType.Data()));
  cFinalPaperStyle->SaveAs(Form("%s/DrawSinglePanel_CorrelationDistributions_%sAverage_2.pdf",outdir.Data(),avType.Data()));
  cFinalPaperStyle->SaveAs(Form("%s/DrawSinglePanel_CorrelationDistributions_%sAverage_2.eps",outdir.Data(),avType.Data()));

}

void Set3x3PadPositions(TCanvas* c){

  TPad * pd1 =(TPad*) c->GetPad(1);
  TPad * pd2 =(TPad*) c->GetPad(2);
  TPad * pd3 =(TPad*) c->GetPad(3);
  TPad * pd4 =(TPad*) c->GetPad(4);
  TPad * pd5 =(TPad*) c->GetPad(5);
  TPad * pd6 =(TPad*) c->GetPad(6);
  TPad * pd7 =(TPad*) c->GetPad(7);
  TPad * pd8 =(TPad*) c->GetPad(8);
  TPad * pd9 =(TPad*) c->GetPad(9);

  SetPadStyle(pd1);

  Double_t xl,xu,yl,yu;
  Double_t marginLeft=0.1;
  Double_t marginRight=0.02;
  Double_t marginTop=0.04;
  Double_t marginBottom=0.08;
  innerPadWidth=(1-marginLeft-marginRight)/3.;// this is the width w/o margin, not the real pad width!!
  innerPadHeight=(1-marginTop-marginBottom)/3.;// this is the height w/o margin, not the real pad height, which differs between inner pads and pads at the "boarders"!!
  Printf("innerPadHeight: %f",innerPadHeight);
  Printf("innerPadWidth: %f",innerPadWidth);
  Double_t marginLeftForXAxis=0.02;
  Double_t marginBottomForYAxis=0.0;

 // Bottom row

    pd7->GetPadPar(xl,yl,xu,yu);
    Printf("PAD 7 Original values: xl %f  xu %f  yl  %f  yu %f, gPad->GetwNDC=%f, gPad->GetHNDC=%f",xl,xu,yl,yu,gPad->GetWNDC(),gPad->GetHNDC());
    pd7->SetPad(0.,0.,innerPadWidth+marginLeft,innerPadHeight+marginBottom);
    pd7->GetPadPar(xl,yl,xu,yu);
    Printf("New values: xl %f  xu %f  yl  %f  yu %f, gPad->GetwNDC=%f, gPad->GetHNDC=%f",xl,xu,yl,yu,gPad->GetWNDC(),gPad->GetHNDC());

    pd7->SetLeftMargin(marginLeft/(marginLeft+innerPadWidth));
    pd7->SetRightMargin(0);
    pd7->SetBottomMargin(marginBottom/(marginBottom+innerPadHeight));
    pd7->SetTopMargin(0.);
    pd7->Modified();
    pd7->SetFillStyle(0);

    pd8->GetPadPar(xl,yl,xu,yu);
    Printf("PAD 8 Original values: xl %f  xu %f  yl  %f  yu %f, gPad->GetwNDC=%f, gPad->GetHNDC=%f",xl,xu,yl,yu,gPad->GetWNDC(),gPad->GetHNDC());
    Float_t xLowPad8=innerPadWidth+marginLeft-0.006;
    Float_t marginLeftPad8=0.015;
    pd8->SetPad(innerPadWidth+marginLeft-marginLeftForXAxis,0,2*innerPadWidth+marginLeft,innerPadHeight+marginBottom);
    pd8->GetPadPar(xl,yl,xu,yu);
    Printf("New values: xl %f  xu %f  yl  %f  yu %f, gPad->GetwNDC=%f, gPad->GetHNDC=%f",xl,xu,yl,yu,gPad->GetWNDC(),gPad->GetHNDC());

    pd8->SetLeftMargin(marginLeftForXAxis/(innerPadWidth+marginLeftForXAxis));
    //pd8->SetLeftMargin(0.004/(1.-innerPadWidth-marginLeft+0.004));
    pd8->SetRightMargin(0.);
    pd8->SetBottomMargin(marginBottom/(marginBottom+innerPadHeight));
    pd8->SetTopMargin(0);
    pd8->SetFillStyle(0);

    pd8->Modified();
    pd8->Update();

    pd9->GetPadPar(xl,yl,xu,yu);
    Printf("PAD 9 Original values: xl %f  xu %f  yl  %f  yu %f, gPad->GetwNDC=%f, gPad->GetHNDC=%f",xl,xu,yl,yu,gPad->GetWNDC(),gPad->GetHNDC());
    Float_t xLowPad9=2*innerPadWidth+marginLeft-0.004;
    Float_t xHighPad9=3*innerPadWidth+marginLeft+0.02;
    Float_t marginLeftPad9=0.008/(1.-innerPadWidth-marginLeft+0.008);

    pd9->SetPad(2*innerPadWidth+marginLeft-marginLeftForXAxis,0,1.,innerPadHeight+marginBottom);
    pd9->GetPadPar(xl,yl,xu,yu);
    Printf("New values: xl %f  xu %f  yl  %f  yu %f, gPad->GetwNDC=%f, gPad->GetHNDC=%f",xl,xu,yl,yu,gPad->GetWNDC(),gPad->GetHNDC());

    pd9->SetLeftMargin(marginLeftForXAxis/(innerPadWidth+marginLeftForXAxis+marginRight));
    pd9->SetRightMargin(marginRight/(innerPadWidth+marginRight));
    pd9->SetBottomMargin(marginBottom/(marginBottom+innerPadHeight));
    pd9->SetTopMargin(0.);
    pd9->SetFillStyle(0);

    pd9->Modified();
    pd9->Update();

    // Middle Row
    pd4->GetPadPar(xl,yl,xu,yu);
    Printf("Original values: xl %f  xu %f  yl  %f  yu %f",xl,xu,yl,yu);
    pd4->SetPad(0.,innerPadHeight+marginBottom-marginBottomForYAxis,innerPadWidth+marginLeft,2.*innerPadHeight+marginBottom);
    pd4->SetLeftMargin(marginLeft/(marginLeft+innerPadWidth));
    pd4->SetRightMargin(0.);
    pd4->SetBottomMargin(marginBottomForYAxis/(innerPadHeight+marginBottomForYAxis));
    pd4->SetTopMargin(0.);
    pd4->SetFillStyle(0);

    pd4->Modified();
    pd4->Update();

    pd5->GetPadPar(xl,yl,xu,yu);
    Printf("Original values: xl %f  xu %f  yl  %f  yu %f",xl,xu,yl,yu);
    pd5->SetPad(innerPadWidth+marginLeft-marginLeftForXAxis,innerPadHeight+marginBottom-marginBottomForYAxis,2*innerPadWidth+marginLeft,2.*innerPadHeight+marginBottom);
    pd5->SetLeftMargin(marginLeftForXAxis/(innerPadWidth+marginLeftForXAxis));
    pd5->SetRightMargin(0.);
    pd5->SetBottomMargin(marginBottomForYAxis/(innerPadHeight+marginBottomForYAxis));
    pd5->SetTopMargin(0.);
    pd5->SetFillStyle(0);

    pd5->Modified();
    pd5->Update();

    pd6->GetPadPar(xl,yl,xu,yu);
    Printf("Original values: xl %f  xu %f  yl  %f  yu %f",xl,xu,yl,yu);
    pd6->SetPad(2*innerPadWidth+marginLeft-marginLeftForXAxis,innerPadHeight+marginBottom-marginBottomForYAxis,1.,2.*innerPadHeight+marginBottom);
    pd6->SetLeftMargin(marginLeftForXAxis/(innerPadWidth+marginLeftForXAxis+marginRight));
    pd6->SetRightMargin(marginRight/(innerPadWidth+marginRight));
    pd6->SetBottomMargin(marginBottomForYAxis/(innerPadHeight+marginBottomForYAxis));
    pd6->SetTopMargin(0.);
    pd6->Modified();
    pd6->Update();

  // Top Row
    pd1->GetPadPar(xl,yl,xu,yu);
    Printf("Original values: xl %f  xu %f  yl  %f  yu %f",xl,xu,yl,yu);
    pd1->SetPad(0,2.*innerPadHeight+marginBottom-marginBottomForYAxis,innerPadWidth+marginLeft,1.);
    pd1->SetLeftMargin(marginLeft/(marginLeft+innerPadWidth));
    pd1->SetRightMargin(0.);
    pd1->SetBottomMargin(marginBottomForYAxis/(innerPadHeight+marginBottomForYAxis+marginTop));
    pd1->SetTopMargin(marginTop/(innerPadHeight+marginTop));
    pd1->SetFillStyle(0);
    pd1->Modified();
    pd1->Update();

    pd2->GetPadPar(xl,yl,xu,yu);
    Printf("Original values: xl %f  xu %f  yl  %f  yu %f",xl,xu,yl,yu);
    pd2->SetPad(innerPadWidth+marginLeft-marginLeftForXAxis,2.*innerPadHeight+marginBottom-marginBottomForYAxis,2*innerPadWidth+marginLeft,1);
    pd2->SetLeftMargin(marginLeftForXAxis/(innerPadWidth+marginLeftForXAxis));
    pd2->SetFillStyle(0);
    pd2->SetRightMargin(0);
    pd2->SetBottomMargin(marginBottomForYAxis/(innerPadHeight+marginBottomForYAxis+marginTop));
    pd2->SetTopMargin(marginTop/(innerPadHeight+marginTop));

    pd3->GetPadPar(xl,yl,xu,yu);
    Printf("Original values: xl %f  xu %f  yl  %f  yu %f",xl,xu,yl,yu);
    pd3->SetPad(2*innerPadWidth+marginLeft-marginLeftForXAxis,2.*innerPadHeight+marginBottom-marginBottomForYAxis,1,1);
    pd3->SetLeftMargin(marginLeftForXAxis/(innerPadWidth+marginLeftForXAxis+marginRight));
    pd3->SetRightMargin(marginRight/(innerPadWidth+marginRight));
    pd3->SetBottomMargin(marginBottomForYAxis/(innerPadHeight+marginBottomForYAxis+marginTop));
    pd3->SetTopMargin(marginTop/(innerPadHeight+marginTop));
    pd3->SetFillStyle(0);

    scaleHeightPads=pd1->GetHNDC();
    scaleWidthPads=pd1->GetWNDC();

}

void Set4x3PadPositions(TCanvas* c){

  TPad * pd1 =(TPad*) c->GetPad(1);
  TPad * pd2 =(TPad*) c->GetPad(2);
  TPad * pd3 =(TPad*) c->GetPad(3);
  TPad * pd4 =(TPad*) c->GetPad(4);
  TPad * pd5 =(TPad*) c->GetPad(5);
  TPad * pd6 =(TPad*) c->GetPad(6);
  TPad * pd7 =(TPad*) c->GetPad(7);
  TPad * pd8 =(TPad*) c->GetPad(8);
  TPad * pd9 =(TPad*) c->GetPad(9);
  TPad * pd10 =(TPad*) c->GetPad(10);
  TPad * pd11 =(TPad*) c->GetPad(11);
  TPad * pd12 =(TPad*) c->GetPad(12);

  SetPadStyle(pd1);

  Double_t xl,xu,yl,yu;
  Double_t marginLeft=0.1;
  Double_t marginRight=0.02;
  Double_t marginTop=0.04;
  Double_t marginBottom=0.08;
  innerPadWidth=(1-marginLeft-marginRight)/4.;// this is the width w/o margin, not the real pad width!!
  innerPadHeight=(1-marginTop-marginBottom)/3.;// this is the height w/o margin, not the real pad height, which differs between inner pads and pads at the "boarders"!!
  Printf("innerPadHeight: %f",innerPadHeight);
  Printf("innerPadWidth: %f",innerPadWidth);
  Double_t marginLeftForXAxis=0.02;
  Double_t marginBottomForYAxis=0.0;

 // Bottom row

    pd9->GetPadPar(xl,yl,xu,yu);
    Printf("PAD 7 Original values: xl %f  xu %f  yl  %f  yu %f, gPad->GetwNDC=%f, gPad->GetHNDC=%f",xl,xu,yl,yu,gPad->GetWNDC(),gPad->GetHNDC());
    pd9->SetPad(0.,0.,innerPadWidth+marginLeft,innerPadHeight+marginBottom);
    pd9->GetPadPar(xl,yl,xu,yu);
    Printf("New values: xl %f  xu %f  yl  %f  yu %f, gPad->GetwNDC=%f, gPad->GetHNDC=%f",xl,xu,yl,yu,gPad->GetWNDC(),gPad->GetHNDC());

    pd9->SetLeftMargin(marginLeft/(marginLeft+innerPadWidth));
    pd9->SetRightMargin(0);
    pd9->SetBottomMargin(marginBottom/(marginBottom+innerPadHeight));
    pd9->SetTopMargin(0.);
    pd9->Modified();
    pd9->SetFillStyle(0);

    pd10->GetPadPar(xl,yl,xu,yu);
    Printf("PAD 10 Original values: xl %f  xu %f  yl  %f  yu %f, gPad->GetwNDC=%f, gPad->GetHNDC=%f",xl,xu,yl,yu,gPad->GetWNDC(),gPad->GetHNDC());
    pd10->SetPad(innerPadWidth+marginLeft-marginLeftForXAxis,0,2*innerPadWidth+marginLeft,innerPadHeight+marginBottom);
    pd10->GetPadPar(xl,yl,xu,yu);
    Printf("New values: xl %f  xu %f  yl  %f  yu %f, gPad->GetwNDC=%f, gPad->GetHNDC=%f",xl,xu,yl,yu,gPad->GetWNDC(),gPad->GetHNDC());

    pd10->SetLeftMargin(marginLeftForXAxis/(innerPadWidth+marginLeftForXAxis));
    //pd8->SetLeftMargin(0.004/(1.-innerPadWidth-marginLeft+0.004));
    pd10->SetRightMargin(0.);
    pd10->SetBottomMargin(marginBottom/(marginBottom+innerPadHeight));
    pd10->SetTopMargin(0);
    pd10->SetFillStyle(0);

    pd10->Modified();
    pd10->Update();

    pd11->GetPadPar(xl,yl,xu,yu);
    Printf("PAD 11 Original values: xl %f  xu %f  yl  %f  yu %f, gPad->GetwNDC=%f, gPad->GetHNDC=%f",xl,xu,yl,yu,gPad->GetWNDC(),gPad->GetHNDC());

    pd11->SetPad(2*innerPadWidth+marginLeft-marginLeftForXAxis,0,3*innerPadWidth+marginLeft,innerPadHeight+marginBottom);
    pd11->GetPadPar(xl,yl,xu,yu);
    Printf("New values: xl %f  xu %f  yl  %f  yu %f, gPad->GetwNDC=%f, gPad->GetHNDC=%f",xl,xu,yl,yu,gPad->GetWNDC(),gPad->GetHNDC());
    pd11->SetLeftMargin(marginLeftForXAxis/(innerPadWidth+marginLeftForXAxis));
    pd11->SetRightMargin(0);
    pd11->SetBottomMargin(marginBottom/(marginBottom+innerPadHeight));
    pd11->SetTopMargin(0.);
    pd11->SetFillStyle(0);

    pd11->Modified();
    pd11->Update();

    pd12->GetPadPar(xl,yl,xu,yu);
    Printf("PAD 12 Original values: xl %f  xu %f  yl  %f  yu %f, gPad->GetwNDC=%f, gPad->GetHNDC=%f",xl,xu,yl,yu,gPad->GetWNDC(),gPad->GetHNDC());
    pd12->SetPad(3*innerPadWidth+marginLeft-marginLeftForXAxis,0,1.,innerPadHeight+marginBottom);
    pd12->GetPadPar(xl,yl,xu,yu);
    Printf("New values: xl %f  xu %f  yl  %f  yu %f, gPad->GetwNDC=%f, gPad->GetHNDC=%f",xl,xu,yl,yu,gPad->GetWNDC(),gPad->GetHNDC());

    pd12->SetLeftMargin(marginLeftForXAxis/(innerPadWidth+marginLeftForXAxis+marginRight));
    pd12->SetRightMargin(marginRight/(innerPadWidth+marginRight));
    pd12->SetBottomMargin(marginBottom/(marginBottom+innerPadHeight));
    pd12->SetTopMargin(0.);
    pd12->SetFillStyle(0);

    pd12->Modified();
    pd12->Update();

    // Middle Row
    pd5->GetPadPar(xl,yl,xu,yu);
    Printf("Original values: xl %f  xu %f  yl  %f  yu %f",xl,xu,yl,yu);
    pd5->SetPad(0.,innerPadHeight+marginBottom-marginBottomForYAxis,innerPadWidth+marginLeft,2.*innerPadHeight+marginBottom);
    pd5->SetLeftMargin(marginLeft/(marginLeft+innerPadWidth));
    pd5->SetRightMargin(0.);
    pd5->SetBottomMargin(marginBottomForYAxis/(innerPadHeight+marginBottomForYAxis));
    pd5->SetTopMargin(0.);
    pd5->SetFillStyle(0);

    pd5->Modified();
    pd5->Update();

    pd6->GetPadPar(xl,yl,xu,yu);
    Printf("Original values: xl %f  xu %f  yl  %f  yu %f",xl,xu,yl,yu);
    pd6->SetPad(innerPadWidth+marginLeft-marginLeftForXAxis,innerPadHeight+marginBottom-marginBottomForYAxis,2*innerPadWidth+marginLeft,2.*innerPadHeight+marginBottom);
    pd6->SetLeftMargin(marginLeftForXAxis/(innerPadWidth+marginLeftForXAxis));
    pd6->SetRightMargin(0.);
    pd6->SetBottomMargin(marginBottomForYAxis/(innerPadHeight+marginBottomForYAxis));
    pd6->SetTopMargin(0.);
    pd6->SetFillStyle(0);

    pd6->Modified();
    pd6->Update();

    pd7->GetPadPar(xl,yl,xu,yu);
    Printf("Original values: xl %f  xu %f  yl  %f  yu %f",xl,xu,yl,yu);
    pd7->SetPad(2*innerPadWidth+marginLeft-marginLeftForXAxis,innerPadHeight+marginBottom-marginBottomForYAxis,3*innerPadWidth+marginLeft,2.*innerPadHeight+marginBottom);
    pd7->SetLeftMargin(marginLeftForXAxis/(innerPadWidth+marginLeftForXAxis));
    pd7->SetRightMargin(0.);
    pd7->SetBottomMargin(marginBottomForYAxis/(innerPadHeight+marginBottomForYAxis));
    pd7->SetTopMargin(0.);

    pd7->Modified();
    pd7->Update();

    pd8->GetPadPar(xl,yl,xu,yu);
    Printf("Original values: xl %f  xu %f  yl  %f  yu %f",xl,xu,yl,yu);
    pd8->SetPad(3*innerPadWidth+marginLeft-marginLeftForXAxis,innerPadHeight+marginBottom-marginBottomForYAxis,1.,2.*innerPadHeight+marginBottom);
    pd8->SetLeftMargin(marginLeftForXAxis/(innerPadWidth+marginLeftForXAxis+marginRight));
    pd8->SetRightMargin(marginRight/(innerPadWidth+marginRight));
    pd8->SetBottomMargin(marginBottomForYAxis/(innerPadHeight+marginBottomForYAxis));
    pd8->SetTopMargin(0.);

    pd8->Modified();
    pd8->Update();

  // Top Row
    pd1->GetPadPar(xl,yl,xu,yu);
    Printf("Original values: xl %f  xu %f  yl  %f  yu %f",xl,xu,yl,yu);
    pd1->SetPad(0,2.*innerPadHeight+marginBottom-marginBottomForYAxis,innerPadWidth+marginLeft,1.);
    pd1->SetLeftMargin(marginLeft/(marginLeft+innerPadWidth));
    pd1->SetRightMargin(0.);
    pd1->SetBottomMargin(marginBottomForYAxis/(innerPadHeight+marginBottomForYAxis+marginTop));
    pd1->SetTopMargin(marginTop/(innerPadHeight+marginTop));
    pd1->SetFillStyle(0);
    pd1->Modified();
    pd1->Update();

    pd2->GetPadPar(xl,yl,xu,yu);
    Printf("Original values: xl %f  xu %f  yl  %f  yu %f",xl,xu,yl,yu);
    pd2->SetPad(innerPadWidth+marginLeft-marginLeftForXAxis,2.*innerPadHeight+marginBottom-marginBottomForYAxis,2*innerPadWidth+marginLeft,1);
    pd2->SetLeftMargin(marginLeftForXAxis/(innerPadWidth+marginLeftForXAxis));
    pd2->SetFillStyle(0);
    pd2->SetRightMargin(0);
    pd2->SetBottomMargin(marginBottomForYAxis/(innerPadHeight+marginBottomForYAxis+marginTop));
    pd2->SetTopMargin(marginTop/(innerPadHeight+marginTop));

    pd3->GetPadPar(xl,yl,xu,yu);
    Printf("Original values: xl %f  xu %f  yl  %f  yu %f",xl,xu,yl,yu);
    pd3->SetPad(2*innerPadWidth+marginLeft-marginLeftForXAxis,2.*innerPadHeight+marginBottom-marginBottomForYAxis,3*innerPadWidth+marginLeft,1);
    pd3->SetLeftMargin(marginLeftForXAxis/(innerPadWidth+marginLeftForXAxis));
    pd3->SetRightMargin(0);
    pd3->SetBottomMargin(marginBottomForYAxis/(innerPadHeight+marginBottomForYAxis+marginTop));
    pd3->SetTopMargin(marginTop/(innerPadHeight+marginTop));
    pd3->SetFillStyle(0);

    pd4->GetPadPar(xl,yl,xu,yu);
    Printf("Original values: xl %f  xu %f  yl  %f  yu %f",xl,xu,yl,yu);
    pd4->SetPad(3*innerPadWidth+marginLeft-marginLeftForXAxis,2.*innerPadHeight+marginBottom-marginBottomForYAxis,1,1);
    pd4->SetLeftMargin(marginLeftForXAxis/(innerPadWidth+marginLeftForXAxis+marginRight));
    pd4->SetRightMargin(marginRight/(innerPadWidth+marginRight));
    pd4->SetBottomMargin(marginBottomForYAxis/(innerPadHeight+marginBottomForYAxis+marginTop));
    pd4->SetTopMargin(marginTop/(innerPadHeight+marginTop));
    pd4->SetFillStyle(0);

    scaleHeightPads=pd1->GetHNDC();
    scaleWidthPads=pd1->GetWNDC();

}


text:
<!DOCTYPE html>

<meta content="text/html; charset=utf-8" http-equiv="Content-Type">

<title>Rails Application Documentation</title>

<link type="text/css" media="screen" href="./rdoc.css" rel="stylesheet">

    Home
    Classes
    Methods

  <form action="#" method="get" accept-charset="utf-8">

      <input type="text" name="search" placeholder="Search" id="search-field"
             title="Type to search, Up and Down to navigate, Enter to load">

  </form>

Pages

README

Class and Module Index

AdminController

AdminHelper

ApplicationController

ApplicationHelper

Cart

CartsController

CartsHelper

CurrentCart

LineItem

LineItemsController

LineItemsHelper

Order

OrderNotifier

OrdersController

OrdersHelper

Product

ProductsController

ProductsHelper

SessionsController

SessionsHelper

StoreController

StoreHelper

User

UsersController

UsersHelper

This is the API documentation for Rails Application Documentation.

[Validate]

Generated by RDoc 3.12.2.

Generated with the Darkfish Rdoc Generator 3.


text:
namespace apigen
{
class type
{
public:
    type( const type& type ) = default;

    type( const clang::QualType& ctype );

    type( const clang::SourceManager&  source_manager,
          const clang::TypeSourceInfo* ctype );

    type( const clang::SourceManager& source_manager,
          const clang::SourceRange&   source_range );

    virtual ~type() = default;

    friend std ::ostream& operator<<( std::ostream& os,
                                      const type&   type );

    std::string str() const;

private:
    std::string _str;
};
}

#endif // ifndef APIGEN_TYPE_H


text:
package com.navercorp.pinpoint.profiler.instrument.mock;

import com.navercorp.pinpoint.bootstrap.interceptor.AroundInterceptor;

import java.util.Arrays;

public class ExceptionInterceptor implements AroundInterceptor {

    public static boolean before;
    public static boolean after;
    public static Object beforeTarget;
    public static Object[] beforeArgs;
    public static Object afterTarget;
    public static Object[] afterArgs;
    public static Object result;
    public static Throwable throwable;

    public static void clear() {
        before = false;
        after = false;
        beforeTarget = null;
        beforeArgs = null;
        afterTarget = null;
        afterArgs = null;
        result = null;
        throwable = null;
    }

    @Override
    public void before(Object target, Object[] args) {
        this.before = true;
        this.beforeTarget = target;
        this.beforeArgs = args;

        throw new RuntimeException("before exception");
    }

    @Override
    public void after(Object target, Object[] args, Object result, Throwable throwable) {
        this.after = true;
        this.afterTarget = target;
        this.afterArgs = args;
        this.result = result;
        this.throwable = throwable;

        throw new RuntimeException("after exception");
    }

    private String toArgs(Object[] args) {
        if (args == null) {
            return "null";
        }

        return Arrays.asList(args).toString();
    }

}


text:
require("firecast.lua");
local __o_rrpgObjs = require("rrpgObjs.lua");
require("rrpgGUI.lua");
require("rrpgDialogs.lua");
require("rrpgLFM.lua");
require("ndb.lua");
require("locale.lua");
local __o_Utils = require("utils.lua");

local function constructNew_frmFichaRPGmeister6ES_svg()
    local obj = GUI.fromHandle(_obj_newObject("form"));
    local self = obj;
    local sheet = nil;

    rawset(obj, "_oldSetNodeObjectFunction", rawget(obj, "setNodeObject"));

    function obj:setNodeObject(nodeObject)
        sheet = nodeObject;
        self.sheet = nodeObject;
        self:_oldSetNodeObjectFunction(nodeObject);
    end;

    function obj:setNodeDatabase(nodeObject)
        self:setNodeObject(nodeObject);
    end;

    _gui_assignInitialParentForForm(obj.handle);
    obj:beginUpdate();
    obj:setName("frmFichaRPGmeister6ES_svg");
    obj:setWidth(150);
    obj:setHeight(40);
    obj:setTheme("dark");
    obj:setMargins({top=3});

		local function use()
			local mesa = Firecast.getMesaDe(sheet);

			local texto = (sheet.nome or "Equipamento") .. " foi usado.";
			if sheet.cd~=nil then
				texto = texto .. " CD: " .. sheet.cd .. ".";
			end;

			if sheet.dados~=nil then
				local rolagem = Firecast.interpretarRolagem(sheet.dados);

				mesa.activeChat:rolarDados(rolagem, texto);
			end;

			if sheet.BarrinhaValor~=nil then
				sheet.BarrinhaValor = tonumber(sheet.BarrinhaValor) - 1;

				if sheet.dados==nil then
					mesa.activeChat:enviarMensagem(texto);
				end;
			end;
		end;

    obj.background = GUI.fromHandle(_obj_newObject("rectangle"));
    obj.background:setParent(obj);
    obj.background:setAlign("client");
    obj.background:setColor("#333333");
    obj.background:setHitTest(false);
    obj.background:setName("background");

    obj.button1 = GUI.fromHandle(_obj_newObject("button"));
    obj.button1:setParent(obj);
    obj.button1:setLeft(5);
    obj.button1:setTop(5);
    obj.button1:setWidth(20);
    obj.button1:setHeight(20);
    obj.button1:setText("U");
    obj.button1:setName("button1");

    obj.label1 = GUI.fromHandle(_obj_newObject("label"));
    obj.label1:setParent(obj);
    obj.label1:setLeft(5);
    obj.label1:setTop(0);
    obj.label1:setWidth(140);
    obj.label1:setHeight(25);
    obj.label1:setField("slot");
    obj.label1:setFontSize(16);
    obj.label1:setHorzTextAlign("center");
    obj.label1:setName("label1");

    obj.label2 = GUI.fromHandle(_obj_newObject("label"));
    obj.label2:setParent(obj);
    obj.label2:setLeft(5);
    obj.label2:setTop(25);
    obj.label2:setWidth(140);
    obj.label2:setHeight(15);
    obj.label2:setField("nome");
    obj.label2:setFontSize(9);
    obj.label2:setHorzTextAlign("center");
    obj.label2:setName("label2");

    obj._e_event0 = obj:addEventListener("onMouseEnter",
        function (_)
            self.background.color = "#444444";
        end, obj);

    obj._e_event1 = obj:addEventListener("onMouseLeave",
        function (_)
            self.background.color = "#333333";
        end, obj);

    obj._e_event2 = obj.button1:addEventListener("onClick",
        function (_)
            use();
        end, obj);

    function obj:_releaseEvents()
        __o_rrpgObjs.removeEventListenerById(self._e_event2);
        __o_rrpgObjs.removeEventListenerById(self._e_event1);
        __o_rrpgObjs.removeEventListenerById(self._e_event0);
    end;

    obj._oldLFMDestroy = obj.destroy;

    function obj:destroy()
        self:_releaseEvents();

        if (self.handle ~= 0) and (self.setNodeDatabase ~= nil) then
          self:setNodeDatabase(nil);
        end;

        if self.label2 ~= nil then self.label2:destroy(); self.label2 = nil; end;
        if self.background ~= nil then self.background:destroy(); self.background = nil; end;
        if self.button1 ~= nil then self.button1:destroy(); self.button1 = nil; end;
        if self.label1 ~= nil then self.label1:destroy(); self.label1 = nil; end;
        self:_oldLFMDestroy();
    end;

    obj:endUpdate();

    return obj;
end;

function newfrmFichaRPGmeister6ES_svg()
    local retObj = nil;
    __o_rrpgObjs.beginObjectsLoading();

    __o_Utils.tryFinally(
      function()
        retObj = constructNew_frmFichaRPGmeister6ES_svg();
      end,
      function()
        __o_rrpgObjs.endObjectsLoading();
      end);

    assert(retObj ~= nil);
    return retObj;
end;

local _frmFichaRPGmeister6ES_svg = {
    newEditor = newfrmFichaRPGmeister6ES_svg,
    new = newfrmFichaRPGmeister6ES_svg,
    name = "frmFichaRPGmeister6ES_svg",
    dataType = "",
    formType = "undefined",
    formComponentName = "form",
    title = "",
    description=""};

frmFichaRPGmeister6ES_svg = _frmFichaRPGmeister6ES_svg;
Firecast.registrarForm(_frmFichaRPGmeister6ES_svg);

return _frmFichaRPGmeister6ES_svg;


text:
package main

import (
	"context"
	"fmt"
	"io/ioutil"
	"log"
	"math/rand"
	"os"

	"github.com/cayleygraph/cayley"
	"github.com/cayleygraph/cayley/graph"
	_ "github.com/cayleygraph/cayley/graph/kv/bolt"
	"github.com/cayleygraph/cayley/schema"
	"github.com/cayleygraph/quad"
	"github.com/cayleygraph/quad/voc"

	// Import RDF vocabulary definitions to be able to expand IRIs like rdf:label.
	_ "github.com/cayleygraph/quad/voc/core"
)

type Person struct {
	// dummy field to enforce all object to have a <id> <rdf:type> <ex:Person> relation
	// means nothing for Go itself
	rdfType struct{} `quad:"@type > ex:Person"`
	ID      quad.IRI `json:"@id"`     // tag @id is a special one - graph node value will be stored in this field
	Name    string   `json:"ex:name"` // field name (predicate) may be written as json field name
	Age     int      `quad:"ex:age"`  // or in a quad tag
}

type Coords struct {
	// Object may be without id - it will be generated automatically.
	// It's also not necessary to have a type definition.
	Lat float64 `json:"ex:lat"`
	Lng float64 `json:"ex:lng"`
}

func checkErr(err error) {
	if err != nil {
		log.Fatal(err)
	}
}

func main() {
	// Define an "ex:" prefix for IRIs that will be expanded to "http://example.org".
	// "ex:name" will become "http://example.org/name"
	voc.RegisterPrefix("ex:", "http://example.org/")

	// Associate Go type with an IRI.
	// All Coords objects will now generate a <id> <rdf:type> <ex:Coords> triple.
	schema.RegisterType(quad.IRI("ex:Coords"), Coords{})

	sch := schema.NewConfig()
	// Override a function to generate IDs. Can be changed to generate UUIDs, for example.
	sch.GenerateID = func(_ interface{}) quad.Value {
		return quad.BNode(fmt.Sprintf("node%d", rand.Intn(1000)))
	}

	// File for your new BoltDB. Use path to regular file and not temporary in the real world
	tmpdir, err := ioutil.TempDir("", "example")
	checkErr(err)

	defer os.RemoveAll(tmpdir) // clean up

	// Initialize the database
	err = graph.InitQuadStore("bolt", tmpdir, nil)
	checkErr(err)

	// Open and use the database
	store, err := cayley.NewGraph("bolt", tmpdir, nil)
	checkErr(err)
	defer store.Close()
	qw := graph.NewWriter(store)

	// Save an object
	bob := Person{
		ID:   quad.IRI("ex:bob").Full().Short(),
		Name: "Bob", Age: 32,
	}
	fmt.Printf("saving: %+v\n", bob)
	id, err := sch.WriteAsQuads(qw, bob)
	checkErr(err)
	err = qw.Close()
	checkErr(err)

	fmt.Println("id for object:", id, "=", bob.ID) // should be equal

	// Get object by id
	var someone Person
	err = sch.LoadTo(nil, store, &someone, id)
	checkErr(err)
	fmt.Printf("loaded: %+v\n", someone)

	// Or get all objects of type Person
	var people []Person
	err = sch.LoadTo(nil, store, &people)
	checkErr(err)
	fmt.Printf("people: %+v\n", people)

	fmt.Println()

	// Store objects with no ID and type
	coords := []Coords{
		{Lat: 12.3, Lng: 34.5},
		{Lat: 39.7, Lng: 8.41},
	}
	qw = graph.NewWriter(store)
	for _, c := range coords {
		id, err = sch.WriteAsQuads(qw, c)
		checkErr(err)
		fmt.Println("generated id:", id)
	}
	err = qw.Close()
	checkErr(err)

	// Get coords back
	var newCoords []Coords
	err = sch.LoadTo(nil, store, &newCoords)
	checkErr(err)
	fmt.Printf("coords: %+v\n", newCoords)

	// Print quads
	fmt.Println("\nquads:")
	ctx := context.TODO()
	it := store.QuadsAllIterator().Iterate()
	defer it.Close()
	for it.Next(ctx) {
		fmt.Println(store.Quad(it.Result()))
	}
}