<commit_before>/*
 ============================================================================
 * Name        : DmdSetProcessName.cpp
 * Author      : weizhenwei, <weizhenwei1988@gmail.com>
 * Date        : 2016.02.29
 *
 * Copyright   :
 * Copyright (c) 2016, weizhenwei
 * All rights reserved.
 *
 * 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 the {organization} 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 HOLDER 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.
 *
 * Description : implementation file of DmdSetProcessName.cpp
 ============================================================================
 */

#include <stdlib.h>
#include <string.h>

#include "DmdLog.h"
#include "DmdSetProcessName.h"

extern char **environ;

namespace opendmd {

/*
 * Inspired by nginx's ngx_setproctitle.h/.cpp code:
 *
 * To change the process title in Linux and Solaris we have to set argv[1]
 * to NULL and to copy the title to the same place where the argv[0] points to.
 * However, argv[0] may be too small to hold a new title.  Fortunately, Linux
 * and Solaris store argv[] and environ[] one after another.  So we should
 * ensure that is the continuous memory and then we allocate the new memory
 * for environ[] and copy it.  After this we could use the memory starting
 * from argv[0] for our process title.
 *
 * The Solaris's standard /bin/ps does not show the changed process title.
 * You have to use "/usr/ucb/ps -w" instead.  Besides, the UCB ps does not
 * show a new title if its length less than the origin command line length.
 * To avoid it we append to a new title the origin command line in the
 * parenthesis.
 */

DmdArgv *g_pDmdArgv = NULL;
DmdEnviron *g_pDmdEnviron = NULL;

static void releaseArgc(DmdArgv **ppArgv) {
    DmdArgv *pArgv = *ppArgv;
    if (pArgv) {
        if (pArgv->base) {
            free(pArgv->base);
            pArgv->base = NULL;
        }

        if (pArgv->pArgv) {
            free(pArgv->pArgv);
            pArgv->pArgv = NULL;
        }

        if (pArgv->pOriginArgv) {
            free(pArgv->pOriginArgv);
            pArgv->pOriginArgv = NULL;
        }

        free(pArgv);
        pArgv = NULL;
    }
}

static void releaseEnviron(DmdEnviron **ppEnviron) {
    DmdEnviron *pEnviron = *ppEnviron;
    if (pEnviron) {
        if (pEnviron->base) {
            free(pEnviron->base);
            pEnviron->base = NULL;
        }

        if (pEnviron->pEnviron) {
            free(pEnviron->pEnviron);
            pEnviron->pEnviron = NULL;
        }

        free(pEnviron);
        pEnviron = NULL;
    }
}

DMD_RESULT InitArgvEnviron() {
    releaseArgc(&g_pDmdArgv);
    releaseEnviron(&g_pDmdEnviron);

    g_pDmdArgv = static_cast<DmdArgv *>(malloc(sizeof(DmdArgv)));
    if (NULL == g_pDmdArgv) {
        DMD_LOG_ERROR("InitArgvEnviron(), failed to new g_pDmdArgv");
        return DMD_S_FAIL;
    }
    g_pDmdEnviron = static_cast<DmdEnviron *>(malloc(sizeof(DmdEnviron)));
    if (NULL == g_pDmdEnviron) {
        DMD_LOG_ERROR("InitArgvEnviron(), failed to new g_pDmdEnviron");
        return DMD_S_FAIL;
    }

    return DMD_S_OK;
}

DMD_RESULT UnInitArgvEnviron() {
    releaseArgc(&g_pDmdArgv);
    releaseEnviron(&g_pDmdEnviron);

    return DMD_S_OK;
}

DMD_RESULT SaveArgv(int argc, char *argv[]) {
    if (!g_pDmdArgv) {
        DMD_LOG_ERROR("SaveArgv(), g_pDmdArgv == NULL");
        return DMD_S_FAIL;
    }
    if (g_pDmdArgv->base) {
        free(g_pDmdArgv->base);
        g_pDmdArgv->base = NULL;
    }
    if (g_pDmdArgv->pArgv) {
        free(g_pDmdArgv->pArgv);
        g_pDmdArgv->pArgv = NULL;
    }
    if (g_pDmdArgv->pOriginArgv) {
        free(g_pDmdArgv->pOriginArgv);
        g_pDmdArgv->pOriginArgv = NULL;
    }

    g_pDmdArgv->base = NULL;
    g_pDmdArgv->iArgc = argc;
    g_pDmdArgv->pOriginArgv = static_cast<char **>
        (malloc(sizeof(char **) * argc));
    if (NULL == g_pDmdArgv->pOriginArgv) {
        DMD_LOG_ERROR("SaveArgv(), malloc g_pDmdArgv->pOriginArgv error");
        return DMD_S_FAIL;
    }
    g_pDmdArgv->pArgv = static_cast<char **>(malloc(sizeof(char **) * argc));
    if (NULL == g_pDmdArgv->pArgv) {
        DMD_LOG_ERROR("SaveArgv(), malloc g_pDmdArgv->pArgv error");
        return DMD_S_FAIL;
    }

    int totallen = 0;
    for (int i = 0; i < argc; i++) {
        totallen += strlen(argv[i]);
    }

    g_pDmdArgv->base = static_cast<char *>(malloc(totallen));
    if (NULL == g_pDmdArgv->base) {
        DMD_LOG_ERROR("SaveArgv(), malloc g_pDmdArgv->base error");
        return DMD_S_FAIL;
    }
    memset(g_pDmdArgv->base, 0, totallen);

    char *pCurrent = g_pDmdArgv->base;
    for (int i = 0; i < argc; i++) {
        strncpy(pCurrent, argv[i], strlen(argv[i]));
        g_pDmdArgv->pOriginArgv[i] = argv[i];
        g_pDmdArgv->pArgv[i] = pCurrent;
        pCurrent = pCurrent + strlen(argv[i]) + 1;
    }

#ifdef DEBUG
    for (int i = 0; i < g_pDmdArgv->iArgc; i++) {
        DMD_LOG_INFO("SaveArgv(), argv[" << i << "] = "
                << g_pDmdArgv->pArgv[i]);
    }
#endif

    return DMD_S_OK;
}

DMD_RESULT SaveEnviron() {
    if (!g_pDmdEnviron) {
        DMD_LOG_ERROR("SaveEnviron(), g_pDmdEnviron == NULL");
        return DMD_S_FAIL;
    }
    if (g_pDmdEnviron->base) {
        free(g_pDmdEnviron->base);
        g_pDmdEnviron->base = NULL;
    }
    if (g_pDmdEnviron->pEnviron) {
        free(g_pDmdEnviron->pEnviron);
        g_pDmdEnviron->pEnviron = NULL;
    }

    g_pDmdEnviron->base = NULL;
    g_pDmdEnviron->iNumOfEnviron = 0;

    int totallen = 0;
    int iNumOfEnviron = 0;
    for (iNumOfEnviron = 0; environ[iNumOfEnviron]; iNumOfEnviron++) {
        totallen += strlen(environ[iNumOfEnviron]);
    }
    g_pDmdEnviron->pEnviron = static_cast<char **>
        (malloc(sizeof(char **) * iNumOfEnviron));
    if (NULL == g_pDmdEnviron->pEnviron) {
        DMD_LOG_ERROR("SaveEnviron(), malloc g_pDmdEnviron->pEnviron error");
        return DMD_S_FAIL;
    }

    g_pDmdEnviron->base = static_cast<char *>(malloc(totallen));
    if (NULL == g_pDmdEnviron->base) {
        DMD_LOG_ERROR("SaveEnviron(), malloc g_pDmdEnviron->base error");
        return DMD_S_FAIL;
    }
    memset(g_pDmdEnviron->base, 0, totallen);

    char *pCurrent = g_pDmdEnviron->base;
    g_pDmdEnviron->iNumOfEnviron = iNumOfEnviron;
    for (int i = 0; i < iNumOfEnviron; i++) {
        strncpy(pCurrent, environ[i], strlen(environ[i]));
        g_pDmdEnviron->pEnviron[i] = pCurrent;
        environ[i] = pCurrent;
        pCurrent = pCurrent + strlen(environ[i]) + 1;
    }

#ifdef DEBUG
    for (int i = 0; i < g_pDmdEnviron->iNumOfEnviron; i++) {
        DMD_LOG_INFO("SaveEnviron(), saved environ[" << i << "] = "
                << g_pDmdEnviron->pEnviron[i]);
        DMD_LOG_INFO("SaveEnviron(), environ[" << i << "] = "
                << environ[i]);
    }
#endif

    return DMD_S_OK;
}

DMD_RESULT SetProcessName(char *pProcessName) {
    g_pDmdArgv->pOriginArgv[1] = NULL;
    strncpy(g_pDmdArgv->pOriginArgv[0], pProcessName, strlen(pProcessName));
    g_pDmdArgv->pOriginArgv[0][strlen(pProcessName)] = '\0';

    return DMD_S_OK;
}

}  // namespace opendmd

<commit_msg>bugfix on heap malloc corruption<commit_after>/*
 ============================================================================
 * Name        : DmdSetProcessName.cpp
 * Author      : weizhenwei, <weizhenwei1988@gmail.com>
 * Date        : 2016.02.29
 *
 * Copyright   :
 * Copyright (c) 2016, weizhenwei
 * All rights reserved.
 *
 * 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 the {organization} 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 HOLDER 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.
 *
 * Description : implementation file of DmdSetProcessName.cpp
 ============================================================================
 */

#include <stdlib.h>
#include <string.h>

#include <string>

#include "DmdLog.h"
#include "DmdSetProcessName.h"

extern char **environ;

