<commit_before>// $Id$

AliAnalysisTaskEmcalJetSample* AddTaskEmcalJetSample(
  const char *ntracks            = "Tracks",
  const char *nclusters          = "CaloClusters",
  const char *njets              = "Jets",
  const char *nrho               = "Rho",
  Int_t       nCentBins          = 1,
  Double_t    jetradius          = 0.2,
  Double_t    jetptcut           = 1,
  Double_t    jetareacut         = 0.6,
  const char *type               = "EMCAL",
  Int_t       leadhadtype        = 0,
  const char *taskname           = "AliAnalysisTaskEmcalJetSample"
)
{
  // Get the pointer to the existing analysis manager via the static access method.
  //==============================================================================
  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
  if (!mgr)
  {
    ::Error("AddTaskEmcalJetSample", "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("AddTaskEmcalJetSample", "This task requires an input event handler");
    return NULL;
  }

  //-------------------------------------------------------
  // Init the task and do settings
  //-------------------------------------------------------

  TString name(taskname);
  if (strcmp(njets,"")) {
    name += "_";
    name += njets;
  }
  if (strcmp(nrho,"")) {
    name += "_";
    name += nrho;
  }
  if (strcmp(type,"")) {
    name += "_";
    name += type;
  }

  Printf("name: %s",name.Data());

  AliAnalysisTaskEmcalJetSample* jetTask = new AliAnalysisTaskEmcalJetSample(name);
  jetTask->SetCentRange(0.,100.);
  jetTask->SetNCentBins(nCentBins);

  AliParticleContainer *trackCont  = jetTask->AddParticleContainer(ntracks);
  trackCont->SetClassName("AliVTrack");
  AliClusterContainer *clusterCont = jetTask->AddClusterContainer(nclusters);

  TString strType(type);
  AliJetContainer *jetCont = jetTask->AddJetContainer(njets,strType,jetradius);
  if(jetCont) {
    jetCont->SetRhoName(nrho);
    jetCont->ConnectParticleContainer(trackCont);
    jetCont->ConnectClusterContainer(clusterCont);
    jetCont->SetZLeadingCut(0.98,0.98);
    jetCont->SetPercAreaCut(0.6);
    jetCont->SetJetPtCut(jetptcut);
    jetCont->SetLeadingHadronType(leadhadtype);
  }

  //-------------------------------------------------------
  // Final settings, pass to manager and set the containers
  //-------------------------------------------------------

  mgr->AddTask(jetTask);

  // Create containers for input/output
  AliAnalysisDataContainer *cinput1  = mgr->GetCommonInputContainer()  ;
  TString contname(name);
  contname += "_histos";
  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer(contname.Data(),
							    TList::Class(),AliAnalysisManager::kOutputContainer,
							    Form("%s", AliAnalysisManager::GetCommonFileName()));
  mgr->ConnectInput  (jetTask, 0,  cinput1 );
  mgr->ConnectOutput (jetTask, 1, coutput1 );

  return jetTask;
}

AliAnalysisTaskEmcalJetSample* AddTaskEmcalJetSample( AliEmcalJetTask* jetFinderTask,
  Int_t       nCentBins          = 1,
  Double_t    jetareacut         = 0.6,
  const char *type               = "EMCAL",
  Int_t       leadhadtype        = 0,
  const char *taskname           = "AliAnalysisTaskEmcalJetSample"
)
    {
    const char* ntracks            = jetFinderTask->GetTracksName();
    const char* nclusters          = jetFinderTask->GetClusName();
    const char* njets              = jetFinderTask->GetJetsName();
    const char* nrho               = jetFinderTask->GetRhoName();
    Double_t    jetradius          = jetFinderTask->GetRadius();
    Double_t    jetptcut           = jetFinderTask->GetMinJetPt();

    AliAnalysisTaskEmcalJetSample* jetTask = AddTaskEmcalJetSample(ntracks , nclusters, njets, nrho, nCentBins, jetradius, jetptcut, jetareacut, type, leadhadtype, taskname);

    return jetTask;
    }
<commit_msg>Fixed bug: Parameter jetareacut was not used.<commit_after>// $Id$

AliAnalysisTaskEmcalJetSample* AddTaskEmcalJetSample(
  const char *ntracks            = "Tracks",
  const char *nclusters          = "CaloClusters",
  const char *njets              = "Jets",
  const char *nrho               = "Rho",
  Int_t       nCentBins          = 1,
  Double_t    jetradius          = 0.2,
  Double_t    jetptcut           = 1,
  Double_t    jetareacut         = 0.6,
  const char *type               = "EMCAL",
  Int_t       leadhadtype        = 0,
  const char *taskname           = "AliAnalysisTaskEmcalJetSample"
)
{
  // Get the pointer to the existing analysis manager via the static access method.
  //==============================================================================
  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
  if (!mgr)
  {
    ::Error("AddTaskEmcalJetSample", "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("AddTaskEmcalJetSample", "This task requires an input event handler");
    return NULL;
  }

  //-------------------------------------------------------
  // Init the task and do settings
  //-------------------------------------------------------

  TString name(taskname);
  if (strcmp(njets,"")) {
    name += "_";
    name += njets;
  }
  if (strcmp(nrho,"")) {
    name += "_";
    name += nrho;
  }
  if (strcmp(type,"")) {
    name += "_";
    name += type;
  }

  Printf("name: %s",name.Data());

  AliAnalysisTaskEmcalJetSample* jetTask = new AliAnalysisTaskEmcalJetSample(name);
  jetTask->SetCentRange(0.,100.);
  jetTask->SetNCentBins(nCentBins);

  AliParticleContainer *trackCont  = jetTask->AddParticleContainer(ntracks);
  trackCont->SetClassName("AliVTrack");
  AliClusterContainer *clusterCont = jetTask->AddClusterContainer(nclusters);

  TString strType(type);
  AliJetContainer *jetCont = jetTask->AddJetContainer(njets,strType,jetradius);
  if(jetCont) {
    jetCont->SetRhoName(nrho);
    jetCont->ConnectParticleContainer(trackCont);
    jetCont->ConnectClusterContainer(clusterCont);
    jetCont->SetZLeadingCut(0.98,0.98);
    jetCont->SetPercAreaCut(jetareacut);
    jetCont->SetJetPtCut(jetptcut);
    jetCont->SetLeadingHadronType(leadhadtype);
  }

  //-------------------------------------------------------
  // Final settings, pass to manager and set the containers
  //-------------------------------------------------------

  mgr->AddTask(jetTask);

  // Create containers for input/output
  AliAnalysisDataContainer *cinput1  = mgr->GetCommonInputContainer()  ;
  TString contname(name);
  contname += "_histos";
  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer(contname.Data(),
							    TList::Class(),AliAnalysisManager::kOutputContainer,
							    Form("%s", AliAnalysisManager::GetCommonFileName()));
  mgr->ConnectInput  (jetTask, 0,  cinput1 );
  mgr->ConnectOutput (jetTask, 1, coutput1 );

  return jetTask;
}

AliAnalysisTaskEmcalJetSample* AddTaskEmcalJetSample( AliEmcalJetTask* jetFinderTask,
  Int_t       nCentBins          = 1,
  Double_t    jetareacut         = 0.6,
  const char *type               = "EMCAL",
  Int_t       leadhadtype        = 0,
  const char *taskname           = "AliAnalysisTaskEmcalJetSample"
)
    {
    const char* ntracks            = jetFinderTask->GetTracksName();
    const char* nclusters          = jetFinderTask->GetClusName();
    const char* njets              = jetFinderTask->GetJetsName();
    const char* nrho               = jetFinderTask->GetRhoName();
    Double_t    jetradius          = jetFinderTask->GetRadius();
    Double_t    jetptcut           = jetFinderTask->GetMinJetPt();

    AliAnalysisTaskEmcalJetSample* jetTask = AddTaskEmcalJetSample(ntracks , nclusters, njets, nrho, nCentBins, jetradius, jetptcut, jetareacut, type, leadhadtype, taskname);

    return jetTask;
    }
<|endoftext|>


<commit_before>#include "DySySim.h"
#include "LibInfoDySySim.h"
#include <unittest++/UnitTest++.h>
#include <iostream>

namespace dss = dysysim;
using namespace std;

const double EPS {0.0001};

SUITE(DySySim)
{
   TEST(Attenuator) {
      cout << "-- Attenuator" << endl;
      dss::Attenuator att{1, 10.0};
      att.input(1.0);
      CHECK_CLOSE(0.1, att.output(), EPS);
      att.input(-1.0);
      CHECK_CLOSE(-0.1, att.output(), EPS);
   }

   TEST(Gain) {
      cout << "-- Gain" << endl;
      dss::Gain gain{1, 10.0};
      gain.input(1.0);
      CHECK_CLOSE(10.0, gain.output(), EPS);
      gain.input(-1.0);
      CHECK_CLOSE(-10.0, gain.output(), EPS);
   }

   TEST(OnOff) {
      cout << "-- OnOff" << endl;
      dss::OnOff onoff{2, 10, 1.0, 0.0};
      onoff.input(-1.0);
      CHECK_CLOSE(0.0, onoff.output(), EPS);
      onoff.input(0.0);
      CHECK_CLOSE(0.0, onoff.output(), EPS);
      onoff.input(5.0);
      CHECK_CLOSE(0.0, onoff.output(), EPS);
      onoff.input(10.0);
      CHECK_CLOSE(1.0, onoff.output(), EPS);
      onoff.input(20.0);
      CHECK_CLOSE(1.0, onoff.output(), EPS);
   }

   TEST(Time) {
      cout << "-- Time" << endl;
      const double delta_t{0.1};
      dss::Time time{1, delta_t};
      CHECK_CLOSE(0.0, time.output(), EPS);
      for(int  i = 1; i < 10; ++i) {
         time.next();
         CHECK_CLOSE(i * delta_t, time.output(), EPS);
      }
   }

   TEST(Step) {
      const double delta_t{0.1};
      dss::Time time{1, delta_t};
      cout << "-- Step" << endl;
      dss::Step step{2, 0.0, 1.0, 4 * delta_t};
      CHECK_CLOSE(0.0, step.output(), EPS);
      time.next();
      step.next();
      CHECK_CLOSE(0.0, step.output(), EPS);
      time.next();
      step.next();
      CHECK_CLOSE(0.0, step.output(), EPS);
      time.next();
      step.next();
      CHECK_CLOSE(0.0, step.output(), EPS);
      time.next();
      step.next();
      CHECK_CLOSE(1.0, step.output(), EPS);
      time.next();
      step.next();
      CHECK_CLOSE(1.0, step.output(), EPS);
   }

   TEST(Delay) {
      const double delta_t{0.1};
      const double delayTime{3 * delta_t};
      dss::Time time{1, delta_t};
      cout << "-- Delay" << endl;
      dss::Step step{2, 0.0, 1.0, 2 * delta_t};
      dss::Delay delay{3, delayTime, 0.0};
      for(int i = 0; i < 10; ++i){
         auto input = step.output();
         delay.input(input);
         cout << step.output() << "  " << delay.output() << endl;
         if (i < 5) {
            CHECK_CLOSE(0.0, delay.output(), EPS);
         }
         else {
            CHECK_CLOSE(1.0, delay.output(), EPS);
         }
         time.next();
         step.next();
      }
   }
}

int main() {
   cout << "\n== Tests DySySim lib: " << dss::libVersion
        << " " << string(50, '=') << endl << endl;

   auto result = UnitTest::RunAllTests();

   cout << endl << string(80, '=') << endl;

   return result;
}
<commit_msg>DySySimTests: added Constant and Limit tests.<commit_after>#include "DySySim.h"
#include "LibInfoDySySim.h"
#include <unittest++/UnitTest++.h>
#include <iostream>

namespace dss = dysysim;
using namespace std;

const double EPS {0.0001};

SUITE(DySySim)
{
   TEST(Attenuator) {
      cout << "-- Attenuator" << endl;
      dss::Attenuator att{1, 10.0};
      att.input(1.0);
      CHECK_CLOSE(0.1, att.output(), EPS);
      att.input(-1.0);
      CHECK_CLOSE(-0.1, att.output(), EPS);
   }

   TEST(Constant) {
      cout << "-- Constant" << endl;
      dss::Constant con{1, 10.0};
      CHECK_CLOSE(10.0, con.output(), EPS);
   }

   TEST(Gain) {
      cout << "-- Gain" << endl;
      dss::Gain gain{1, 10.0};
      gain.input(1.0);
      CHECK_CLOSE(10.0, gain.output(), EPS);
      gain.input(-1.0);
      CHECK_CLOSE(-10.0, gain.output(), EPS);
   }

   TEST(Limit) {
      cout << "-- Limit" << endl;
      dss::Limit limit{1, -10.0, 20.0};
      limit.input(0.0);
      CHECK_CLOSE(0.0, limit.output(), EPS);
      limit.input(-12.0);
      CHECK_CLOSE(-10.0, limit.output(), EPS);
      limit.input(22.0);
      CHECK_CLOSE(20.0, limit.output(), EPS);
   }

   TEST(OnOff) {
      cout << "-- OnOff" << endl;
      dss::OnOff onoff{2, 10, 1.0, 0.0};
      onoff.input(-1.0);
      CHECK_CLOSE(0.0, onoff.output(), EPS);
      onoff.input(0.0);
      CHECK_CLOSE(0.0, onoff.output(), EPS);
      onoff.input(5.0);
      CHECK_CLOSE(0.0, onoff.output(), EPS);
      onoff.input(10.0);
      CHECK_CLOSE(1.0, onoff.output(), EPS);
      onoff.input(20.0);
      CHECK_CLOSE(1.0, onoff.output(), EPS);
   }

   TEST(Time) {
      cout << "-- Time" << endl;
      const double delta_t{0.1};
      dss::Time time{1, delta_t};
      CHECK_CLOSE(0.0, time.output(), EPS);
      for(int i = 1; i < 10; ++i) {
         time.next();
         CHECK_CLOSE(i * delta_t, time.output(), EPS);
      }
   }

   TEST(Step) {
      const double delta_t{0.1};
      dss::Time time{1, delta_t};
      cout << "-- Step" << endl;
      dss::Step step{2, 0.0, 1.0, 4 * delta_t};
      CHECK_CLOSE(0.0, step.output(), EPS);
      time.next();
      step.next();
      CHECK_CLOSE(0.0, step.output(), EPS);
      time.next();
      step.next();
      CHECK_CLOSE(0.0, step.output(), EPS);
      time.next();
      step.next();
      CHECK_CLOSE(0.0, step.output(), EPS);
      time.next();
      step.next();
      CHECK_CLOSE(1.0, step.output(), EPS);
      time.next();
      step.next();
      CHECK_CLOSE(1.0, step.output(), EPS);
   }

   TEST(Delay) {
      const double delta_t{0.1};
      const double delayTime{3 * delta_t};
      dss::Time time{1, delta_t};
      cout << "-- Delay" << endl;
      dss::Step step{2, 0.0, 1.0, 2 * delta_t};
      dss::Delay delay{3, delayTime, 0.0};
      for(int i = 0; i < 10; ++i){
         auto input = step.output();
         delay.input(input);
         if (i < 5) {
            CHECK_CLOSE(0.0, delay.output(), EPS);
         }
         else {
            CHECK_CLOSE(1.0, delay.output(), EPS);
         }
         time.next();
         step.next();
      }
   }
}

int main() {
   cout << "\n== Tests DySySim lib: " << dss::libVersion
        << " " << string(50, '=') << endl << endl;

   auto result = UnitTest::RunAllTests();

   cout << endl << string(80, '=') << endl;

   return result;
}
<|endoftext|>


<commit_before>/*
 * Copyright (c) 2007-2009 Digital Bazaar, Inc. All rights reserved.
 */
#include "db/sql/sqlite3/Sqlite3Connection.h"

#include "db/sql/sqlite3/Sqlite3Statement.h"
#include "db/io/File.h"

using namespace std;
using namespace db::io;
using namespace db::sql;
using namespace db::sql::sqlite3;
using namespace db::net;
using namespace db::rt;

Sqlite3Connection::Sqlite3Connection()
{
   // initialize handle to NULL
   mHandle = NULL;
}

Sqlite3Connection::~Sqlite3Connection()
{
   // ensure connection is closed
   Sqlite3Connection::close();
}

inline ::sqlite3* Sqlite3Connection::getHandle()
{
   return mHandle;
}

bool Sqlite3Connection::connect(Url* url)
{
   bool rval = false;

   if(strncmp(url->getScheme().c_str(), "sqlite3", 7) != 0)
   {
      ExceptionRef e = new Exception(
         "Could not connect to sqlite3 database, url scheme doesn't "
         "start with 'sqlite3'.",
         "db.sql.BadUrlScheme");
      e->getDetails()["url"] = url->toString().c_str();
      Exception::set(e);
   }
   else
   {
      // get database name
      string db;
      if(strcmp(url->toString().c_str(), "sqlite3::memory:") == 0)
      {
         // use in-memory database
         db = ":memory:";
         rval = true;
      }
      else
      {
         // use local file for database
         File file(url->getPath().c_str());
         db = file->getAbsolutePath();
         rval = file->mkdirs();
      }

      if(rval)
      {
         // open sqlite3 connection
         int ec = sqlite3_open(db.c_str(), &mHandle);
         if(ec != SQLITE_OK)
         {
            // create exception, close connection
            ExceptionRef e = new Sqlite3Exception(this);
            e->getDetails()["url"] = url->toString().c_str();
            e->getDetails()["db"] = db.c_str();
            Exception::set(e);
            Sqlite3Connection::close();
            rval = false;
         }
         else
         {
            // connected, set busy timeout to 15 seconds
            sqlite3_busy_timeout(mHandle, 15000);
         }
      }
   }

   return rval;
}

void Sqlite3Connection::close()
{
   AbstractConnection::close();

   if(mHandle != NULL)
   {
      sqlite3_close(mHandle);
      mHandle = NULL;
   }
}

bool Sqlite3Connection::rollback()
{
   bool rval = true;

   // save the reason for the rollback
   ExceptionRef reason = Exception::get();

   // Note: This is necessary on the current version of sqlite3... all
   // statements must be reset or finalized before doing a rollback:
   for(PreparedStmtMap::iterator i = mPreparedStmts.begin();
       rval && i != mPreparedStmts.end(); i++)
   {
      Sqlite3Statement* s = (Sqlite3Statement*)i->second;
      rval = s->reset();
   }

   if(rval)
   {
      // attempt to do the rollback
      Statement* s = prepare("ROLLBACK");
      rval = (s != NULL) && s->execute() && s->reset();
   }

   if(!rval)
   {
      ExceptionRef e = new Exception(
         "Could not rollback transaction.",
         "db.sql.Connection.TransactionRollbackError");
      if(!reason.isNull())
      {
         e->getDetails()["rollbackReason"] =
            Exception::convertToDynamicObject(reason);
      }
      Exception::push(e);
   }

   return rval;
}

inline bool Sqlite3Connection::isConnected()
{
   return mHandle != NULL;
}

Statement* Sqlite3Connection::createStatement(const char* sql)
{
   // create statement
   Sqlite3Statement* rval = new Sqlite3Statement(sql);
   if(!rval->initialize(this))
   {
      // delete statement if it could not be initialized
      delete rval;
      rval = NULL;
   }

   return rval;
}
<commit_msg>Updated open call to use new API. This allows multithreaded access to sqlite databases.<commit_after>/*
 * Copyright (c) 2007-2009 Digital Bazaar, Inc. All rights reserved.
 */
#include "db/sql/sqlite3/Sqlite3Connection.h"

#include "db/sql/sqlite3/Sqlite3Statement.h"
#include "db/io/File.h"

using namespace std;
using namespace db::io;
using namespace db::sql;
using namespace db::sql::sqlite3;
using namespace db::net;
using namespace db::rt;

Sqlite3Connection::Sqlite3Connection()
{
   // initialize handle to NULL
   mHandle = NULL;
}

Sqlite3Connection::~Sqlite3Connection()
{
   // ensure connection is closed
   Sqlite3Connection::close();
}

inline ::sqlite3* Sqlite3Connection::getHandle()
{
   return mHandle;
}

bool Sqlite3Connection::connect(Url* url)
{
   bool rval = false;

   if(strncmp(url->getScheme().c_str(), "sqlite3", 7) != 0)
   {
      ExceptionRef e = new Exception(
         "Could not connect to sqlite3 database, url scheme doesn't "
         "start with 'sqlite3'.",
         "db.sql.BadUrlScheme");
      e->getDetails()["url"] = url->toString().c_str();
      Exception::set(e);
   }
   else
   {
      // get database name
      string db;
      if(strcmp(url->toString().c_str(), "sqlite3::memory:") == 0)
      {
         // use in-memory database
         db = ":memory:";
         rval = true;
      }
      else
      {
         // use local file for database
         File file(url->getPath().c_str());
         db = file->getAbsolutePath();
         rval = file->mkdirs();
      }

      if(rval)
      {
         // open sqlite3 connection, SQLITE_OPEN_NOMUTEX will allow
         // multi-threaded access to the database as opposed to
         // SQLITE_OPEN_FULLMUTEX which would serialize all access to
         // the database
         int ec = sqlite3_open_v2(
            db.c_str(), &mHandle,
            SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_NOMUTEX,
            NULL);
         if(ec != SQLITE_OK)
         {
            // create exception, close connection
            ExceptionRef e = new Sqlite3Exception(this);
            e->getDetails()["url"] = url->toString().c_str();
            e->getDetails()["db"] = db.c_str();
            Exception::set(e);
            Sqlite3Connection::close();
            rval = false;
         }
         else
         {
            // connected, set busy timeout to 15 seconds
            sqlite3_busy_timeout(mHandle, 15000);
         }
      }
   }

   return rval;
}

void Sqlite3Connection::close()
{
   AbstractConnection::close();

   if(mHandle != NULL)
   {
      sqlite3_close(mHandle);
      mHandle = NULL;
   }
}

bool Sqlite3Connection::rollback()
{
   bool rval = true;

   // save the reason for the rollback
   ExceptionRef reason = Exception::get();

   // Note: This is necessary on the current version of sqlite3... all
   // statements must be reset or finalized before doing a rollback:
   for(PreparedStmtMap::iterator i = mPreparedStmts.begin();
       rval && i != mPreparedStmts.end(); i++)
   {
      Sqlite3Statement* s = (Sqlite3Statement*)i->second;
      rval = s->reset();
   }

   if(rval)
   {
      // attempt to do the rollback
      Statement* s = prepare("ROLLBACK");
      rval = (s != NULL) && s->execute() && s->reset();
   }

   if(!rval)
   {
      ExceptionRef e = new Exception(
         "Could not rollback transaction.",
         "db.sql.Connection.TransactionRollbackError");
      if(!reason.isNull())
      {
         e->getDetails()["rollbackReason"] =
            Exception::convertToDynamicObject(reason);
      }
      Exception::push(e);
   }

   return rval;
}

inline bool Sqlite3Connection::isConnected()
{
   return mHandle != NULL;
}

Statement* Sqlite3Connection::createStatement(const char* sql)
{
   // create statement
   Sqlite3Statement* rval = new Sqlite3Statement(sql);
   if(!rval->initialize(this))
   {
      // delete statement if it could not be initialized
      delete rval;
      rval = NULL;
   }

   return rval;
}
<|endoftext|>


<commit_before>AliAnalysisTaskFilterHe3Local *AddTask_FilterHe3Local(TString name = "standard")
{

  //get the current analysis manager
  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
  if (!mgr) {
    Error("AddTask_FilterHe3", "No analysis manager found.");
    return 0;
  }

  // Check the analysis type using the event handlers connected to the analysis manager.
   //==============================================================================
   if (!mgr->GetInputEventHandler()) {
      ::Error("AddTask_FilterHe3", "This task requires an input event handler");
      return NULL;
   }

  //========= Add task to the ANALYSIS manager =====
  AliAnalysisTaskFilterHe3Local *task = new AliAnalysisTaskFilterHe3Local(Form("akalweitTaskFilterHe3_%s", name.Data()));
  //task->SelectCollisionCandidates(AliVEvent::kINT7|AliVEvent::kCentral|AliVEvent::kSemiCentral);

  //================================================
  //              data containers
  //================================================

  //dumm output container
  AliAnalysisDataContainer *coutput0 =
      mgr->CreateContainer("akalweit_treeFilterHe3",
                           TTree::Class(),
                           AliAnalysisManager::kExchangeContainer,
                           "akalweit_default");

// Create containers for input/output
  AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("akalweit_filterHe3_hist", TList::Class(), AliAnalysisManager::kOutputContainer, Form("AnalysisResults.root:FilterHe3_%s", name.Data()));
  AliAnalysisDataContainer *coutput2 = mgr->CreateContainer("akalweit_filterHe3_names", TTree::Class(), AliAnalysisManager::kOutputContainer, Form("AnalysisResults.root:FilterHe3_List_%s", name.Data()));

  // Connect input/output
  mgr->ConnectInput(task, 0, cinput);
  mgr->ConnectOutput(task, 1, coutput1);
  mgr->ConnectOutput(task, 2, coutput2);

  return task;
}
<commit_msg>Bux fix in addtask name<commit_after>AliAnalysisTaskFilterHe3 *AddTask_FilterHe3(TString name = "standard")
{

  //get the current analysis manager
  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
  if (!mgr) {
    Error("AddTask_FilterHe3", "No analysis manager found.");
    return 0;
  }

  // Check the analysis type using the event handlers connected to the analysis manager.
   //==============================================================================
   if (!mgr->GetInputEventHandler()) {
      ::Error("AddTask_FilterHe3", "This task requires an input event handler");
      return NULL;
   }

  //========= Add task to the ANALYSIS manager =====
  AliAnalysisTaskFilterHe3 *task = new AliAnalysisTaskFilterHe3(Form("akalweitTaskFilterHe3_%s", name.Data()));
  //task->SelectCollisionCandidates(AliVEvent::kINT7|AliVEvent::kCentral|AliVEvent::kSemiCentral);

  //================================================
  //              data containers
  //================================================

  //dumm output container
  AliAnalysisDataContainer *coutput0 =
      mgr->CreateContainer("akalweit_treeFilterHe3",
                           TTree::Class(),
                           AliAnalysisManager::kExchangeContainer,
                           "akalweit_default");

// Create containers for input/output
  AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("akalweit_filterHe3_hist", TList::Class(), AliAnalysisManager::kOutputContainer, Form("AnalysisResults.root:FilterHe3_%s", name.Data()));
  AliAnalysisDataContainer *coutput2 = mgr->CreateContainer("akalweit_filterHe3_names", TTree::Class(), AliAnalysisManager::kOutputContainer, Form("AnalysisResults.root:FilterHe3_List_%s", name.Data()));

  // Connect input/output
  mgr->ConnectInput(task, 0, cinput);
  mgr->ConnectOutput(task, 1, coutput1);
  mgr->ConnectOutput(task, 2, coutput2);

  return task;
}
<|endoftext|>


<commit_before>#include "DySySim.h"
#include "LibInfoDySySim.h"
#include <unittest++/UnitTest++.h>
#include <iostream>

namespace dss = dysysim;
using namespace std;

const double EPS {0.0001};

SUITE(DySySim)
{
   TEST(Attenuator) {
      cout << "-- Attenuator" << endl;
      dss::Attenuator att{1, 10.0};
      att.input(1.0);
      CHECK_CLOSE(0.1, att.output(), EPS);
      att.input(-1.0);
      CHECK_CLOSE(-0.1, att.output(), EPS);
   }

   TEST(Constant) {
      cout << "-- Constant" << endl;
      dss::Constant con{1, 10.0};
      CHECK_CLOSE(10.0, con.output(), EPS);
   }

   TEST(Gain) {
      cout << "-- Gain" << endl;
      dss::Gain gain{1, 10.0};
      gain.input(1.0);
      CHECK_CLOSE(10.0, gain.output(), EPS);
      gain.input(-1.0);
      CHECK_CLOSE(-10.0, gain.output(), EPS);
   }

   TEST(Limit) {
      cout << "-- Limit" << endl;
      dss::Limit limit{1, -10.0, 20.0};
      limit.input(0.0);
      CHECK_CLOSE(0.0, limit.output(), EPS);
      limit.input(-12.0);
      CHECK_CLOSE(-10.0, limit.output(), EPS);
      limit.input(22.0);
      CHECK_CLOSE(20.0, limit.output(), EPS);
   }

   TEST(OnOff) {
      cout << "-- OnOff" << endl;
      dss::OnOff onoff{2, 10, 1.0, 0.0};
      onoff.input(-1.0);
      CHECK_CLOSE(0.0, onoff.output(), EPS);
      onoff.input(0.0);
      CHECK_CLOSE(0.0, onoff.output(), EPS);
      onoff.input(5.0);
      CHECK_CLOSE(0.0, onoff.output(), EPS);
      onoff.input(10.0);
      CHECK_CLOSE(1.0, onoff.output(), EPS);
      onoff.input(20.0);
      CHECK_CLOSE(1.0, onoff.output(), EPS);
   }

   TEST(Time) {
      cout << "-- Time" << endl;
      const double delta_t{0.1};
      dss::Time time{1, delta_t};
      CHECK_CLOSE(0.0, time.output(), EPS);
      for(int i = 1; i < 10; ++i) {
         time.next();
         CHECK_CLOSE(i * delta_t, time.output(), EPS);
      }
   }

   TEST(Step) {
      const double delta_t{0.1};
      dss::Time time{1, delta_t};
      cout << "-- Step" << endl;
      dss::Step step{2, 0.0, 1.0, 4 * delta_t};
      CHECK_CLOSE(0.0, step.output(), EPS);
      time.next();
      step.next();
      CHECK_CLOSE(0.0, step.output(), EPS);
      time.next();
      step.next();
      CHECK_CLOSE(0.0, step.output(), EPS);
      time.next();
      step.next();
      CHECK_CLOSE(0.0, step.output(), EPS);
      time.next();
      step.next();
      CHECK_CLOSE(1.0, step.output(), EPS);
      time.next();
      step.next();
      CHECK_CLOSE(1.0, step.output(), EPS);
   }

   TEST(Delay) {
      const double delta_t{0.1};
      const double delayTime{3 * delta_t};
      dss::Time time{1, delta_t};
      cout << "-- Delay" << endl;
      dss::Step step{2, 0.0, 1.0, 2 * delta_t};
      dss::Delay delay{3, delayTime, 0.0};
      for(int i = 0; i < 10; ++i){
         auto input = step.output();
         delay.input(input);
         if (i < 5) {
            CHECK_CLOSE(0.0, delay.output(), EPS);
         }
         else {
            CHECK_CLOSE(1.0, delay.output(), EPS);
         }
         time.next();
         step.next();
      }
   }

   TEST(FirstOrder) {
      const double delta_t{0.1};
      const double tau{10 * delta_t};
      const double stp{1.0};
      dss::Time time{1, delta_t};
      auto fio_response = [tau, stp](double in, double t) {
         return stp * (1 - exp(-t / tau));
      };
      cout << "-- FirstOrder" << endl;
      dss::Step step{2, 0.0, stp, 0.0}; //5 * delta_t};
      dss::FirstOrder fio{3, tau, 0.0};
      for(int i = 0; i < 30; ++i){
         auto input = step.output();
         fio.input(input);
         if (i < 0) {
            CHECK_CLOSE(0.0, fio.output(), EPS);
         }
         else {
            CHECK_CLOSE(fio_response(input, time.output()), fio.output(), stp/50);
         }
         time.next();
         step.next();
      }
   }
}

int main() {
   cout << "\n== Tests DySySim lib: " << dss::libVersion
        << " " << string(50, '=') << endl << endl;

   auto result = UnitTest::RunAllTests();

   cout << endl << string(80, '=') << endl;

   return result;
}
<commit_msg>DySySimTests: improved FirstOrder test.<commit_after>#include "DySySim.h"
#include "LibInfoDySySim.h"
#include <unittest++/UnitTest++.h>
#include <iostream>

namespace dss = dysysim;
using namespace std;

const double EPS {0.0001};

SUITE(DySySim)
{
   TEST(Attenuator) {
      cout << "-- Attenuator" << endl;
      dss::Attenuator att{1, 10.0};
      att.input(1.0);
      CHECK_CLOSE(0.1, att.output(), EPS);
      att.input(-1.0);
      CHECK_CLOSE(-0.1, att.output(), EPS);
   }

   TEST(Constant) {
      cout << "-- Constant" << endl;
      dss::Constant con{1, 10.0};
      CHECK_CLOSE(10.0, con.output(), EPS);
   }

   TEST(Gain) {
      cout << "-- Gain" << endl;
      dss::Gain gain{1, 10.0};
      gain.input(1.0);
      CHECK_CLOSE(10.0, gain.output(), EPS);
      gain.input(-1.0);
      CHECK_CLOSE(-10.0, gain.output(), EPS);
   }

   TEST(Limit) {
      cout << "-- Limit" << endl;
      dss::Limit limit{1, -10.0, 20.0};
      limit.input(0.0);
      CHECK_CLOSE(0.0, limit.output(), EPS);
      limit.input(-12.0);
      CHECK_CLOSE(-10.0, limit.output(), EPS);
      limit.input(22.0);
      CHECK_CLOSE(20.0, limit.output(), EPS);
   }

   TEST(OnOff) {
      cout << "-- OnOff" << endl;
      dss::OnOff onoff{2, 10, 1.0, 0.0};
      onoff.input(-1.0);
      CHECK_CLOSE(0.0, onoff.output(), EPS);
      onoff.input(0.0);
      CHECK_CLOSE(0.0, onoff.output(), EPS);
      onoff.input(5.0);
      CHECK_CLOSE(0.0, onoff.output(), EPS);
      onoff.input(10.0);
      CHECK_CLOSE(1.0, onoff.output(), EPS);
      onoff.input(20.0);
      CHECK_CLOSE(1.0, onoff.output(), EPS);
   }

   TEST(Time) {
      cout << "-- Time" << endl;
      const double delta_t{0.1};
      dss::Time time{1, delta_t};
      CHECK_CLOSE(0.0, time.output(), EPS);
      for(int i = 1; i < 10; ++i) {
         time.next();
         CHECK_CLOSE(i * delta_t, time.output(), EPS);
      }
   }

   TEST(Step) {
      const double delta_t{0.1};
      dss::Time time{1, delta_t};
      cout << "-- Step" << endl;
      dss::Step step{2, 0.0, 1.0, 4 * delta_t};
      CHECK_CLOSE(0.0, step.output(), EPS);
      time.next();
      step.next();
      CHECK_CLOSE(0.0, step.output(), EPS);
      time.next();
      step.next();
      CHECK_CLOSE(0.0, step.output(), EPS);
      time.next();
      step.next();
      CHECK_CLOSE(0.0, step.output(), EPS);
      time.next();
      step.next();
      CHECK_CLOSE(1.0, step.output(), EPS);
      time.next();
      step.next();
      CHECK_CLOSE(1.0, step.output(), EPS);
   }

   TEST(Delay) {
      const double delta_t{0.1};
      const double delayTime{3 * delta_t};
      dss::Time time{1, delta_t};
      cout << "-- Delay" << endl;
      dss::Step step{2, 0.0, 1.0, 2 * delta_t};
      dss::Delay delay{3, delayTime, 0.0};
      for(int i = 0; i < 10; ++i){
         auto input = step.output();
         delay.input(input);
         if (i < 5) {
            CHECK_CLOSE(0.0, delay.output(), EPS);
         }
         else {
            CHECK_CLOSE(1.0, delay.output(), EPS);
         }
         time.next();
         step.next();
      }
   }

   TEST(FirstOrder) {
      const double delta_t{0.1};
      const double tau{10 * delta_t};
      const double stp{1.0};
      const double stp_t{5 * delta_t};
      const double simulation_accuracy = 0.10; // 10%

      dss::Time time{1, delta_t};
      auto fio_response = [tau, stp_t, stp](double t) {
         return (t < stp_t) ? 0.0 : (stp * (1 - exp(-(t - stp_t) / tau)));
      };
      cout << "-- FirstOrder (simulation accuracy "
           << 100 * simulation_accuracy << "%)" << endl;
      dss::Step step{2, 0.0, stp, stp_t};
      dss::FirstOrder fio{3, tau, 0.0};
      while(time.output() < stp_t + 10 * tau) {
         auto input = step.output();
         fio.input(input);
         if (time.output() < stp_t) {
            CHECK_CLOSE(0.0, fio.output(), EPS);
         }
         else {
            CHECK_CLOSE(fio_response(time.output()), fio.output(),
                        stp * simulation_accuracy);
         }
         time.next();
         step.next();
      }
   }
}

int main() {
   cout << "\n== Tests DySySim lib: " << dss::libVersion
        << " " << string(50, '=') << endl << endl;

   auto result = UnitTest::RunAllTests();

   cout << endl << string(80, '=') << endl;

   return result;
}
<|endoftext|>


<commit_before>//===-- X86ATTInstPrinter.cpp - AT&T assembly instruction printing --------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file includes code for rendering MCInst instances as AT&T-style
// assembly.
//
//===----------------------------------------------------------------------===//

#define DEBUG_TYPE "asm-printer"
#include "llvm/MC/MCInst.h"
#include "X86ATTAsmPrinter.h"
#include "llvm/Support/raw_ostream.h"
using namespace llvm;

// Include the auto-generated portion of the assembly writer.
#define MachineInstr MCInst
#define NO_ASM_WRITER_BOILERPLATE
#include "X86GenAsmWriter.inc"
#undef MachineInstr

void X86ATTAsmPrinter::printSSECC(const MCInst *MI, unsigned Op) {
  unsigned char value = MI->getOperand(Op).getImm();
  assert(value <= 7 && "Invalid ssecc argument!");
  switch (value) {
  case 0: O << "eq"; break;
  case 1: O << "lt"; break;
  case 2: O << "le"; break;
  case 3: O << "unord"; break;
  case 4: O << "neq"; break;
  case 5: O << "nlt"; break;
  case 6: O << "nle"; break;
  case 7: O << "ord"; break;
  }
}

void X86ATTAsmPrinter::printPICLabel(const MCInst *MI, unsigned Op) {
  assert(0 &&
         "This is only used for MOVPC32r, should lower before asm printing!");
}

void X86ATTAsmPrinter::printOperand(const MCInst *MI, unsigned OpNo,
                                    const char *Modifier, bool NotRIPRel) {
  //assert(Modifier == 0 && "Modifiers should not be used");

  const MCOperand &Op = MI->getOperand(OpNo);
  if (Op.isReg()) {
    O << '%';
    unsigned Reg = Op.getReg();
#if 0
    if (Modifier && strncmp(Modifier, "subreg", strlen("subreg")) == 0) {
      MVT VT = (strcmp(Modifier+6,"64") == 0) ?
      MVT::i64 : ((strcmp(Modifier+6, "32") == 0) ? MVT::i32 :
                  ((strcmp(Modifier+6,"16") == 0) ? MVT::i16 : MVT::i8));
      Reg = getX86SubSuperRegister(Reg, VT);
    }
#endif
    O << TRI->getAsmName(Reg);
    return;
  } else if (Op.isImm()) {
    //if (!Modifier || (strcmp(Modifier, "debug") && strcmp(Modifier, "mem") &&
    // strcmp(Modifier, "call")))
    O << '$';
    O << Op.getImm();
    return;
  }

  O << "<<UNKNOWN OPERAND KIND>>";

#if 0
  const MachineOperand &MO = MI->getOperand(OpNo);
  switch (MO.getType()) {
    case MachineOperand::MO_Register: {
      assert(TargetRegisterInfo::isPhysicalRegister(MO.getReg()) &&
             "Virtual registers should not make it this far!");
      O << '%';
      unsigned Reg = MO.getReg();
      if (Modifier && strncmp(Modifier, "subreg", strlen("subreg")) == 0) {
        MVT VT = (strcmp(Modifier+6,"64") == 0) ?
        MVT::i64 : ((strcmp(Modifier+6, "32") == 0) ? MVT::i32 :
                    ((strcmp(Modifier+6,"16") == 0) ? MVT::i16 : MVT::i8));
        Reg = getX86SubSuperRegister(Reg, VT);
      }
      O << TRI->getAsmName(Reg);
      return;
    }

    case MachineOperand::MO_Immediate:
      if (!Modifier || (strcmp(Modifier, "debug") &&
                        strcmp(Modifier, "mem") &&
                        strcmp(Modifier, "call")))
        O << '$';
      O << MO.getImm();
      return;
    case MachineOperand::MO_MachineBasicBlock:
      printBasicBlockLabel(MO.getMBB(), false, false, VerboseAsm);
      return;
    case MachineOperand::MO_JumpTableIndex: {
      bool isMemOp  = Modifier && !strcmp(Modifier, "mem");
      if (!isMemOp) O << '$';
      O << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber() << '_'
      << MO.getIndex();

      if (TM.getRelocationModel() == Reloc::PIC_) {
        if (Subtarget->isPICStyleStub())
          O << "-\"" << TAI->getPrivateGlobalPrefix() << getFunctionNumber()
          << "$pb\"";
        else if (Subtarget->isPICStyleGOT())
          O << "@GOTOFF";
      }

      if (isMemOp && Subtarget->isPICStyleRIPRel() && !NotRIPRel)
        O << "(%rip)";
      return;
    }
    case MachineOperand::MO_ConstantPoolIndex: {
      bool isMemOp  = Modifier && !strcmp(Modifier, "mem");
      if (!isMemOp) O << '$';
      O << TAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << '_'
      << MO.getIndex();

      if (TM.getRelocationModel() == Reloc::PIC_) {
        if (Subtarget->isPICStyleStub())
          O << "-\"" << TAI->getPrivateGlobalPrefix() << getFunctionNumber()
          << "$pb\"";
        else if (Subtarget->isPICStyleGOT())
          O << "@GOTOFF";
      }

      printOffset(MO.getOffset());

      if (isMemOp && Subtarget->isPICStyleRIPRel() && !NotRIPRel)
        O << "(%rip)";
      return;
    }
    case MachineOperand::MO_GlobalAddress: {
      bool isCallOp = Modifier && !strcmp(Modifier, "call");
      bool isMemOp  = Modifier && !strcmp(Modifier, "mem");
      bool needCloseParen = false;

      const GlobalValue *GV = MO.getGlobal();
      const GlobalVariable *GVar = dyn_cast<GlobalVariable>(GV);
      if (!GVar) {
        // If GV is an alias then use the aliasee for determining
        // thread-localness.
        if (const GlobalAlias *GA = dyn_cast<GlobalAlias>(GV))
          GVar = dyn_cast_or_null<GlobalVariable>(GA->resolveAliasedGlobal(false));
      }

      bool isThreadLocal = GVar && GVar->isThreadLocal();

      std::string Name = Mang->getValueName(GV);
      decorateName(Name, GV);

      if (!isMemOp && !isCallOp)
        O << '$';
      else if (Name[0] == '$') {
        // The name begins with a dollar-sign. In order to avoid having it look
        // like an integer immediate to the assembler, enclose it in parens.
        O << '(';
        needCloseParen = true;
      }

      if (shouldPrintStub(TM, Subtarget)) {
        // Link-once, declaration, or Weakly-linked global variables need
        // non-lazily-resolved stubs
        if (GV->isDeclaration() || GV->isWeakForLinker()) {
          // Dynamically-resolved functions need a stub for the function.
          if (isCallOp && isa<Function>(GV)) {
            // Function stubs are no longer needed for Mac OS X 10.5 and up.
            if (Subtarget->isTargetDarwin() && Subtarget->getDarwinVers() >= 9) {
              O << Name;
            } else {
              FnStubs.insert(Name);
              printSuffixedName(Name, "$stub");
            }
          } else if (GV->hasHiddenVisibility()) {
            if (!GV->isDeclaration() && !GV->hasCommonLinkage())
              // Definition is not definitely in the current translation unit.
              O << Name;
            else {
              HiddenGVStubs.insert(Name);
              printSuffixedName(Name, "$non_lazy_ptr");
            }
          } else {
            GVStubs.insert(Name);
            printSuffixedName(Name, "$non_lazy_ptr");
          }
        } else {
          if (GV->hasDLLImportLinkage())
            O << "__imp_";
          O << Name;
        }

        if (!isCallOp && TM.getRelocationModel() == Reloc::PIC_)
          O << '-' << getPICLabelString(getFunctionNumber(), TAI, Subtarget);
      } else {
        if (GV->hasDLLImportLinkage()) {
          O << "__imp_";
        }
        O << Name;

        if (isCallOp) {
          if (shouldPrintPLT(TM, Subtarget)) {
            // Assemble call via PLT for externally visible symbols
            if (!GV->hasHiddenVisibility() && !GV->hasProtectedVisibility() &&
                !GV->hasLocalLinkage())
              O << "@PLT";
          }
          if (Subtarget->isTargetCygMing() && GV->isDeclaration())
            // Save function name for later type emission
            FnStubs.insert(Name);
        }
      }

      if (GV->hasExternalWeakLinkage())
        ExtWeakSymbols.insert(GV);

      printOffset(MO.getOffset());

      if (isThreadLocal) {
        TLSModel::Model model = getTLSModel(GVar, TM.getRelocationModel());
        switch (model) {
          case TLSModel::GeneralDynamic:
            O << "@TLSGD";
            break;
          case TLSModel::LocalDynamic:
            // O << "@TLSLD"; // local dynamic not implemented
            O << "@TLSGD";
            break;
          case TLSModel::InitialExec:
            if (Subtarget->is64Bit()) {
              assert (!NotRIPRel);
              O << "@GOTTPOFF(%rip)";
            } else {
              O << "@INDNTPOFF";
            }
            break;
          case TLSModel::LocalExec:
            if (Subtarget->is64Bit())
              O << "@TPOFF";
            else
              O << "@NTPOFF";
            break;
          default:
            assert (0 && "Unknown TLS model");
        }
      } else if (isMemOp) {
        if (shouldPrintGOT(TM, Subtarget)) {
          if (Subtarget->GVRequiresExtraLoad(GV, TM, false))
            O << "@GOT";
          else
            O << "@GOTOFF";
        } else if (Subtarget->isPICStyleRIPRel() && !NotRIPRel) {
          if (TM.getRelocationModel() != Reloc::Static) {
            if (Subtarget->GVRequiresExtraLoad(GV, TM, false))
              O << "@GOTPCREL";

            if (needCloseParen) {
              needCloseParen = false;
              O << ')';
            }
          }

          // Use rip when possible to reduce code size, except when
          // index or base register are also part of the address. e.g.
          // foo(%rip)(%rcx,%rax,4) is not legal
          O << "(%rip)";
        }
      }

      if (needCloseParen)
        O << ')';

      return;
    }
    case MachineOperand::MO_ExternalSymbol: {
      bool isCallOp = Modifier && !strcmp(Modifier, "call");
      bool isMemOp  = Modifier && !strcmp(Modifier, "mem");
      bool needCloseParen = false;
      std::string Name(TAI->getGlobalPrefix());
      Name += MO.getSymbolName();
      // Print function stub suffix unless it's Mac OS X 10.5 and up.
      if (isCallOp && shouldPrintStub(TM, Subtarget) &&
          !(Subtarget->isTargetDarwin() && Subtarget->getDarwinVers() >= 9)) {
        FnStubs.insert(Name);
        printSuffixedName(Name, "$stub");
        return;
      }
      if (!isMemOp && !isCallOp)
        O << '$';
      else if (Name[0] == '$') {
        // The name begins with a dollar-sign. In order to avoid having it look
        // like an integer immediate to the assembler, enclose it in parens.
        O << '(';
        needCloseParen = true;
      }

      O << Name;

      if (shouldPrintPLT(TM, Subtarget)) {
        std::string GOTName(TAI->getGlobalPrefix());
        GOTName+="_GLOBAL_OFFSET_TABLE_";
        if (Name == GOTName)
          // HACK! Emit extra offset to PC during printing GOT offset to
          // compensate for the size of popl instruction. The resulting code
          // should look like:
          //   call .piclabel
          // piclabel:
          //   popl %some_register
          //   addl $_GLOBAL_ADDRESS_TABLE_ + [.-piclabel], %some_register
          O << " + [.-"
          << getPICLabelString(getFunctionNumber(), TAI, Subtarget) << ']';

        if (isCallOp)
          O << "@PLT";
      }

      if (needCloseParen)
        O << ')';

      if (!isCallOp && Subtarget->isPICStyleRIPRel())
        O << "(%rip)";

      return;
    }
    default:
      O << "<unknown operand type>"; return;
  }
#endif
}

void X86ATTAsmPrinter::printLeaMemReference(const MCInst *MI, unsigned Op,
                                            const char *Modifier,
                                            bool NotRIPRel) {
  const MCOperand &BaseReg  = MI->getOperand(Op);
  const MCOperand &IndexReg = MI->getOperand(Op+2);
  const MCOperand &DispSpec = MI->getOperand(Op+3);

  NotRIPRel |= IndexReg.getReg() || BaseReg.getReg();
  if (DispSpec.isImm()) {
    int64_t DispVal = DispSpec.getImm();
    if (DispVal || (!IndexReg.getReg() && !BaseReg.getReg()))
      O << DispVal;
  } else {
    abort();
    //assert(DispSpec.isGlobal() || DispSpec.isCPI() ||
    //       DispSpec.isJTI() || DispSpec.isSymbol());
    //printOperand(MI, Op+3, "mem", NotRIPRel);
  }

  if (IndexReg.getReg() || BaseReg.getReg()) {
    unsigned ScaleVal = MI->getOperand(Op+1).getImm();
    unsigned BaseRegOperand = 0, IndexRegOperand = 2;

    // There are cases where we can end up with ESP/RSP in the indexreg slot.
    // If this happens, swap the base/index register to support assemblers that
    // don't work when the index is *SP.
    // FIXME: REMOVE THIS.
    if (IndexReg.getReg() == X86::ESP || IndexReg.getReg() == X86::RSP) {
      assert(ScaleVal == 1 && "Scale not supported for stack pointer!");
      abort();
      //std::swap(BaseReg, IndexReg);
      //std::swap(BaseRegOperand, IndexRegOperand);
    }

    O << '(';
    if (BaseReg.getReg())
      printOperand(MI, Op+BaseRegOperand, Modifier);

    if (IndexReg.getReg()) {
      O << ',';
      printOperand(MI, Op+IndexRegOperand, Modifier);
      if (ScaleVal != 1)
        O << ',' << ScaleVal;
    }
    O << ')';
  }
}

void X86ATTAsmPrinter::printMemReference(const MCInst *MI, unsigned Op,
                                         const char *Modifier, bool NotRIPRel){
#if 0
  assert(isMem(MI, Op) && "Invalid memory reference!");
  MachineOperand Segment = MI->getOperand(Op+4);
  if (Segment.getReg()) {
    printOperand(MI, Op+4, Modifier);
    O << ':';
  }
  printLeaMemReference(MI, Op, Modifier, NotRIPRel);
#endif
}
<commit_msg>hook up printMemReference.<commit_after>//===-- X86ATTInstPrinter.cpp - AT&T assembly instruction printing --------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file includes code for rendering MCInst instances as AT&T-style
// assembly.
//
//===----------------------------------------------------------------------===//

#define DEBUG_TYPE "asm-printer"
#include "llvm/MC/MCInst.h"
#include "X86ATTAsmPrinter.h"
#include "llvm/Support/raw_ostream.h"
using namespace llvm;

// Include the auto-generated portion of the assembly writer.
#define MachineInstr MCInst
#define NO_ASM_WRITER_BOILERPLATE
#include "X86GenAsmWriter.inc"
#undef MachineInstr

void X86ATTAsmPrinter::printSSECC(const MCInst *MI, unsigned Op) {
  unsigned char value = MI->getOperand(Op).getImm();
  assert(value <= 7 && "Invalid ssecc argument!");
  switch (value) {
  case 0: O << "eq"; break;
  case 1: O << "lt"; break;
  case 2: O << "le"; break;
  case 3: O << "unord"; break;
  case 4: O << "neq"; break;
  case 5: O << "nlt"; break;
  case 6: O << "nle"; break;
  case 7: O << "ord"; break;
  }
}

void X86ATTAsmPrinter::printPICLabel(const MCInst *MI, unsigned Op) {
  assert(0 &&
         "This is only used for MOVPC32r, should lower before asm printing!");
}

void X86ATTAsmPrinter::printOperand(const MCInst *MI, unsigned OpNo,
                                    const char *Modifier, bool NotRIPRel) {
  //assert(Modifier == 0 && "Modifiers should not be used");

  const MCOperand &Op = MI->getOperand(OpNo);
  if (Op.isReg()) {
    O << '%';
    unsigned Reg = Op.getReg();
#if 0
    if (Modifier && strncmp(Modifier, "subreg", strlen("subreg")) == 0) {
      MVT VT = (strcmp(Modifier+6,"64") == 0) ?
      MVT::i64 : ((strcmp(Modifier+6, "32") == 0) ? MVT::i32 :
                  ((strcmp(Modifier+6,"16") == 0) ? MVT::i16 : MVT::i8));
      Reg = getX86SubSuperRegister(Reg, VT);
    }
#endif
    O << TRI->getAsmName(Reg);
    return;
  } else if (Op.isImm()) {
    //if (!Modifier || (strcmp(Modifier, "debug") && strcmp(Modifier, "mem") &&
    // strcmp(Modifier, "call")))
    O << '$';
    O << Op.getImm();
    return;
  }

  O << "<<UNKNOWN OPERAND KIND>>";

#if 0
  const MachineOperand &MO = MI->getOperand(OpNo);
  switch (MO.getType()) {
    case MachineOperand::MO_Register: {
      assert(TargetRegisterInfo::isPhysicalRegister(MO.getReg()) &&
             "Virtual registers should not make it this far!");
      O << '%';
      unsigned Reg = MO.getReg();
      if (Modifier && strncmp(Modifier, "subreg", strlen("subreg")) == 0) {
        MVT VT = (strcmp(Modifier+6,"64") == 0) ?
        MVT::i64 : ((strcmp(Modifier+6, "32") == 0) ? MVT::i32 :
                    ((strcmp(Modifier+6,"16") == 0) ? MVT::i16 : MVT::i8));
        Reg = getX86SubSuperRegister(Reg, VT);
      }
      O << TRI->getAsmName(Reg);
      return;
    }

    case MachineOperand::MO_Immediate:
      if (!Modifier || (strcmp(Modifier, "debug") &&
                        strcmp(Modifier, "mem") &&
                        strcmp(Modifier, "call")))
        O << '$';
      O << MO.getImm();
      return;
    case MachineOperand::MO_MachineBasicBlock:
      printBasicBlockLabel(MO.getMBB(), false, false, VerboseAsm);
      return;
    case MachineOperand::MO_JumpTableIndex: {
      bool isMemOp  = Modifier && !strcmp(Modifier, "mem");
      if (!isMemOp) O << '$';
      O << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber() << '_'
      << MO.getIndex();

      if (TM.getRelocationModel() == Reloc::PIC_) {
        if (Subtarget->isPICStyleStub())
          O << "-\"" << TAI->getPrivateGlobalPrefix() << getFunctionNumber()
          << "$pb\"";
        else if (Subtarget->isPICStyleGOT())
          O << "@GOTOFF";
      }

      if (isMemOp && Subtarget->isPICStyleRIPRel() && !NotRIPRel)
        O << "(%rip)";
      return;
    }
    case MachineOperand::MO_ConstantPoolIndex: {
      bool isMemOp  = Modifier && !strcmp(Modifier, "mem");
      if (!isMemOp) O << '$';
      O << TAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << '_'
      << MO.getIndex();

      if (TM.getRelocationModel() == Reloc::PIC_) {
        if (Subtarget->isPICStyleStub())
          O << "-\"" << TAI->getPrivateGlobalPrefix() << getFunctionNumber()
          << "$pb\"";
        else if (Subtarget->isPICStyleGOT())
          O << "@GOTOFF";
      }

      printOffset(MO.getOffset());

      if (isMemOp && Subtarget->isPICStyleRIPRel() && !NotRIPRel)
        O << "(%rip)";
      return;
    }
    case MachineOperand::MO_GlobalAddress: {
      bool isCallOp = Modifier && !strcmp(Modifier, "call");
      bool isMemOp  = Modifier && !strcmp(Modifier, "mem");
      bool needCloseParen = false;

      const GlobalValue *GV = MO.getGlobal();
      const GlobalVariable *GVar = dyn_cast<GlobalVariable>(GV);
      if (!GVar) {
        // If GV is an alias then use the aliasee for determining
        // thread-localness.
        if (const GlobalAlias *GA = dyn_cast<GlobalAlias>(GV))
          GVar = dyn_cast_or_null<GlobalVariable>(GA->resolveAliasedGlobal(false));
      }

      bool isThreadLocal = GVar && GVar->isThreadLocal();

      std::string Name = Mang->getValueName(GV);
      decorateName(Name, GV);

      if (!isMemOp && !isCallOp)
        O << '$';
      else if (Name[0] == '$') {
        // The name begins with a dollar-sign. In order to avoid having it look
        // like an integer immediate to the assembler, enclose it in parens.
        O << '(';
        needCloseParen = true;
      }

      if (shouldPrintStub(TM, Subtarget)) {
        // Link-once, declaration, or Weakly-linked global variables need
        // non-lazily-resolved stubs
        if (GV->isDeclaration() || GV->isWeakForLinker()) {
          // Dynamically-resolved functions need a stub for the function.
          if (isCallOp && isa<Function>(GV)) {
            // Function stubs are no longer needed for Mac OS X 10.5 and up.
            if (Subtarget->isTargetDarwin() && Subtarget->getDarwinVers() >= 9) {
              O << Name;
            } else {
              FnStubs.insert(Name);
              printSuffixedName(Name, "$stub");
            }
          } else if (GV->hasHiddenVisibility()) {
            if (!GV->isDeclaration() && !GV->hasCommonLinkage())
              // Definition is not definitely in the current translation unit.
              O << Name;
            else {
              HiddenGVStubs.insert(Name);
              printSuffixedName(Name, "$non_lazy_ptr");
            }
          } else {
            GVStubs.insert(Name);
            printSuffixedName(Name, "$non_lazy_ptr");
          }
        } else {
          if (GV->hasDLLImportLinkage())
            O << "__imp_";
          O << Name;
        }

        if (!isCallOp && TM.getRelocationModel() == Reloc::PIC_)
          O << '-' << getPICLabelString(getFunctionNumber(), TAI, Subtarget);
      } else {
        if (GV->hasDLLImportLinkage()) {
          O << "__imp_";
        }
        O << Name;

        if (isCallOp) {
          if (shouldPrintPLT(TM, Subtarget)) {
            // Assemble call via PLT for externally visible symbols
            if (!GV->hasHiddenVisibility() && !GV->hasProtectedVisibility() &&
                !GV->hasLocalLinkage())
              O << "@PLT";
          }
          if (Subtarget->isTargetCygMing() && GV->isDeclaration())
            // Save function name for later type emission
            FnStubs.insert(Name);
        }
      }

      if (GV->hasExternalWeakLinkage())
        ExtWeakSymbols.insert(GV);

      printOffset(MO.getOffset());

      if (isThreadLocal) {
        TLSModel::Model model = getTLSModel(GVar, TM.getRelocationModel());
        switch (model) {
          case TLSModel::GeneralDynamic:
            O << "@TLSGD";
            break;
          case TLSModel::LocalDynamic:
            // O << "@TLSLD"; // local dynamic not implemented
            O << "@TLSGD";
            break;
          case TLSModel::InitialExec:
            if (Subtarget->is64Bit()) {
              assert (!NotRIPRel);
              O << "@GOTTPOFF(%rip)";
            } else {
              O << "@INDNTPOFF";
            }
            break;
          case TLSModel::LocalExec:
            if (Subtarget->is64Bit())
              O << "@TPOFF";
            else
              O << "@NTPOFF";
            break;
          default:
            assert (0 && "Unknown TLS model");
        }
      } else if (isMemOp) {
        if (shouldPrintGOT(TM, Subtarget)) {
          if (Subtarget->GVRequiresExtraLoad(GV, TM, false))
            O << "@GOT";
          else
            O << "@GOTOFF";
        } else if (Subtarget->isPICStyleRIPRel() && !NotRIPRel) {
          if (TM.getRelocationModel() != Reloc::Static) {
            if (Subtarget->GVRequiresExtraLoad(GV, TM, false))
              O << "@GOTPCREL";

            if (needCloseParen) {
              needCloseParen = false;
              O << ')';
            }
          }

          // Use rip when possible to reduce code size, except when
          // index or base register are also part of the address. e.g.
          // foo(%rip)(%rcx,%rax,4) is not legal
          O << "(%rip)";
        }
      }

      if (needCloseParen)
        O << ')';

      return;
    }
    case MachineOperand::MO_ExternalSymbol: {
      bool isCallOp = Modifier && !strcmp(Modifier, "call");
      bool isMemOp  = Modifier && !strcmp(Modifier, "mem");
      bool needCloseParen = false;
      std::string Name(TAI->getGlobalPrefix());
      Name += MO.getSymbolName();
      // Print function stub suffix unless it's Mac OS X 10.5 and up.
      if (isCallOp && shouldPrintStub(TM, Subtarget) &&
          !(Subtarget->isTargetDarwin() && Subtarget->getDarwinVers() >= 9)) {
        FnStubs.insert(Name);
        printSuffixedName(Name, "$stub");
        return;
      }
      if (!isMemOp && !isCallOp)
        O << '$';
      else if (Name[0] == '$') {
        // The name begins with a dollar-sign. In order to avoid having it look
        // like an integer immediate to the assembler, enclose it in parens.
        O << '(';
        needCloseParen = true;
      }

      O << Name;

      if (shouldPrintPLT(TM, Subtarget)) {
        std::string GOTName(TAI->getGlobalPrefix());
        GOTName+="_GLOBAL_OFFSET_TABLE_";
        if (Name == GOTName)
          // HACK! Emit extra offset to PC during printing GOT offset to
          // compensate for the size of popl instruction. The resulting code
          // should look like:
          //   call .piclabel
          // piclabel:
          //   popl %some_register
          //   addl $_GLOBAL_ADDRESS_TABLE_ + [.-piclabel], %some_register
          O << " + [.-"
          << getPICLabelString(getFunctionNumber(), TAI, Subtarget) << ']';

        if (isCallOp)
          O << "@PLT";
      }

      if (needCloseParen)
        O << ')';

      if (!isCallOp && Subtarget->isPICStyleRIPRel())
        O << "(%rip)";

      return;
    }
    default:
      O << "<unknown operand type>"; return;
  }
#endif
}

void X86ATTAsmPrinter::printLeaMemReference(const MCInst *MI, unsigned Op,
                                            const char *Modifier,
                                            bool NotRIPRel) {
  const MCOperand &BaseReg  = MI->getOperand(Op);
  const MCOperand &IndexReg = MI->getOperand(Op+2);
  const MCOperand &DispSpec = MI->getOperand(Op+3);

  NotRIPRel |= IndexReg.getReg() || BaseReg.getReg();
  if (DispSpec.isImm()) {
    int64_t DispVal = DispSpec.getImm();
    if (DispVal || (!IndexReg.getReg() && !BaseReg.getReg()))
      O << DispVal;
  } else {
    abort();
    //assert(DispSpec.isGlobal() || DispSpec.isCPI() ||
    //       DispSpec.isJTI() || DispSpec.isSymbol());
    //printOperand(MI, Op+3, "mem", NotRIPRel);
  }

  if (IndexReg.getReg() || BaseReg.getReg()) {
    unsigned ScaleVal = MI->getOperand(Op+1).getImm();
    unsigned BaseRegOperand = 0, IndexRegOperand = 2;

    // There are cases where we can end up with ESP/RSP in the indexreg slot.
    // If this happens, swap the base/index register to support assemblers that
    // don't work when the index is *SP.
    // FIXME: REMOVE THIS.
    if (IndexReg.getReg() == X86::ESP || IndexReg.getReg() == X86::RSP) {
      assert(ScaleVal == 1 && "Scale not supported for stack pointer!");
      abort();
      //std::swap(BaseReg, IndexReg);
      //std::swap(BaseRegOperand, IndexRegOperand);
    }

    O << '(';
    if (BaseReg.getReg())
      printOperand(MI, Op+BaseRegOperand, Modifier);

    if (IndexReg.getReg()) {
      O << ',';
      printOperand(MI, Op+IndexRegOperand, Modifier);
      if (ScaleVal != 1)
        O << ',' << ScaleVal;
    }
    O << ')';
  }
}

void X86ATTAsmPrinter::printMemReference(const MCInst *MI, unsigned Op,
                                         const char *Modifier, bool NotRIPRel){
  //assert(isMem(MI, Op) && "Invalid memory reference!");
  const MCOperand &Segment = MI->getOperand(Op+4);
  if (Segment.getReg()) {
    printOperand(MI, Op+4, Modifier);
    O << ':';
  }
  printLeaMemReference(MI, Op, Modifier, NotRIPRel);
}
<|endoftext|>


<commit_before>/***************************************************************************
  priyanka.sett@cern.ch - last modified on 27/10/2016
  for L* in pp 13 TeV analysis

// General macro to configure the RSN analysis task.
// It calls all configs desired by the user, by means
// of the boolean switches defined in the first lines.
// ---
// Inputs:
//  1) flag to know if running on MC or data
//  2) path where all configs are stored
// ---
// Returns:
//  kTRUE  --> initialization successful
//  kFALSE --> initialization failed (some config gave errors)
//
****************************************************************************/

enum eventCutSet { kDefaultVtx = 0,
		   kDefaultVtx12,//=1
		   kDefaultVtx8 //=2
                 };

AliRsnMiniAnalysisTask * AddTaskLstar13TeVpp
(
   Bool_t      isMC = kFALSE,
   Bool_t      isPP = kTRUE,
   Int_t       aodFilterBit = 5,
   Int_t       evtCutSetID = 0,
   Int_t       MultBins = 1,// default for V0_M and MultBins = 2 for RefMult0_8
   Int_t       customQualityCutsID=1, // for default
   AliRsnCutSetDaughterParticle::ERsnDaughterCutSet cutPrCandidate = AliRsnCutSetDaughterParticle::kTPCTOFpidLstar13ppTeV,
   AliRsnCutSetDaughterParticle::ERsnDaughterCutSet cutKaCandidate = AliRsnCutSetDaughterParticle::kTPCTOFpidLstar13ppTeV,
   Float_t     nsigmaPr = 2.0,
   Float_t     nsigmaKa = 2.0,
   Bool_t      enableMonitor = kTRUE,
   Bool_t      IsMcTrueOnly = kFALSE,
   UInt_t      triggerMask = AliVEvent::kINT7,
   Int_t       signedPdg = 3124,
   TString     monitorOpt = "NoSIGN",  //Flag for AddMonitorOutput.C e.g."NoSIGN"
   Bool_t      useCrossedRows = kTRUE,
   const char *yaxisVar = "",  //yaxisVar = "PtDaughter_PDaughter_cent"
   Bool_t      useMixLS = 0,
   Int_t       nmix = 5,
   Float_t     maxDiffVzMix = 1.0,
   Float_t     maxDiffMultMix = 5.0,
   TString     outNameSuffix = "Default"
)

{
  //-------------------------------------------
  // event cuts
  //-------------------------------------------

  Double_t  vtxZcut = 10.0;//default cut on vtx z

  //  if(evtCutSetID==eventCutSet::kDefaultVtx) vtxZcut=10.0; //cm
  if(evtCutSetID==eventCutSet::kDefaultVtx12) vtxZcut=12.0; //cm
  if(evtCutSetID==eventCutSet::kDefaultVtx8) vtxZcut=8.0; //cm

  //vtxZcut = 10.0;//default cut on vtx z

  //
  // -- INITIALIZATION ----------------------------------------------------------------------------
  // retrieve analysis manager
  //

  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
   if (!mgr) {
      ::Error("AddTaskLstar13TeVpp", "No analysis manager to connect to.");
      return NULL;
   }

   // create the task and configure
   TString taskName = Form("LStar%s%s_%i%i_%s", (isPP? "pp" : "pPb"), (isMC ? "MC" : "Data"), (Int_t)cutPrCandidate,(Int_t)cutKaCandidate, outNameSuffix.Data() );

   AliRsnMiniAnalysisTask *task = new AliRsnMiniAnalysisTask(taskName.Data(), isMC);

   //if(is2011PbPb)
   //task->SelectCollisionCandidates(AliVEvent::kMB | AliVEvent::kCentral | AliVEvent::kSemiCentral);
   //else
   task->SelectCollisionCandidates(triggerMask);

   /*
   AliMultSelectionTask *taskm = AddTaskMultSelection();

   if(isMC == 1)
     {
       taskm->SetAlternateOADBforEstimators( "LHC15f" );
     }
   */

   //   task->UseMultiplicity("QUALITY");

   if (isPP) {
     //     task->UseMultiplicity("QUALITY");
     if (MultBins == 1) task->UseMultiplicity("AliMultSelection_V0M"); // for multiplicity percentile
     else if(MultBins == 2) task->UseMultiplicity("AliMultSelection_RefMult05");
     else task->UseMultiplicity("QUALITY");
   }
   else
     task->UseCentrality("V0M");

   // set event mixing options
   task->UseContinuousMix();
   //task->UseBinnedMix();
   task->SetNMix(nmix);
   task->SetMaxDiffVz(maxDiffVzMix);
   task->SetMaxDiffMult(maxDiffMultMix);
   //if (!isPP) task->SetMaxDiffAngle(maxDiffAngleMixDeg*TMath::DegToRad()); //set angle diff in rad
   ::Info("AddTaskLstar13TeVpp", Form("Event mixing configuration: \n events to mix = %i \n max diff. vtxZ = cm %5.3f \n max diff multi = %5.3f \n ", nmix, maxDiffVzMix, maxDiffMultMix));

   mgr->AddTask(task);

   //
   // -- EVENT CUTS (same for all configs) ---------------------------------------------------------
   //
   // cut on primary vertex:
   // - 2nd argument --> |Vz| range
   // - 3rd argument --> minimum required number of contributors
   // - 4th argument --> tells if TPC stand-alone vertexes must be accepted
   //   if (isPP)
   //{

   Bool_t  rejectPileUp = kTRUE;

   //   if(!isPP || isMC || MultBins) rejectPileUp=kFALSE;
   if(!isPP || isMC) rejectPileUp=kFALSE;

   AliRsnCutPrimaryVertex *cutVertex = new AliRsnCutPrimaryVertex("cutVertex", vtxZcut, 0, kFALSE);
   cutVertex->SetCheckZResolutionSPD();
   cutVertex->SetCheckDispersionSPD();
   cutVertex->SetCheckZDifferenceSPDTrack();

   AliRsnCutEventUtils *cutEventUtils = new AliRsnCutEventUtils("cutEventUtils", kTRUE, rejectPileUp);
   //   cutEventUtils->SetCheckIncompleteDAQ();
   //   cutEventUtils->SetCheckSPDClusterVsTrackletBG();
   if(!MultBins){
     cutEventUtils->SetCheckIncompleteDAQ();
     cutEventUtils->SetCheckSPDClusterVsTrackletBG();
     cutEventUtils->SetCheckInelGt0SPDtracklets();
   }
   else{
     cutEventUtils->SetRemovePileUppA2013(kFALSE);
     cutEventUtils->SetCheckAcceptedMultSelection();
   }

   // if(isPP && (!isMC)){
   if(isPP && (!isMC) && cutVertex){ // modified on 21 July. Ref Anders code on git
     cutVertex->SetCheckPileUp(rejectPileUp);// set the check for pileup
     ::Info("AddTaskLstar13TeVpp", Form(":::::::::::::::::: Pile-up rejection mode: %s", (rejectPileUp)?"ON":"OFF"));
   }

   // define and fill cut set for event cut
   AliRsnCutSet *eventCuts = new AliRsnCutSet("eventCuts", AliRsnTarget::kEvent);
   eventCuts->AddCut(cutEventUtils);
   eventCuts->AddCut(cutVertex);
   eventCuts->SetCutScheme(Form("%s&%s",cutEventUtils->GetName(),cutVertex->GetName()));
   cout<< "--------------"<< cutVertex <<"cm ---------------- "<<endl;

   // set cuts in task
   task->SetEventCuts(eventCuts);

   //
   // -- EVENT-ONLY COMPUTATIONS -------------------------------------------------------------------
   //
   //vertex
   Int_t vtxID = task->CreateValue(AliRsnMiniValue::kVz, kFALSE);
   AliRsnMiniOutput *outVtx = task->CreateOutput("eventVtx", "HIST", "EVENT");
   outVtx->AddAxis(vtxID, 400, -20.0, 20.0);

   //multiplicity or centrality
   Int_t multID = task->CreateValue(AliRsnMiniValue::kMult, kFALSE);
   AliRsnMiniOutput *outMult = task->CreateOutput("eventMult", "HIST", "EVENT");
   if (isPP && !MultBins)   outMult->AddAxis(multID, 300, 0.0, 300.0);
   else  outMult->AddAxis(multID, 110, 0.0, 110.0);

   //
   // -- PAIR CUTS  -------------------------------------------------------------------------------
   //
   AliRsnCutMiniPair *cutY = new AliRsnCutMiniPair("cutRapidity", AliRsnCutMiniPair::kRapidityRange);
   if(isPP) cutY->SetRangeD(-0.5, 0.5);
   else     cutY->SetRangeD(-0.465, 0.035);

   AliRsnCutSet *cutsPair = new AliRsnCutSet("pairCuts", AliRsnTarget::kMother);
   cutsPair->AddCut(cutY);
   cutsPair->SetCutScheme(cutY->GetName());

   //   AliRsnValuePair * openangle = new AliRsnValuePair("openangle", AliRsnValuePair::kDipAngle);
   //   openangle->DipAngle(1);

//   AliRsnMiniPair * pairangle = new AliRsnMiniPair();
//   Double_t openangle = pairangle->PhiV(isMC);
//   cout<<"--------- Opening Angle ----------------- "<<openangle<<endl;

//     AliRsnCutMiniPair *cutPhiV = new AliRsnCutMiniPair("cutPhiV", AliRsnCutMiniPair::kPhiVRange);
     AliRsnCutMiniPair *cutPhiV = new AliRsnCutMiniPair("cutPhiV", 7);
     cutPhiV->SetRangeD(0.0, 360);

    AliRsnCutSet *cutsPhiV = new AliRsnCutSet("pairCutsPhiV", AliRsnTarget::kMother);
    cutsPhiV->AddCut(cutPhiV);
    cutsPhiV->SetCutScheme(cutPhiV->GetName());

   //   AliRsnMiniOutput *outangle = task->CreateOutput("OpeningAngle", "HIST", "Daughter");
   //   if (isPP && !MultBins)   outangle->AddAxis(openangle, 300, 0.0, 300.0);
   //   else  outMult->AddAxis(openangle, 110, 0.0, 110.0);

   //
   // -- CONFIG ANALYSIS --------------------------------------------------------------------------

   //for systematic checks
     {
       gROOT->LoadMacro("$ALICE_ROOT/PWGLF/RESONANCES/macros/mini/ConfigLStar.C");
       //gROOT->LoadMacro("ConfigureLstar13TeVpp.C");
       //gROOT->LoadMacro("$ALICE_PHYSICS/PWGLF/RESONANCES/macros/mini/ConfigureLstar13TeVpp.C");
       if (!ConfigureLstar13TeVpp(task, isMC, isPP, "", cutsPair, aodFilterBit, customQualityCutsID, cutPrCandidate, cutKaCandidate, nsigmaPr, nsigmaKa,  enableMonitor, isMC&IsMcTrueOnly, signedPdg, monitorOpt, useCrossedRows, yaxisVar ,useMixLS))
return 0x0;
     }

   //
   // -- CONTAINERS --------------------------------------------------------------------------------
   //
   TString outputFileName = AliAnalysisManager::GetCommonFileName();
   //  outputFileName += ":Rsn";
   Printf("AddAnalysisTaskTPCKStarSyst - Set OutputFileName : \n %s\n", outputFileName.Data() );

   AliAnalysisDataContainer *output = mgr->CreateContainer(Form("RsnOut_%s",outNameSuffix.Data()),
							   TList::Class(),
							   AliAnalysisManager::kOutputContainer,
							   outputFileName);
   mgr->ConnectInput(task, 0, mgr->GetCommonInputContainer());
   mgr->ConnectOutput(task, 1, output);

   return task;
}
<commit_msg>Change LoadMacro information in Addtask macro for LambdaStar analysis in pp at 13 TeV<commit_after>/***************************************************************************
  priyanka.sett@cern.ch - last modified on 27/10/2016
  for L* in pp 13 TeV analysis

// General macro to configure the RSN analysis task.
// It calls all configs desired by the user, by means
// of the boolean switches defined in the first lines.
// ---
// Inputs:
//  1) flag to know if running on MC or data
//  2) path where all configs are stored
// ---
// Returns:
//  kTRUE  --> initialization successful
//  kFALSE --> initialization failed (some config gave errors)
//
****************************************************************************/

enum eventCutSet { kDefaultVtx = 0,
		   kDefaultVtx12,//=1
		   kDefaultVtx8 //=2
                 };

AliRsnMiniAnalysisTask * AddTaskLstar13TeVpp
(
   Bool_t      isMC = kFALSE,
   Bool_t      isPP = kTRUE,
   Int_t       aodFilterBit = 5,
   Int_t       evtCutSetID = 0,
   Int_t       MultBins = 1,// default for V0_M and MultBins = 2 for RefMult0_8
   Int_t       customQualityCutsID=1, // for default
   AliRsnCutSetDaughterParticle::ERsnDaughterCutSet cutPrCandidate = AliRsnCutSetDaughterParticle::kTPCTOFpidLstar13ppTeV,
   AliRsnCutSetDaughterParticle::ERsnDaughterCutSet cutKaCandidate = AliRsnCutSetDaughterParticle::kTPCTOFpidLstar13ppTeV,
   Float_t     nsigmaPr = 2.0,
   Float_t     nsigmaKa = 2.0,
   Bool_t      enableMonitor = kTRUE,
   Bool_t      IsMcTrueOnly = kFALSE,
   UInt_t      triggerMask = AliVEvent::kINT7,
   Int_t       signedPdg = 3124,
   TString     monitorOpt = "NoSIGN",  //Flag for AddMonitorOutput.C e.g."NoSIGN"
   Bool_t      useCrossedRows = kTRUE,
   const char *yaxisVar = "",  //yaxisVar = "PtDaughter_PDaughter_cent"
   Bool_t      useMixLS = 0,
   Int_t       nmix = 5,
   Float_t     maxDiffVzMix = 1.0,
   Float_t     maxDiffMultMix = 5.0,
   TString     outNameSuffix = "Default"
)

{
  //-------------------------------------------
  // event cuts
  //-------------------------------------------

  Double_t  vtxZcut = 10.0;//default cut on vtx z

  //  if(evtCutSetID==eventCutSet::kDefaultVtx) vtxZcut=10.0; //cm
  if(evtCutSetID==eventCutSet::kDefaultVtx12) vtxZcut=12.0; //cm
  if(evtCutSetID==eventCutSet::kDefaultVtx8) vtxZcut=8.0; //cm

  //vtxZcut = 10.0;//default cut on vtx z

  //
  // -- INITIALIZATION ----------------------------------------------------------------------------
  // retrieve analysis manager
  //

  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
   if (!mgr) {
      ::Error("AddTaskLstar13TeVpp", "No analysis manager to connect to.");
      return NULL;
   }

   // create the task and configure
   TString taskName = Form("LStar%s%s_%i%i_%s", (isPP? "pp" : "pPb"), (isMC ? "MC" : "Data"), (Int_t)cutPrCandidate,(Int_t)cutKaCandidate, outNameSuffix.Data() );

   AliRsnMiniAnalysisTask *task = new AliRsnMiniAnalysisTask(taskName.Data(), isMC);

   //if(is2011PbPb)
   //task->SelectCollisionCandidates(AliVEvent::kMB | AliVEvent::kCentral | AliVEvent::kSemiCentral);
   //else
   task->SelectCollisionCandidates(triggerMask);

   /*
   AliMultSelectionTask *taskm = AddTaskMultSelection();

   if(isMC == 1)
     {
       taskm->SetAlternateOADBforEstimators( "LHC15f" );
     }
   */

   //   task->UseMultiplicity("QUALITY");

   if (isPP) {
     //     task->UseMultiplicity("QUALITY");
     if (MultBins == 1) task->UseMultiplicity("AliMultSelection_V0M"); // for multiplicity percentile
     else if(MultBins == 2) task->UseMultiplicity("AliMultSelection_RefMult05");
     else task->UseMultiplicity("QUALITY");
   }
   else
     task->UseCentrality("V0M");

   // set event mixing options
   task->UseContinuousMix();
   //task->UseBinnedMix();
   task->SetNMix(nmix);
   task->SetMaxDiffVz(maxDiffVzMix);
   task->SetMaxDiffMult(maxDiffMultMix);
   //if (!isPP) task->SetMaxDiffAngle(maxDiffAngleMixDeg*TMath::DegToRad()); //set angle diff in rad
   ::Info("AddTaskLstar13TeVpp", Form("Event mixing configuration: \n events to mix = %i \n max diff. vtxZ = cm %5.3f \n max diff multi = %5.3f \n ", nmix, maxDiffVzMix, maxDiffMultMix));

   mgr->AddTask(task);

   //
   // -- EVENT CUTS (same for all configs) ---------------------------------------------------------
   //
   // cut on primary vertex:
   // - 2nd argument --> |Vz| range
   // - 3rd argument --> minimum required number of contributors
   // - 4th argument --> tells if TPC stand-alone vertexes must be accepted
   //   if (isPP)
   //{

   Bool_t  rejectPileUp = kTRUE;

   //   if(!isPP || isMC || MultBins) rejectPileUp=kFALSE;
   if(!isPP || isMC) rejectPileUp=kFALSE;

   AliRsnCutPrimaryVertex *cutVertex = new AliRsnCutPrimaryVertex("cutVertex", vtxZcut, 0, kFALSE);
   cutVertex->SetCheckZResolutionSPD();
   cutVertex->SetCheckDispersionSPD();
   cutVertex->SetCheckZDifferenceSPDTrack();

   AliRsnCutEventUtils *cutEventUtils = new AliRsnCutEventUtils("cutEventUtils", kTRUE, rejectPileUp);
   //   cutEventUtils->SetCheckIncompleteDAQ();
   //   cutEventUtils->SetCheckSPDClusterVsTrackletBG();
   if(!MultBins){
     cutEventUtils->SetCheckIncompleteDAQ();
     cutEventUtils->SetCheckSPDClusterVsTrackletBG();
     cutEventUtils->SetCheckInelGt0SPDtracklets();
   }
   else{
     cutEventUtils->SetRemovePileUppA2013(kFALSE);
     cutEventUtils->SetCheckAcceptedMultSelection();
   }

   // if(isPP && (!isMC)){
   if(isPP && (!isMC) && cutVertex){ // modified on 21 July. Ref Anders code on git
     cutVertex->SetCheckPileUp(rejectPileUp);// set the check for pileup
     ::Info("AddTaskLstar13TeVpp", Form(":::::::::::::::::: Pile-up rejection mode: %s", (rejectPileUp)?"ON":"OFF"));
   }

   // define and fill cut set for event cut
   AliRsnCutSet *eventCuts = new AliRsnCutSet("eventCuts", AliRsnTarget::kEvent);
   eventCuts->AddCut(cutEventUtils);
   eventCuts->AddCut(cutVertex);
   eventCuts->SetCutScheme(Form("%s&%s",cutEventUtils->GetName(),cutVertex->GetName()));
   cout<< "--------------"<< cutVertex <<"cm ---------------- "<<endl;

   // set cuts in task
   task->SetEventCuts(eventCuts);

   //
   // -- EVENT-ONLY COMPUTATIONS -------------------------------------------------------------------
   //
   //vertex
   Int_t vtxID = task->CreateValue(AliRsnMiniValue::kVz, kFALSE);
   AliRsnMiniOutput *outVtx = task->CreateOutput("eventVtx", "HIST", "EVENT");
   outVtx->AddAxis(vtxID, 400, -20.0, 20.0);

   //multiplicity or centrality
   Int_t multID = task->CreateValue(AliRsnMiniValue::kMult, kFALSE);
   AliRsnMiniOutput *outMult = task->CreateOutput("eventMult", "HIST", "EVENT");
   if (isPP && !MultBins)   outMult->AddAxis(multID, 300, 0.0, 300.0);
   else  outMult->AddAxis(multID, 110, 0.0, 110.0);

   //
   // -- PAIR CUTS  -------------------------------------------------------------------------------
   //
   AliRsnCutMiniPair *cutY = new AliRsnCutMiniPair("cutRapidity", AliRsnCutMiniPair::kRapidityRange);
   if(isPP) cutY->SetRangeD(-0.5, 0.5);
   else     cutY->SetRangeD(-0.465, 0.035);

   AliRsnCutSet *cutsPair = new AliRsnCutSet("pairCuts", AliRsnTarget::kMother);
   cutsPair->AddCut(cutY);
   cutsPair->SetCutScheme(cutY->GetName());

   //   AliRsnValuePair * openangle = new AliRsnValuePair("openangle", AliRsnValuePair::kDipAngle);
   //   openangle->DipAngle(1);

//   AliRsnMiniPair * pairangle = new AliRsnMiniPair();
//   Double_t openangle = pairangle->PhiV(isMC);
//   cout<<"--------- Opening Angle ----------------- "<<openangle<<endl;

//     AliRsnCutMiniPair *cutPhiV = new AliRsnCutMiniPair("cutPhiV", AliRsnCutMiniPair::kPhiVRange);
     AliRsnCutMiniPair *cutPhiV = new AliRsnCutMiniPair("cutPhiV", 7);
     cutPhiV->SetRangeD(0.0, 360);

    AliRsnCutSet *cutsPhiV = new AliRsnCutSet("pairCutsPhiV", AliRsnTarget::kMother);
    cutsPhiV->AddCut(cutPhiV);
    cutsPhiV->SetCutScheme(cutPhiV->GetName());

   //   AliRsnMiniOutput *outangle = task->CreateOutput("OpeningAngle", "HIST", "Daughter");
   //   if (isPP && !MultBins)   outangle->AddAxis(openangle, 300, 0.0, 300.0);
   //   else  outMult->AddAxis(openangle, 110, 0.0, 110.0);

   //
   // -- CONFIG ANALYSIS --------------------------------------------------------------------------

   //for systematic checks
     {
       //       gROOT->LoadMacro("$ALICE_ROOT/PWGLF/RESONANCES/macros/mini/ConfigLStar.C");
       //gROOT->LoadMacro("ConfigureLstar13TeVpp.C");
       gROOT->LoadMacro("$ALICE_PHYSICS/PWGLF/RESONANCES/macros/mini/ConfigureLstar13TeVpp.C");
       if (!ConfigureLstar13TeVpp(task, isMC, isPP, "", cutsPair, aodFilterBit, customQualityCutsID, cutPrCandidate, cutKaCandidate, nsigmaPr, nsigmaKa,  enableMonitor, isMC&IsMcTrueOnly, signedPdg, monitorOpt, useCrossedRows, yaxisVar ,useMixLS))
return 0x0;
     }

   //
   // -- CONTAINERS --------------------------------------------------------------------------------
   //
   TString outputFileName = AliAnalysisManager::GetCommonFileName();
   //  outputFileName += ":Rsn";
   Printf("AddAnalysisTaskTPCKStarSyst - Set OutputFileName : \n %s\n", outputFileName.Data() );

   AliAnalysisDataContainer *output = mgr->CreateContainer(Form("RsnOut_%s",outNameSuffix.Data()),
							   TList::Class(),
							   AliAnalysisManager::kOutputContainer,
							   outputFileName);
   mgr->ConnectInput(task, 0, mgr->GetCommonInputContainer());
   mgr->ConnectOutput(task, 1, output);

   return task;
}
<|endoftext|>


<commit_before>#include "SDL\include\SDL.h"
#include "GameObject.h"

GameObject::GameObject(GameObject* parent, const float3 translation, const float3 scale, const Quat rotation, const char* name)
{
	this->name			= name;
	this->translation	= translation;
	this->scale			= scale;
	this->rotation		= rotation;
	this->parent		= parent;

}

GameObject::~GameObject()
{
}

void GameObject::update()
{
}

Component * GameObject::findComponent(ComponentType)
{
	return nullptr;
}

void GameObject::addChild(GameObject* child)
{
	if (child != NULL)
	{
		children.push_back(child);
	}
	else
	{
		SDL_Log("Failed to add a child to %s", name);
	}

}<commit_msg>Child Adds himself to the parent, its weird, but i'm weird too...<commit_after>#include "SDL\include\SDL.h"
#include "GameObject.h"

GameObject::GameObject(GameObject* parent, const float3 translation, const float3 scale, const Quat rotation, const char* name)
{
	this->name			= name;
	this->translation	= translation;
	this->scale			= scale;
	this->rotation		= rotation;
	this->parent		= parent;

	if (parent != NULL)
	{
		parent->addChild(this);
	}
}

GameObject::~GameObject()
{
}

void GameObject::update()
{
}

Component * GameObject::findComponent(ComponentType)
{
	return nullptr;
}

void GameObject::addChild(GameObject* child)
{
	if (child != NULL)
	{
		children.push_back(child);
	}
	else
	{
		SDL_Log("Failed to add a child to %s", name);
	}

}<|endoftext|>