text:
#include "piterobject.h"
#include "plistobject.h"
/* for plist_getitem */

DEFINEFN vinfo_t* PsycoSeqIter_NEW(PsycoObject* po, vinfo_t* seq)
{
	vinfo_t* zero;
	vinfo_t* result = vinfo_new(VirtualTime_New(&psyco_computed_seqiter));
	result->array = array_new(SEQITER_TOTAL);
	result->array->items[iOB_TYPE] =
		vinfo_new(CompileTime_New((long)(&PySeqIter_Type)));
	/* the iterator index is immediately run-time because it is
	   very likely to be unpromoted to run-time anyway */
	zero = psyco_vi_Zero();
	result->array->items[iSEQITER_IT_INDEX] = make_runtime_copy(po, zero);
	vinfo_decref(zero, po);
	/*result->array->items[SEQITER_IT_INDEX] =
		vinfo_new(CompileTime_New(0));*/
	result->array->items[iSEQITER_IT_SEQ] = seq;
	return result;
}

static vinfo_t* piter_getiter(PsycoObject* po, vinfo_t* v)
{
	vinfo_incref(v);
	return v;
}

static vinfo_t* piter_iternext(PsycoObject* po, vinfo_t* v)
{
	vinfo_t* seq;
	vinfo_t* index;
	vinfo_t* result;
	PyTypeObject* tp;

	seq = psyco_get_const(po, v, SEQITER_it_seq);
	if (seq == NULL)
		return NULL;

	tp = Psyco_NeedType(po, seq);
	if (tp == NULL)
		return NULL;

	index = psyco_get_field(po, v, SEQITER_it_index);
	if (index == NULL)
		return NULL;
	assert_nonneg(index);

	if (PyType_IsSubtype(tp, &PyList_Type)) {
		/* If the sequence is a list, explicitly ignore a
		   user-overridden __getitem__ slot.  This is what both
		   Python 2.2 and >=2.3 do (although they use a
		   different trick to reach that effect). */
		result = plist_item(po, seq, index);
	}
	else {
		result = PsycoSequence_GetItem(po, seq, index);
	}
	if (result == NULL) {
		vinfo_t* matches = PycException_Matches(po, PyExc_IndexError);
		if (runtime_NON_NULL_t(po, matches) == true) {
			PycException_SetVInfo(po, PyExc_StopIteration,
					      psyco_vi_None());
		}
	}
	else {
		/* very remotely potential incompatibility: when exhausted,
		   the internal iterator index is not incremented. Python
		   is not consistent in this respect. This could be an
		   issue if an iterator of a mutable object is not
		   immediately deleted when exhausted. Well, I guess that
		   muting an object we iterate over is generally considered
		   as DDIWWY (Don't Do It -- We Warned You.)
		   (Update: Python 2.5 is consistent, and does the same
		   as Psyco.) */
		vinfo_t* index_plus_1 = integer_add_i(po, index, 1, true);
		if (index_plus_1 == NULL ||
		    !psyco_put_field(po, v, SEQITER_it_index, index_plus_1)) {
			vinfo_decref(result, po);
			result = NULL;
		}
		vinfo_xdecref(index_plus_1, po);
	}
	vinfo_decref(index, po);
	return result;
}

static bool compute_seqiter(PsycoObject* po, vinfo_t* v)
{
	vinfo_t* seq;
	vinfo_t* index;
	vinfo_t* newobj;

	index = vinfo_getitem(v, iSEQITER_IT_INDEX);
	if (index == NULL)
		return false;

	seq = vinfo_getitem(v, iSEQITER_IT_SEQ);
	if (seq == NULL)
		return false;

	newobj = psyco_generic_call(po, PySeqIter_New,
				    CfReturnRef|CfPyErrIfNull, "v", seq);
	if (newobj == NULL)
		return false;

	/* Put the current index into the seq iterator.
	   This is done by putting the value directly in the
	   seqiterobject structure; it could be done by calling
	   PyIter_Next() n times but obviously that's not too
	   good a solution */
	if (!psyco_knowntobe(index, 0)) {
		if (!psyco_put_field(po, newobj, SEQITER_it_index, index)) {
			vinfo_decref(newobj, po);
			return false;
		}
	}

	/* Remove the SEQITER_IT_INDEX entry from v->array because it
	   is a mutable field now, and could be changed at any time by
	   anybody .*/
	psyco_forget_field(po, v, SEQITER_it_index);

	vinfo_move(po, v, newobj);
	return true;
}

DEFINEVAR source_virtual_t psyco_computed_seqiter;

