<commit_before>// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc.  All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
//     * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//     * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//     * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include <unordered_map>

#include <Python.h>

#include <google/protobuf/dynamic_message.h>
#include <google/protobuf/pyext/descriptor.h>
#include <google/protobuf/pyext/message.h>
#include <google/protobuf/pyext/message_factory.h>
#include <google/protobuf/pyext/scoped_pyobject_ptr.h>

#if PY_MAJOR_VERSION >= 3
  #if PY_VERSION_HEX < 0x03030000
    #error "Python 3.0 - 3.2 are not supported."
  #endif
  #define PyString_AsStringAndSize(ob, charpp, sizep) \
    (PyUnicode_Check(ob)? \
       ((*(charpp) = PyUnicode_AsUTF8AndSize(ob, (sizep))) == NULL? -1: 0): \
       PyBytes_AsStringAndSize(ob, (charpp), (sizep)))
#endif

namespace google {
namespace protobuf {
namespace python {

namespace message_factory {

PyMessageFactory* NewMessageFactory(PyTypeObject* type, PyDescriptorPool* pool) {
  PyMessageFactory* factory = reinterpret_cast<PyMessageFactory*>(
      PyType_GenericAlloc(type, 0));
  if (factory == NULL) {
    return NULL;
  }

  DynamicMessageFactory* message_factory = new DynamicMessageFactory();
  // This option might be the default some day.
  message_factory->SetDelegateToGeneratedFactory(true);
  factory->message_factory = message_factory;

  factory->pool = pool;
  // TODO(amauryfa): When the MessageFactory is not created from the
  // DescriptorPool this reference should be owned, not borrowed.
  // Py_INCREF(pool);

  factory->classes_by_descriptor = new PyMessageFactory::ClassesByMessageMap();

  return factory;
}

PyObject* New(PyTypeObject* type, PyObject* args, PyObject* kwargs) {
  static char* kwlist[] = {"pool", 0};
  PyObject* pool = NULL;
  if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O", kwlist, &pool)) {
    return NULL;
  }
  ScopedPyObjectPtr owned_pool;
  if (pool == NULL || pool == Py_None) {
    owned_pool.reset(PyObject_CallFunction(
        reinterpret_cast<PyObject*>(&PyDescriptorPool_Type), NULL));
    if (owned_pool == NULL) {
      return NULL;
    }
    pool = owned_pool.get();
  } else {
    if (!PyObject_TypeCheck(pool, &PyDescriptorPool_Type)) {
      PyErr_Format(PyExc_TypeError, "Expected a DescriptorPool, got %s",
                   pool->ob_type->tp_name);
      return NULL;
    }
  }

  return reinterpret_cast<PyObject*>(
      NewMessageFactory(type, reinterpret_cast<PyDescriptorPool*>(pool)));
}

static void Dealloc(PyObject* pself) {
  PyMessageFactory* self = reinterpret_cast<PyMessageFactory*>(pself);

  // TODO(amauryfa): When the MessageFactory is not created from the
  // DescriptorPool this reference should be owned, not borrowed.
  // Py_CLEAR(self->pool);
  typedef PyMessageFactory::ClassesByMessageMap::iterator iterator;
  for (iterator it = self->classes_by_descriptor->begin();
       it != self->classes_by_descriptor->end(); ++it) {
    Py_DECREF(it->second);
  }
  delete self->classes_by_descriptor;
  delete self->message_factory;
  Py_TYPE(self)->tp_free(pself);
}

// Add a message class to our database.
int RegisterMessageClass(PyMessageFactory* self,
                         const Descriptor* message_descriptor,
                         CMessageClass* message_class) {
  Py_INCREF(message_class);
  typedef PyMessageFactory::ClassesByMessageMap::iterator iterator;
  std::pair<iterator, bool> ret = self->classes_by_descriptor->insert(
      std::make_pair(message_descriptor, message_class));
  if (!ret.second) {
    // Update case: DECREF the previous value.
    Py_DECREF(ret.first->second);
    ret.first->second = message_class;
  }
  return 0;
}

CMessageClass* GetOrCreateMessageClass(PyMessageFactory* self,
                                       const Descriptor* descriptor) {
  // This is the same implementation as MessageFactory.GetPrototype().

  // Do not create a MessageClass that already exists.
  std::unordered_map<const Descriptor*, CMessageClass*>::iterator it =
      self->classes_by_descriptor->find(descriptor);
  if (it != self->classes_by_descriptor->end()) {
    Py_INCREF(it->second);
    return it->second;
  }
  ScopedPyObjectPtr py_descriptor(
      PyMessageDescriptor_FromDescriptor(descriptor));
  if (py_descriptor == NULL) {
    return NULL;
  }
  // Create a new message class.
  ScopedPyObjectPtr args(Py_BuildValue(
      "s(){sOsOsO}", descriptor->name().c_str(),
      "DESCRIPTOR", py_descriptor.get(),
      "__module__", Py_None,
      "message_factory", self));
  if (args == NULL) {
    return NULL;
  }
  ScopedPyObjectPtr message_class(PyObject_CallObject(
      reinterpret_cast<PyObject*>(CMessageClass_Type), args.get()));
  if (message_class == NULL) {
    return NULL;
  }
  // Create messages class for the messages used by the fields, and registers
  // all extensions for these messages during the recursion.
  for (int field_idx = 0; field_idx < descriptor->field_count(); field_idx++) {
    const Descriptor* sub_descriptor =
        descriptor->field(field_idx)->message_type();
    // It is NULL if the field type is not a message.
    if (sub_descriptor != NULL) {
      CMessageClass* result = GetOrCreateMessageClass(self, sub_descriptor);
      if (result == NULL) {
        return NULL;
      }
      Py_DECREF(result);
    }
  }

  // Register extensions defined in this message.
  for (int ext_idx = 0 ; ext_idx < descriptor->extension_count() ; ext_idx++) {
    const FieldDescriptor* extension = descriptor->extension(ext_idx);
    ScopedPyObjectPtr py_extended_class(
        GetOrCreateMessageClass(self, extension->containing_type())
            ->AsPyObject());
    if (py_extended_class == NULL) {
      return NULL;
    }
    ScopedPyObjectPtr py_extension(PyFieldDescriptor_FromDescriptor(extension));
    if (py_extension == NULL) {
      return NULL;
    }
    ScopedPyObjectPtr result(cmessage::RegisterExtension(
        py_extended_class.get(), py_extension.get()));
    if (result == NULL) {
      return NULL;
    }
  }
  return reinterpret_cast<CMessageClass*>(message_class.release());
}

// Retrieve the message class added to our database.
CMessageClass* GetMessageClass(PyMessageFactory* self,
                               const Descriptor* message_descriptor) {
  typedef PyMessageFactory::ClassesByMessageMap::iterator iterator;
  iterator ret = self->classes_by_descriptor->find(message_descriptor);
  if (ret == self->classes_by_descriptor->end()) {
    PyErr_Format(PyExc_TypeError, "No message class registered for '%s'",
                 message_descriptor->full_name().c_str());
    return NULL;
  } else {
    return ret->second;
  }
}

static PyMethodDef Methods[] = {
    {NULL}};

static PyObject* GetPool(PyMessageFactory* self, void* closure) {
  Py_INCREF(self->pool);
  return reinterpret_cast<PyObject*>(self->pool);
}

static PyGetSetDef Getters[] = {
    {"pool", (getter)GetPool, NULL, "DescriptorPool"},
    {NULL}
};

}  // namespace message_factory

PyTypeObject PyMessageFactory_Type = {
    PyVarObject_HEAD_INIT(&PyType_Type, 0) FULL_MODULE_NAME
    ".MessageFactory",                        // tp_name
    sizeof(PyMessageFactory),                 // tp_basicsize
    0,                                        // tp_itemsize
    message_factory::Dealloc,                 // tp_dealloc
    0,                                        // tp_print
    0,                                        // tp_getattr
    0,                                        // tp_setattr
    0,                                        // tp_compare
    0,                                        // tp_repr
    0,                                        // tp_as_number
    0,                                        // tp_as_sequence
    0,                                        // tp_as_mapping
    0,                                        // tp_hash
    0,                                        // tp_call
    0,                                        // tp_str
    0,                                        // tp_getattro
    0,                                        // tp_setattro
    0,                                        // tp_as_buffer
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,  // tp_flags
    "A static Message Factory",               // tp_doc
    0,                                        // tp_traverse
    0,                                        // tp_clear
    0,                                        // tp_richcompare
    0,                                        // tp_weaklistoffset
    0,                                        // tp_iter
    0,                                        // tp_iternext
    message_factory::Methods,                 // tp_methods
    0,                                        // tp_members
    message_factory::Getters,                 // tp_getset
    0,                                        // tp_base
    0,                                        // tp_dict
    0,                                        // tp_descr_get
    0,                                        // tp_descr_set
    0,                                        // tp_dictoffset
    0,                                        // tp_init
    0,                                        // tp_alloc
    message_factory::New,                     // tp_new
    PyObject_Del,                             // tp_free
};

bool InitMessageFactory() {
  if (PyType_Ready(&PyMessageFactory_Type) < 0) {
    return false;
  }

  return true;
}

}  // namespace python
}  // namespace protobuf
}  // namespace google
<commit_msg>pyext: missing cast to constant char* (#5713)<commit_after>// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc.  All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
//     * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//     * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//     * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include <unordered_map>

#include <Python.h>

#include <google/protobuf/dynamic_message.h>
#include <google/protobuf/pyext/descriptor.h>
#include <google/protobuf/pyext/message.h>
#include <google/protobuf/pyext/message_factory.h>
#include <google/protobuf/pyext/scoped_pyobject_ptr.h>

#if PY_MAJOR_VERSION >= 3
  #if PY_VERSION_HEX < 0x03030000
    #error "Python 3.0 - 3.2 are not supported."
  #endif
  #define PyString_AsStringAndSize(ob, charpp, sizep) \
    (PyUnicode_Check(ob) ? ((*(charpp) = const_cast<char*>(                   \
                               PyUnicode_AsUTF8AndSize(ob, (sizep)))) == NULL \
                              ? -1                                            \
                              : 0)                                            \
                        : PyBytes_AsStringAndSize(ob, (charpp), (sizep)))
#endif

namespace google {
namespace protobuf {
namespace python {

namespace message_factory {

PyMessageFactory* NewMessageFactory(PyTypeObject* type, PyDescriptorPool* pool) {
  PyMessageFactory* factory = reinterpret_cast<PyMessageFactory*>(
      PyType_GenericAlloc(type, 0));
  if (factory == NULL) {
    return NULL;
  }

  DynamicMessageFactory* message_factory = new DynamicMessageFactory();
  // This option might be the default some day.
  message_factory->SetDelegateToGeneratedFactory(true);
  factory->message_factory = message_factory;

  factory->pool = pool;
  // TODO(amauryfa): When the MessageFactory is not created from the
  // DescriptorPool this reference should be owned, not borrowed.
  // Py_INCREF(pool);

  factory->classes_by_descriptor = new PyMessageFactory::ClassesByMessageMap();

  return factory;
}

PyObject* New(PyTypeObject* type, PyObject* args, PyObject* kwargs) {
  static char* kwlist[] = {"pool", 0};
  PyObject* pool = NULL;
  if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O", kwlist, &pool)) {
    return NULL;
  }
  ScopedPyObjectPtr owned_pool;
  if (pool == NULL || pool == Py_None) {
    owned_pool.reset(PyObject_CallFunction(
        reinterpret_cast<PyObject*>(&PyDescriptorPool_Type), NULL));
    if (owned_pool == NULL) {
      return NULL;
    }
    pool = owned_pool.get();
  } else {
    if (!PyObject_TypeCheck(pool, &PyDescriptorPool_Type)) {
      PyErr_Format(PyExc_TypeError, "Expected a DescriptorPool, got %s",
                   pool->ob_type->tp_name);
      return NULL;
    }
  }

  return reinterpret_cast<PyObject*>(
      NewMessageFactory(type, reinterpret_cast<PyDescriptorPool*>(pool)));
}

static void Dealloc(PyObject* pself) {
  PyMessageFactory* self = reinterpret_cast<PyMessageFactory*>(pself);

  // TODO(amauryfa): When the MessageFactory is not created from the
  // DescriptorPool this reference should be owned, not borrowed.
  // Py_CLEAR(self->pool);
  typedef PyMessageFactory::ClassesByMessageMap::iterator iterator;
  for (iterator it = self->classes_by_descriptor->begin();
       it != self->classes_by_descriptor->end(); ++it) {
    Py_DECREF(it->second);
  }
  delete self->classes_by_descriptor;
  delete self->message_factory;
  Py_TYPE(self)->tp_free(pself);
}

// Add a message class to our database.
int RegisterMessageClass(PyMessageFactory* self,
                         const Descriptor* message_descriptor,
                         CMessageClass* message_class) {
  Py_INCREF(message_class);
  typedef PyMessageFactory::ClassesByMessageMap::iterator iterator;
  std::pair<iterator, bool> ret = self->classes_by_descriptor->insert(
      std::make_pair(message_descriptor, message_class));
  if (!ret.second) {
    // Update case: DECREF the previous value.
    Py_DECREF(ret.first->second);
    ret.first->second = message_class;
  }
  return 0;
}

CMessageClass* GetOrCreateMessageClass(PyMessageFactory* self,
                                       const Descriptor* descriptor) {
  // This is the same implementation as MessageFactory.GetPrototype().

  // Do not create a MessageClass that already exists.
  std::unordered_map<const Descriptor*, CMessageClass*>::iterator it =
      self->classes_by_descriptor->find(descriptor);
  if (it != self->classes_by_descriptor->end()) {
    Py_INCREF(it->second);
    return it->second;
  }
  ScopedPyObjectPtr py_descriptor(
      PyMessageDescriptor_FromDescriptor(descriptor));
  if (py_descriptor == NULL) {
    return NULL;
  }
  // Create a new message class.
  ScopedPyObjectPtr args(Py_BuildValue(
      "s(){sOsOsO}", descriptor->name().c_str(),
      "DESCRIPTOR", py_descriptor.get(),
      "__module__", Py_None,
      "message_factory", self));
  if (args == NULL) {
    return NULL;
  }
  ScopedPyObjectPtr message_class(PyObject_CallObject(
      reinterpret_cast<PyObject*>(CMessageClass_Type), args.get()));
  if (message_class == NULL) {
    return NULL;
  }
  // Create messages class for the messages used by the fields, and registers
  // all extensions for these messages during the recursion.
  for (int field_idx = 0; field_idx < descriptor->field_count(); field_idx++) {
    const Descriptor* sub_descriptor =
        descriptor->field(field_idx)->message_type();
    // It is NULL if the field type is not a message.
    if (sub_descriptor != NULL) {
      CMessageClass* result = GetOrCreateMessageClass(self, sub_descriptor);
      if (result == NULL) {
        return NULL;
      }
      Py_DECREF(result);
    }
  }

  // Register extensions defined in this message.
  for (int ext_idx = 0 ; ext_idx < descriptor->extension_count() ; ext_idx++) {
    const FieldDescriptor* extension = descriptor->extension(ext_idx);
    ScopedPyObjectPtr py_extended_class(
        GetOrCreateMessageClass(self, extension->containing_type())
            ->AsPyObject());
    if (py_extended_class == NULL) {
      return NULL;
    }
    ScopedPyObjectPtr py_extension(PyFieldDescriptor_FromDescriptor(extension));
    if (py_extension == NULL) {
      return NULL;
    }
    ScopedPyObjectPtr result(cmessage::RegisterExtension(
        py_extended_class.get(), py_extension.get()));
    if (result == NULL) {
      return NULL;
    }
  }
  return reinterpret_cast<CMessageClass*>(message_class.release());
}

// Retrieve the message class added to our database.
CMessageClass* GetMessageClass(PyMessageFactory* self,
                               const Descriptor* message_descriptor) {
  typedef PyMessageFactory::ClassesByMessageMap::iterator iterator;
  iterator ret = self->classes_by_descriptor->find(message_descriptor);
  if (ret == self->classes_by_descriptor->end()) {
    PyErr_Format(PyExc_TypeError, "No message class registered for '%s'",
                 message_descriptor->full_name().c_str());
    return NULL;
  } else {
    return ret->second;
  }
}

static PyMethodDef Methods[] = {
    {NULL}};

static PyObject* GetPool(PyMessageFactory* self, void* closure) {
  Py_INCREF(self->pool);
  return reinterpret_cast<PyObject*>(self->pool);
}

static PyGetSetDef Getters[] = {
    {"pool", (getter)GetPool, NULL, "DescriptorPool"},
    {NULL}
};

}  // namespace message_factory

PyTypeObject PyMessageFactory_Type = {
    PyVarObject_HEAD_INIT(&PyType_Type, 0) FULL_MODULE_NAME
    ".MessageFactory",                        // tp_name
    sizeof(PyMessageFactory),                 // tp_basicsize
    0,                                        // tp_itemsize
    message_factory::Dealloc,                 // tp_dealloc
    0,                                        // tp_print
    0,                                        // tp_getattr
    0,                                        // tp_setattr
    0,                                        // tp_compare
    0,                                        // tp_repr
    0,                                        // tp_as_number
    0,                                        // tp_as_sequence
    0,                                        // tp_as_mapping
    0,                                        // tp_hash
    0,                                        // tp_call
    0,                                        // tp_str
    0,                                        // tp_getattro
    0,                                        // tp_setattro
    0,                                        // tp_as_buffer
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,  // tp_flags
    "A static Message Factory",               // tp_doc
    0,                                        // tp_traverse
    0,                                        // tp_clear
    0,                                        // tp_richcompare
    0,                                        // tp_weaklistoffset
    0,                                        // tp_iter
    0,                                        // tp_iternext
    message_factory::Methods,                 // tp_methods
    0,                                        // tp_members
    message_factory::Getters,                 // tp_getset
    0,                                        // tp_base
    0,                                        // tp_dict
    0,                                        // tp_descr_get
    0,                                        // tp_descr_set
    0,                                        // tp_dictoffset
    0,                                        // tp_init
    0,                                        // tp_alloc
    message_factory::New,                     // tp_new
    PyObject_Del,                             // tp_free
};

bool InitMessageFactory() {
  if (PyType_Ready(&PyMessageFactory_Type) < 0) {
    return false;
  }

  return true;
}

}  // namespace python
}  // namespace protobuf
}  // namespace google
<|endoftext|>