namespace opendmd {

/*
 * Inspired by nginx's ngx_setproctitle.h/.cpp code:
 *
 * To change the process title in Linux and Solaris we have to set argv[1]
 * to NULL and to copy the title to the same place where the argv[0] points to.
 * However, argv[0] may be too small to hold a new title.  Fortunately, Linux
 * and Solaris store argv[] and environ[] one after another.  So we should
 * ensure that is the continuous memory and then we allocate the new memory
 * for environ[] and copy it.  After this we could use the memory starting
 * from argv[0] for our process title.
 *
 * The Solaris's standard /bin/ps does not show the changed process title.
 * You have to use "/usr/ucb/ps -w" instead.  Besides, the UCB ps does not
 * show a new title if its length less than the origin command line length.
 * To avoid it we append to a new title the origin command line in the
 * parenthesis.
 */

DmdArgv *g_pDmdArgv = NULL;
DmdEnviron *g_pDmdEnviron = NULL;

static void releaseArgc(DmdArgv **ppArgv) {
    DmdArgv *pArgv = *ppArgv;
    if (pArgv) {
        if (pArgv->base) {
            delete [] pArgv->base;
            pArgv->base = NULL;
        }

        if (pArgv->pArgv) {
            delete [] pArgv->pArgv;
            pArgv->pArgv = NULL;
        }

        if (pArgv->pOriginArgv) {
            delete [] pArgv->pOriginArgv;
            pArgv->pOriginArgv = NULL;
        }

        delete pArgv;
        pArgv = NULL;
    }
}

static void releaseEnviron(DmdEnviron **ppEnviron) {
    DmdEnviron *pEnviron = *ppEnviron;
    if (pEnviron) {
        if (pEnviron->base) {
            delete [] pEnviron->base;
            pEnviron->base = NULL;
        }

        if (pEnviron->pEnviron) {
            delete [] pEnviron->pEnviron;
            pEnviron->pEnviron = NULL;
        }

        delete pEnviron;
        pEnviron = NULL;
    }
}

DMD_RESULT InitArgvEnviron() {
    releaseArgc(&g_pDmdArgv);
    releaseEnviron(&g_pDmdEnviron);

    g_pDmdArgv = new DmdArgv;
    if (NULL == g_pDmdArgv) {
        DMD_LOG_ERROR("InitArgvEnviron(), failed to new g_pDmdArgv");
        return DMD_S_FAIL;
    }
    g_pDmdEnviron = new DmdEnviron;
    if (NULL == g_pDmdEnviron) {
        DMD_LOG_ERROR("InitArgvEnviron(), failed to new g_pDmdEnviron");
        return DMD_S_FAIL;
    }

    return DMD_S_OK;
}

DMD_RESULT UnInitArgvEnviron() {
    releaseArgc(&g_pDmdArgv);
    releaseEnviron(&g_pDmdEnviron);

    return DMD_S_OK;
}

typedef char *charP;
DMD_RESULT SaveArgv(int argc, char *argv[]) {
    if (!g_pDmdArgv) {
        DMD_LOG_ERROR("SaveArgv(), g_pDmdArgv == NULL");
        return DMD_S_FAIL;
    }
    if (g_pDmdArgv->base) {
        delete [] g_pDmdArgv->base;
        g_pDmdArgv->base = NULL;
    }
    if (g_pDmdArgv->pArgv) {
        delete [] g_pDmdArgv->pArgv;
        g_pDmdArgv->pArgv = NULL;
    }
    if (g_pDmdArgv->pOriginArgv) {
        delete [] g_pDmdArgv->pOriginArgv;
        g_pDmdArgv->pOriginArgv = NULL;
    }

    g_pDmdArgv->base = NULL;
    g_pDmdArgv->iArgc = argc;
    g_pDmdArgv->pOriginArgv = new charP[argc];
    if (NULL == g_pDmdArgv->pOriginArgv) {
        DMD_LOG_ERROR("SaveArgv(), new g_pDmdArgv->pOriginArgv error");
        return DMD_S_FAIL;
    }
    g_pDmdArgv->pArgv = new charP[argc];
    if (NULL == g_pDmdArgv->pArgv) {
        DMD_LOG_ERROR("SaveArgv(), new g_pDmdArgv->pArgv error");
        return DMD_S_FAIL;
    }

    int totallen = 0;
    for (int i = 0; i < argc; i++) {
        totallen += strlen(argv[i]) + 1;
    }

    g_pDmdArgv->base = new char[totallen];
    if (NULL == g_pDmdArgv->base) {
        DMD_LOG_ERROR("SaveArgv(), new g_pDmdArgv->base error");
        return DMD_S_FAIL;
    }
    memset(g_pDmdArgv->base, 0, totallen);

    char *pCurrent = g_pDmdArgv->base;
    for (int i = 0; i < argc; i++) {
        strncpy(pCurrent, argv[i], strlen(argv[i]));
        g_pDmdArgv->pOriginArgv[i] = argv[i];
        g_pDmdArgv->pArgv[i] = pCurrent;
        pCurrent = pCurrent + strlen(argv[i]) + 1;
    }

#ifdef DEBUG
    for (int i = 0; i < g_pDmdArgv->iArgc; i++) {
        DMD_LOG_INFO("SaveArgv(), argv[" << i << "] = "
                << g_pDmdArgv->pArgv[i]);
    }
#endif

    return DMD_S_OK;
}

DMD_RESULT SaveEnviron() {
    if (!g_pDmdEnviron) {
        DMD_LOG_ERROR("SaveEnviron(), g_pDmdEnviron == NULL");
        return DMD_S_FAIL;
    }
    if (g_pDmdEnviron->base) {
        delete [] g_pDmdEnviron->base;
        g_pDmdEnviron->base = NULL;
    }
    if (g_pDmdEnviron->pEnviron) {
        delete [] g_pDmdEnviron->pEnviron;
        g_pDmdEnviron->pEnviron = NULL;
    }

    g_pDmdEnviron->base = NULL;
    g_pDmdEnviron->iNumOfEnviron = 0;

    int totallen = 0;
    int iNumOfEnviron = 0;
    for (iNumOfEnviron = 0; environ[iNumOfEnviron]; iNumOfEnviron++) {
        totallen += strlen(environ[iNumOfEnviron]) + 1;
    }
    g_pDmdEnviron->iNumOfEnviron = iNumOfEnviron;
    g_pDmdEnviron->pEnviron = new charP[iNumOfEnviron];
    if (NULL == g_pDmdEnviron->pEnviron) {
        DMD_LOG_ERROR("SaveEnviron(), new g_pDmdEnviron->pEnviron error");
        return DMD_S_FAIL;
    }

    g_pDmdEnviron->base = new char[totallen];
    if (NULL == g_pDmdEnviron->base) {
        DMD_LOG_ERROR("SaveEnviron(), new g_pDmdEnviron->base error");
        return DMD_S_FAIL;
    }
    memset(g_pDmdEnviron->base, 0, totallen);

    char *pCurrent = g_pDmdEnviron->base;
    for (int i = 0; i < iNumOfEnviron; i++) {
        strncpy(pCurrent, environ[i], strlen(environ[i]));
        g_pDmdEnviron->pEnviron[i] = pCurrent;
        environ[i] = pCurrent;
        pCurrent = pCurrent + strlen(environ[i]) + 1;
    }

#ifdef DEBUG
    for (int i = 0; i < g_pDmdEnviron->iNumOfEnviron; i++) {
        DMD_LOG_INFO("SaveEnviron(), saved environ[" << i << "] = "
                << string(g_pDmdEnviron->pEnviron[i]));
        DMD_LOG_INFO("SaveEnviron(), environ[" << i << "] = "
                << environ[i]);
    }
#endif

    return DMD_S_OK;
}

DMD_RESULT SetProcessName(char *pProcessName) {
    g_pDmdArgv->pOriginArgv[1] = NULL;
    strncpy(g_pDmdArgv->pOriginArgv[0], pProcessName, strlen(pProcessName));
    g_pDmdArgv->pOriginArgv[0][strlen(pProcessName)] = '\0';

    return DMD_S_OK;
}

}  // namespace opendmd

<|endoftext|>


<commit_before>// $Id:$

#if !defined(__CINT__) || defined(__MAKECINT__)
#include <vector>
#include <map>
#include <Riostream.h>
#include <TChain.h>
#include <TClonesArray.h>
#include <TError.h>
#include <TFile.h>
#include <TDirectory.h>
#include <TMath.h>
#include <TRandom3.h>
#include <TSystem.h>
#include <TObjectTable.h>
#include "TreeClasses.C"
#endif

#define DUPLICATECHECK
#ifdef DUPLICATECHECK
#define DUPLICATEVERBOSE
#endif

struct EvInfo
{
  Int_t         fRun;
  Short_t       fArrId;
  UInt_t        fEntry;
};

void mergeCorr(Int_t run_from=-1,
               Int_t run_to=-1,
               const char *outPrefix = "merged",
               const char *inFileNames = "res/output_*.root");

void mergeCorr(Int_t nEvents,
               const char *outFileName,
               const char *inFileNames);

//-----------------------------------------------------------------------------------------------------

void mergeCorr(Int_t run_from,
               Int_t run_to,
               const char *outPrefix,
               const char *inFileNames)
{
  TChain *c = new TChain("MyTree");
  c->Add(inFileNames);

  std::map<Int_t,Int_t> goodruns;

  TObjArray *filenames = c->GetListOfFiles();
  Int_t nfiles = filenames->GetEntries();
  for(Int_t i=0; i<nfiles; ++i) {
    TString fname(filenames->At(i)->GetTitle());
    TFile *file = TFile::Open(fname);
    if (!file)
      continue;
    TList *output = dynamic_cast<TList*>(file->Get("output"));
    output->SetOwner(1);
    TTree *tree = dynamic_cast<TTree*>(output->FindObject("MyTree"));
    Int_t nent = tree->GetEntries();
    if (nent<1) {
      delete output;
      file->Close();
      delete file;
      continue;
    }

    MyHeader *header = 0;
    TBranch *br = tree->GetBranch("header");
    br->SetAddress(&header);

    std::vector<Int_t> multruns;

    Int_t runno = -1;
    for (Int_t ev=0;ev<nent;++ev) {
      br->GetEntry(ev);
      if (header->fRun==0) {
        continue;
      }
      if (runno<0)
        runno = header->fRun;
      else if (runno!=header->fRun) {
        Bool_t found = 0;
        for (UInt_t j=0;j<multruns.size();++j) {
          if (multruns.at(j)==header->fRun) {
            found = 1;
            break;
          }
        }
        if (!found)
          multruns.push_back(header->fRun);
      }
    }
    if (multruns.size()<=0) {
      if ((runno>run_from) && (run_to<0 || runno<run_to)) {
        cout << "Found run " << runno << " associated to " << fname << endl;
        goodruns.insert(pair<Int_t,Int_t>(runno,0));
        TString dir(gSystem->DirName(inFileNames));
        dir+="/runs";
        TString link(Form("%s/%s",gSystem->pwd(),fname.Data()));
        TString rundir(Form("%s/%d", dir.Data(), runno));
        TString cmd(Form("mkdir -p %s && cd %s && ln -sf %s",
                         rundir.Data(), rundir.Data(), link.Data()));
        gSystem->Exec(cmd);
      }
    } else {
      cout << "Multiple runs (" << runno;
      for (UInt_t j=0;j<multruns.size();++j)
        cout << ", " << multruns.at(j);
      cout << ") found in " << fname << endl;
      cout << " Cannot deal with this case yet!!!" << endl;
    }
    delete output;
    file->Close();
    delete file;
  }

  for (map<Int_t, Int_t>::iterator it = goodruns.begin();it!=goodruns.end();++it) {
    TString infiles(Form("%s/runs/%d/*.root",gSystem->DirName(inFileNames),it->first));
    TString outdir(Form("%s/mergedruns",gSystem->DirName(inFileNames)));
    TString outFileName(Form("%s/%s_run%d.root",outdir.Data(),outPrefix,it->first));
    gSystem->Exec(Form("mkdir -p %s",outdir.Data()));
    gSystem->Exec(Form("root -b -q mergeCorr.C+'(-1,\"%s\",\"%s\")'",
                       outFileName.Data(),infiles.Data()));
  }
}

//-----------------------------------------------------------------------------------------------------