INITIALIZATIONFN
void psy_iterobject_init(void)
{
        Psyco_DefineMeta(PySeqIter_Type.tp_iter, &piter_getiter);
        Psyco_DefineMeta(PySeqIter_Type.tp_iternext, &piter_iternext);

        /* iterator object are mutable;
           they must be forced out of virtual-time across function calls */
        INIT_SVIRTUAL_NOCALL(psyco_computed_seqiter, compute_seqiter, 1);
}


text:
Terms of Reference
=====================================
1. Register
2. Login
3. Referral Opportunity Registration
4. Visibility new maseges (Ajax)

redpajama_set_name: RedPajamaGithub


text:
_id: 28bc03d0-4981-11e9-a3de-2dac567c917c
layout: idee
title: Die Zeit läuft!
desc: 'Entwickle ein Spiel, in dem du nur wenig Zeit, aber viele Möglichkeiten hast!'
themacontent: fs1
subtool: subtool3
link: >-
  https://thevirtualmirror.com/DerBlindband/index.php/2015/01/28/ethik-als-spielmechanik3-die-normative-kraft-des-ethischen
dauer: dauer-3
tags: Laptop
schwierigkeitsgrad: s-2
author-name: Matthias Löwe
author-email: ''
author-website: 'https://okfn.de/team/'
date: '2019-03-18T13:24:29.966Z'
slug: die-zeit-lauft
---
Zeitdruck ist eine häufige Spielmechanik. Entschärfe die Bombe, fliehe aus dem Raum, bevor er geflutet wird, oder lauf schneller als dein Gegenüber. Was aber, wenn die Zeit vergeht, aber kein Druck vorhanden ist? Stell z.B. einen normalen Tag dar und überlasse es den Spielenden, was sie tun: den ganzen Tag im Bett bleiben, Projekten nachgehen, sich um andere kümmern oder Geld verdienen? Am Ende gibt es eine Auswertung davon, was alles geschafft wurde. Vielleicht ist mehr schaffen aber nicht gleich mehr Erfolg? Wichtig ist jedenfalls, dass immer zu wenig Zeit zur Verfügung steht und du dich entscheiden musst. Ganz wie im realen Leben.


text:
<?php
namespace oasis\names\specification\ubl\schema\xsd\CommonAggregateComponents_2;

/**
 * @xmlNamespace urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2
 * @xmlType
 * @xmlName OrderedShipmentType
 * @var oasis\names\specification\ubl\schema\xsd\CommonAggregateComponents_2\OrderedShipmentType
 * @xmlComponentType ABIE
 * @xmlDictionaryEntryName Ordered Shipment. Details
 * @xmlDefinition Information about an Ordered Shipment.
 * @xmlObjectClass Ordered Shipment
 */
class OrderedShipmentType
{

    /**
     * @ComponentType ASBIE
     * @DictionaryEntryName Ordered Shipment. Shipment
     * @Definition An association to Shipment.
     * @Cardinality 1
     * @ObjectClass Ordered Shipment
     * @PropertyTerm Shipment
     * @AssociatedObjectClass Shipment
     * @xmlType element
     * @xmlNamespace urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2
     * @xmlMinOccurs 1
     * @xmlMaxOccurs 1
     * @xmlName Shipment
     * @var oasis\names\specification\ubl\schema\xsd\CommonAggregateComponents_2\Shipment
     */
    public $Shipment;
    /**
     * @ComponentType ASBIE
     * @DictionaryEntryName Ordered Shipment. Package
     * @Definition An association to Package.
     * @Cardinality 0..n
     * @ObjectClass Ordered Shipment
     * @PropertyTerm Package
     * @AssociatedObjectClass Package
     * @xmlType element
     * @xmlNamespace urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2
     * @xmlMinOccurs 0
     * @xmlMaxOccurs unbounded
     * @xmlName Package
     * @var oasis\names\specification\ubl\schema\xsd\CommonAggregateComponents_2\Package
     */
    public $Package;
} // end class OrderedShipmentType


text:
'use strict';

/**
 * @ngdoc overview
 * @name angularJsSampleApp
 * @description
 * # angularJsSampleApp
 *
 * Main module of the application.
 */
var app = angular
  .module('angularJsSampleApp', [
    'ngAnimate',
    'ngAria',
    'ngResource',
    'ngSanitize',
    'ngTouch',
    'ui.router'
  ]);

  app.config(function($stateProvider, $urlRouterProvider) {
    //
    // For any unmatched url, redirect to /state1
    $urlRouterProvider.otherwise('/');
    //
    // Now set up the states
    $stateProvider
      .state('main', {
        url: '/',
        templateUrl: 'views/main.html',
        controller: 'MainCtrl'
      });
  });