<commit_before>/* -------------------------------------------------------------------------- *
 *                       OpenSim:  testFunctions.cpp                          *
 * -------------------------------------------------------------------------- *
 * The OpenSim API is a toolkit for musculoskeletal modeling and simulation.  *
 * See http://opensim.stanford.edu and the NOTICE file for more information.  *
 * OpenSim is developed at Stanford University and supported by the US        *
 * National Institutes of Health (U54 GM072970, R24 HD065690) and by DARPA    *
 * through the Warrior Web program.                                           *
 *                                                                            *
 * Copyright (c) 2005-2017 Stanford University and the Authors                *
 * Author(s): Christopher Dembia                                              *
 *                                                                            *
 * Licensed 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.                                             *
 * -------------------------------------------------------------------------- */

#include <OpenSim/Common/Sine.h>
#include <OpenSim/Common/SignalGenerator.h>
#include <OpenSim/Common/Reporter.h>

#include "ComponentsForTesting.h"

using namespace OpenSim;
using namespace SimTK;

void testSignalGenerator() {
    // Feed a SignalGenerator's output into a TableReporter, and make sure the
    // reported value is correct.

    // Build the model.
    RootComponent world;
    auto* signalGen = new SignalGenerator();
    signalGen->setName("sinusoid");
    const double amplitude = 1.5;
    const double omega = 3.1;
    const double phase = 0.3;
    signalGen->set_function(Sine(amplitude, omega, phase));
    world.addComponent(signalGen);

    auto* reporter = new TableReporter();
    reporter->addToReport(signalGen->getOutput("signal"));
    world.addComponent(reporter);

    // Build the system.
    MultibodySystem system;
    world.buildUpSystem(system);
    State s = system.realizeTopology();
    system.realize(s, Stage::Model);

    // "Simulate."
    const int numTimePoints = 5;
    for (int i = 0; i < numTimePoints; ++i) {
        s.setTime(0.1 * i);
        system.realize(s, Stage::Report);
    }

    // Check that the SignalGenerator produced the correct values.
    const TimeSeriesTable_<Real>& results = reporter->getTable();
    SimTK_TEST_EQ((int)results.getNumRows(), numTimePoints);
    for (int i = 0; i < numTimePoints; ++i) {
        const double time = 0.1 * i;
        system.realize(s, Stage::Report);
        SimTK_TEST_EQ(results.getRowAtIndex(i)[0],
                amplitude * std::sin(omega * time + phase));
    }
}

int main() {

    SimTK_START_TEST("testSignalGenerator");
        SimTK_SUBTEST(testSignalGenerator);
    SimTK_END_TEST();
}
<commit_msg>Add offset to Sine function case.<commit_after>/* -------------------------------------------------------------------------- *
 *                       OpenSim:  testFunctions.cpp                          *
 * -------------------------------------------------------------------------- *
 * The OpenSim API is a toolkit for musculoskeletal modeling and simulation.  *
 * See http://opensim.stanford.edu and the NOTICE file for more information.  *
 * OpenSim is developed at Stanford University and supported by the US        *
 * National Institutes of Health (U54 GM072970, R24 HD065690) and by DARPA    *
 * through the Warrior Web program.                                           *
 *                                                                            *
 * Copyright (c) 2005-2017 Stanford University and the Authors                *
 * Author(s): Christopher Dembia                                              *
 *                                                                            *
 * Licensed 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.                                             *
 * -------------------------------------------------------------------------- */

#include <OpenSim/Common/Sine.h>
#include <OpenSim/Common/SignalGenerator.h>
#include <OpenSim/Common/Reporter.h>

#include "ComponentsForTesting.h"

using namespace OpenSim;
using namespace SimTK;

void testSignalGenerator() {
    // Feed a SignalGenerator's output into a TableReporter, and make sure the
    // reported value is correct.

    // Build the model.
    RootComponent world;
    auto* signalGen = new SignalGenerator();
    signalGen->setName("sinusoid");
    const double amplitude = 1.5;
    const double omega = 3.1;
    const double phase = 0.3;
    const double offset = 0.12345;
    signalGen->set_function(Sine(amplitude, omega, phase, offset));
    world.addComponent(signalGen);

    auto* reporter = new TableReporter();
    reporter->addToReport(signalGen->getOutput("signal"));
    world.addComponent(reporter);

    // Build the system.
    MultibodySystem system;
    world.buildUpSystem(system);
    State s = system.realizeTopology();
    system.realize(s, Stage::Model);

    // "Simulate."
    const int numTimePoints = 5;
    for (int i = 0; i < numTimePoints; ++i) {
        s.setTime(0.1 * i);
        system.realize(s, Stage::Report);
    }

    // Check that the SignalGenerator produced the correct values.
    const TimeSeriesTable_<Real>& results = reporter->getTable();
    SimTK_TEST_EQ((int)results.getNumRows(), numTimePoints);
    for (int i = 0; i < numTimePoints; ++i) {
        const double time = 0.1 * i;
        system.realize(s, Stage::Report);
        SimTK_TEST_EQ(results.getRowAtIndex(i)[0],
                amplitude * std::sin(omega * time + phase) + offset);
    }
}