void mergeCorr(Int_t nEvents,
               const char *outFileName,
               const char *inFileNames)
{
  TChain *c = new TChain("MyTree");
  c->Add(inFileNames);

  map<ULong64_t, EvInfo*> einfos;
#ifdef DUPLICATEVERBOSE
  map<ULong64_t, MyHeader*> eheaders;
#endif

  Int_t totnent = 0;
  Int_t totnsus = 0;
#ifdef DUPLICATECHECK
  Int_t totncan = 0;
#ifdef DUPLICATEVERBOSE
  Int_t totndup = 0;
#endif
#endif

  TObjArray *maps = new TObjArray;
  maps->SetOwner(1);
  Int_t lrun = 0;
  TObjArray *filenames = c->GetListOfFiles();
  Int_t nfiles = filenames->GetEntries();
  for(Int_t i=0; i<nfiles; ++i) {
    TString fname(filenames->At(i)->GetTitle());
    TFile *file = TFile::Open(fname);
    if (!file)
      continue;
    TList *output = dynamic_cast<TList*>(file->Get("output"));
    output->SetOwner(1);
    TTree *tree = dynamic_cast<TTree*>(output->FindObject("MyTree"));
    Int_t nent = tree->GetEntries();
    if (nent<1) {
      delete output;
      file->Close();
      delete file;
      continue;
    }

    totnent += nent;
    cout << "Found "<< nent << " entries in " << fname << endl;

    MyHeader *header = 0;
    TBranch *br = tree->GetBranch("header");
    br->SetAddress(&header);

    for (Int_t ev=0;ev<nent;++ev) {
      br->GetEntry(ev);
      if (header->fRun==0) {
#ifdef DUPLICATEVERBOSE
        cout << "--> Suspicious found for " << header->fRun << " "
             << header->fTime << " " << header->fPeriod << " " << header->fBx << endl;
#endif
        ++totnsus;
        continue;
      }

      //ULong64_t evtid = header->fTime;
      ULong64_t evtid = header->GetEventId();
#ifdef DUPLICATECHECK
      if (einfos.find(evtid)!=einfos.end()) {
#ifdef DUPLICATEVERBOSE
        cout << "--> Potential duplicate found for " << header->fRun << " "
             << header->fTime << " " << header->fPeriod << " " << header->fBx << endl;
#endif
      ++totncan;
#ifdef DUPLICATEVERBOSE
        map<ULong64_t, MyHeader*>::iterator it = eheaders.find(evtid);
        if ( (it->second->fRun==header->fRun) &&
             (it->second->fNTracks==header->fNTracks) &&
             (it->second->fNSelTracks==header->fNSelTracks) &&
             (it->second->fNTracklets==header->fNTracklets) &&
             (it->second->fVz==header->fVz)) {
          cout << "--> Duplicate found:" << endl;
          cout << " Run: " << it->second->fRun << " vs " << header->fRun << endl;
          cout << " Ntracks: " << it->second->fNTracks << " vs " << header->fNTracks << endl;
          cout << " Nseltracks: " << it->second->fNSelTracks << " vs " << header->fNSelTracks << endl;
          cout << " Ntracklets: " << it->second->fNTracklets << " vs " << header->fNTracklets << endl;
          cout << " Vz: " << it->second->fVz << " vs " << header->fVz << endl;
          ++totndup;
        }
#endif
        continue;
      }
#ifdef DUPLICATEVERBOSE
      MyHeader *cheader = new MyHeader(*header);
      eheaders.insert( pair<ULong64_t, MyHeader*>(evtid,cheader) );
#endif
#endif
      EvInfo *cinfo = new EvInfo;
      cinfo->fRun = header->fRun;
      cinfo->fArrId = i;
      cinfo->fEntry = ev;
      einfos.insert( pair<ULong64_t, EvInfo*>(evtid,cinfo) );
      if (lrun != header->fRun) {
        for (Int_t lx=0;lx<4;++lx) {
          lrun = header->fRun;
          TString cname(Form("L%d_run%d_map",lx,lrun));
          if (lx==3)
            cname=Form("TrigClass_run%d_map",lrun);
          TMap *map = dynamic_cast<TMap*>(output->FindObject(cname));
          if (map) {
            maps->Add(map);
            output->Remove(map);
          }
        }
      }
    }
    delete output;
    file->Close();
    delete file;
    if ((nEvents>0) && (einfos.size()>=(UInt_t)nEvents))
      break;
  }
  cout << "Found total: " << totnent << endl;
  cout << "Found suspicious: " << totnsus << endl;
#ifdef DUPLICATECHECK
  cout << "Found potential duplicates: " << totncan << endl;
#ifdef DUPLICATEVERBOSE
  cout << "Found duplicates: " << totndup << endl;
#endif
#endif

  // sort output tree
  std::vector<TFile*> files(nfiles);
  std::vector<TTree*> trees(nfiles);
  std::vector<MyHeader*> headers(nfiles);
  std::vector<TClonesArray*> partas(nfiles);
  std::vector<TClonesArray*> trklas(nfiles);

  MyHeader *newHeader = new MyHeader;
  if (TClass::GetClass("MyPart"))
    TClass::GetClass("MyPart")->IgnoreTObjectStreamer();
  TClonesArray *newParts     = new TClonesArray("MyPart",10000);
  if (TClass::GetClass("MyTracklet"))
    TClass::GetClass("MyTracklet")->IgnoreTObjectStreamer();
  TClonesArray *newTracklets = new TClonesArray("MyTracklet",10000);

  TFile *newFile = TFile::Open(outFileName,"recreate","Merged/Sorted MyTree created by mergeCorr.C",5);
  TDirectory::TContext cd(newFile);
  for (Int_t m=0;m<maps->GetEntries();++m) {
    TMap *map = (TMap*)maps->At(m);
    //map->Print();
    map->Write(map->GetName(),TObject::kSingleKey);
  }
  TTree *newTree = new TTree("MyTree", "MyTree created by MyAliTask.cxx");
  newTree->Branch("header",&newHeader, 32*1024, 99);
  newTree->Branch("parts",&newParts, 256*1024, 99);
  newTree->Branch("tracklets",&newTracklets, 256*1024, 99);
  Int_t newEntries = 0;
  for (map<ULong64_t, EvInfo*>::iterator it = einfos.begin();it!=einfos.end();++it) {
    Short_t id = it->second->fArrId;
    UInt_t entry = it->second->fEntry;
    if (!trees.at(id)) { // connect new tree
      TString fname(filenames->At(id)->GetTitle());
      TFile *file = TFile::Open(fname);
      TDirectory::TContext cd2(newFile,file);
      files[id] = file;
      TList *output = dynamic_cast<TList*>(file->Get("output"));
      TTree *tree = dynamic_cast<TTree*>(output->FindObject("MyTree"));
      trees[id] = tree;
      output->Remove(tree);
      output->SetOwner(1);
      delete output;
      tree->SetBranchAddress("header",&headers[id]);
      tree->SetBranchAddress("parts",&partas[id]);
      tree->SetBranchAddress("tracklets",&trklas[id]);
    }
    files[id]->cd();
    trees.at(id)->GetEntry(entry);
    *newHeader = *(headers[id]);
    newParts->Clear();
    Int_t nparts = partas[id]->GetEntries();
    for (Int_t p = 0; p < nparts; ++p) {
      MyPart *orig = dynamic_cast<MyPart*>(partas[id]->At(p));
      new((*newParts)[p]) MyPart(*orig);
    }
    Int_t ntrkls = trklas[id]->GetEntries();
    for (Int_t p = 0; p < ntrkls; ++p) {
      MyTracklet *orig = dynamic_cast<MyTracklet*>(trklas[id]->At(p));
      new((*newTracklets)[p]) MyTracklet(*orig);
    }
    newFile->cd();
    newTree->Fill();
    ++newEntries;
    delete it->second;
    if ((nEvents>0) && (newEntries>=nEvents))
      break;
  }

  newTree->Write();
  newFile->Close();
  delete newFile;

  for(Int_t i=0;i<nfiles;++i) {
    delete trees.at(i);
    delete files.at(i);
  }
}
<commit_msg>Printout event info if duplicate event found<commit_after>// $Id:$

#if !defined(__CINT__) || defined(__MAKECINT__)
#include <vector>
#include <map>
#include <Riostream.h>
#include <TChain.h>
#include <TClonesArray.h>
#include <TError.h>
#include <TFile.h>
#include <TDirectory.h>
#include <TMath.h>
#include <TRandom3.h>
#include <TSystem.h>
#include <TObjectTable.h>
#include "TreeClasses.C"
#endif

#define DUPLICATECHECK
#ifdef DUPLICATECHECK
#define DUPLICATEVERBOSE
#endif

struct EvInfo
{
  Int_t         fRun;
  Short_t       fArrId;
  UInt_t        fEntry;
};

void mergeCorr(Int_t run_from=-1,
               Int_t run_to=-1,
               const char *outPrefix = "merged",
               const char *inFileNames = "res/output_*.root");

void mergeCorr(Int_t nEvents,
               const char *outFileName,
               const char *inFileNames);

//-----------------------------------------------------------------------------------------------------

void mergeCorr(Int_t run_from,
               Int_t run_to,
               const char *outPrefix,
               const char *inFileNames)
{
  TChain *c = new TChain("MyTree");
  c->Add(inFileNames);

  std::map<Int_t,Int_t> goodruns;

  TObjArray *filenames = c->GetListOfFiles();
  Int_t nfiles = filenames->GetEntries();
  for(Int_t i=0; i<nfiles; ++i) {
    TString fname(filenames->At(i)->GetTitle());
    TFile *file = TFile::Open(fname);
    if (!file)
      continue;
    TList *output = dynamic_cast<TList*>(file->Get("output"));
    output->SetOwner(1);
    TTree *tree = dynamic_cast<TTree*>(output->FindObject("MyTree"));
    Int_t nent = tree->GetEntries();
    if (nent<1) {
      delete output;
      file->Close();
      delete file;
      continue;
    }

    MyHeader *header = 0;
    TBranch *br = tree->GetBranch("header");
    br->SetAddress(&header);

    std::vector<Int_t> multruns;

    Int_t runno = -1;
    for (Int_t ev=0;ev<nent;++ev) {
      br->GetEntry(ev);
      if (header->fRun==0) {
        continue;
      }
      if (runno<0)
        runno = header->fRun;
      else if (runno!=header->fRun) {
        Bool_t found = 0;
        for (UInt_t j=0;j<multruns.size();++j) {
          if (multruns.at(j)==header->fRun) {
            found = 1;
            break;
          }
        }
        if (!found)
          multruns.push_back(header->fRun);
      }
    }
    if (multruns.size()<=0) {
      if ((runno>run_from) && (run_to<0 || runno<run_to)) {
        cout << "Found run " << runno << " associated to " << fname << endl;
        goodruns.insert(pair<Int_t,Int_t>(runno,0));
        TString dir(gSystem->DirName(inFileNames));
        dir+="/runs";
        TString link(Form("%s/%s",gSystem->pwd(),fname.Data()));
        TString rundir(Form("%s/%d", dir.Data(), runno));
        TString cmd(Form("mkdir -p %s && cd %s && ln -sf %s",
                         rundir.Data(), rundir.Data(), link.Data()));
        gSystem->Exec(cmd);
      }
    } else {
      cout << "Multiple runs (" << runno;
      for (UInt_t j=0;j<multruns.size();++j)
        cout << ", " << multruns.at(j);
      cout << ") found in " << fname << endl;
      cout << " Cannot deal with this case yet!!!" << endl;
    }
    delete output;
    file->Close();
    delete file;
  }

  for (map<Int_t, Int_t>::iterator it = goodruns.begin();it!=goodruns.end();++it) {
    TString infiles(Form("%s/runs/%d/*.root",gSystem->DirName(inFileNames),it->first));
    TString outdir(Form("%s/mergedruns",gSystem->DirName(inFileNames)));
    TString outFileName(Form("%s/%s_run%d.root",outdir.Data(),outPrefix,it->first));
    gSystem->Exec(Form("mkdir -p %s",outdir.Data()));
    gSystem->Exec(Form("root -b -q mergeCorr.C+'(-1,\"%s\",\"%s\")'",
                       outFileName.Data(),infiles.Data()));
  }
}

//-----------------------------------------------------------------------------------------------------