text:
class CMainFrame : public CMDIFrameWnd
{
    DECLARE_DYNAMIC(CMainFrame)
public:
    CMainFrame();

// Attributes
public:

// Operations
public:

// Implementation
public:
    virtual ~CMainFrame();
#ifdef _DEBUG
    virtual void AssertValid() const;
    virtual void Dump(CDumpContext& dc) const;
#endif

protected:  // control bar embedded members
    CStatusBar  m_wndStatusBar;
    CToolBar    m_wndToolBar;

// Generated message map functions
protected:
    //{{AFX_MSG(CMainFrame)
    afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	    // NOTE - the ClassWizard will add and remove member functions here.
	    //    DO NOT EDIT what you see in these blocks of generated code!
    //}}AFX_MSG
    DECLARE_MESSAGE_MAP()
};

/////////////////////////////////////////////////////////////////////////////


text:
package phone

import (
	"testing"

	. "github.com/smartystreets/goconvey/convey"
)

func TestCountryCallingCodes(t *testing.T) {
	Convey("CountryCallingCodes", t, func() {
		Convey("No duplicates", func() {
			seen := map[string]struct{}{}
			var duplicates []string
			for _, ccc := range CountryCallingCodes {
				_, ok := seen[ccc]
				if ok {
					duplicates = append(duplicates, ccc)
				}
				seen[ccc] = struct{}{}
			}
			So(duplicates, ShouldBeEmpty)
		})
	})
}


text:
import React from 'react'
import renderer from 'react-test-renderer'

import 'folioTestSetup'

import { Atoms } from '../'
import { SerializedAtom } from 'components/SerializedAtoms'

import atomsReducer, {
  atomsSelector,
  atomTypesSelector,
  initialState,
  setAtomsData
} from 'ducks/atoms'

import { SINGLE_LOCALE_ATOMS, MULTI_LOCALE_ATOMS } from 'constants/tests/atoms'

describe('Atoms', () => {
  it('single locale', () => {
    const state = { atoms: atomsReducer(initialState, setAtomsData(SINGLE_LOCALE_ATOMS)) }
    const props = {
      dispatch: () => {},
      atoms: atomsSelector(state),
      atomTypes: atomTypesSelector(state)
    }

    const component = renderer.create(<Atoms {...props} />)
    const atomForms = component.root.findAllByType(SerializedAtom)
    expect(atomForms.length).toEqual(6)
  })

  it('multiple locales', () => {
    const state = { atoms: atomsReducer(initialState, setAtomsData(MULTI_LOCALE_ATOMS)) }
    const props = {
      dispatch: () => {},
      atoms: atomsSelector(state),
      atomTypes: atomTypesSelector(state)
    }

    const component = renderer.create(<Atoms {...props} />)
    const atomForms = component.root.findAllByType(SerializedAtom)
    expect(atomForms.length).toEqual(2 * 6)
  })
})


text:
<?xml version="1.0" encoding="UTF-8"?>

<!-- Licensed to the Indoqa Software Design und Beratung GmbH (Indoqa) under
  one or more contributor license agreements. See the NOTICE file distributed
  with this work for additional information regarding copyright ownership.
  Indoqa licenses this file to You under the Apache License, Version 2.0 (the
  "License"); you may not use this file except in compliance with the License.
  You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
  Unless required by applicable law or agreed to in writing, software distributed
  under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
  OR CONDITIONS OF ANY KIND, either express or implied. See the License for
  the specific language governing permissions and limitations under the License. -->