int main() {

    SimTK_START_TEST("testSignalGenerator");
        SimTK_SUBTEST(testSignalGenerator);
    SimTK_END_TEST();
}
<|endoftext|>


<commit_before>/* -------------------------------------------------------------------------- *
 *                           OpenSim:  ForceSet.cpp                           *
 * -------------------------------------------------------------------------- *
 * The OpenSim API is a toolkit for musculoskeletal modeling and simulation.  *
 * See http://opensim.stanford.edu and the NOTICE file for more information.  *
 * OpenSim is developed at Stanford University and supported by the US        *
 * National Institutes of Health (U54 GM072970, R24 HD065690) and by DARPA    *
 * through the Warrior Web program.                                           *
 *                                                                            *
 * Copyright (c) 2005-2018 Stanford University and the Authors                *
 * Author(s): Ajay Seth, Jack Middleton                                       *
 *                                                                            *
 * Licensed 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.                                             *
 * -------------------------------------------------------------------------- */

//=============================================================================
// INCLUDES
//=============================================================================
#include "ForceSet.h"

using namespace std;
using namespace OpenSim;

void ForceSet::extendConnectToModel(Model& aModel)
{
    // BASE CLASS
    Super::extendConnectToModel(aModel);

    _actuators.setMemoryOwner(false);
    _muscles.setMemoryOwner(false);

    updateActuators();
    updateMuscles();
}

//=============================================================================
// GET AND SET
//=============================================================================

//-----------------------------------------------------------------------------
// ACTUATOR
//-----------------------------------------------------------------------------
//_____________________________________________________________________________
/**
 * Remove an actuator from the actuator set.
 *
 * @param aIndex Index of the actuator to be removed.
 * @return True if the remove was successful; false otherwise.
 */
bool ForceSet::remove(int aIndex)
{
    bool success = Super::remove(aIndex);

    updateActuators();
    updateMuscles();

    return(success);
}

//_____________________________________________________________________________
/**
 * Append an actuator on to the set.  A copy of the specified actuator
 * is not made.
 *
 * This method overrides the method in Set<Force> so that several
 * internal variables of the actuator set can be updated.
 *
 * @param aActuator Pointer to the actuator to be appended.
 * @return True if successful; false otherwise.
 */
bool ForceSet::append(Force *aForce)
{
    bool success = Super::adoptAndAppend(aForce);

    if (success && hasModel()) {
        updateActuators();
        updateMuscles();
    }

    return(success);
}
//_____________________________________________________________________________
/**
 * Append an actuator on to the set.  A copy of the specified actuator
 * is made.
 *
 * This method overrides the method in Set<Force> so that several
 * internal variables of the actuator set can be updated.
 *
 * @param aActuator reference to the actuator to be appended.
 * @return True if successful; false otherwise.
 */
bool ForceSet::
append(Force &aForce)
{
    bool success = Super::cloneAndAppend(aForce);

    if (success && hasModel()) {
        updateActuators();
        updateMuscles();
    }

    return(success);
}
//_____________________________________________________________________________
/**
 * Append actuators from an actuator set to this set.  Copies of the actuators are not made.
 *
 * This method overrides the method in Set<Force> so that several
 * internal variables of the actuator set can be updated.
 *
 * @param aForceSet The set of actuators to be appended.
 * @param aAllowDuplicateNames If true, all actuators will be appended; If false, don't append actuators whose
 * name already exists in this model's actuator set.
 * @return True if successful; false otherwise.
 */
bool ForceSet::append(ForceSet &aForceSet, bool aAllowDuplicateNames)
{
    bool success = true;
    for(int i=0;i<aForceSet.getSize() && success;i++) {
        bool nameExists = false;
        if(!aAllowDuplicateNames) {
            std::string name = aForceSet.get(i).getName();
            for(int j=0;j<getSize();j++) {
                if(get(j).getName() == name) {
                    nameExists = true;
                    break;
                }
            }
        }
        if(!nameExists) {
            if(!Super::adoptAndAppend(&aForceSet.get(i)))
                success = false;
        }
    }

    if(success) {
        updateActuators();
        updateMuscles();
    }

    return(success);
}
//_____________________________________________________________________________
/**
 * Set the actuator at an index.  A copy of the specified actuator is NOT made.
 * The actuator previously set at the index is removed (and deleted).
 *
 * This method overrides the method in Set<Force> so that several
 * internal variables of the actuator set can be updated.
 *
 * @param aIndex Array index where the actuator is to be stored.  aIndex
 * should be in the range 0 <= aIndex <= getSize();
 * @param aActuator Pointer to the actuator to be set.
 * @return True if successful; false otherwise.
 */
bool ForceSet::set(int aIndex,Force *aActuator, bool preserveGroups)
{
    bool success = Super::set(aIndex, aActuator, preserveGroups);

    if(success) {
        updateActuators();
        updateMuscles();
    }

    return(success);
}

bool ForceSet::insert(int aIndex, Force *aForce)
{
    bool success = Super::insert(aIndex, aForce);

    if(success) {
        updateActuators();
        updateMuscles();
    }

    return(success);
}

//_____________________________________________________________________________
/**
 * Get the list of Actuators.
 */
const Set<Actuator>& ForceSet::getActuators() const
{
    return _actuators;
}

Set<Actuator>& ForceSet::updActuators()
{
    updateActuators();
    return _actuators;
}
//_____________________________________________________________________________
/**
 * Rebuild the list of Actuators.
 */
void ForceSet::updateActuators()
{
    _actuators.setMemoryOwner(false);
    _actuators.setSize(0);
    for (int i = 0; i < getSize(); ++i) {
        Actuator* act = dynamic_cast<Actuator*>(&get(i));
        if (act)  _actuators.adoptAndAppend(act);
    }
}

//=============================================================================
//_____________________________________________________________________________
/**
 * Get the list of Muscles.
 */
const Set<Muscle>& ForceSet::getMuscles() const
{
    if (_muscles.getSize() == 0)
        const_cast<ForceSet*>(this)->updateMuscles();
    return _muscles;
}
Set<Muscle>& ForceSet::updMuscles()
{
    if (_muscles.getSize() == 0)
        updateMuscles();
    return _muscles;
}
//_____________________________________________________________________________
/**
 * Rebuild the list of Muscles.
 */
void ForceSet::updateMuscles()
{
    _muscles.setMemoryOwner(false);
    _muscles.setSize(0);
    for (int i = 0; i < getSize(); ++i) {
        Muscle* m = dynamic_cast<Muscle*>(&get(i));
        if (m)  _muscles.adoptAndAppend(m);
    }
}

//=============================================================================
// COMPUTATIONS
//=============================================================================
//_____________________________________________________________________________

//_____________________________________________________________________________
/**
 * Get the names of the states of the actuators.
 *
 * @param rNames Array of names.
 */
void ForceSet::
getStateVariableNames(OpenSim::Array<std::string> &rNames) const
{
    for(int i=0;i<getSize();i++) {
        ScalarActuator *act = dynamic_cast<ScalarActuator*>(&get(i));

        if(act) {
            rNames.append(act->getStateVariableNames());
        }
    }
}

//=============================================================================
// CHECK
//=============================================================================
//_____________________________________________________________________________
/**
 * Check that all actuators are valid.
 */
bool ForceSet::
check() const
{
    bool status=true;

    // LOOP THROUGH ACTUATORS
    ScalarActuator *act;
    int size = getSize();
    for(int i=0;i<size;i++) {
        act = dynamic_cast<ScalarActuator *>(&get(i));
        if(!act) continue;
    }

    return(status);
}
<commit_msg>Revert ForceSet to its previous behavior where the Muscles list is NOT updated upon getMuscles<commit_after>/* -------------------------------------------------------------------------- *
 *                           OpenSim:  ForceSet.cpp                           *
 * -------------------------------------------------------------------------- *
 * The OpenSim API is a toolkit for musculoskeletal modeling and simulation.  *
 * See http://opensim.stanford.edu and the NOTICE file for more information.  *
 * OpenSim is developed at Stanford University and supported by the US        *
 * National Institutes of Health (U54 GM072970, R24 HD065690) and by DARPA    *
 * through the Warrior Web program.                                           *
 *                                                                            *
 * Copyright (c) 2005-2018 Stanford University and the Authors                *
 * Author(s): Ajay Seth, Jack Middleton                                       *
 *                                                                            *
 * Licensed 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.                                             *
 * -------------------------------------------------------------------------- */

//=============================================================================
// INCLUDES
//=============================================================================
#include "ForceSet.h"

using namespace std;
using namespace OpenSim;

void ForceSet::extendConnectToModel(Model& aModel)
{
    // BASE CLASS
    Super::extendConnectToModel(aModel);

    _actuators.setMemoryOwner(false);
    _muscles.setMemoryOwner(false);

    updateActuators();
    updateMuscles();
}

//=============================================================================
// GET AND SET
//=============================================================================

//-----------------------------------------------------------------------------
// ACTUATOR
//-----------------------------------------------------------------------------
//_____________________________________________________________________________
/**
 * Remove an actuator from the actuator set.
 *
 * @param aIndex Index of the actuator to be removed.
 * @return True if the remove was successful; false otherwise.
 */
bool ForceSet::remove(int aIndex)
{
    bool success = Super::remove(aIndex);

    updateActuators();
    updateMuscles();

    return(success);
}

//_____________________________________________________________________________
/**
 * Append an actuator on to the set.  A copy of the specified actuator
 * is not made.
 *
 * This method overrides the method in Set<Force> so that several
 * internal variables of the actuator set can be updated.
 *
 * @param aActuator Pointer to the actuator to be appended.
 * @return True if successful; false otherwise.
 */
bool ForceSet::append(Force *aForce)
{
    bool success = Super::adoptAndAppend(aForce);

    if (success && hasModel()) {
        updateActuators();
        updateMuscles();
    }

    return(success);
}
//_____________________________________________________________________________
/**
 * Append an actuator on to the set.  A copy of the specified actuator
 * is made.
 *
 * This method overrides the method in Set<Force> so that several
 * internal variables of the actuator set can be updated.
 *
 * @param aActuator reference to the actuator to be appended.
 * @return True if successful; false otherwise.
 */
bool ForceSet::
append(Force &aForce)
{
    bool success = Super::cloneAndAppend(aForce);

    if (success && hasModel()) {
        updateActuators();
        updateMuscles();
    }

    return(success);
}
//_____________________________________________________________________________
/**
 * Append actuators from an actuator set to this set.  Copies of the actuators are not made.
 *
 * This method overrides the method in Set<Force> so that several
 * internal variables of the actuator set can be updated.
 *
 * @param aForceSet The set of actuators to be appended.
 * @param aAllowDuplicateNames If true, all actuators will be appended; If false, don't append actuators whose
 * name already exists in this model's actuator set.
 * @return True if successful; false otherwise.
 */