void mergeCorr(Int_t nEvents,
               const char *outFileName,
               const char *inFileNames)
{
  TChain *c = new TChain("MyTree");
  c->Add(inFileNames);

  map<ULong64_t, EvInfo*> einfos;
#ifdef DUPLICATEVERBOSE
  map<ULong64_t, MyHeader*> eheaders;
#endif

  Int_t totnent = 0;
  Int_t totnsus = 0;
#ifdef DUPLICATECHECK
  Int_t totncan = 0;
#ifdef DUPLICATEVERBOSE
  Int_t totndup = 0;
#endif
#endif

  TObjArray *maps = new TObjArray;
  maps->SetOwner(1);
  Int_t lrun = 0;
  TObjArray *filenames = c->GetListOfFiles();
  Int_t nfiles = filenames->GetEntries();
  for(Int_t i=0; i<nfiles; ++i) {
    TString fname(filenames->At(i)->GetTitle());
    TFile *file = TFile::Open(fname);
    if (!file)
      continue;
    TList *output = dynamic_cast<TList*>(file->Get("output"));
    output->SetOwner(1);
    TTree *tree = dynamic_cast<TTree*>(output->FindObject("MyTree"));
    Int_t nent = tree->GetEntries();
    if (nent<1) {
      delete output;
      file->Close();
      delete file;
      continue;
    }

    totnent += nent;
    cout << "Found "<< nent << " entries in " << fname << endl;
    TObjArray *filesnames = dynamic_cast<TObjArray*>(output->FindObject("filesnames"));

    MyHeader *header = 0;
    TBranch *br = tree->GetBranch("header");
    br->SetAddress(&header);

    for (Int_t ev=0;ev<nent;++ev) {
      br->GetEntry(ev);
      if (header->fRun==0) {
#ifdef DUPLICATEVERBOSE
        cout << "--> Suspicious found for " << header->fRun << " "
             << header->fTime << " " << header->fPeriod << " " << header->fBx << endl;
#endif
        ++totnsus;
        continue;
      }

      //ULong64_t evtid = header->fTime;
      ULong64_t evtid = header->GetEventId();
#ifdef DUPLICATECHECK
      if (einfos.find(evtid)!=einfos.end()) {
#ifdef DUPLICATEVERBOSE
        cout << "--> Potential duplicate found for " << header->fRun << " "
             << header->fTime << " " << header->fPeriod << " " << header->fBx << endl;
#endif
      ++totncan;
#ifdef DUPLICATEVERBOSE
        map<ULong64_t, MyHeader*>::iterator it = eheaders.find(evtid);
        if ( (it->second->fRun==header->fRun) &&
             (it->second->fNTracks==header->fNTracks) &&
             (it->second->fNSelTracks==header->fNSelTracks) &&
             (it->second->fNTracklets==header->fNTracklets) &&
             (it->second->fVz==header->fVz)) {
          cout << "--> Duplicate found:" << endl;
          cout << " Run: " << it->second->fRun << " vs " << header->fRun << endl;
          cout << " Ntracks: " << it->second->fNTracks << " vs " << header->fNTracks << endl;
          cout << " Nseltracks: " << it->second->fNSelTracks << " vs " << header->fNSelTracks << endl;
          cout << " Ntracklets: " << it->second->fNTracklets << " vs " << header->fNTracklets << endl;
          cout << " Vz: " << it->second->fVz << " vs " << header->fVz << endl;
          cout << " Duplicate event " << header->fEvNumberInFile << " in file "
               << filesnames->At(header->fFileId)->GetName() << endl;
          ++totndup;
        }
#endif
        continue;
      }
#ifdef DUPLICATEVERBOSE
      MyHeader *cheader = new MyHeader(*header);
      eheaders.insert( pair<ULong64_t, MyHeader*>(evtid,cheader) );
#endif
#endif
      EvInfo *cinfo = new EvInfo;
      cinfo->fRun = header->fRun;
      cinfo->fArrId = i;
      cinfo->fEntry = ev;
      einfos.insert( pair<ULong64_t, EvInfo*>(evtid,cinfo) );
      if (lrun != header->fRun) {
        for (Int_t lx=0;lx<4;++lx) {
          lrun = header->fRun;
          TString cname(Form("L%d_run%d_map",lx,lrun));
          if (lx==3)
            cname=Form("TrigClass_run%d_map",lrun);
          TMap *map = dynamic_cast<TMap*>(output->FindObject(cname));
          if (map) {
            maps->Add(map);
            output->Remove(map);
          }
        }
      }
    }
    delete output;
    file->Close();
    delete file;
    if ((nEvents>0) && (einfos.size()>=(UInt_t)nEvents))
      break;
  }
  cout << "Found total: " << totnent << endl;
  cout << "Found suspicious: " << totnsus << endl;
#ifdef DUPLICATECHECK
  cout << "Found potential duplicates: " << totncan << endl;
#ifdef DUPLICATEVERBOSE
  cout << "Found duplicates: " << totndup << endl;
#endif
#endif

  // sort output tree
  std::vector<TFile*> files(nfiles);
  std::vector<TTree*> trees(nfiles);
  std::vector<MyHeader*> headers(nfiles);
  std::vector<TClonesArray*> partas(nfiles);
  std::vector<TClonesArray*> trklas(nfiles);

  MyHeader *newHeader = new MyHeader;
  if (TClass::GetClass("MyPart"))
    TClass::GetClass("MyPart")->IgnoreTObjectStreamer();
  TClonesArray *newParts     = new TClonesArray("MyPart",10000);
  if (TClass::GetClass("MyTracklet"))
    TClass::GetClass("MyTracklet")->IgnoreTObjectStreamer();
  TClonesArray *newTracklets = new TClonesArray("MyTracklet",10000);

  TFile *newFile = TFile::Open(outFileName,"recreate","Merged/Sorted MyTree created by mergeCorr.C",5);
  TDirectory::TContext cd(newFile);
  for (Int_t m=0;m<maps->GetEntries();++m) {
    TMap *map = (TMap*)maps->At(m);
    //map->Print();
    map->Write(map->GetName(),TObject::kSingleKey);
  }
  TTree *newTree = new TTree("MyTree", "MyTree created by MyAliTask.cxx");
  newTree->Branch("header",&newHeader, 32*1024, 99);
  newTree->Branch("parts",&newParts, 256*1024, 99);
  newTree->Branch("tracklets",&newTracklets, 256*1024, 99);
  Int_t newEntries = 0;
  for (map<ULong64_t, EvInfo*>::iterator it = einfos.begin();it!=einfos.end();++it) {
    Short_t id = it->second->fArrId;
    UInt_t entry = it->second->fEntry;
    if (!trees.at(id)) { // connect new tree
      TString fname(filenames->At(id)->GetTitle());
      TFile *file = TFile::Open(fname);
      TDirectory::TContext cd2(newFile,file);
      files[id] = file;
      TList *output = dynamic_cast<TList*>(file->Get("output"));
      TTree *tree = dynamic_cast<TTree*>(output->FindObject("MyTree"));
      trees[id] = tree;
      output->Remove(tree);
      output->SetOwner(1);
      delete output;
      tree->SetBranchAddress("header",&headers[id]);
      tree->SetBranchAddress("parts",&partas[id]);
      tree->SetBranchAddress("tracklets",&trklas[id]);
    }
    files[id]->cd();
    trees.at(id)->GetEntry(entry);
    *newHeader = *(headers[id]);
    newParts->Clear();
    Int_t nparts = partas[id]->GetEntries();
    for (Int_t p = 0; p < nparts; ++p) {
      MyPart *orig = dynamic_cast<MyPart*>(partas[id]->At(p));
      new((*newParts)[p]) MyPart(*orig);
    }
    Int_t ntrkls = trklas[id]->GetEntries();
    for (Int_t p = 0; p < ntrkls; ++p) {
      MyTracklet *orig = dynamic_cast<MyTracklet*>(trklas[id]->At(p));
      new((*newTracklets)[p]) MyTracklet(*orig);
    }
    newFile->cd();
    newTree->Fill();
    ++newEntries;
    delete it->second;
    if ((nEvents>0) && (newEntries>=nEvents))
      break;
  }

  newTree->Write();
  newFile->Close();
  delete newFile;

  for(Int_t i=0;i<nfiles;++i) {
    delete trees.at(i);
    delete files.at(i);
  }
}
<|endoftext|>


<commit_before>// $Id:$

#if !defined(__CINT__) || defined(__MAKECINT__)
#include <vector>
#include <map>
#include <Riostream.h>
#include <TChain.h>
#include <TClonesArray.h>
#include <TError.h>
#include <TFile.h>
#include <TDirectory.h>
#include <TMath.h>
#include <TRandom3.h>
#include <TSystem.h>
#include "MyClasses.cxx"
#endif

//#define DUPLICATECHECK
#ifdef DUPLICATECHECK
//#define DUPLICATEVERBOSE
#endif

struct EvInfo
{
  Int_t         fRun;
  Short_t       fArrId;
  UInt_t        fEntry;
};

void mergeCorr(Int_t run_from=-1,
               Int_t run_to=-1,
               const char *outPrefix = "merged",
               const char *inFileNames = "res/output_*.root");

void mergeCorr(Int_t nEvents,
               const char *outFileName,
               const char *inFileNames);

//-----------------------------------------------------------------------------------------------------

void mergeCorr(Int_t run_from,
               Int_t run_to,
               const char *outPrefix,
               const char *inFileNames)
{
  TChain *c = new TChain("MyTree");
  c->Add(inFileNames);

  std::map<Int_t,Int_t> goodruns;

  TObjArray *filenames = c->GetListOfFiles();
  Int_t nfiles = filenames->GetEntries();
  for(Int_t i=0; i<nfiles; ++i) {
    TString fname(filenames->At(i)->GetTitle());
    TFile *file = TFile::Open(fname);
    if (!file)
      continue;
    TList *output = dynamic_cast<TList*>(file->Get("output"));
    TTree *tree = dynamic_cast<TTree*>(output->FindObject("MyTree"));
    Int_t nent = tree->GetEntries();
    if (nent<1) {
      file->Close();
      delete file;
      continue;
    }

    MyHeader *header = 0;
    TBranch *br = tree->GetBranch("header");
    br->SetAddress(&header);

    std::vector<Int_t> multruns;

    Int_t runno = -1;
    for (Int_t ev=0;ev<nent;++ev) {
      br->GetEntry(ev);
      if (header->fRun==0) {
        continue;
      }
      if (runno<0)
        runno = header->fRun;
      else if (runno!=header->fRun) {
        Bool_t found = 0;
        for (UInt_t j=0;j<multruns.size();++j) {
          if (multruns.at(j)==header->fRun) {
            found = 1;
            break;
          }
        }
        if (!found)
          multruns.push_back(header->fRun);
      }
    }
    if (multruns.size()<=0) {
      if ((runno>run_from) && (run_to<0 || runno<run_to)) {
        cout << "Found run " << runno << " associated to " << fname << endl;
        goodruns.insert(pair<Int_t,Int_t>(runno,0));
        TString dir(gSystem->DirName(inFileNames));
        dir+="/runs";
        TString link(Form("%s/%s",gSystem->pwd(),fname.Data()));
        TString rundir(Form("%s/%d", dir.Data(), runno));
        TString cmd(Form("mkdir -p %s && cd %s && ln -sf %s",
                         rundir.Data(), rundir.Data(), link.Data()));
        gSystem->Exec(cmd);
      }
    } else {
      cout << "Multiple runs (" << runno;
      for (UInt_t j=0;j<multruns.size();++j)
        cout << ", " << multruns.at(j);
      cout << ") found in " << fname << endl;
      cout << " Cannot deal with this case yet!!!" << endl;
    }
    file->Close();
    delete file;
  }

  for (map<Int_t, Int_t>::iterator it = goodruns.begin();it!=goodruns.end();++it) {
    TString infiles(Form("%s/runs/%d/*.root",gSystem->DirName(inFileNames),it->first));
    TString outdir(Form("%s/mergedruns",gSystem->DirName(inFileNames)));
    TString outFileName(Form("%s/%s_run%d.root",outdir.Data(),outPrefix,it->first));
    gSystem->Exec(Form("mkdir -p %s",outdir.Data()));
    gSystem->Exec(Form("root -b -q mergeCorr.C+'(-1,\"%s\",\"%s\")'",
                       outFileName.Data(),infiles.Data()));
  }
}

//-----------------------------------------------------------------------------------------------------