<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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <packaging>jar</packaging>

  <parent>
    <groupId>com.indoqa</groupId>
    <artifactId>indoqa-oss-parent</artifactId>
    <version>3</version>
  </parent>

  <groupId>com.indoqa.solr</groupId>
  <artifactId>spring-server</artifactId>
  <version>4.10.1-SNAPSHOT</version>

  <name>Solr Spring Server</name>
  <description>A Solr Server Factory for Spring</description>

  <scm>
    <connection>scm:git:git@github.com:Indoqa/solr-spring-server.git</connection>
    <developerConnection>scm:git:git@github.com:Indoqa/solr-spring-server.git</developerConnection>
    <url>https://github.com/Indoqa/solr-spring-server</url>
    <tag>HEAD</tag>
  </scm>

  <licenses>
    <license>
      <name>Apache License 2.0</name>
      <url>http://www.apache.org/licenses/LICENSE-2.0</url>
      <distribution>repo</distribution>
    </license>
  </licenses>

  <properties>
    <project.build.compiler.version>1.6</project.build.compiler.version>

    <slf4j-version>1.7.7</slf4j-version>

    <solr-version>4.10.3</solr-version>

    <spring-version>3.1.1.RELEASE</spring-version>
  </properties>

  <dependencies>
    <!-- Solr -->
    <dependency>
      <groupId>org.apache.solr</groupId>
      <artifactId>solr-solrj</artifactId>
      <version>${solr-version}</version>
    </dependency>

    <!-- Optional Dependencies for Embedded Solr Servers -->
    <dependency>
      <groupId>org.apache.solr</groupId>
      <artifactId>solr-core</artifactId>
      <version>${solr-version}</version>
      <optional>true</optional>
    </dependency>

    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-beans</artifactId>
      <version>${spring-version}</version>
    </dependency>

    <!-- Testing -->
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.10</version>
      <scope>test</scope>
    </dependency>

    <!-- Logging -->
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>${slf4j-version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>jcl-over-slf4j</artifactId>
      <version>${slf4j-version}</version>
      <scope>provided</scope>
      <optional>true</optional>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>jul-to-slf4j</artifactId>
      <version>${slf4j-version}</version>
      <scope>provided</scope>
      <optional>true</optional>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.rat</groupId>
        <artifactId>apache-rat-plugin</artifactId>
        <configuration>
          <excludes>
            <exclude>**/bin/*</exclude>
            <exclude>README.md</exclude>
            <exclude>CONTRIBUTORS.txt</exclude>
            <exclude>**/_rest_managed.json</exclude>
            <exclude>**/solr.xml</exclude>
            <exclude>**/write.lock</exclude>
          </excludes>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>


text:
.. _following-latest:

=============================
 Following the latest source
=============================

These are the instructions if you just want to follow the latest
DIPY source, but you don't need to do any development for now.

The steps are:

* :ref:`install-git`
* get local copy of the `dipy github`_ git repository
* update local copy from time to time

Get the local copy of the code
==============================

From the command line::

   git clone git://github.com/nipy/dipy.git

You now have a copy of the code tree in the new ``dipy`` directory.

Updating the code
=================

From time to time you may want to pull down the latest code.  Do this with::

   cd dipy
   git pull

The tree in ``dipy`` will now have the latest changes from the initial
repository.

.. include:: links.inc


text:
days = 365
hours = 24
tot = days * hours
puts(tot.to_s + " hours per year.")

years = 10
mins = 60
output = tot * years * mins
puts(output.to_s + " minutes per decade.")


text:
package com.intellij.codeInsight.hints.filtering;

import javax.annotation.Nonnull;

import java.util.List;

/**
 * from kotlin
 */
public interface MethodMatcher {
  boolean isMatching(@Nonnull String fullyQualifiedMethodName, @Nonnull List<String> paramNames);
}


text:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    >
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="192dp"
        android:id="@+id/header"
        android:background="@drawable/layer_23"
        android:adjustViewBounds="true"
        android:scaleType="fitCenter"
        android:padding="16dp"
        android:theme="@style/ThemeOverlay.AppCompat.Dark"
        android:orientation="vertical">

        <TextView
            android:gravity="right"
            android:textSize="45sp"
            android:paddingTop="20dp"
            android:textStyle="italic"
            android:paddingRight="40dp"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/app_name"
            android:textColor="@android:color/white"
            android:textAppearance="@style/TextAppearance.AppCompat.Body1"/>

    </LinearLayout>
    <View
        android:layout_width="wrap_content"
        android:layout_height="5dp"
        android:background="@drawable/toolbar_shadow"></View>
</LinearLayout>


text:
<?php
	/********************************************************************/
	/*                                                                  */
	/*      Copyright (C) 2004 Arash Dejkam, All Rights Reserved.       */
	/*      http://www.tracewatch.com                                   */
	/*                                                                  */
	/*      Please read the licence file distributed with this          */
	/*      file or the one available at tracewatch.com for             */
	/*      the terms under which you can use or modify this file.      */
	/*                                                                  */
	/********************************************************************/

	global $ardeUser;

	require_once $ardeUser->path( 'lib/PassivePage.php' );

	$ardeUser->makeParentClass( 'ArdeUserPage', 'ArdeUserPassivePage' );

	class ArdeUserPage extends ArdeUserPageParent {

		private $configData;

		public $selectedLocaleId;

		protected function isAdminPage() { return false; }

		public function __construct() {
			global $ardeUser;
			require_once $ardeUser->path( 'data/DataGlobal.php' );
			$this->configData = array( ArdeUserConfig::$defaultProperties );
			parent::__construct();
		}

		protected function printInHtmlHead( ArdePrinter $p ) {
			global $ardeUser;
			parent::printInHtmlHead( $p );
			$p->pl( '<script type="text/javascript" src="'.$ardeUser->url( $this->getToRoot(), 'js/Global.js' ).'"></script>' );
		}

		protected function hasLangCont() {
			return true;
		}

		protected function isRightToLeft() {
			global $ardeUser;
			return $ardeUser->locale->rightToLeft;
		}

		protected function getPageTitle() {
			return '';
		}

		protected function getTitle() {
			global $ardeUser;
			return $ardeUser->locale->text( $this->getPageTitle() );
		}

		protected function getSelectedTopButton() { return 0; }

		protected function getTopButtons() {
			global $ardeUser;
			$topButtons = array();

			$url = new ArdeUrlWriter();
			$url->setParam( 'lang', $this->selectedLocaleId, $ardeUser->config->get( ArdeUserConfig::DEFAULT_LANG ) );
			$url->setParam( 'profile', $ardeUser->profile, 'default' );

			$i = 0;
			$url->setAddress( $ardeUser->url( $this->getToRoot(), '' ) );
			$topButtons[ $i++ ] = array( $ardeUser->locale->text( 'Your Account' ), $url->getUrl() );

			if( $ardeUser->user->id == ArdeUser::USER_PUBLIC || $this instanceof LoginPage ) {
				$url->setAddress( $ardeUser->url( $this->getToRoot(), 'login.php' ) );
				$topButtons[ $i++ ] = array( $ardeUser->locale->text( 'Login' ), $url->getUrl() );
			}
			if( $ardeUser->user->id != ArdeUser::USER_PUBLIC || $this instanceof LogoutPage ) {
				$url->setAddress( $ardeUser->url( $this->getToRoot(), 'logout.php' ) );
				$topButtons[ $i++ ] = array( $ardeUser->locale->text( 'Logout' ), $url->getUrl() );
			}

			if( $ardeUser->user->hasPermission( ArdeUserData::ADMINISTRATE ) ) {
				$url->setAddress( $ardeUser->url( $this->getToRoot(), 'admin/' ) );
				$topButtons[ $i++ ] = array( $ardeUser->locale->text( 'Administrate' ), $url->getUrl() );
			}

			return $topButtons;
		}

		protected function init() {
			global $ardeUser;

			$ardeUser->db = new ArdeDb( $ardeUser->settings );

			$ardeUser->db->connect();

			$ardeUser->config = new ArdeUserConfig( $ardeUser->db );

			foreach( $this->configData as $k => $v ) {
				$ardeUser->config->addDefaults( $this->configData[ $k ] );
			}
			$ardeUser->config->applyAllChanges();

			ArdeUserApp::initUser();

			if( isset( $_GET[ 'lang' ] ) && $ardeUser->localeExists( $_GET[ 'lang' ] ) ) {
				$this->selectedLocaleId = $_GET[ 'lang' ];
			} else {
				$this->selectedLocaleId = $ardeUser->config->get( ArdeUserConfig::DEFAULT_LANG );
			}
			$this->loadLocale();

			if( $this->isAdminPage() && !$ardeUser->user->hasPermission( ArdeUserData::ADMINISTRATE ) ) {
				$url = new ArdeUrlWriter( 'login.php' );
				$url->setParam( 'back', ardeRequestUri() )->setParam( 'profile', $ardeUser->profile, 'default' );

				if( $ardeUser->user->id == ArdeUser::USER_PUBLIC ) {
					ardeRedirect( $ardeUser->url( $this->getToRoot(), $url->getUrl() ) );
				} else {
					throw new ArdeUserError( 'You do not have permission.' );
				}
				return false;
			}
		}

		protected function loadLocale() {
			global $ardeUser;
			$ardeUser->loadLocale( $this->selectedLocaleId );
		}

		protected function printInLangCont( ArdePrinter $p ) {
			global $ardeUser;
			$p->pl( 'Language: <select id="lang_select">' );
			$url = ArdeUrlWriter::getCurrentRelative();
			$defaultId = $ardeUser->config->get( ArdeUserConfig::DEFAULT_LANG );

			foreach( $ardeUser->getLocaleIds() as $id ) {
				$url->setParam( 'lang', $id, $defaultId );
				$p->pl( '<option value="'.$url->getUrl().'"'.($id == $this->selectedLocaleId?' selected="selected"':'').'>'.$id.'</option>' );
			}
			$p->pl( '</select>' );
			$p->pl( '<script type="text/javascript">activateLinkSelect( "lang_select" );</script>' );
		}

	}

?>


text:
namespace o2::tpc
{

/// flags to set which corrections will be loaded from the CCDB
enum class CalibsdEdx : unsigned short {
  CalTopologySpline = 1 << 0,  ///< flag for a topology correction using splines
  CalTopologyPol = 1 << 1,     ///< flag for a topology correction using polynomials
  CalThresholdMap = 1 << 2,    ///< flag for using threshold map
  CalGainMap = 1 << 3,         ///< flag for using the gain map to get the correct cluster charge
  CalResidualGainMap = 1 << 4, ///< flag for applying residual gain map
  CalTimeGain = 1 << 5,        ///< flag for residual dE/dx time dependent gain correction
};

inline CalibsdEdx operator|(CalibsdEdx a, CalibsdEdx b) { return static_cast<CalibsdEdx>(static_cast<int>(a) | static_cast<int>(b)); }

inline CalibsdEdx operator&(CalibsdEdx a, CalibsdEdx b) { return static_cast<CalibsdEdx>(static_cast<int>(a) & static_cast<int>(b)); }

inline CalibsdEdx operator~(CalibsdEdx a) { return static_cast<CalibsdEdx>(~static_cast<int>(a)); }

///
/// This container class contains all necessary corrections for the dE/dx
/// Currently it holds the residual dE/dx correction and the track topology correction, which can be either provided by 2D-splines or by 5D-polynomials.
/// To be able to correctly use the flat buffer functionality only one of the topology corrections should be set: 2D-splines or by 5D-polynomials!
///   The track topology corrections are set as a nullptr for default as a member.
///   By loading only one of them memory overhead for the classes are avoided and appropriate flat buffer sizes are used.
///
class CalibdEdxContainer : public o2::gpu::FlatObject
{
 public:
  /// Default constructor: creates an empty uninitialized object
  CalibdEdxContainer() CON_DEFAULT;

  /// Copy constructor: disabled to avoid ambiguity. Use cloneFromObject() instead
  CalibdEdxContainer(const CalibdEdxContainer&) CON_DELETE;

  /// Assignment operator: disabled to avoid ambiguity. Use cloneFromObject() instead
  CalibdEdxContainer& operator=(const CalibdEdxContainer&) CON_DELETE;

  /// Destructor
  ~CalibdEdxContainer() CON_DEFAULT;

  /// \return returns the topology correction for the cluster charge
  /// \param region region of the TPC
  /// \param chargeT type of the charge (qMax or qTot)
  /// \param tanTheta local inclination angle tanTheta
  /// \param sinPhi snp track parameter
  /// \param z z position
  /// \param relPad relative pad position of the cluster
  /// \param relTime relative time position of the cluster
  /// \param threshold zero supression threshold
  /// \param charge charge of the cluster
  GPUd() float getTopologyCorrection(const int region, const ChargeType chargeT, const float tanTheta, const float sinPhi, const float z, const float relPad, const float relTime, const float threshold, const float charge) const
  {
    return mCalibTrackTopologyPol ? mCalibTrackTopologyPol->getCorrection(region, chargeT, tanTheta, sinPhi, z, relPad, relTime, threshold, charge) : (mCalibTrackTopologySpline ? mCalibTrackTopologySpline->getCorrection(region, chargeT, tanTheta, sinPhi, z) : getDefaultTopologyCorrection(tanTheta, sinPhi));
  }

  /// \return returns the topology correction for the cluster charge
  /// \param region region of the TPC
  /// \param chargeT type of the charge (qMax or qTot)
  /// \param x coordinates where the correction is evaluated
  GPUd() float getTopologyCorrection(const int region, const ChargeType chargeT, const float x[]) const
  {
    return mCalibTrackTopologyPol ? mCalibTrackTopologyPol->getCorrection(region, chargeT, x) : (mCalibTrackTopologySpline ? mCalibTrackTopologySpline->getCorrection(region, chargeT, x) : getDefaultTopologyCorrection(x[0], x[1]));
  }

  /// \return returns analytical default correction
  /// Correction corresponds to: "sqrt((dz/dx)^2 + (dy/dx)^2 + (dx/dx)^2) / padlength" simple track length correction (ToDo add division by pad length)
  GPUd() float getDefaultTopologyCorrection(const float tanTheta, const float sinPhi) const { return gpu::CAMath::Sqrt(tanTheta * tanTheta + 1 / (1 - sinPhi * sinPhi)); }

  /// \return returns maximum tanTheta for which the topology correction is valid
  GPUd() float getMaxTanThetaTopologyCorrection() const { return mCalibTrackTopologyPol ? mCalibTrackTopologyPol->getMaxTanTheta() : (mCalibTrackTopologySpline ? mCalibTrackTopologySpline->getMaxTanTheta() : 2); }

  /// \return returns maximum sinPhi for which the topology correction is valid
  GPUd() float getMaxSinPhiTopologyCorrection() const { return mCalibTrackTopologyPol ? mCalibTrackTopologyPol->getMaxSinPhi() : (mCalibTrackTopologySpline ? mCalibTrackTopologySpline->getMaxSinPhi() : 1); }

  /// \return returns the the minimum qTot for which the polynomials are valid
  GPUd() float getMinqTot() const { return mCalibTrackTopologyPol ? mCalibTrackTopologyPol->getMinqTot() : 0; };

  /// \return returns the the maximum qTot for which the polynomials are valid
  GPUd() float getMaxqTot() const { return mCalibTrackTopologyPol ? mCalibTrackTopologyPol->getMaxqTot() : 10000; };

#if !defined(GPUCA_GPUCODE)
  /// \returns the minimum zero supression threshold for which the track topology correction is valid
  float getMinZeroSupresssionThreshold() const;

  /// \returns the maximum zero supression threshold for which the track topology correction is valid
  float getMaxZeroSupresssionThreshold() const;
#endif

  /// \return returns zero supression threshold
  /// \param sector tpc sector
  /// \param row global pad row
  GPUd() float getZeroSupressionThreshold(const int sector, const gpu::tpccf::Row row, const gpu::tpccf::Pad pad) const { return mThresholdMap.getGainCorrection(sector, row, pad); }

  /// \return returns gain from the full gain map
  /// \param sector tpc sector
  /// \param row global pad row
  GPUd() float getGain(const int sector, const gpu::tpccf::Row row, const gpu::tpccf::Pad pad) const { return mGainMap.getGainCorrection(sector, row, pad); }

  /// \return returns gain from residual gain map
  /// \param sector tpc sector
  /// \param row global pad row
  GPUd() float getResidualGain(const int sector, const gpu::tpccf::Row row, const gpu::tpccf::Pad pad) const { return mGainMapResidual.getGainCorrection(sector, row, pad); }

  /// \return returns the residual dE/dx correction for the cluster charge
  /// \param stack ID of the GEM stack
  /// \param charge type of the charge (qMax or qTot)
  /// \param z z position
  /// \param tgl tracking parameter tgl
  GPUd() float getResidualCorrection(const StackID& stack, const ChargeType charge, const float tgl = 0, const float snp = 0) const { return mCalibResidualdEdx.getCorrection(stack, charge, tgl, snp); }

  /// \return returns if the full gain map will be used during the calculation of the dE/dx to correct the cluster charge
  GPUd() bool isUsageOfFullGainMap() const { return mApplyFullGainMap; }

  /// ========== FlatObject functionality, see FlatObject class for description  =================
#if !defined(GPUCA_GPUCODE)
  /// cloning a container object (use newFlatBufferPtr=nullptr for simple copy)
  void cloneFromObject(const CalibdEdxContainer& obj, char* newFlatBufferPtr);

  /// move flat buffer to new location
  /// \param newBufferPtr new buffer location
  void moveBufferTo(char* newBufferPtr);
#endif

  /// destroy the object (release internal flat buffer)
  void destroy();

  /// set location of external flat buffer
  void setActualBufferAddress(char* actualFlatBufferPtr);

  /// set future location of the flat buffer
  void setFutureBufferAddress(char* futureFlatBufferPtr);
  /// ================================================================================================

#if !defined(GPUCA_GPUCODE) && !defined(GPUCA_STANDALONE)
  // loading the polynomial track topology correction from a file
  /// \param fileName input file containing the correction
  void loadPolTopologyCorrectionFromFile(std::string_view fileName);

  // loading the spline track topology correction from a file
  /// \param fileName input file containing the correction
  void loadSplineTopologyCorrectionFromFile(std::string_view fileName);

  /// set the polynomial track topology
  /// \param calibTrackTopology polynomial track topology correction
  void setPolTopologyCorrection(const CalibdEdxTrackTopologyPol& calibTrackTopology);

  /// setting a default topology correction which just returns 1
  void setDefaultPolTopologyCorrection();

  /// set the spline track topology
  /// \param calibTrackTopology spline track topology correction
  void setSplineTopologyCorrection(const CalibdEdxTrackTopologySpline& calibTrackTopology);

  // loading the residual dE/dx correction from a file
  /// \param fileName input file containing the correction
  void loadResidualCorrectionFromFile(std::string_view fileName) { mCalibResidualdEdx.loadFromFile(fileName); }

  /// setting the residual dEdx correction
  /// \param residualCorr residual gain calibration object
  void setResidualCorrection(const CalibdEdxCorrection& residualCorr) { mCalibResidualdEdx = residualCorr; }

  // loading the zero supression threshold map from a file
  /// \param fileName input file containing the CalDet map
  void loadZeroSupresssionThresholdFromFile(std::string_view fileName, std::string_view objName, const float minCorrectionFactor, const float maxCorrectionFactor);

  /// setting the zero supression threshold map from a CalDet
  /// \param thresholdMap CalDet containing the zero supression threshold
  void setZeroSupresssionThreshold(const CalDet<float>& thresholdMap) { setZeroSupresssionThreshold(thresholdMap, getMinZeroSupresssionThreshold(), getMaxZeroSupresssionThreshold()); }

  /// setting the zero supression threshold map from a CalDet
  /// \param thresholdMap CalDet containing the zero supression threshold
  void setZeroSupresssionThreshold(const CalDet<float>& thresholdMap, const float minCorrectionFactor, const float maxCorrectionFactor);

  /// setting the gain map map from a CalDet
  void setGainMap(const CalDet<float>& gainMap, const float minGain, const float maxGain);

  /// setting the gain map map from a CalDet
  void setGainMapResidual(const CalDet<float>& gainMapResidual, const float minResidualGain = 0.7f, const float maxResidualGain = 1.3f);

  /// setting default zero supression threshold map (all values are set to getMinZeroSupresssionThreshold())
  /// \param fileName input file containing the CalDet map
  void setDefaultZeroSupresssionThreshold();

  /// returns status if the spline correction is set
  bool isTopologyCorrectionSplinesSet() const { return mCalibTrackTopologySpline ? true : false; }

  /// returns status if the polynomials correction is set
  bool isTopologyCorrectionPolynomialsSet() const { return mCalibTrackTopologyPol ? true : false; }

  /// set loading of a correction from CCDB
  /// \param calib calibration which will be loaded from CCDB
  void setCorrectionCCDB(const CalibsdEdx calib) { mCalibsLoad = calib | mCalibsLoad; }

  /// disable loading of a correction from CCDB
  /// \param calib calibration which will not be loaded from CCDB
  void disableCorrectionCCDB(const CalibsdEdx calib) { mCalibsLoad = ~calib & mCalibsLoad; }

  /// check if a correction will be loaded from CCDB
  /// \param calib calibration which will be loaded from CCDB
  bool isCorrectionCCDB(const CalibsdEdx calib) const { return ((mCalibsLoad & calib) == calib) ? true : false; }

  /// \param applyFullGainMap if set to true the cluster charge will be corrected with the full gain map
  void setUsageOfFullGainMap(const bool applyFullGainMap) { mApplyFullGainMap = applyFullGainMap; }
#endif // !GPUCA_GPUCODE

 private:
  CalibdEdxTrackTopologySpline* mCalibTrackTopologySpline{nullptr};                                                                                ///< calibration for the track topology correction (splines)
  CalibdEdxTrackTopologyPol* mCalibTrackTopologyPol{nullptr};                                                                                ///< calibration for the track topology correction (polynomial)
  o2::gpu::TPCPadGainCalib mThresholdMap{};                                                                                ///< calibration object containing the zero supression threshold map
  o2::gpu::TPCPadGainCalib mGainMap{};                                                                                ///< calibration object containing the gain map
  o2::gpu::TPCPadGainCalib mGainMapResidual{};                                                                                ///< calibration object containing the residual gain map
  CalibdEdxCorrection mCalibResidualdEdx{};                                                                                ///< calibration for the residual dE/dx correction
  bool mApplyFullGainMap{false};                                                                                ///< if set to true the cluster charge will be corrected with the full gain map (when the gain map was not applied during the clusterizer)
  CalibsdEdx mCalibsLoad{CalibsdEdx::CalTopologyPol | CalibsdEdx::CalThresholdMap | CalibsdEdx::CalGainMap | CalibsdEdx::CalResidualGainMap | CalibsdEdx::CalTimeGain}; ///< flags to set which corrections will be loaded from the CCDB and used during calculation of the dE/dx

#if !defined(GPUCA_GPUCODE)
  template <class Type>
  std::size_t sizeOfCalibdEdxTrackTopologyObj() const
  {
    return alignSize(sizeof(Type), FlatObject::getClassAlignmentBytes());
  }

  template <class Type>
  void loadTopologyCorrectionFromFile(std::string_view fileName, Type*& obj);

  template <class Type>
  void setTopologyCorrection(const Type& calibTrackTopologyTmp, Type*& obj);
#endif

  template <class Type>
  void setActualBufferAddress(Type*& obj);

  template <class Type>
  void setFutureBufferAddress(Type*& obj, char* futureFlatBufferPtr);

#if !defined(GPUCA_GPUCODE)
  template <class Type>
  void subobjectCloneFromObject(Type*& obj, const Type* objOld);

  /// this functions 'smoothes' a CalDet by calculating for each value in a pad the average value using the neighbouring pads, but do not take into account the current pad
  /// \return returns 'smoothed' CalDet object
  /// \param thresholdMap zero supression threshold map which will be 'smoothed'
  /// \param maxThreshold max threshold value which will be considered for averaging
  /// \param nPadsInRowCl number of pads in row direction which will be taken into account (+- nPadsInRowCl)
  /// \param nPadsInPadCl number of pads in pad direction which will be taken into account (+- nPadsInPadCl)
  CalDet<float> processThresholdMap(const CalDet<float>& thresholdMap, const float maxThreshold, const int nPadsInRowCl = 2, const int nPadsInPadCl = 2) const;
#endif

#ifndef GPUCA_ALIROOT_LIB
  ClassDefNV(CalibdEdxContainer, 1);
#endif
};

} // namespace o2::tpc

#endif