bool ForceSet::append(ForceSet &aForceSet, bool aAllowDuplicateNames)
{
    bool success = true;
    for(int i=0;i<aForceSet.getSize() && success;i++) {
        bool nameExists = false;
        if(!aAllowDuplicateNames) {
            std::string name = aForceSet.get(i).getName();
            for(int j=0;j<getSize();j++) {
                if(get(j).getName() == name) {
                    nameExists = true;
                    break;
                }
            }
        }
        if(!nameExists) {
            if(!Super::adoptAndAppend(&aForceSet.get(i)))
                success = false;
        }
    }

    if(success) {
        updateActuators();
        updateMuscles();
    }

    return(success);
}
//_____________________________________________________________________________
/**
 * Set the actuator at an index.  A copy of the specified actuator is NOT made.
 * The actuator previously set at the index is removed (and deleted).
 *
 * This method overrides the method in Set<Force> so that several
 * internal variables of the actuator set can be updated.
 *
 * @param aIndex Array index where the actuator is to be stored.  aIndex
 * should be in the range 0 <= aIndex <= getSize();
 * @param aActuator Pointer to the actuator to be set.
 * @return True if successful; false otherwise.
 */
bool ForceSet::set(int aIndex,Force *aActuator, bool preserveGroups)
{
    bool success = Super::set(aIndex, aActuator, preserveGroups);

    if(success) {
        updateActuators();
        updateMuscles();
    }

    return(success);
}

bool ForceSet::insert(int aIndex, Force *aForce)
{
    bool success = Super::insert(aIndex, aForce);

    if(success) {
        updateActuators();
        updateMuscles();
    }

    return(success);
}

//_____________________________________________________________________________
/**
 * Get the list of Actuators.
 */
const Set<Actuator>& ForceSet::getActuators() const
{
    return _actuators;
}

Set<Actuator>& ForceSet::updActuators()
{
    updateActuators();
    return _actuators;
}
//_____________________________________________________________________________
/**
 * Rebuild the list of Actuators.
 */
void ForceSet::updateActuators()
{
    _actuators.setMemoryOwner(false);
    _actuators.setSize(0);
    for (int i = 0; i < getSize(); ++i) {
        Actuator* act = dynamic_cast<Actuator*>(&get(i));
        if (act)  _actuators.adoptAndAppend(act);
    }
}

//=============================================================================
//_____________________________________________________________________________
/**
 * Get the list of Muscles.
 */
const Set<Muscle>& ForceSet::getMuscles() const
{
    return _muscles;
}
Set<Muscle>& ForceSet::updMuscles()
{
    if (_muscles.getSize() == 0)
        updateMuscles();
    return _muscles;
}
//_____________________________________________________________________________
/**
 * Rebuild the list of Muscles.
 */
void ForceSet::updateMuscles()
{
    _muscles.setMemoryOwner(false);
    _muscles.setSize(0);
    for (int i = 0; i < getSize(); ++i) {
        Muscle* m = dynamic_cast<Muscle*>(&get(i));
        if (m)  _muscles.adoptAndAppend(m);
    }
}

//=============================================================================
// COMPUTATIONS
//=============================================================================
//_____________________________________________________________________________

//_____________________________________________________________________________
/**
 * Get the names of the states of the actuators.
 *
 * @param rNames Array of names.
 */
void ForceSet::
getStateVariableNames(OpenSim::Array<std::string> &rNames) const
{
    for(int i=0;i<getSize();i++) {
        ScalarActuator *act = dynamic_cast<ScalarActuator*>(&get(i));

        if(act) {
            rNames.append(act->getStateVariableNames());
        }
    }
}

//=============================================================================
// CHECK
//=============================================================================
//_____________________________________________________________________________
/**
 * Check that all actuators are valid.
 */
bool ForceSet::
check() const
{
    bool status=true;

    // LOOP THROUGH ACTUATORS
    ScalarActuator *act;
    int size = getSize();
    for(int i=0;i<size;i++) {
        act = dynamic_cast<ScalarActuator *>(&get(i));
        if(!act) continue;
    }

    return(status);
}
<|endoftext|>


<commit_before>#ifndef GCL_TYPE_INFO__
# define GCL_TYPE_INFO__

#include <gcl_cpp/preprocessor.hpp>

#include <tuple>
#include <memory>
#include <functional>
#include <cassert>
#include <vector>
#include <typeindex>

#include <gcl_cpp/mp.hpp>
#include <gcl_cpp/tuple_utils.hpp>

namespace gcl::type_info
{
	namespace id
	{
		using type = std::type_index;
#if defined(__cpp_rtti)
		template <typename T>
		static const type value = typeid(T);
#endif
		template <typename T>
		static constexpr auto type_name = experimental::type_name<T>();
	}

	template<typename ... Ts>
	static constexpr std::vector<id::type> make_ids_vector() { return { id<Ts>::value... }; }
	template<typename ... Ts>
	static constexpr std::array<id::type, sizeof...(Ts)> make_ids_array() { return { id<T>::value... }; }

	template <typename ... Ts>
	struct variadic_template
	{	// wrapper to gcl::mp::<function_name>

		using std_type = std::tuple<Ts...>;

		inline static constexpr auto size = sizeof...(Ts); // or std::tuple_size_v<tuple_type>

		template <size_t N>
		using type_at = gcl::mp::type_at<N, Ts...>;

		template <typename T>
		static constexpr inline size_t index_of = gcl::mp::index_of<T, Ts...>;

		template <typename T>
		static constexpr inline bool contains = gcl::mp::contains<T, Ts...>;

		auto to_std()
		{
			return std_type{};
		}
	};
	template <typename ... Ts>
	using pack = variadic_template<Ts...>;

	namespace experimental
	{
		template <typename T>
		constexpr std::string_view type_name(/*no parameters allowed*/)
		{
#ifdef _MSC_VER
			std::string_view str_view = __FUNCSIG__;

			str_view.remove_prefix(str_view.find(__FUNCTION__) + sizeof(__FUNCTION__));
			str_view.remove_suffix(str_view.length() - str_view.rfind('>'));
#elif defined (__GNUC__)
			std::string_view str_view = __PRETTY_FUNCTION__;

			str_view.remove_prefix(str_view.find(__FUNCTION__) + sizeof(__FUNCTION__));
			const char prefix[] = " [with T = ";
			str_view.remove_prefix(str_view.find(prefix) + sizeof(prefix) - 1);
			str_view.remove_suffix(str_view.length() - str_view.find(';'));
#else
			static_assert(false, "not supported compiler");
#endif
			return str_view;
		}

		struct holder final
		{	// hold a value anonymously
			// /!\ cost much more than std::any
			struct interface_t
			{	// as interface, for safe y-shaped inheritance tree (type erasure)
				interface_t() = default;
				interface_t(const interface_t &) = delete;
				interface_t(interface_t &&) = delete;
				virtual ~interface_t() = default;
			};
			using value_type = std::unique_ptr<interface_t>;
			template <typename T>
			struct type_eraser : interface_t, std::decay_t<T>
			{
				using target_type = std::decay_t<T>;

				explicit type_eraser(target_type && value)
					: target_type{ std::forward<target_type>(value) }
				{}
			};

			holder() = delete;
			holder(holder &) = delete;
			holder(holder &&) = default;

			template <typename concret_t>
			explicit holder(concret_t && elem)
				: value(std::unique_ptr<interface_t>(new type_eraser<concret_t>{ std::forward<concret_t>(elem) }))
				, id(type_info::id::value<concret_t>)
			{}

			template <typename T>
			T & cast() const
			{
				using target_type = std::decay_t<T>;

				if (id != gcl::type_info::id::value<target_type>)
					throw std::bad_cast();

				auto * as_type_eraser_ptr = static_cast<type_eraser<target_type&>*>(value.get());
				return static_cast<target_type&>(*as_type_eraser_ptr);
			}

			const gcl::type_info::id::type id;
			const value_type value;
		};
	}
}

inline std::ostream & operator<<(std::ostream & os, const std::type_index & index)
{
	return os << "type_id=[(" << index.hash_code() << ')' << index.name() << ']';
}

#include <memory>

namespace gcl::deprecated::type_info
{	//	C++11
	template <typename ... Ts>
	struct variadic_template
	{
		using tuple_type = std::tuple<Ts...>;

		inline static constexpr auto size = sizeof...(Ts); // or std::tuple_size_v<tuple_type>

		template <size_t N>
		using type_at = typename std::tuple_element<N, tuple_type>::type;

		template <typename T>
		static constexpr inline size_t index_of(void)
		{
			return index_of_impl<T, 0, Ts...>();
		}

		auto to_std()
		{
			return tuple_type{};
		}

	private:
		template <typename needle_t, size_t it_n, typename iterated_t, typename ... haystack_t>
		static constexpr inline size_t index_of_impl(void)
		{
			return (std::is_same<needle_t, iterated_t>::value ? it_n : index_of_impl<needle_t, it_n + 1, haystack_t...>());
		}
		template <typename needle_t, size_t iterated_t>
		static constexpr inline size_t index_of_impl(void)
		{
			throw std::out_of_range("variadic_template::index_of_impl : Not found");
		}
};

#if (defined _DEBUG && defined GCL_UNSAFE_CODE)
	using id_type = uint64_t;
	template <typename T>
	struct id
	{
		// Warning : Values change per program instance
		// Error   : compiler optimization may set the same value per instance
		static const id_type value; // [todo]::[C++14] : MS compiler (VS2015) do not support variable-template
									// [todo]::[C++17] : seems to no be able to self-reference a template variable
	};

#pragma warning (disable : 4311 4302)
	template <typename T>
	const gcl::deprecated::type_info::id_type gcl::deprecated::type_info::id<T>::value
		= reinterpret_cast<gcl::deprecated::type_info::id_type>(&(gcl::deprecated::type_info::id<T>::value));
#pragma warning (default : 4311 4302)
#else
	using id_type = std::type_index;
	template <typename T>
	struct id
	{
		static inline const id_type value = typeid(T);
	};
#endif

	template <typename interface_t>
	struct holder final
	{
		using typeid_type = id_type;
		using value_type = std::unique_ptr<interface_t>;

		holder() = delete;
		holder(holder &) = default;
		holder(holder &&) = default;

		holder(id_type _id, value_type && ptr)
			: value(std::move(ptr))
			, id(_id)
		{}

		template <typename concret_t>
		explicit holder(std::unique_ptr<concret_t> && ptr)
			: value(std::forward<std::unique_ptr<concret_t>>(ptr))
			, id(gcl::deprecated::type_info::id<concret_t>::value)
		{
			check_<concret_t>();
		}
		template <typename concret_t>
		explicit holder(concret_t * ptr)
			: value(std::move(ptr))
			, id(gcl::deprecated::type_info::id<concret_t>::value)
		{
			check_<concret_t>();
		}

		const id_type id;
		const value_type value;

	private:
		template <typename concret_t>
		static constexpr void check_()
		{
			static_assert(!std::is_same<interface_t, concret_t>::value, "interface and concrete types are the same");
			static_assert(std::is_base_of<interface_t, concret_t>::value, "interface_t is not base of concrete_t");
		}
	};

	namespace experimental
	{
		struct any
		{
			any(const any &) = delete;
			any(const any &&) = delete;
			virtual inline ~any() = 0 {}

			virtual inline const gcl::deprecated::type_info::id_type id() const = 0;

			inline bool operator==(const any & other)
			{
				return other.id() == id() && compare_impl(other);
			}
		protected:
			virtual inline const bool compare_impl(const any &) const = 0;

			any() = default;
		};

		template <typename T>
		struct any_impl : public any, public T
		{
			friend any;
			using type_t = any_impl<T>;