void mergeCorr(Int_t nEvents,
               const char *outFileName,
               const char *inFileNames)
{
  TChain *c = new TChain("MyTree");
  c->Add(inFileNames);

  map<ULong64_t, EvInfo*> einfos;
#ifdef DUPLICATEVERBOSE
  map<ULong64_t, MyHeader*> eheaders;
#endif

  Int_t totnent = 0;
  Int_t totnsus = 0;
#ifdef DUPLICATECHECK
  Int_t totncan = 0;
#ifdef DUPLICATEVERBOSE
  Int_t totndup = 0;
#endif
#endif

  TObjArray *filenames = c->GetListOfFiles();
  Int_t nfiles = filenames->GetEntries();
  for(Int_t i=0; i<nfiles; ++i) {
    TString fname(filenames->At(i)->GetTitle());
    TFile *file = TFile::Open(fname);
    if (!file)
      continue;
    TList *output = dynamic_cast<TList*>(file->Get("output"));
    TTree *tree = dynamic_cast<TTree*>(output->FindObject("MyTree"));
    Int_t nent = tree->GetEntries();
    if (nent<1) {
      file->Close();
      delete file;
      continue;
    }

    totnent += nent;
    cout << "Found "<< nent << " entries in " << fname << endl;

    MyHeader *header = 0;
    TBranch *br = tree->GetBranch("header");
    br->SetAddress(&header);

    for (Int_t ev=0;ev<nent;++ev) {
      br->GetEntry(ev);
      if (header->fPeriod!=0) // fix take period from runinfo block
        cout << "--> Non-zero period found " << header->fRun << " "
             << header->fTime << " " << header->fPeriod << " " << header->fBx << endl;
      if (header->fRun==0) {
#ifdef DUPLICATEVERBOSE
        cout << "--> Suspicious found for " << header->fRun << " "
             << header->fTime << " " << header->fPeriod << " " << header->fBx << endl;
#endif
        ++totnsus;
        continue;
      }

      ULong64_t evtid = header->fTime;//header->GetEventId();
#ifdef DUPLICATECHECK
      if (einfos.find(evtid)!=einfos.end()) {
#ifdef DUPLICATEVERBOSE
        cout << "--> Potential duplicate found for " << header->fRun << " "
             << header->fTime << " " << header->fPeriod << " " << header->fBx << endl;
#endif
      ++totncan;
#ifdef DUPLICATEVERBOSE
        map<ULong64_t, MyHeader*>::iterator it = eheaders.find(evtid);
        if ( (it->second->fRun==header->fRun) &&
             (it->second->fNTracks==header->fNTracks) &&
             (it->second->fNSelTracks==header->fNSelTracks) &&
             (it->second->fNTracklets==header->fNTracklets) &&
             (it->second->fVz==header->fVz)) {
          cout << "--> Duplicate found:" << endl;
          cout << " Run: " << it->second->fRun << " vs " << header->fRun << endl;
          cout << " Ntracks: " << it->second->fNTracks << " vs " << header->fNTracks << endl;
          cout << " Nseltracks: " << it->second->fNSelTracks << " vs " << header->fNSelTracks << endl;
          cout << " Ntracklets: " << it->second->fNTracklets << " vs " << header->fNTracklets << endl;
          cout << " Vz: " << it->second->fVz << " vs " << header->fVz << endl;
          ++totndup;
        }
#endif
        continue;
      }
#ifdef DUPLICATEVERBOSE
      MyHeader *cheader = new MyHeader(*header);
      eheaders.insert( pair<ULong64_t, MyHeader*>(evtid,cheader) );
#endif
#endif
      EvInfo *cinfo = new EvInfo;
      cinfo->fRun = header->fRun;
      cinfo->fArrId = i;
      cinfo->fEntry = ev;
      einfos.insert( pair<ULong64_t, EvInfo*>(evtid,cinfo) );
    }

    file->Close();
    delete file;
    if ((nEvents>0) && (einfos.size()>=(UInt_t)nEvents))
      break;
  }
  cout << "Found total: " << totnent << endl;
  cout << "Found suspicious: " << totnsus << endl;
#ifdef DUPLICATECHECK
  cout << "Found potential duplicates: " << totncan << endl;
#ifdef DUPLICATEVERBOSE
  cout << "Found duplicates: " << totndup << endl;
#endif
#endif

  // sort output tree
  std::vector<TFile*> files(nfiles);
  std::vector<TTree*> trees(nfiles);
  std::vector<MyHeader*> headers(nfiles);
  std::vector<TClonesArray*> partas(nfiles);

  MyHeader *newHeader = new MyHeader;
  if (TClass::GetClass("MyPart"))
    TClass::GetClass("MyPart")->IgnoreTObjectStreamer();
  TClonesArray *newParts = new TClonesArray("MyPart",10000);

  TFile *newFile = TFile::Open(outFileName,"recreate","Merged/Sorted MyTree created by mergeCorr.C",5);
  TDirectory::TContext cd(newFile);
  TTree *newTree = new TTree("MyTree", "MyTree created by MyAliTask.cxx");
  newTree->Branch("header",&newHeader, 32*1024, 99);
  newTree->Branch("parts",&newParts, 256*1024, 99);
  Int_t newEntries = 0;
  for (map<ULong64_t, EvInfo*>::iterator it = einfos.begin();it!=einfos.end();++it) {
    Short_t id = it->second->fArrId;
    UInt_t entry = it->second->fEntry;
    if (!trees.at(id)) { // connect new tree
      TString fname(filenames->At(id)->GetTitle());
      TFile *file = TFile::Open(fname);
      TDirectory::TContext cd2(newFile,file);
      files[id] = file;
      TList *output = dynamic_cast<TList*>(file->Get("output"));
      TTree *tree = dynamic_cast<TTree*>(output->FindObject("MyTree"));
      trees[id] = tree;
      tree->SetBranchAddress("header",&headers[id]);
      tree->SetBranchAddress("parts",&partas[id]);
    }
    files[id]->cd();
    trees.at(id)->GetEntry(entry);
    *newHeader = *(headers[id]);
    newParts->Clear();
    Int_t nparts = partas[id]->GetEntries();
    for (Int_t p = 0; p < nparts; ++p) {
      MyPart *orig = dynamic_cast<MyPart*>(partas[id]->At(p));
      new((*newParts)[p]) MyPart(*orig);
    }
    newFile->cd();
    newTree->Fill();
    ++newEntries;
    delete it->second;
    if ((nEvents>0) && (newEntries>=nEvents))
      break;
  }

  newTree->Write();
  newFile->Close();
  delete newFile;

  for(Int_t i=0;i<nfiles;++i)
    delete files.at(i);

#if 0
  TClonesArray *parts = 0;
  MyHeader *header = 0;

  c->SetBranchAddress("info",&info);
  c->SetBranchAddress("nucs",&nucs);
  c->SetBranchAddress("parts",&parts);

  Int_t nRead = nEvents;
  if (nRead<0)
    nRead = c->GetEntries();
  else if (0 && (nRead>c->GetEntries()))
    nRead = c->GetEntries();

#endif
}
<commit_msg>First working merge version.<commit_after>// $Id:$

#if !defined(__CINT__) || defined(__MAKECINT__)
#include <vector>
#include <map>
#include <Riostream.h>
#include <TChain.h>
#include <TClonesArray.h>
#include <TError.h>
#include <TFile.h>
#include <TDirectory.h>
#include <TMath.h>
#include <TRandom3.h>
#include <TSystem.h>
#include "MyClasses.cxx"
#endif

//#define DUPLICATECHECK
#ifdef DUPLICATECHECK
//#define DUPLICATEVERBOSE
#endif

struct EvInfo
{
  Int_t         fRun;
  Short_t       fArrId;
  UInt_t        fEntry;
};

void mergeCorr(Int_t run_from=-1,
               Int_t run_to=-1,
               const char *outPrefix = "merged",
               const char *inFileNames = "res/output_*.root");

void mergeCorr(Int_t nEvents,
               const char *outFileName,
               const char *inFileNames);

//-----------------------------------------------------------------------------------------------------

void mergeCorr(Int_t run_from,
               Int_t run_to,
               const char *outPrefix,
               const char *inFileNames)
{
  TChain *c = new TChain("MyTree");
  c->Add(inFileNames);

  std::map<Int_t,Int_t> goodruns;

  TObjArray *filenames = c->GetListOfFiles();
  Int_t nfiles = filenames->GetEntries();
  for(Int_t i=0; i<nfiles; ++i) {
    TString fname(filenames->At(i)->GetTitle());
    TFile *file = TFile::Open(fname);
    if (!file)
      continue;
    TList *output = dynamic_cast<TList*>(file->Get("output"));
    TTree *tree = dynamic_cast<TTree*>(output->FindObject("MyTree"));
    Int_t nent = tree->GetEntries();
    if (nent<1) {
      delete tree;
      file->Close();
      delete file;
      continue;
    }

    MyHeader *header = 0;
    TBranch *br = tree->GetBranch("header");
    br->SetAddress(&header);

    std::vector<Int_t> multruns;

    Int_t runno = -1;
    for (Int_t ev=0;ev<nent;++ev) {
      br->GetEntry(ev);
      if (header->fRun==0) {
        continue;
      }
      if (runno<0)
        runno = header->fRun;
      else if (runno!=header->fRun) {
        Bool_t found = 0;
        for (UInt_t j=0;j<multruns.size();++j) {
          if (multruns.at(j)==header->fRun) {
            found = 1;
            break;
          }
        }
        if (!found)
          multruns.push_back(header->fRun);
      }
    }
    if (multruns.size()<=0) {
      if ((runno>run_from) && (run_to<0 || runno<run_to)) {
        cout << "Found run " << runno << " associated to " << fname << endl;
        goodruns.insert(pair<Int_t,Int_t>(runno,0));
        TString dir(gSystem->DirName(inFileNames));
        dir+="/runs";
        TString link(Form("%s/%s",gSystem->pwd(),fname.Data()));
        TString rundir(Form("%s/%d", dir.Data(), runno));
        TString cmd(Form("mkdir -p %s && cd %s && ln -sf %s",
                         rundir.Data(), rundir.Data(), link.Data()));
        gSystem->Exec(cmd);
      }
    } else {
      cout << "Multiple runs (" << runno;
      for (UInt_t j=0;j<multruns.size();++j)
        cout << ", " << multruns.at(j);
      cout << ") found in " << fname << endl;
      cout << " Cannot deal with this case yet!!!" << endl;
    }
    delete tree;
    file->Close();
    delete file;
  }

  for (map<Int_t, Int_t>::iterator it = goodruns.begin();it!=goodruns.end();++it) {
    TString infiles(Form("%s/runs/%d/*.root",gSystem->DirName(inFileNames),it->first));
    TString outdir(Form("%s/mergedruns",gSystem->DirName(inFileNames)));
    TString outFileName(Form("%s/%s_run%d.root",outdir.Data(),outPrefix,it->first));
    gSystem->Exec(Form("mkdir -p %s",outdir.Data()));
    gSystem->Exec(Form("root -b -q mergeCorr.C+'(-1,\"%s\",\"%s\")'",
                       outFileName.Data(),infiles.Data()));
  }
}

//-----------------------------------------------------------------------------------------------------

