1 |
// $Id: runFileCataloger.C,v 1.5 2012/02/28 11:54:37 paus Exp $
|
2 |
|
3 |
#if !defined(__CINT__) || defined(__MAKECINT__)
|
4 |
#include <TROOT.h>
|
5 |
#include <TSystem.h>
|
6 |
#include "MitAna/DataUtil/interface/Debug.h"
|
7 |
#include "MitAna/Catalog/interface/Catalog.h"
|
8 |
#include "MitAna/Catalog/interface/Dataset.h"
|
9 |
#include "MitAna/TreeMod/interface/HLTMod.h"
|
10 |
#include "MitAna/TreeMod/interface/CatalogingMod.h"
|
11 |
#include "MitAna/TreeMod/interface/Analysis.h"
|
12 |
#endif
|
13 |
|
14 |
using namespace mithep;
|
15 |
const TString slash = "/";
|
16 |
const TString hadoopDoor = "root://xrootd.cmsaf.mit.edu/";
|
17 |
|
18 |
void catalogFile(const char *dir, const char *file);
|
19 |
void reset();
|
20 |
|
21 |
Analysis *gAna(0);
|
22 |
HLTMod *hMod(0);
|
23 |
CatalogingMod *gMod(0);
|
24 |
|
25 |
//--------------------------------------------------------------------------------------------------
|
26 |
void runFileCataloger(const char *dir = "/castor/cern.ch/user/p/paus/filler/004/s8-qcddj_15_20-id9",
|
27 |
const char *file = "s8-qcddj_15_20-id9_000_1.root")
|
28 |
{
|
29 |
// -----------------------------------------------------------------------------------------------
|
30 |
// This script runs a full cataloging action on the given directory
|
31 |
// -----------------------------------------------------------------------------------------------
|
32 |
gDebugMask = Debug::kNone;
|
33 |
gDebugLevel = 0;
|
34 |
gErrorIgnoreLevel = kWarning;
|
35 |
|
36 |
reset();
|
37 |
catalogFile(dir,file);
|
38 |
return;
|
39 |
}
|
40 |
|
41 |
//--------------------------------------------------------------------------------------------------
|
42 |
void catalogFile(const char *dir, const char *file)
|
43 |
{
|
44 |
// set up the modules
|
45 |
gMod->SetMetaDataString((TString(dir)+slash+TString(file)).Data());
|
46 |
gMod->SetNFileSet (0);
|
47 |
|
48 |
// set up analysis
|
49 |
hMod->Add(gMod);
|
50 |
gAna->SetSuperModule(hMod);
|
51 |
|
52 |
TString fileName = TString(dir) + slash + + TString(file);
|
53 |
//printf("Index: %d\n",fileName.Index("castor/cern.ch"));
|
54 |
if (fileName.Index("castor/cern.ch") != -1)
|
55 |
fileName = TString("castor:") + fileName;
|
56 |
if (fileName.Index("mnt/hadoop/cms/store") != -1) {
|
57 |
fileName.Remove(0,15);
|
58 |
fileName = hadoopDoor + fileName;
|
59 |
gMod->SetMetaDataString(fileName.Data());
|
60 |
}
|
61 |
|
62 |
printf(" Adding: %s\n",fileName.Data());
|
63 |
gAna->AddFile(fileName);
|
64 |
gAna->SetUseHLT(1);
|
65 |
|
66 |
// run the analysis after successful initialisation
|
67 |
gAna->Run(false);
|
68 |
}
|
69 |
|
70 |
//--------------------------------------------------------------------------------------------------
|
71 |
void reset()
|
72 |
{
|
73 |
// reset pointers
|
74 |
if (gAna)
|
75 |
delete gAna;
|
76 |
gAna = new Analysis();
|
77 |
|
78 |
if (hMod)
|
79 |
delete hMod;
|
80 |
hMod = new HLTMod();
|
81 |
//hMod->SetPrintTable(kTRUE);
|
82 |
|
83 |
if (gMod)
|
84 |
delete gMod;
|
85 |
gMod = new CatalogingMod();
|
86 |
}
|