			template <typename ... Args>
			explicit any_impl(Args... args)
				: any()
				, T(std::forward<std::decay<Args...>::type>(args...))
			{}
			~any_impl() override {}

			operator T()
			{
				return static_cast<T&>(*this);
			}

			inline const gcl::deprecated::type_info::id_type id() const override
			{
				return gcl::deprecated::type_info::id<T>::value;
			}
			inline const bool compare_impl(const any & other) const override
			{
				assert(id() == other.id());
				return (dynamic_cast<const T &>(dynamic_cast<const type_t &>(other)) == dynamic_cast<const T&>(*this));
			}
		};
	}
}

#endif // GCL_TYPE_INFO__
<commit_msg>gcl::type_info : fix compilation issues for few compilers / compile-options. e.g template keyword use and member-function declaration order<commit_after>#ifndef GCL_TYPE_INFO__
# define GCL_TYPE_INFO__

#include <gcl_cpp/preprocessor.hpp>

#include <tuple>
#include <memory>
#include <functional>
#include <cassert>
#include <vector>
#include <typeindex>

#include <gcl_cpp/mp.hpp>
#include <gcl_cpp/tuple_utils.hpp>

namespace gcl::type_info
{
	namespace id
	{
		using type = std::type_index;
#if defined(__cpp_rtti)
		template <typename T>
		static const type value = typeid(T);
#endif
		template <typename T>
		static constexpr auto type_name = experimental::template type_name<T>();
	}

	template <typename ... Ts>
	static constexpr std::vector<id::type> make_ids_vector() { return { id<Ts>::value... }; }
	template <typename ... Ts>
	static constexpr std::array<id::type, sizeof...(Ts)> make_ids_array() { return { id<Ts>::value... }; }

	template <typename ... Ts>
	struct variadic_template
	{	// wrapper to gcl::mp::<function_name>

		using std_type = std::tuple<Ts...>;

		inline static constexpr auto size = sizeof...(Ts); // or std::tuple_size_v<tuple_type>

		template <size_t N>
		using type_at = gcl::mp::type_at<N, Ts...>;

		template <typename T>
		static constexpr inline size_t index_of = gcl::mp::index_of<T, Ts...>;

		template <typename T>
		static constexpr inline bool contains = gcl::mp::contains<T, Ts...>;

		auto to_std()
		{
			return std_type{};
		}
	};
	template <typename ... Ts>
	using pack = variadic_template<Ts...>;

	namespace experimental
	{
		template <typename T>
		constexpr std::string_view type_name(/*no parameters allowed*/)
		{
#ifdef _MSC_VER
			std::string_view str_view = __FUNCSIG__;

			str_view.remove_prefix(str_view.find(__FUNCTION__) + sizeof(__FUNCTION__));
			str_view.remove_suffix(str_view.length() - str_view.rfind('>'));
#elif defined (__GNUC__)
			std::string_view str_view = __PRETTY_FUNCTION__;

			str_view.remove_prefix(str_view.find(__FUNCTION__) + sizeof(__FUNCTION__));
			const char prefix[] = " [with T = ";
			str_view.remove_prefix(str_view.find(prefix) + sizeof(prefix) - 1);
			str_view.remove_suffix(str_view.length() - str_view.find(';'));
#else
			static_assert(false, "not supported compiler");
#endif
			return str_view;
		}

		struct holder final
		{	// hold a value anonymously
			// /!\ cost much more than std::any
			struct interface_t
			{	// as interface, for safe y-shaped inheritance tree (type erasure)
				interface_t() = default;
				interface_t(const interface_t &) = delete;
				interface_t(interface_t &&) = delete;
				virtual ~interface_t() = default;
			};
			using value_type = std::unique_ptr<interface_t>;
			template <typename T>
			struct type_eraser : interface_t, std::decay_t<T>
			{
				using target_type = std::decay_t<T>;

				explicit type_eraser(target_type && value)
					: target_type{ std::forward<target_type>(value) }
				{}
			};

			holder() = delete;
			holder(holder &) = delete;
			holder(holder &&) = default;

			template <typename concret_t>
			explicit holder(concret_t && elem)
				: value(std::unique_ptr<interface_t>(new type_eraser<concret_t>{ std::forward<concret_t>(elem) }))
				, id(type_info::id::value<concret_t>)
			{}

			template <typename T>
			T & cast() const
			{
				using target_type = std::decay_t<T>;

				if (id != gcl::type_info::id::value<target_type>)
					throw std::bad_cast();

				auto * as_type_eraser_ptr = static_cast<type_eraser<target_type&>*>(value.get());
				return static_cast<target_type&>(*as_type_eraser_ptr);
			}

			const gcl::type_info::id::type id;
			const value_type value;
		};
	}
}

inline std::ostream & operator<<(std::ostream & os, const std::type_index & index)
{
	return os << "type_id=[(" << index.hash_code() << ')' << index.name() << ']';
}

#include <memory>

namespace gcl::deprecated::type_info
{	//	C++11
	template <typename ... Ts>
	struct variadic_template
	{
		using tuple_type = std::tuple<Ts...>;

		inline static constexpr auto size = sizeof...(Ts); // or std::tuple_size_v<tuple_type>

		template <size_t N>
		using type_at = typename std::tuple_element<N, tuple_type>::type;

		template <typename T>
		static constexpr inline size_t index_of(void)
		{
			return index_of_impl<T, 0, Ts...>();
		}

		auto to_std()
		{
			return tuple_type{};
		}

	private:
		template <typename needle_t, size_t it_n, typename iterated_t, typename ... haystack_t>
		static constexpr inline size_t index_of_impl(void)
		{
			return (std::is_same<needle_t, iterated_t>::value ? it_n : index_of_impl<needle_t, it_n + 1, haystack_t...>());
		}
		template <typename needle_t, size_t iterated_t>
		static constexpr inline size_t index_of_impl(void)
		{
			throw std::out_of_range("variadic_template::index_of_impl : Not found");
		}
};

#if (defined _DEBUG && defined GCL_UNSAFE_CODE)
	using id_type = uint64_t;
	template <typename T>
	struct id
	{
		// Warning : Values change per program instance
		// Error   : compiler optimization may set the same value per instance
		static const id_type value; // [todo]::[C++14] : MS compiler (VS2015) do not support variable-template
									// [todo]::[C++17] : seems to no be able to self-reference a template variable
	};

#pragma warning (disable : 4311 4302)
	template <typename T>
	const gcl::deprecated::type_info::id_type gcl::deprecated::type_info::id<T>::value
		= reinterpret_cast<gcl::deprecated::type_info::id_type>(&(gcl::deprecated::type_info::id<T>::value));
#pragma warning (default : 4311 4302)
#else
	using id_type = std::type_index;
	template <typename T>
	struct id
	{
		static inline const id_type value = typeid(T);
	};
#endif

	template <typename interface_t>
	struct holder final
	{
		using typeid_type = id_type;
		using value_type = std::unique_ptr<interface_t>;

		holder() = delete;
		holder(holder &) = default;
		holder(holder &&) = default;

		holder(id_type _id, value_type && ptr)
			: value(std::move(ptr))
			, id(_id)
		{}

		template <typename concret_t>
		explicit holder(std::unique_ptr<concret_t> && ptr)
			: value(std::forward<std::unique_ptr<concret_t>>(ptr))
			, id(gcl::deprecated::type_info::id<concret_t>::value)
		{
			check_<concret_t>();
		}
		template <typename concret_t>
		explicit holder(concret_t * ptr)
			: value(std::move(ptr))
			, id(gcl::deprecated::type_info::id<concret_t>::value)
		{
			check_<concret_t>();
		}

		const id_type id;
		const value_type value;

	private:
		template <typename concret_t>
		static constexpr void check_()
		{
			static_assert(!std::is_same<interface_t, concret_t>::value, "interface and concrete types are the same");
			static_assert(std::is_base_of<interface_t, concret_t>::value, "interface_t is not base of concrete_t");
		}
	};

	namespace experimental
	{
		struct any
		{
			any(const any &) = delete;
			any(const any &&) = delete;
			virtual inline ~any() = 0 {}

			virtual inline const gcl::deprecated::type_info::id_type id() const = 0;

			inline bool operator==(const any & other)
			{
				return other.id() == id() && compare_impl(other);
			}
		protected:
			virtual inline const bool compare_impl(const any &) const = 0;

			any() = default;
		};

		template <typename T>
		struct any_impl : public any, public T
		{
			friend any;
			using type_t = any_impl<T>;

			template <typename ... Args>
			explicit any_impl(Args... args)
				: any()
				, T(std::forward<std::decay<Args...>::type>(args...))
			{}
			~any_impl() override {}

			operator T()
			{
				return static_cast<T&>(*this);
			}

			inline const gcl::deprecated::type_info::id_type id() const override
			{
				return gcl::deprecated::type_info::id<T>::value;
			}
			inline const bool compare_impl(const any & other) const override
			{
				assert(id() == other.id());
				return (dynamic_cast<const T &>(dynamic_cast<const type_t &>(other)) == dynamic_cast<const T&>(*this));
			}
		};
	}
}

#endif // GCL_TYPE_INFO__
<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: xmlComponent.cxx,v $
 *
 *  $Revision: 1.3 $
 *
 *  last change: $Author: ihi $ $Date: 2007-11-20 19:00:20 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/
#include "precompiled_reportdesign.hxx"

#ifndef RPT_XMLCOMPONENT_HXX
#include "xmlComponent.hxx"
#endif
#ifndef RPT_XMLFILTER_HXX
#include "xmlfilter.hxx"
#endif
#ifndef _XMLOFF_XMLTOKEN_HXX
#include <xmloff/xmltoken.hxx>
#endif
#ifndef _XMLOFF_XMLNMSPE_HXX
#include <xmloff/xmlnmspe.hxx>
#endif
#ifndef _XMLOFF_XMLUCONV_HXX
#include <xmloff/xmluconv.hxx>
#endif
#ifndef _XMLOFF_NMSPMAP_HXX
#include <xmloff/nmspmap.hxx>
#endif
#ifndef RPT_XMLENUMS_HXX
#include "xmlEnums.hxx"
#endif
#ifndef RPT_XMLHELPER_HXX
#include "xmlHelper.hxx"
#endif
#ifndef RPT_SHARED_XMLSTRINGS_HRC
#include "xmlstrings.hrc"
#endif
#ifndef RPT_XMLSTYLEIMPORT_HXX
#include "xmlStyleImport.hxx"
#endif
#ifndef _UCBHELPER_CONTENT_HXX
#include <ucbhelper/content.hxx>
#endif
#ifndef _TOOLS_DEBUG_HXX
#include <tools/debug.hxx>
#endif
#ifndef _COMPHELPER_NAMECONTAINER_HXX_
#include <comphelper/namecontainer.hxx>
#endif
#ifndef _COMPHELPER_GENERICPROPERTYSET_HXX_
#include <comphelper/genericpropertyset.hxx>
#endif
#ifndef _COM_SUN_STAR_AWT_FONTDESCRIPTOR_HPP_
#include <com/sun/star/awt/FontDescriptor.hpp>
#endif
#ifndef _COM_SUN_STAR_REPORT_XREPORTCONTROLMODEL_HPP_
#include <com/sun/star/report/XReportControlModel.hpp>
#endif
#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HXX_
#include <com/sun/star/beans/PropertyAttribute.hpp>
#endif
#ifndef _TOOLS_DEBUG_HXX
#include <tools/debug.hxx>
#endif