void mergeCorr(Int_t nEvents,
               const char *outFileName,
               const char *inFileNames)
{
  TChain *c = new TChain("MyTree");
  c->Add(inFileNames);

  map<ULong64_t, EvInfo*> einfos;
#ifdef DUPLICATEVERBOSE
  map<ULong64_t, MyHeader*> eheaders;
#endif

  Int_t totnent = 0;
  Int_t totnsus = 0;
#ifdef DUPLICATECHECK
  Int_t totncan = 0;
#ifdef DUPLICATEVERBOSE
  Int_t totndup = 0;
#endif
#endif

  TObjArray *filenames = c->GetListOfFiles();
  Int_t nfiles = filenames->GetEntries();
  for(Int_t i=0; i<nfiles; ++i) {
    TString fname(filenames->At(i)->GetTitle());
    TFile *file = TFile::Open(fname);
    if (!file)
      continue;
    TList *output = dynamic_cast<TList*>(file->Get("output"));
    TTree *tree = dynamic_cast<TTree*>(output->FindObject("MyTree"));
    Int_t nent = tree->GetEntries();
    if (nent<1) {
      delete tree;
      file->Close();
      delete file;
      continue;
    }

    totnent += nent;
    cout << "Found "<< nent << " entries in " << fname << endl;

    MyHeader *header = 0;
    TBranch *br = tree->GetBranch("header");
    br->SetAddress(&header);

    for (Int_t ev=0;ev<nent;++ev) {
      br->GetEntry(ev);
      if (header->fPeriod!=0) // fix take period from runinfo block
        cout << "--> Non-zero period found " << header->fRun << " "
             << header->fTime << " " << header->fPeriod << " " << header->fBx << endl;
      if (header->fRun==0) {
#ifdef DUPLICATEVERBOSE
        cout << "--> Suspicious found for " << header->fRun << " "
             << header->fTime << " " << header->fPeriod << " " << header->fBx << endl;
#endif
        ++totnsus;
        continue;
      }

      ULong64_t evtid = header->fTime;//header->GetEventId();
#ifdef DUPLICATECHECK
      if (einfos.find(evtid)!=einfos.end()) {
#ifdef DUPLICATEVERBOSE
        cout << "--> Potential duplicate found for " << header->fRun << " "
             << header->fTime << " " << header->fPeriod << " " << header->fBx << endl;
#endif
      ++totncan;
#ifdef DUPLICATEVERBOSE
        map<ULong64_t, MyHeader*>::iterator it = eheaders.find(evtid);
        if ( (it->second->fRun==header->fRun) &&
             (it->second->fNTracks==header->fNTracks) &&
             (it->second->fNSelTracks==header->fNSelTracks) &&
             (it->second->fNTracklets==header->fNTracklets) &&
             (it->second->fVz==header->fVz)) {
          cout << "--> Duplicate found:" << endl;
          cout << " Run: " << it->second->fRun << " vs " << header->fRun << endl;
          cout << " Ntracks: " << it->second->fNTracks << " vs " << header->fNTracks << endl;
          cout << " Nseltracks: " << it->second->fNSelTracks << " vs " << header->fNSelTracks << endl;
          cout << " Ntracklets: " << it->second->fNTracklets << " vs " << header->fNTracklets << endl;
          cout << " Vz: " << it->second->fVz << " vs " << header->fVz << endl;
          ++totndup;
        }
#endif
        continue;
      }
#ifdef DUPLICATEVERBOSE
      MyHeader *cheader = new MyHeader(*header);
      eheaders.insert( pair<ULong64_t, MyHeader*>(evtid,cheader) );
#endif
#endif
      EvInfo *cinfo = new EvInfo;
      cinfo->fRun = header->fRun;
      cinfo->fArrId = i;
      cinfo->fEntry = ev;
      einfos.insert( pair<ULong64_t, EvInfo*>(evtid,cinfo) );
    }
    delete tree;
    file->Close();
    delete file;
    if ((nEvents>0) && (einfos.size()>=(UInt_t)nEvents))
      break;
  }
  cout << "Found total: " << totnent << endl;
  cout << "Found suspicious: " << totnsus << endl;
#ifdef DUPLICATECHECK
  cout << "Found potential duplicates: " << totncan << endl;
#ifdef DUPLICATEVERBOSE
  cout << "Found duplicates: " << totndup << endl;
#endif
#endif

  // sort output tree
  std::vector<TFile*> files(nfiles);
  std::vector<TTree*> trees(nfiles);
  std::vector<MyHeader*> headers(nfiles);
  std::vector<TClonesArray*> partas(nfiles);

  MyHeader *newHeader = new MyHeader;
  if (TClass::GetClass("MyPart"))
    TClass::GetClass("MyPart")->IgnoreTObjectStreamer();
  TClonesArray *newParts = new TClonesArray("MyPart",10000);

  TFile *newFile = TFile::Open(outFileName,"recreate","Merged/Sorted MyTree created by mergeCorr.C",5);
  TDirectory::TContext cd(newFile);
  TTree *newTree = new TTree("MyTree", "MyTree created by MyAliTask.cxx");
  newTree->Branch("header",&newHeader, 32*1024, 99);
  newTree->Branch("parts",&newParts, 256*1024, 99);
  Int_t newEntries = 0;
  for (map<ULong64_t, EvInfo*>::iterator it = einfos.begin();it!=einfos.end();++it) {
    Short_t id = it->second->fArrId;
    UInt_t entry = it->second->fEntry;
    if (!trees.at(id)) { // connect new tree
      TString fname(filenames->At(id)->GetTitle());
      TFile *file = TFile::Open(fname);
      TDirectory::TContext cd2(newFile,file);
      files[id] = file;
      TList *output = dynamic_cast<TList*>(file->Get("output"));
      TTree *tree = dynamic_cast<TTree*>(output->FindObject("MyTree"));
      trees[id] = tree;
      tree->SetBranchAddress("header",&headers[id]);
      tree->SetBranchAddress("parts",&partas[id]);
    }
    files[id]->cd();
    trees.at(id)->GetEntry(entry);
    *newHeader = *(headers[id]);
    newParts->Clear();
    Int_t nparts = partas[id]->GetEntries();
    for (Int_t p = 0; p < nparts; ++p) {
      MyPart *orig = dynamic_cast<MyPart*>(partas[id]->At(p));
      new((*newParts)[p]) MyPart(*orig);
    }
    newFile->cd();
    newTree->Fill();
    ++newEntries;
    delete it->second;
    if ((nEvents>0) && (newEntries>=nEvents))
      break;
  }

  newTree->Write();
  newFile->Close();
  delete newFile;

  for(Int_t i=0;i<nfiles;++i) {
    delete trees.at(i);
    delete files.at(i);
  }
}
<|endoftext|>


<commit_before>/******************************************************************************
 *                    _   _____   __________                                  *
 *                   | | / / _ | / __/_  __/     Visibility                   *
 *                   | |/ / __ |_\ \  / /          Across                     *
 *                   |___/_/ |_/___/ /_/       Space and Time                 *
 *                                                                            *
 * This file is part of VAST. It is subject to the license terms in the       *
 * LICENSE file found in the top-level directory of this distribution and at  *
 * http://vast.io/license. No part of VAST, including this file, may be       *
 * copied, modified, propagated, or distributed except according to the terms *
 * contained in the LICENSE file.                                             *
 ******************************************************************************/

#include <caf/actor_system.hpp>
#include <caf/io/middleman.hpp>
#include <caf/message_builder.hpp>

#include "vast/system/default_application.hpp"

using namespace vast;
using namespace vast::system;

namespace {

struct config : configuration {
  config() {
    // Consider only VAST's log messages by default.
    set("logger.component-filter", "vast");
    load<caf::io::middleman>();
    set("middleman.enable-automatic-connections", true);
#ifdef VAST_USE_OPENSSL
    load<caf::openssl::manager>();
#endif
  }
};

} // namespace <anonymous>

int main(int argc, char** argv) {
  // Scaffold
  config cfg;
  cfg.parse(argc, argv);
  cfg.set("logger.console", caf::atom("COLORED"));
  caf::actor_system sys{cfg};
  default_application app;
  // Dispatch to root command.
  auto result = app.run(sys, cfg.command_line.begin(), cfg.command_line.end());
  return result;
}
<commit_msg>Add missing include<commit_after>/******************************************************************************
 *                    _   _____   __________                                  *
 *                   | | / / _ | / __/_  __/     Visibility                   *
 *                   | |/ / __ |_\ \  / /          Across                     *
 *                   |___/_/ |_/___/ /_/       Space and Time                 *
 *                                                                            *
 * This file is part of VAST. It is subject to the license terms in the       *
 * LICENSE file found in the top-level directory of this distribution and at  *
 * http://vast.io/license. No part of VAST, including this file, may be       *
 * copied, modified, propagated, or distributed except according to the terms *
 * contained in the LICENSE file.                                             *
 ******************************************************************************/

#include <caf/actor_system.hpp>
#include <caf/io/middleman.hpp>
#include <caf/message_builder.hpp>

#include "vast/config.hpp"

#ifdef VAST_USE_OPENSSL
#include <caf/openssl/manager.hpp>
#endif

#include "vast/system/default_application.hpp"

using namespace vast;
using namespace vast::system;

namespace {

struct config : configuration {
  config() {
    // Consider only VAST's log messages by default.
    set("logger.component-filter", "vast");
    load<caf::io::middleman>();
    set("middleman.enable-automatic-connections", true);
#ifdef VAST_USE_OPENSSL
    load<caf::openssl::manager>();
#endif
  }
};

} // namespace <anonymous>

int main(int argc, char** argv) {
  // Scaffold
  config cfg;
  cfg.parse(argc, argv);
  cfg.set("logger.console", caf::atom("COLORED"));
  caf::actor_system sys{cfg};
  default_application app;
  // Dispatch to root command.
  auto result = app.run(sys, cfg.command_line.begin(), cfg.command_line.end());
  return result;
}
<|endoftext|>


<commit_before>#ifndef MAPNIK_WARNING_HPP
#define MAPNIK_WARNING_HPP

#if defined(_MSC_VER)
    #define MAPNIK_DISABLE_WARNING_PUSH           __pragma(warning( push ))
    #define MAPNIK_DISABLE_WARNING_POP            __pragma(warning( pop ))
    #define MAPNIK_DISABLE_WARNING(warningNumber) __pragma(warning( disable : warningNumber ))

    // add warnings to deactivate here
    // example: #define DISABLE_WARNING_UNREFERENCED_FORMAL_PARAMETER    DISABLE_WARNING(4100)
    #define MAPNIK_DISABLE_WARNING_UNKNOWN_PRAGMAS         MAPNIK_DISABLE_WARNING(4068)
    #define MAPNIK_DISABLE_WARNING_PRAGMAS                 //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_PRAGMA_MESSAGES         //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_UNSEQUENCED             //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_UNUSED_FUNCTION         //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_UNUSED_PARAMETER        //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_REDECLARED_CLASS_MEMBER //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_UNUSED_LOCAL_TYPEDEF    //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_UNUSED_LOCAL_TYPEDEFS   //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_SHADOW                  //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_CPP11_NARROWING         //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_SIGN_CONVERSION         //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_SIGN_COMPARE            //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_CONVERSION              //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_CPP_98_COMPAT_PEDANTIC  //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_DISABLE_MACRO_EXPANSION //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_OLD_STYLE_CAST          //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_DOCUMENTATION           //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_DOCUMENTATION_UNKNOWN_COMMAND //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_UNDEF                   //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_DEPRECATED              //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_PADDED                  //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_CPP_98_COMPAT           //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_RESERVED_ID_MACRO       //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_WEAK_VTABLE             //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_EXTRA_SEMI              //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_GLOBAL_CONSTRUCTORS     //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_HEADER_HYGIENE          //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_EXIT_TIME_DESTRUCTORS   //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_SWITCH_ENUM             //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_MISSING_NORETURN        //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_COVERED_SWITCH_DEFAULT  //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_FLOAT_EQUAL             //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_LONG_LONG                       //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_UNDEFINED_VAR_TEMPLATE          //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_UNUSED_VARIABLE                 MAPNIK_DISABLE_WARNING(C4101)
    #define MAPNIK_DISABLE_MISMATCHED_TAGS                 //MAPNIK_DISABLE_WARNING(??)