namespace rptxml
{
    using namespace ::comphelper;
    using namespace ::com::sun::star;
    using namespace ::com::sun::star::uno;
    using namespace ::com::sun::star::beans;
    using namespace ::com::sun::star::report;
    using namespace ::com::sun::star::xml::sax;
    DBG_NAME( rpt_OXMLComponent )
OXMLComponent::OXMLComponent( ORptFilter& _rImport
                ,sal_uInt16 nPrfx
                ,const ::rtl::OUString& _sLocalName
                ,const Reference< XAttributeList > & _xAttrList
                ,const Reference< XReportComponent > & _xComponent
                ) :
    SvXMLImportContext( _rImport, nPrfx, _sLocalName )
    ,m_xComponent(_xComponent)
{
    DBG_CTOR( rpt_OXMLComponent,NULL);
    OSL_ENSURE(_xAttrList.is(),"Attribute list is NULL!");
    OSL_ENSURE(m_xComponent.is(),"Component is NULL!");

    const SvXMLNamespaceMap& rMap = _rImport.GetNamespaceMap();
    const SvXMLTokenMap& rTokenMap = _rImport.GetComponentElemTokenMap();

    const sal_Int16 nLength = (_xAttrList.is()) ? _xAttrList->getLength() : 0;
    static const ::rtl::OUString s_sTRUE = ::xmloff::token::GetXMLToken(XML_TRUE);

    for(sal_Int16 i = 0; i < nLength; ++i)
    {
        try
        {
            ::rtl::OUString sLocalName;
            const ::rtl::OUString sAttrName = _xAttrList->getNameByIndex( i );
            const sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName );
            const ::rtl::OUString sValue = _xAttrList->getValueByIndex( i );

            switch( rTokenMap.Get( nPrefix, sLocalName ) )
            {
                case XML_TOK_NAME:
                    m_xComponent->setName(sValue);
                    break;
                case XML_TOK_TEXT_STYLE_NAME:
                    m_sTextStyleName = sValue;
                    break;
                case XML_TOK_TRANSFORM:
                    break;
                default:
                    break;
            }
        }
        catch(const Exception&)
        {
            OSL_ENSURE(0,"Exception catched while putting props into report component!");
        }
    }
}
// -----------------------------------------------------------------------------

OXMLComponent::~OXMLComponent()
{
    DBG_DTOR( rpt_OXMLComponent,NULL);
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
ORptFilter& OXMLComponent::GetOwnImport()
{
    return static_cast<ORptFilter&>(GetImport());
}
// -----------------------------------------------------------------------------
//----------------------------------------------------------------------------
} // namespace rptxml
// -----------------------------------------------------------------------------
<commit_msg>INTEGRATION: CWS changefileheader (1.3.56); FILE MERGED 2008/04/01 15:23:37 thb 1.3.56.3: #i85898# Stripping all external header guards 2008/04/01 12:33:08 thb 1.3.56.2: #i85898# Stripping all external header guards 2008/03/31 13:32:06 rt 1.3.56.1: #i87441# Change license header to LPGL v3.<commit_after>/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * Copyright 2008 by Sun Microsystems, Inc.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * $RCSfile: xmlComponent.cxx,v $
 * $Revision: 1.4 $
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/
#include "precompiled_reportdesign.hxx"
#include "xmlComponent.hxx"
#include "xmlfilter.hxx"
#include <xmloff/xmltoken.hxx>
#include <xmloff/xmlnmspe.hxx>
#include <xmloff/xmluconv.hxx>
#include <xmloff/nmspmap.hxx>
#include "xmlEnums.hxx"
#include "xmlHelper.hxx"
#ifndef RPT_SHARED_XMLSTRINGS_HRC
#include "xmlstrings.hrc"
#endif
#include "xmlStyleImport.hxx"
#include <ucbhelper/content.hxx>
#include <tools/debug.hxx>
#include <comphelper/namecontainer.hxx>
#include <comphelper/genericpropertyset.hxx>
#include <com/sun/star/awt/FontDescriptor.hpp>
#include <com/sun/star/report/XReportControlModel.hpp>
#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HXX_
#include <com/sun/star/beans/PropertyAttribute.hpp>
#endif
#include <tools/debug.hxx>

namespace rptxml
{
    using namespace ::comphelper;
    using namespace ::com::sun::star;
    using namespace ::com::sun::star::uno;
    using namespace ::com::sun::star::beans;
    using namespace ::com::sun::star::report;
    using namespace ::com::sun::star::xml::sax;
    DBG_NAME( rpt_OXMLComponent )
OXMLComponent::OXMLComponent( ORptFilter& _rImport
                ,sal_uInt16 nPrfx
                ,const ::rtl::OUString& _sLocalName
                ,const Reference< XAttributeList > & _xAttrList
                ,const Reference< XReportComponent > & _xComponent
                ) :
    SvXMLImportContext( _rImport, nPrfx, _sLocalName )
    ,m_xComponent(_xComponent)
{
    DBG_CTOR( rpt_OXMLComponent,NULL);
    OSL_ENSURE(_xAttrList.is(),"Attribute list is NULL!");
    OSL_ENSURE(m_xComponent.is(),"Component is NULL!");

    const SvXMLNamespaceMap& rMap = _rImport.GetNamespaceMap();
    const SvXMLTokenMap& rTokenMap = _rImport.GetComponentElemTokenMap();

    const sal_Int16 nLength = (_xAttrList.is()) ? _xAttrList->getLength() : 0;
    static const ::rtl::OUString s_sTRUE = ::xmloff::token::GetXMLToken(XML_TRUE);

    for(sal_Int16 i = 0; i < nLength; ++i)
    {
        try
        {
            ::rtl::OUString sLocalName;
            const ::rtl::OUString sAttrName = _xAttrList->getNameByIndex( i );
            const sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName );
            const ::rtl::OUString sValue = _xAttrList->getValueByIndex( i );

            switch( rTokenMap.Get( nPrefix, sLocalName ) )
            {
                case XML_TOK_NAME:
                    m_xComponent->setName(sValue);
                    break;
                case XML_TOK_TEXT_STYLE_NAME:
                    m_sTextStyleName = sValue;
                    break;
                case XML_TOK_TRANSFORM:
                    break;
                default:
                    break;
            }
        }
        catch(const Exception&)
        {
            OSL_ENSURE(0,"Exception catched while putting props into report component!");
        }
    }
}
// -----------------------------------------------------------------------------

OXMLComponent::~OXMLComponent()
{
    DBG_DTOR( rpt_OXMLComponent,NULL);
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
ORptFilter& OXMLComponent::GetOwnImport()
{
    return static_cast<ORptFilter&>(GetImport());
}
// -----------------------------------------------------------------------------
//----------------------------------------------------------------------------
} // namespace rptxml
// -----------------------------------------------------------------------------
<|endoftext|>


<commit_before>//
// Wagon contacts: EMCAL Gustavo.Conesa.Balbastre@cern.ch
//                 PHOS  Yuri.Kharlov@cern.ch
//
AliAnalysisTaskParticleCorrelation *AddTaskCalorimeterQA(TString data, Bool_t kPrintSettings = kFALSE,Bool_t kSimulation = kFALSE,TString outputFile = "", Bool_t oldAOD=kFALSE)
{
  // Creates a PartCorr task for calorimeters performance studies, configures it and adds it to the analysis manager.

  // Get the pointer to the existing analysis manager via the static access method.
  //==============================================================================
  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
  if (!mgr) {
    ::Error("AddTaskPartCorr", "No analysis manager to connect to.");
    return NULL;
  }

  // Check the analysis type using the event handlers connected to the analysis manager.
  //==============================================================================
  if (!mgr->GetInputEventHandler()) {
    ::Error("AddTaskPartCorr", "This task requires an input event handler");
    return NULL;
  }
  TString inputDataType = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"

  Bool_t kUseKinematics = (mgr->GetMCtruthEventHandler())?kTRUE:kFALSE;

  cout<<"********* ACCESS KINE? "<<kUseKinematics<<endl;

  // Configure analysis
  //===========================================================================

  //Reader
  //For this particular analysis few things done by the reader.
  //Nothing else needs to be set.
  AliCaloTrackReader * reader = 0x0;
  if     (data=="AOD") reader = new AliCaloTrackAODReader();
  else if(data=="ESD") reader = new AliCaloTrackESDReader();
  //reader->SetDebug(10);//10 for lots of messages
  reader->SwitchOnEMCALCells();
  reader->SwitchOnPHOSCells();
  reader->SwitchOnEMCAL();
  reader->SwitchOnPHOS();
  reader->SwitchOnCTS();
  reader->SetEMCALPtMin(0.);
  reader->SetPHOSPtMin (0.);
  reader->SetCTSPtMin  (0.);
  reader->SetZvertexCut(10.);

  if(kUseKinematics){
    if(inputDataType == "ESD"){
      reader->SwitchOnStack();
      reader->SwitchOffAODMCParticles();
    }
    else if(inputDataType == "AOD"){
      reader->SwitchOffStack();
      reader->SwitchOnAODMCParticles();
    }
  }
  //if(!kSimulation) reader->SetFiredTriggerClassName("CINT1B-ABCE-NOPF-ALL");
  reader->SetDeltaAODFileName(""); //Do not create deltaAOD file, this analysis do not create branches.
  reader->SwitchOffWriteDeltaAOD()  ;
  if(oldAOD)         reader->SwitchOnOldAODs();
  if(kPrintSettings) reader->Print("");

  // *** Calorimeters Utils	***
  AliCalorimeterUtils *cu = new AliCalorimeterUtils;
  // Remove clusters close to borders, at least max energy cell is 1 cell away
  cu->SetNumberOfCellsFromEMCALBorder(1);
  cu->SetNumberOfCellsFromPHOSBorder(2);
  cu->SetEMCALGeometryName("EMCAL_COMPLETEV1");
  // Remove EMCAL hottest channels for first LHC10 periods
  //cu->SwitchOnBadChannelsRemoval();
  // SM0
  //cu->SetEMCALChannelStatus(0,3,13);  cu->SetEMCALChannelStatus(0,44,1); cu->SetEMCALChannelStatus(0,3,13);
  //cu->SetEMCALChannelStatus(0,20,7);  cu->SetEMCALChannelStatus(0,38,2);
  // SM1
  //cu->SetEMCALChannelStatus(1,4,7);   cu->SetEMCALChannelStatus(1,4,13);  cu->SetEMCALChannelStatus(1,9,20);
  //cu->SetEMCALChannelStatus(1,14,15); cu->SetEMCALChannelStatus(1,23,16); cu->SetEMCALChannelStatus(1,32,23);
  //cu->SetEMCALChannelStatus(1,37,5);  cu->SetEMCALChannelStatus(1,40,1);  cu->SetEMCALChannelStatus(1,40,2);
  //cu->SetEMCALChannelStatus(1,40,5);  cu->SetEMCALChannelStatus(1,41,0);  cu->SetEMCALChannelStatus(1,41,1);
  //cu->SetEMCALChannelStatus(1,41,2);  cu->SetEMCALChannelStatus(1,41,4);
  // SM2
  //cu->SetEMCALChannelStatus(2,14,15); cu->SetEMCALChannelStatus(2,18,16); cu->SetEMCALChannelStatus(2,18,17);
  //cu->SetEMCALChannelStatus(2,18,18); cu->SetEMCALChannelStatus(2,18,20); cu->SetEMCALChannelStatus(2,18,21);
  //cu->SetEMCALChannelStatus(2,18,23); cu->SetEMCALChannelStatus(2,19,16); cu->SetEMCALChannelStatus(2,19,17);
  //cu->SetEMCALChannelStatus(2,19,19); cu->SetEMCALChannelStatus(2,19,20); cu->SetEMCALChannelStatus(2,19,21);
  //cu->SetEMCALChannelStatus(2,19,22);
  //SM3
  //cu->SetEMCALChannelStatus(3,4,7);

  //Recalibration
  //cu->SwitchOnRecalibration();
  //TFile * f = new TFile("RecalibrationFactors.root","read");
  //cu->SetEMCALChannelRecalibrationFactors(0,(TH2F*)f->Get("EMCALRecalFactors_SM0"));
  //cu->SetEMCALChannelRecalibrationFactors(1,(TH2F*)f->Get("EMCALRecalFactors_SM1"));
  //cu->SetEMCALChannelRecalibrationFactors(2,(TH2F*)f->Get("EMCALRecalFactors_SM2"));
  //cu->SetEMCALChannelRecalibrationFactors(3,(TH2F*)f->Get("EMCALRecalFactors_SM3"));

  cu->SetDebug(-1);
  if(kPrintSettings) cu->Print("");

  // ##### Analysis algorithm settings ####
  //AliFiducialCut * fidCut = new AliFiducialCut();
  //fidCut->DoCTSFiducialCut(kFALSE) ;
  //fidCut->DoEMCALFiducialCut(kTRUE) ;
  //fidCut->DoPHOSFiducialCut(kTRUE) ;

  AliAnaCalorimeterQA *emcalQA = new AliAnaCalorimeterQA();
  //emcalQA->SetDebug(2); //10 for lots of messages
  emcalQA->SetCalorimeter("EMCAL");
  if(kUseKinematics) emcalQA->SwitchOnDataMC() ;//Access MC stack and fill more histograms, AOD MC not implemented yet.
  else  emcalQA->SwitchOffDataMC() ;
  emcalQA->AddToHistogramsName("EMCAL_"); //Begining of histograms name
  //emcalQA->SetFiducialCut(fidCut);
  emcalQA->SwitchOffFiducialCut();
  emcalQA->SwitchOffPlotsMaking();
  emcalQA->SwitchOnCorrelation();
  if(!kUseKinematics)emcalQA->SetTimeCut(400,850);//Open for the moment
  //Set Histrograms bins and ranges
  emcalQA->SetHistoPtRangeAndNBins(0, 50, 200) ;
  emcalQA->SetHistoFinePtRangeAndNBins(0, 10, 200) ; // bining for fhAmpId
  emcalQA->SetHistoPhiRangeAndNBins(79*TMath::DegToRad(), 181*TMath::DegToRad(), 200) ;
  emcalQA->SetHistoEtaRangeAndNBins(-0.71, 0.71, 200) ;
  emcalQA->SetNumberOfModules(10);
  emcalQA->SetHistoMassRangeAndNBins(0., 1, 400) ;
  emcalQA->SetHistoAsymmetryRangeAndNBins(0., 1. , 10 );
  emcalQA->SetHistoPOverERangeAndNBins(0,10.,100);
  emcalQA->SetHistodEdxRangeAndNBins(0.,200.,200);
  emcalQA->SetHistodRRangeAndNBins(0.,TMath::Pi(),150);
  emcalQA->SetHistoTimeRangeAndNBins(300.,900,300);
  emcalQA->SetHistoRatioRangeAndNBins(0.,2.,100);
  emcalQA->SetHistoVertexDistRangeAndNBins(0.,500.,500);
  emcalQA->SetHistoNClusterCellRangeAndNBins(0,500,500);
  emcalQA->SetHistoXRangeAndNBins(-230,90,120);
  emcalQA->SetHistoYRangeAndNBins(370,450,40);
  emcalQA->SetHistoZRangeAndNBins(-400,400,200);
  emcalQA->SetHistoRRangeAndNBins(400,450,25);
  emcalQA->SetHistoV0SignalRangeAndNBins(0,5000,500);
  emcalQA->SetHistoV0MultiplicityRangeAndNBins(0,5000,500);
  emcalQA->SetHistoTrackMultiplicityRangeAndNBins(0,5000,500);
  //emcalQA->GetMCAnalysisUtils()->SetDebug(10);

  if(kPrintSettings) emcalQA->Print("");

  AliAnaCalorimeterQA *phosQA = new AliAnaCalorimeterQA();
  //phosQA->SetDebug(2); //10 for lots of messages
  phosQA->SetCalorimeter("PHOS");
  if(kUseKinematics) phosQA->SwitchOnDataMC() ;//Access MC stack and fill more histograms, AOD MC not implemented yet.
  else  phosQA->SwitchOffDataMC() ;
  phosQA->AddToHistogramsName("PHOS_");//Begining of histograms name
  //phosQA->SetFiducialCut(fidCut);
  phosQA->SwitchOffFiducialCut();
  //phosQA->GetMCAnalysisUtils()->SetDebug(10);
  phosQA->SwitchOffPlotsMaking();
  //Set Histrograms bins and ranges
  phosQA->SetHistoPtRangeAndNBins(0, 50, 200) ;
  phosQA->SetHistoFinePtRangeAndNBins(0, 10, 200) ; // bining for fhAmpId
  phosQA->SetHistoPhiRangeAndNBins(259*TMath::DegToRad(), 321*TMath::DegToRad(), 130) ;
  phosQA->SetHistoEtaRangeAndNBins(-0.125, 0.125, 57) ;
  phosQA->SetNumberOfModules(3); //PHOS first year
  phosQA->SetHistoMassRangeAndNBins(0., 1., 400) ;
  phosQA->SetHistoAsymmetryRangeAndNBins(0., 1. , 10) ;
  phosQA->SetHistoPOverERangeAndNBins(0,10.,100);
  phosQA->SetHistodEdxRangeAndNBins(0.,200.,200);
  phosQA->SetHistodRRangeAndNBins(0.,TMath::Pi(),150);
  phosQA->SetHistoTimeRangeAndNBins(0.,300,300);
  phosQA->SetHistoRatioRangeAndNBins(0.,2.,100);
  phosQA->SetHistoVertexDistRangeAndNBins(0.,500.,500);
  phosQA->SetHistoNClusterCellRangeAndNBins(0,500,500);
  phosQA->SetHistoXRangeAndNBins(-100,400,100);
  phosQA->SetHistoYRangeAndNBins(-490,-290,100);
  phosQA->SetHistoZRangeAndNBins(-80,80,100);
  phosQA->SetHistoRRangeAndNBins(440,480,80);
  phosQA->SetHistoV0SignalRangeAndNBins(0,5000,500);
  phosQA->SetHistoV0MultiplicityRangeAndNBins(0,5000,500);
  phosQA->SetHistoTrackMultiplicityRangeAndNBins(0,5000,500);

  // #### Configure Maker ####
  AliAnaPartCorrMaker * maker = new AliAnaPartCorrMaker();
  maker->SetReader(reader);//pointer to reader
  maker->SetCaloUtils(cu); //pointer to calorimeter utils
  maker->AddAnalysis(emcalQA,0);
  maker->AddAnalysis(phosQA,1);
  maker->SetAnaDebug(-1)  ; // 0 to at least print the event number
  maker->SwitchOnHistogramsMaker()  ;
  maker->SwitchOffAODsMaker()  ;
  if(kPrintSettings) maker->Print("");

  printf("======================== \n");
  printf(" End Configuration of Calorimeter QA \n");
  printf("======================== \n");

  // Create task
  //===========================================================================
  AliAnalysisTaskParticleCorrelation * task = new AliAnalysisTaskParticleCorrelation ("CalorimeterPerformance");
  task->SetConfigFileName(""); //Don't configure the analysis via configuration file.
  //task->SetDebugLevel(-1);
  task->SelectCollisionCandidates();
  task->SetAnalysisMaker(maker);
  mgr->AddTask(task);

  //Create containers
  //  AliAnalysisDataContainer *cout_pc = mgr->CreateContainer("Calo.Performance",TList::Class(),
  //							   AliAnalysisManager::kOutputContainer, "Calo.Performance.root");

  if(outputFile.Length()==0)outputFile = AliAnalysisManager::GetCommonFileName();

  AliAnalysisDataContainer *cout_pc   = mgr->CreateContainer("CaloQA", TList::Class(),
                                                             AliAnalysisManager::kOutputContainer,
                                                             Form("%s:CaloQA",outputFile.Data()));

  AliAnalysisDataContainer *cout_cuts = mgr->CreateContainer("CaloQACuts", TList::Class(),
                                                             AliAnalysisManager::kParamContainer,
                                                             Form("%s:CaloQACuts",outputFile.Data()));
	//Form("%s:PartCorrCuts",outputfile.Data()));
  // Create ONLY the output containers for the data produced by the task.
  // Get and connect other common input/output containers via the manager as below
  //==============================================================================
  mgr->ConnectInput  (task, 0, mgr->GetCommonInputContainer());
  mgr->ConnectOutput (task, 1, cout_pc);
  mgr->ConnectOutput (task, 2, cout_cuts);

  return task;
}