#elif defined(__GNUC__) || defined(__clang__)
    #define MAPNIK_DO_PRAGMA(X) _Pragma(#X)
    #define MAPNIK_DISABLE_WARNING_PUSH           MAPNIK_DO_PRAGMA(GCC diagnostic push)
    #define MAPNIK_DISABLE_WARNING_POP            MAPNIK_DO_PRAGMA(GCC diagnostic pop)
    #define MAPNIK_DISABLE_WARNING(warningName)   MAPNIK_DO_PRAGMA(GCC diagnostic ignored #warningName)
   // add warnings to deactivate here
   // example: #define DISABLE_WARNING_UNREFERENCED_FORMAL_PARAMETER    DISABLE_WARNING(-Wunused-parameter)
    #define MAPNIK_DISABLE_WARNING_UNKNOWN_PRAGMAS         MAPNIK_DISABLE_WARNING(-Wunknown-pragmas)
    #define MAPNIK_DISABLE_WARNING_PRAGMAS                 MAPNIK_DISABLE_WARNING(-Wpragmas)
    #define MAPNIK_DISABLE_WARNING_PRAGMA_MESSAGES         MAPNIK_DISABLE_WARNING(-W#pragma-messages)
    #define MAPNIK_DISABLE_WARNING_UNSEQUENCED             MAPNIK_DISABLE_WARNING(-Wunsequenced)
    #define MAPNIK_DISABLE_WARNING_UNUSED_FUNCTION         MAPNIK_DISABLE_WARNING(-Wunused-function)
    #define MAPNIK_DISABLE_WARNING_UNUSED_PARAMETER        MAPNIK_DISABLE_WARNING(-Wunused-parameter)
    #define MAPNIK_DISABLE_WARNING_REDECLARED_CLASS_MEMBER MAPNIK_DISABLE_WARNING(-Wredeclared-class-member)
    #define MAPNIK_DISABLE_WARNING_UNUSED_LOCAL_TYPEDEF    MAPNIK_DISABLE_WARNING(-Wunused-local-typedef)
    #define MAPNIK_DISABLE_WARNING_UNUSED_LOCAL_TYPEDEFS   MAPNIK_DISABLE_WARNING(-Wunused-local-typedefs)
    #define MAPNIK_DISABLE_WARNING_SHADOW                  MAPNIK_DISABLE_WARNING(-Wshadow)
    #define MAPNIK_DISABLE_WARNING_CPP11_NARROWING         MAPNIK_DISABLE_WARNING(-Wc++11-narrowing)
    #define MAPNIK_DISABLE_WARNING_SIGN_CONVERSION         MAPNIK_DISABLE_WARNING(-Wsign-conversion)
    #define MAPNIK_DISABLE_WARNING_SIGN_COMPARE            MAPNIK_DISABLE_WARNING(-Wsign-compare)
    #define MAPNIK_DISABLE_WARNING_CONVERSION              MAPNIK_DISABLE_WARNING(-Wconversion)
    #define MAPNIK_DISABLE_WARNING_CPP_98_COMPAT_PEDANTIC  MAPNIK_DISABLE_WARNING(-Wc++98-compat-pedantic)
    #define MAPNIK_DISABLE_WARNING_DISABLE_MACRO_EXPANSION MAPNIK_DISABLE_WARNING(-Wdisabled-macro-expansion)
    #define MAPNIK_DISABLE_WARNING_OLD_STYLE_CAST          MAPNIK_DISABLE_WARNING(-Wold-style-cast)
    #define MAPNIK_DISABLE_WARNING_DOCUMENTATION           MAPNIK_DISABLE_WARNING(-Wdocumentation)
    #define MAPNIK_DISABLE_WARNING_DOCUMENTATION_UNKNOWN_COMMAND MAPNIK_DISABLE_WARNING(-Wdocumentation-unknown-command)
    #define MAPNIK_DISABLE_WARNING_UNDEF                   MAPNIK_DISABLE_WARNING(-Wundef)
    #define MAPNIK_DISABLE_WARNING_DEPRECATED              MAPNIK_DISABLE_WARNING(-Wdeprecated)
    #define MAPNIK_DISABLE_WARNING_PADDED                  MAPNIK_DISABLE_WARNING(-Wpadded)
    #define MAPNIK_DISABLE_WARNING_CPP_98_COMPAT           MAPNIK_DISABLE_WARNING(-Wc++98-compat)
    #define MAPNIK_DISABLE_WARNING_RESERVED_ID_MACRO       MAPNIK_DISABLE_WARNING(-Wreserved-id-macro)
    #define MAPNIK_DISABLE_WARNING_WEAK_VTABLE             MAPNIK_DISABLE_WARNING(-Wweak-vtables)
    #define MAPNIK_DISABLE_WARNING_EXTRA_SEMI              MAPNIK_DISABLE_WARNING(-Wextra-semi)
    #define MAPNIK_DISABLE_WARNING_GLOBAL_CONSTRUCTORS     MAPNIK_DISABLE_WARNING(-Wglobal-constructors)
    #define MAPNIK_DISABLE_WARNING_HEADER_HYGIENE          MAPNIK_DISABLE_WARNING(-Wheader-hygiene)
    #define MAPNIK_DISABLE_WARNING_EXIT_TIME_DESTRUCTORS   MAPNIK_DISABLE_WARNING(-Wexit-time-destructors)
    #define MAPNIK_DISABLE_WARNING_SWITCH_ENUM             MAPNIK_DISABLE_WARNING(-Wswitch-enum)
    #define MAPNIK_DISABLE_WARNING_MISSING_NORETURN        MAPNIK_DISABLE_WARNING(-Wmissing-noreturn)
    #define MAPNIK_DISABLE_WARNING_COVERED_SWITCH_DEFAULT  MAPNIK_DISABLE_WARNING(-Wcovered-switch-default)
    #define MAPNIK_DISABLE_WARNING_FLOAT_EQUAL             MAPNIK_DISABLE_WARNING(-Wfloat-equal)
    #define MAPNIK_DISABLE_LONG_LONG                       MAPNIK_DISABLE_WARNING(-Wlong-long)
    #define MAPNIK_DISABLE_UNDEFINED_VAR_TEMPLATE          MAPNIK_DISABLE_WARNING(-Wundefined-var-template)
    #define MAPNIK_DISABLE_UNUSED_VARIABLE                 MAPNIK_DISABLE_WARNING(-Wunused-variable)
    #define MAPNIK_DISABLE_MISMATCHED_TAGS                 MAPNIK_DISABLE_WARNING(-Wmismatched-tags)
#else
    #define MAPNIK_MAPNIK_DISABLE_WARNING_PUSH
    #define MAPNIK_MAPNIK_DISABLE_WARNING_POP
    // add all of the above warnings here (will be used if unknown compiler)
    #define MAPNIK_DISABLE_WARNING_UNKNOWN_PRAGMAS
    #define MAPNIK_DISABLE_WARNING_PRAGMAS
    #define MAPNIK_DISABLE_WARNING_PRAGMA_MESSAGES
    #define MAPNIK_DISABLE_WARNING_UNSEQUENCED
    #define MAPNIK_DISABLE_WARNING_UNUSED_FUNCTION
    #define MAPNIK_DISABLE_WARNING_UNUSED_PARAMETER
    #define MAPNIK_DISABLE_WARNING_REDECLARED_CLASS_MEMBER
    #define MAPNIK_DISABLE_WARNING_UNUSED_LOCAL_TYPEDEF
    #define MAPNIK_DISABLE_WARNING_UNUSED_LOCAL_TYPEDEFS
    #define MAPNIK_DISABLE_WARNING_SHADOW
    #define MAPNIK_DISABLE_WARNING_CPP11_NARROWING
    #define MAPNIK_DISABLE_WARNING_SIGN_CONVERSION
    #define MAPNIK_DISABLE_WARNING_SIGN_COMPARE
    #define MAPNIK_DISABLE_WARNING_CONVERSION
    #define MAPNIK_DISABLE_WARNING_CPP_98_COMPAT_PEDANTIC
    #define MAPNIK_DISABLE_WARNING_DISABLE_MACRO_EXPANSION
    #define MAPNIK_DISABLE_WARNING_OLD_STYLE_CAST
    #define MAPNIK_DISABLE_WARNING_DOCUMENTATION
    #define MAPNIK_DISABLE_WARNING_DOCUMENTATION_UNKNOWN_COMMAND
    #define MAPNIK_DISABLE_WARNING_UNDEF
    #define MAPNIK_DISABLE_WARNING_DEPRECATED
    #define MAPNIK_DISABLE_WARNING_PADDED
    #define MAPNIK_DISABLE_WARNING_CPP_98_COMPAT
    #define MAPNIK_DISABLE_WARNING_RESERVED_ID_MACRO
    #define MAPNIK_DISABLE_WARNING_WEAK_VTABLE
    #define MAPNIK_DISABLE_WARNING_EXTRA_SEMI
    #define MAPNIK_DISABLE_WARNING_GLOBAL_CONSTRUCTORS
    #define MAPNIK_DISABLE_WARNING_HEADER_HYGIENE
    #define MAPNIK_DISABLE_WARNING_EXIT_TIME_DESTRUCTORS
    #define MAPNIK_DISABLE_WARNING_SWITCH_ENUM
    #define MAPNIK_DISABLE_WARNING_MISSING_NORETURN
    #define MAPNIK_DISABLE_WARNING_COVERED_SWITCH_DEFAULT
    #define MAPNIK_DISABLE_WARNING_FLOAT_EQUAL
    #define MAPNIK_DISABLE_LONG_LONG
    #define MAPNIK_DISABLE_UNDEFINED_VAR_TEMPLATE
    #define MAPNIK_DISABLE_UNUSED_VARIABLE
    #define MAPNIK_DISABLE_MISMATCHED_TAGS
#endif
#endif<commit_msg>more msvc warnings<commit_after>#ifndef MAPNIK_WARNING_HPP
#define MAPNIK_WARNING_HPP

#if defined(_MSC_VER)
    #define MAPNIK_DISABLE_WARNING_PUSH           __pragma(warning( push ))
    #define MAPNIK_DISABLE_WARNING_POP            __pragma(warning( pop ))
    #define MAPNIK_DISABLE_WARNING(warningNumber) __pragma(warning( disable : warningNumber ))

    // add warnings to deactivate here
    // example: #define DISABLE_WARNING_UNREFERENCED_FORMAL_PARAMETER    DISABLE_WARNING(4100)
    #define MAPNIK_DISABLE_WARNING_UNKNOWN_PRAGMAS         MAPNIK_DISABLE_WARNING(4068)
    #define MAPNIK_DISABLE_WARNING_PRAGMAS                 //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_PRAGMA_MESSAGES         //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_UNSEQUENCED             //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_UNUSED_FUNCTION         //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_UNUSED_PARAMETER        //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_REDECLARED_CLASS_MEMBER //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_UNUSED_LOCAL_TYPEDEF    //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_UNUSED_LOCAL_TYPEDEFS   //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_SHADOW                  //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_CPP11_NARROWING         //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_SIGN_CONVERSION         //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_SIGN_COMPARE            //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_CONVERSION              MAPNIK_DISABLE_WARNING(4244)
    #define MAPNIK_DISABLE_WARNING_CPP_98_COMPAT_PEDANTIC  //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_DISABLE_MACRO_EXPANSION //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_OLD_STYLE_CAST          //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_DOCUMENTATION           //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_DOCUMENTATION_UNKNOWN_COMMAND //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_UNDEF                   //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_DEPRECATED              MAPNIK_DISABLE_WARNING(4996)
    #define MAPNIK_DISABLE_WARNING_PADDED                  //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_CPP_98_COMPAT           //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_RESERVED_ID_MACRO       //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_WEAK_VTABLE             //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_EXTRA_SEMI              //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_GLOBAL_CONSTRUCTORS     //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_HEADER_HYGIENE          //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_EXIT_TIME_DESTRUCTORS   //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_SWITCH_ENUM             //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_MISSING_NORETURN        //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_COVERED_SWITCH_DEFAULT  //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_WARNING_FLOAT_EQUAL             //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_LONG_LONG                       //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_UNDEFINED_VAR_TEMPLATE          //MAPNIK_DISABLE_WARNING(??)
    #define MAPNIK_DISABLE_UNUSED_VARIABLE                 MAPNIK_DISABLE_WARNING(4101)
    #define MAPNIK_DISABLE_MISMATCHED_TAGS                 //MAPNIK_DISABLE_WARNING(??)

#elif defined(__GNUC__) || defined(__clang__)
    #define MAPNIK_DO_PRAGMA(X) _Pragma(#X)
    #define MAPNIK_DISABLE_WARNING_PUSH           MAPNIK_DO_PRAGMA(GCC diagnostic push)
    #define MAPNIK_DISABLE_WARNING_POP            MAPNIK_DO_PRAGMA(GCC diagnostic pop)
    #define MAPNIK_DISABLE_WARNING(warningName)   MAPNIK_DO_PRAGMA(GCC diagnostic ignored #warningName)
   // add warnings to deactivate here
   // example: #define DISABLE_WARNING_UNREFERENCED_FORMAL_PARAMETER    DISABLE_WARNING(-Wunused-parameter)
    #define MAPNIK_DISABLE_WARNING_UNKNOWN_PRAGMAS         MAPNIK_DISABLE_WARNING(-Wunknown-pragmas)
    #define MAPNIK_DISABLE_WARNING_PRAGMAS                 MAPNIK_DISABLE_WARNING(-Wpragmas)
    #define MAPNIK_DISABLE_WARNING_PRAGMA_MESSAGES         MAPNIK_DISABLE_WARNING(-W#pragma-messages)
    #define MAPNIK_DISABLE_WARNING_UNSEQUENCED             MAPNIK_DISABLE_WARNING(-Wunsequenced)
    #define MAPNIK_DISABLE_WARNING_UNUSED_FUNCTION         MAPNIK_DISABLE_WARNING(-Wunused-function)
    #define MAPNIK_DISABLE_WARNING_UNUSED_PARAMETER        MAPNIK_DISABLE_WARNING(-Wunused-parameter)
    #define MAPNIK_DISABLE_WARNING_REDECLARED_CLASS_MEMBER MAPNIK_DISABLE_WARNING(-Wredeclared-class-member)
    #define MAPNIK_DISABLE_WARNING_UNUSED_LOCAL_TYPEDEF    MAPNIK_DISABLE_WARNING(-Wunused-local-typedef)
    #define MAPNIK_DISABLE_WARNING_UNUSED_LOCAL_TYPEDEFS   MAPNIK_DISABLE_WARNING(-Wunused-local-typedefs)
    #define MAPNIK_DISABLE_WARNING_SHADOW                  MAPNIK_DISABLE_WARNING(-Wshadow)
    #define MAPNIK_DISABLE_WARNING_CPP11_NARROWING         MAPNIK_DISABLE_WARNING(-Wc++11-narrowing)
    #define MAPNIK_DISABLE_WARNING_SIGN_CONVERSION         MAPNIK_DISABLE_WARNING(-Wsign-conversion)
    #define MAPNIK_DISABLE_WARNING_SIGN_COMPARE            MAPNIK_DISABLE_WARNING(-Wsign-compare)
    #define MAPNIK_DISABLE_WARNING_CONVERSION              MAPNIK_DISABLE_WARNING(-Wconversion)
    #define MAPNIK_DISABLE_WARNING_CPP_98_COMPAT_PEDANTIC  MAPNIK_DISABLE_WARNING(-Wc++98-compat-pedantic)
    #define MAPNIK_DISABLE_WARNING_DISABLE_MACRO_EXPANSION MAPNIK_DISABLE_WARNING(-Wdisabled-macro-expansion)
    #define MAPNIK_DISABLE_WARNING_OLD_STYLE_CAST          MAPNIK_DISABLE_WARNING(-Wold-style-cast)
    #define MAPNIK_DISABLE_WARNING_DOCUMENTATION           MAPNIK_DISABLE_WARNING(-Wdocumentation)
    #define MAPNIK_DISABLE_WARNING_DOCUMENTATION_UNKNOWN_COMMAND MAPNIK_DISABLE_WARNING(-Wdocumentation-unknown-command)
    #define MAPNIK_DISABLE_WARNING_UNDEF                   MAPNIK_DISABLE_WARNING(-Wundef)
    #define MAPNIK_DISABLE_WARNING_DEPRECATED              MAPNIK_DISABLE_WARNING(-Wdeprecated)
    #define MAPNIK_DISABLE_WARNING_PADDED                  MAPNIK_DISABLE_WARNING(-Wpadded)
    #define MAPNIK_DISABLE_WARNING_CPP_98_COMPAT           MAPNIK_DISABLE_WARNING(-Wc++98-compat)
    #define MAPNIK_DISABLE_WARNING_RESERVED_ID_MACRO       MAPNIK_DISABLE_WARNING(-Wreserved-id-macro)
    #define MAPNIK_DISABLE_WARNING_WEAK_VTABLE             MAPNIK_DISABLE_WARNING(-Wweak-vtables)
    #define MAPNIK_DISABLE_WARNING_EXTRA_SEMI              MAPNIK_DISABLE_WARNING(-Wextra-semi)
    #define MAPNIK_DISABLE_WARNING_GLOBAL_CONSTRUCTORS     MAPNIK_DISABLE_WARNING(-Wglobal-constructors)
    #define MAPNIK_DISABLE_WARNING_HEADER_HYGIENE          MAPNIK_DISABLE_WARNING(-Wheader-hygiene)
    #define MAPNIK_DISABLE_WARNING_EXIT_TIME_DESTRUCTORS   MAPNIK_DISABLE_WARNING(-Wexit-time-destructors)
    #define MAPNIK_DISABLE_WARNING_SWITCH_ENUM             MAPNIK_DISABLE_WARNING(-Wswitch-enum)
    #define MAPNIK_DISABLE_WARNING_MISSING_NORETURN        MAPNIK_DISABLE_WARNING(-Wmissing-noreturn)
    #define MAPNIK_DISABLE_WARNING_COVERED_SWITCH_DEFAULT  MAPNIK_DISABLE_WARNING(-Wcovered-switch-default)
    #define MAPNIK_DISABLE_WARNING_FLOAT_EQUAL             MAPNIK_DISABLE_WARNING(-Wfloat-equal)
    #define MAPNIK_DISABLE_LONG_LONG                       MAPNIK_DISABLE_WARNING(-Wlong-long)
    #define MAPNIK_DISABLE_UNDEFINED_VAR_TEMPLATE          MAPNIK_DISABLE_WARNING(-Wundefined-var-template)
    #define MAPNIK_DISABLE_UNUSED_VARIABLE                 MAPNIK_DISABLE_WARNING(-Wunused-variable)
    #define MAPNIK_DISABLE_MISMATCHED_TAGS                 MAPNIK_DISABLE_WARNING(-Wmismatched-tags)
#else
    #define MAPNIK_MAPNIK_DISABLE_WARNING_PUSH
    #define MAPNIK_MAPNIK_DISABLE_WARNING_POP
    // add all of the above warnings here (will be used if unknown compiler)
    #define MAPNIK_DISABLE_WARNING_UNKNOWN_PRAGMAS
    #define MAPNIK_DISABLE_WARNING_PRAGMAS
    #define MAPNIK_DISABLE_WARNING_PRAGMA_MESSAGES
    #define MAPNIK_DISABLE_WARNING_UNSEQUENCED
    #define MAPNIK_DISABLE_WARNING_UNUSED_FUNCTION
    #define MAPNIK_DISABLE_WARNING_UNUSED_PARAMETER
    #define MAPNIK_DISABLE_WARNING_REDECLARED_CLASS_MEMBER
    #define MAPNIK_DISABLE_WARNING_UNUSED_LOCAL_TYPEDEF
    #define MAPNIK_DISABLE_WARNING_UNUSED_LOCAL_TYPEDEFS
    #define MAPNIK_DISABLE_WARNING_SHADOW
    #define MAPNIK_DISABLE_WARNING_CPP11_NARROWING
    #define MAPNIK_DISABLE_WARNING_SIGN_CONVERSION
    #define MAPNIK_DISABLE_WARNING_SIGN_COMPARE
    #define MAPNIK_DISABLE_WARNING_CONVERSION
    #define MAPNIK_DISABLE_WARNING_CPP_98_COMPAT_PEDANTIC
    #define MAPNIK_DISABLE_WARNING_DISABLE_MACRO_EXPANSION
    #define MAPNIK_DISABLE_WARNING_OLD_STYLE_CAST
    #define MAPNIK_DISABLE_WARNING_DOCUMENTATION
    #define MAPNIK_DISABLE_WARNING_DOCUMENTATION_UNKNOWN_COMMAND
    #define MAPNIK_DISABLE_WARNING_UNDEF
    #define MAPNIK_DISABLE_WARNING_DEPRECATED
    #define MAPNIK_DISABLE_WARNING_PADDED
    #define MAPNIK_DISABLE_WARNING_CPP_98_COMPAT
    #define MAPNIK_DISABLE_WARNING_RESERVED_ID_MACRO
    #define MAPNIK_DISABLE_WARNING_WEAK_VTABLE
    #define MAPNIK_DISABLE_WARNING_EXTRA_SEMI
    #define MAPNIK_DISABLE_WARNING_GLOBAL_CONSTRUCTORS
    #define MAPNIK_DISABLE_WARNING_HEADER_HYGIENE
    #define MAPNIK_DISABLE_WARNING_EXIT_TIME_DESTRUCTORS
    #define MAPNIK_DISABLE_WARNING_SWITCH_ENUM
    #define MAPNIK_DISABLE_WARNING_MISSING_NORETURN
    #define MAPNIK_DISABLE_WARNING_COVERED_SWITCH_DEFAULT
    #define MAPNIK_DISABLE_WARNING_FLOAT_EQUAL
    #define MAPNIK_DISABLE_LONG_LONG
    #define MAPNIK_DISABLE_UNDEFINED_VAR_TEMPLATE
    #define MAPNIK_DISABLE_UNUSED_VARIABLE
    #define MAPNIK_DISABLE_MISMATCHED_TAGS
#endif
#endif<|endoftext|>


<commit_before>/*M///////////////////////////////////////////////////////////////////////////////////////
//
//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
//  By downloading, copying, installing or using the software you agree to this license.
//  If you do not agree to this license, do not download, install,
//  copy or use the software.
//
//
//                           License Agreement
//                For Open Source Computer Vision Library
//
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2009-2010, Willow Garage Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
//   * Redistribution's of source code must retain the above copyright notice,
//     this list of conditions and the following disclaimer.
//
//   * Redistribution's 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.
//
//   * The name of the copyright holders may not 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 Intel Corporation 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.
//
//M*/

#ifndef __OPENCV_ALL_HPP__
#define __OPENCV_ALL_HPP__

#include "opencv2/core/core_c.h"
#include "opencv2/core/core.hpp"
#include "opencv2/core/wimage.hpp"
#include "opencv2/imgproc/imgproc_c.h"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/video/tracking.hpp"
#include "opencv2/video/blobtrack.hpp"
#include "opencv2/video/background_segm.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/objdetect/objdetect.hpp"
#include "opencv2/calib3d/calib3d.hpp"
#include "opencv2/ml/ml.hpp"
#include "opencv2/highgui/highgui_c.h"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/legacy/legacy.hpp"
#include "opencv2/contrib/contrib.hpp"

#endif
<commit_msg>added flann<commit_after>/*M///////////////////////////////////////////////////////////////////////////////////////
//
//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
//  By downloading, copying, installing or using the software you agree to this license.
//  If you do not agree to this license, do not download, install,
//  copy or use the software.
//
//
//                           License Agreement
//                For Open Source Computer Vision Library
//
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2009-2010, Willow Garage Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
//   * Redistribution's of source code must retain the above copyright notice,
//     this list of conditions and the following disclaimer.
//
//   * Redistribution's 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.
//
//   * The name of the copyright holders may not 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 Intel Corporation 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.
//
//M*/

#ifndef __OPENCV_ALL_HPP__
#define __OPENCV_ALL_HPP__

#include "opencv2/core/core_c.h"
#include "opencv2/core/core.hpp"
#include "opencv2/core/wimage.hpp"
#include "opencv2/flann/flann.hpp"
#include "opencv2/imgproc/imgproc_c.h"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/video/tracking.hpp"
#include "opencv2/video/blobtrack.hpp"
#include "opencv2/video/background_segm.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/objdetect/objdetect.hpp"
#include "opencv2/calib3d/calib3d.hpp"
#include "opencv2/ml/ml.hpp"
#include "opencv2/highgui/highgui_c.h"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/legacy/legacy.hpp"
#include "opencv2/contrib/contrib.hpp"

#endif
<|endoftext|>