<commit_msg>trick to fill missing histograms<commit_after>//
// Wagon contacts: EMCAL Gustavo.Conesa.Balbastre@cern.ch
//                 PHOS  Yuri.Kharlov@cern.ch
//
AliAnalysisTaskParticleCorrelation *AddTaskCalorimeterQA(TString data, Bool_t kPrintSettings = kFALSE,Bool_t kSimulation = kFALSE,TString outputFile = "", Bool_t oldAOD=kFALSE)
{
  // Creates a PartCorr task for calorimeters performance studies, configures it and adds it to the analysis manager.

  // Get the pointer to the existing analysis manager via the static access method.
  //==============================================================================
  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
  if (!mgr) {
    ::Error("AddTaskPartCorr", "No analysis manager to connect to.");
    return NULL;
  }

  // Check the analysis type using the event handlers connected to the analysis manager.
  //==============================================================================
  if (!mgr->GetInputEventHandler()) {
    ::Error("AddTaskPartCorr", "This task requires an input event handler");
    return NULL;
  }
  TString inputDataType = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"

  Bool_t kUseKinematics = (mgr->GetMCtruthEventHandler())?kTRUE:kFALSE;

  cout<<"********* ACCESS KINE? "<<kUseKinematics<<endl;

  // Configure analysis
  //===========================================================================

  //Reader
  //For this particular analysis few things done by the reader.
  //Nothing else needs to be set.
  AliCaloTrackReader * reader = 0x0;
  if     (data=="AOD") reader = new AliCaloTrackAODReader();
  else if(data=="ESD") reader = new AliCaloTrackESDReader();
  //reader->SetDebug(10);//10 for lots of messages
  reader->SwitchOnEMCALCells();
  reader->SwitchOnPHOSCells();
  reader->SwitchOnEMCAL();
  reader->SwitchOnPHOS();
  reader->SwitchOnCTS();
  reader->SetEMCALPtMin(0.);
  reader->SetPHOSPtMin (0.);
  reader->SetCTSPtMin  (0.);
  reader->SetZvertexCut(10.);

  if(kUseKinematics){
    if(inputDataType == "ESD"){
      reader->SwitchOnStack();
      reader->SwitchOffAODMCParticles();
    }
    else if(inputDataType == "AOD"){
      reader->SwitchOffStack();
      reader->SwitchOnAODMCParticles();
    }
  }
  //if(!kSimulation) reader->SetFiredTriggerClassName("CINT1B-ABCE-NOPF-ALL");
  reader->SetDeltaAODFileName(""); //Do not create deltaAOD file, this analysis do not create branches.
  reader->SwitchOffWriteDeltaAOD()  ;
  if(oldAOD)         reader->SwitchOnOldAODs();
  if(kPrintSettings) reader->Print("");

  // *** Calorimeters Utils	***
  AliCalorimeterUtils *cu = new AliCalorimeterUtils;
  // Remove clusters close to borders, at least max energy cell is 1 cell away
  cu->SetNumberOfCellsFromEMCALBorder(1);
  cu->SetNumberOfCellsFromPHOSBorder(2);
  cu->SetEMCALGeometryName("EMCAL_COMPLETEV1");
  // Remove EMCAL hottest channels for first LHC10 periods
  cu->SwitchOnBadChannelsRemoval();
  // SM0
  //cu->SetEMCALChannelStatus(0,3,13);  cu->SetEMCALChannelStatus(0,44,1); cu->SetEMCALChannelStatus(0,3,13);
  //cu->SetEMCALChannelStatus(0,20,7);  cu->SetEMCALChannelStatus(0,38,2);
  // SM1
  //cu->SetEMCALChannelStatus(1,4,7);   cu->SetEMCALChannelStatus(1,4,13);  cu->SetEMCALChannelStatus(1,9,20);
  //cu->SetEMCALChannelStatus(1,14,15); cu->SetEMCALChannelStatus(1,23,16); cu->SetEMCALChannelStatus(1,32,23);
  //cu->SetEMCALChannelStatus(1,37,5);  cu->SetEMCALChannelStatus(1,40,1);  cu->SetEMCALChannelStatus(1,40,2);
  //cu->SetEMCALChannelStatus(1,40,5);  cu->SetEMCALChannelStatus(1,41,0);  cu->SetEMCALChannelStatus(1,41,1);
  //cu->SetEMCALChannelStatus(1,41,2);  cu->SetEMCALChannelStatus(1,41,4);
  // SM2
  //cu->SetEMCALChannelStatus(2,14,15); cu->SetEMCALChannelStatus(2,18,16); cu->SetEMCALChannelStatus(2,18,17);
  //cu->SetEMCALChannelStatus(2,18,18); cu->SetEMCALChannelStatus(2,18,20); cu->SetEMCALChannelStatus(2,18,21);
  //cu->SetEMCALChannelStatus(2,18,23); cu->SetEMCALChannelStatus(2,19,16); cu->SetEMCALChannelStatus(2,19,17);
  //cu->SetEMCALChannelStatus(2,19,19); cu->SetEMCALChannelStatus(2,19,20); cu->SetEMCALChannelStatus(2,19,21);
  //cu->SetEMCALChannelStatus(2,19,22);
  //SM3
  //cu->SetEMCALChannelStatus(3,4,7);

  //Recalibration
  //cu->SwitchOnRecalibration();
  //TFile * f = new TFile("RecalibrationFactors.root","read");
  //cu->SetEMCALChannelRecalibrationFactors(0,(TH2F*)f->Get("EMCALRecalFactors_SM0"));
  //cu->SetEMCALChannelRecalibrationFactors(1,(TH2F*)f->Get("EMCALRecalFactors_SM1"));
  //cu->SetEMCALChannelRecalibrationFactors(2,(TH2F*)f->Get("EMCALRecalFactors_SM2"));
  //cu->SetEMCALChannelRecalibrationFactors(3,(TH2F*)f->Get("EMCALRecalFactors_SM3"));

  cu->SetDebug(-1);
  if(kPrintSettings) cu->Print("");

  // ##### Analysis algorithm settings ####
  //AliFiducialCut * fidCut = new AliFiducialCut();
  //fidCut->DoCTSFiducialCut(kFALSE) ;
  //fidCut->DoEMCALFiducialCut(kTRUE) ;
  //fidCut->DoPHOSFiducialCut(kTRUE) ;

  AliAnaCalorimeterQA *emcalQA = new AliAnaCalorimeterQA();
  //emcalQA->SetDebug(10); //10 for lots of messages
  emcalQA->SetCalorimeter("EMCAL");
  if(kUseKinematics) emcalQA->SwitchOnDataMC() ;//Access MC stack and fill more histograms, AOD MC not implemented yet.
  else  emcalQA->SwitchOffDataMC() ;
  emcalQA->AddToHistogramsName("EMCAL_"); //Begining of histograms name
  //emcalQA->SetFiducialCut(fidCut);
  emcalQA->SwitchOffFiducialCut();
  emcalQA->SwitchOffPlotsMaking();
  emcalQA->SwitchOnCorrelation();
//  if(!kUseKinematics)emcalQA->SetTimeCut(400,850);//Open for the moment
  //Set Histrograms bins and ranges
  emcalQA->SetHistoPtRangeAndNBins(0, 50, 200) ;
  emcalQA->SetHistoFinePtRangeAndNBins(0, 10, 200) ; // bining for fhAmpId
  emcalQA->SetHistoPhiRangeAndNBins(79*TMath::DegToRad(), 181*TMath::DegToRad(), 200) ;
  emcalQA->SetHistoEtaRangeAndNBins(-0.71, 0.71, 200) ;
  emcalQA->SetNumberOfModules(10);
  emcalQA->SetHistoMassRangeAndNBins(0., 1, 400) ;
  emcalQA->SetHistoAsymmetryRangeAndNBins(0., 1. , 10 );
  emcalQA->SetHistoPOverERangeAndNBins(0,10.,100);
  emcalQA->SetHistodEdxRangeAndNBins(0.,200.,200);
  emcalQA->SetHistodRRangeAndNBins(0.,TMath::Pi(),150);
  emcalQA->SetHistoTimeRangeAndNBins(300.,900,300);
  emcalQA->SetHistoRatioRangeAndNBins(0.,2.,100);
  emcalQA->SetHistoVertexDistRangeAndNBins(0.,500.,500);
  emcalQA->SetHistoNClusterCellRangeAndNBins(0,500,500);
  emcalQA->SetHistoXRangeAndNBins(-230,90,120);
  emcalQA->SetHistoYRangeAndNBins(370,450,40);
  emcalQA->SetHistoZRangeAndNBins(-400,400,200);
  emcalQA->SetHistoRRangeAndNBins(400,450,25);
  emcalQA->SetHistoV0SignalRangeAndNBins(0,5000,500);
  emcalQA->SetHistoV0MultiplicityRangeAndNBins(0,5000,500);
  emcalQA->SetHistoTrackMultiplicityRangeAndNBins(0,5000,500);
  //emcalQA->GetMCAnalysisUtils()->SetDebug(10);

  if(kPrintSettings) emcalQA->Print("");

  AliAnaCalorimeterQA *phosQA = new AliAnaCalorimeterQA();
  //phosQA->SetDebug(2); //10 for lots of messages
  phosQA->SetCalorimeter("PHOS");
  if(kUseKinematics) phosQA->SwitchOnDataMC() ;//Access MC stack and fill more histograms, AOD MC not implemented yet.
  else  phosQA->SwitchOffDataMC() ;
  phosQA->AddToHistogramsName("PHOS_");//Begining of histograms name
  //phosQA->SetFiducialCut(fidCut);
  phosQA->SwitchOffFiducialCut();
  //phosQA->GetMCAnalysisUtils()->SetDebug(10);
  phosQA->SwitchOffPlotsMaking();
  //Set Histrograms bins and ranges
  phosQA->SetHistoPtRangeAndNBins(0, 50, 200) ;
  phosQA->SetHistoFinePtRangeAndNBins(0, 10, 200) ; // bining for fhAmpId
  phosQA->SetHistoPhiRangeAndNBins(259*TMath::DegToRad(), 321*TMath::DegToRad(), 130) ;
  phosQA->SetHistoEtaRangeAndNBins(-0.125, 0.125, 57) ;
  phosQA->SetNumberOfModules(3); //PHOS first year
  phosQA->SetHistoMassRangeAndNBins(0., 1., 400) ;
  phosQA->SetHistoAsymmetryRangeAndNBins(0., 1. , 10) ;
  phosQA->SetHistoPOverERangeAndNBins(0,10.,100);
  phosQA->SetHistodEdxRangeAndNBins(0.,200.,200);
  phosQA->SetHistodRRangeAndNBins(0.,TMath::Pi(),150);
  phosQA->SetHistoTimeRangeAndNBins(0.,300,300);
  phosQA->SetHistoRatioRangeAndNBins(0.,2.,100);
  phosQA->SetHistoVertexDistRangeAndNBins(0.,500.,500);
  phosQA->SetHistoNClusterCellRangeAndNBins(0,500,500);
  phosQA->SetHistoXRangeAndNBins(-100,400,100);
  phosQA->SetHistoYRangeAndNBins(-490,-290,100);
  phosQA->SetHistoZRangeAndNBins(-80,80,100);
  phosQA->SetHistoRRangeAndNBins(440,480,80);
  phosQA->SetHistoV0SignalRangeAndNBins(0,5000,500);
  phosQA->SetHistoV0MultiplicityRangeAndNBins(0,5000,500);
  phosQA->SetHistoTrackMultiplicityRangeAndNBins(0,5000,500);

  // #### Configure Maker ####
  AliAnaPartCorrMaker * maker = new AliAnaPartCorrMaker();
  maker->SetReader(reader);//pointer to reader
  maker->SetCaloUtils(cu); //pointer to calorimeter utils
  maker->AddAnalysis(emcalQA,0);
  maker->AddAnalysis(phosQA,1);
  maker->SetAnaDebug(-1)  ; // 0 to at least print the event number
  maker->SwitchOnHistogramsMaker()  ;
  maker->SwitchOffAODsMaker()  ;
  if(kPrintSettings) maker->Print("");

  printf("======================== \n");
  printf(" End Configuration of Calorimeter QA \n");
  printf("======================== \n");

  // Create task
  //===========================================================================
  AliAnalysisTaskParticleCorrelation * task = new AliAnalysisTaskParticleCorrelation ("CalorimeterPerformance");
  task->SetConfigFileName(""); //Don't configure the analysis via configuration file.
  //task->SetDebugLevel(-1);
  task->SelectCollisionCandidates();
  task->SetAnalysisMaker(maker);
  mgr->AddTask(task);

  //Create containers
  //  AliAnalysisDataContainer *cout_pc = mgr->CreateContainer("Calo.Performance",TList::Class(),
  //							   AliAnalysisManager::kOutputContainer, "Calo.Performance.root");

  if(outputFile.Length()==0)outputFile = AliAnalysisManager::GetCommonFileName();

  AliAnalysisDataContainer *cout_pc   = mgr->CreateContainer("CaloQA", TList::Class(),
                                                             AliAnalysisManager::kOutputContainer,
                                                             Form("%s:CaloQA",outputFile.Data()));

  AliAnalysisDataContainer *cout_cuts = mgr->CreateContainer("CaloQACuts", TList::Class(),
                                                             AliAnalysisManager::kParamContainer,
                                                             Form("%s:CaloQACuts",outputFile.Data()));
	//Form("%s:PartCorrCuts",outputfile.Data()));
  // Create ONLY the output containers for the data produced by the task.
  // Get and connect other common input/output containers via the manager as below
  //==============================================================================
  mgr->ConnectInput  (task, 0, mgr->GetCommonInputContainer());
  mgr->ConnectOutput (task, 1, cout_pc);
  mgr->ConnectOutput (task, 2, cout_cuts);

  return task;
}

<|endoftext|>


<commit_before><commit_msg>add get_logger_debug to disable logging by default<commit_after><|endoftext|>