]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
macro for merging run files to fill files
authorhqvigsta <hqvigsta@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 1 Oct 2012 14:02:08 +0000 (14:02 +0000)
committerhqvigsta <hqvigsta@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 1 Oct 2012 14:02:08 +0000 (14:02 +0000)
PWGGA/PHOSTasks/PHOS_PbPb/macros/QA/FillMerge.C [new file with mode: 0644]
PWGGA/PHOSTasks/PHOS_PbPb/macros/QA/run_fill.txt [new file with mode: 0644]

diff --git a/PWGGA/PHOSTasks/PHOS_PbPb/macros/QA/FillMerge.C b/PWGGA/PHOSTasks/PHOS_PbPb/macros/QA/FillMerge.C
new file mode 100644 (file)
index 0000000..8ea890e
--- /dev/null
@@ -0,0 +1,90 @@
+#include "TFileMerger.h"
+#include "TSystem.h"
+
+#include <map>
+#include <iostream>
+#include <fstream>
+#include <string>
+
+std::map<int, int> runToFill; // maps: run -> fill
+std::map<int, TFileMerger*> fillToMerger;
+
+void makeFillMap()
+{
+}
+
+void FillMerge(const TString filelist="filelist.txt",
+              const TString runlist="runlist.txt",
+              const TString runFillFile = "run_fill.txt")
+{
+  // Use to merge run files to fill files
+  // For some reason, it does not work without compiling:
+  // .L FillMerge.C+g
+  // FillMerge()
+  //
+  // run_fill.txt must be a two column txt file, 
+  // column 1 being run and column 2 being fill.
+
+  //TGrid::Connect("alien://");
+  
+
+  // Make runToFill map
+  std::ifstream rfin;
+  rfin.open(runFillFile.Data());
+  
+  while (1) {
+    int run=0, fill=0;
+    rfin >> run >> fill;
+    if (!rfin.good()) break;
+    runToFill[run] = fill;
+  }
+
+
+  // Make FillMergers and add run files to them.
+  std::ifstream in;
+  in.open(filelist.Data());
+  std::ifstream inRuns;
+  inRuns.open(runlist.Data());
+  char rootFileName[256];
+  Int_t runNumber=0;
+  while (1) {
+    in >> rootFileName;
+    if (!in.good()) break;
+    inRuns >> runNumber;
+    if (!inRuns.good()) break;
+    
+    if(169094 == runNumber ) 
+      continue;
+
+    if( ! runToFill.count(runNumber) ) {
+      Printf("can't map run %d to fill, not in file %s", runNumber, runFillFile.Data());
+      continue;
+    }
+    
+    int fill = runToFill[runNumber];
+    
+    if( ! fillToMerger.count( fill ) ) { // if no merger for fill
+      fillToMerger[fill] = new TFileMerger(); // create merger
+      gSystem->mkdir("fillMerge");
+      fillToMerger[fill]->OutputFile(Form("fillMerge/%d.root", fill));
+    }
+    
+    fillToMerger[fill]->AddFile(rootFileName);
+  }
+
+  std::ofstream fls("fillList.txt");
+  std::ofstream ffls("fillFileList.txt");
+
+  
+  // Merge:
+  std::map<int, TFileMerger*>::iterator it;
+  for( it = fillToMerger.begin(); it != fillToMerger.end(); ++it ) {
+    TFileMerger* fm = (*it).second;
+    Printf("merging %s", fm->GetOutputFileName());
+    fm->Merge();
+    fls << (*it).first << std::endl;
+    ffls << fm->GetOutputFileName() << std::endl;
+    delete fm;
+  }
+
+}
diff --git a/PWGGA/PHOSTasks/PHOS_PbPb/macros/QA/run_fill.txt b/PWGGA/PHOSTasks/PHOS_PbPb/macros/QA/run_fill.txt
new file mode 100644 (file)
index 0000000..6510012
--- /dev/null
@@ -0,0 +1,257 @@
+170593 2351
+170592 2351
+170572 2350
+170556 2349
+170554 2349
+170552 2349
+170546 2349
+170545 2349
+170390 2344
+170389 2344
+170388 2344
+170387 2344
+170315 2343
+170313 2343
+170312 2343
+170311 2343
+170309 2343
+170308 2343
+170306 2343
+170270 2342
+170269 2342
+170268 2342
+170267 2342
+170264 2342
+170262 2342
+170230 2341
+170228 2341
+170226 2341
+170225 2341
+170208 2340
+170207 2340
+170206 2340
+170205 2340
+170204 2340
+170203 2340
+170199 2340
+170196 2340
+170195 2340
+170193 2340
+170163 2339
+170162 2339
+170161 2339
+170159 2339
+170155 2339
+170154 2339
+170152 2339
+170091 2338
+170090 2338
+170089 2338
+170088 2338
+170087 2338
+170086 2338
+170085 2338
+170084 2338
+170083 2338
+170081 2338
+170040 2337
+170038 2337
+170036 2337
+170027 2337
+170026 2337
+169981 2336
+169979 2336
+169978 2336
+169977 2336
+169976 2336
+169975 2336
+169969 2336
+169965 2336
+169961 2336
+169960 2336
+169959 2336
+169958 2336
+169957 2336
+169956 2336
+169954 2336
+169926 2335
+169924 2335
+169923 2335
+169922 2335
+169920 2335
+169919 2335
+169918 2335
+169914 2335
+169911 2335
+169859 2334
+169858 2334
+169855 2334
+169846 2334
+169838 2334
+169837 2334
+169835 2334
+169683 2332
+169681 2332
+169591 2330
+169590 2330
+169589 2330
+169588 2330
+169587 2330
+169586 2330
+169584 2330
+169557 2329
+169555 2329
+169554 2329
+169553 2329
+169550 2329
+169549 2329
+169515 2328
+169512 2328
+169506 2328
+169504 2328
+169498 2328
+169477 2327
+169475 2327
+169420 2325
+169419 2325
+169418 2325
+169417 2325
+169415 2325
+169411 2325
+169238 2320
+169236 2320
+169167 2319
+169160 2319
+169159 2319
+169156 2319
+169148 2319
+169145 2319
+169144 2319
+169143 2319
+169138 2319
+169099 2318
+169097 2318
+169096 2318
+169094 2318
+169091 2318
+169045 2317
+169044 2317
+169040 2317
+169035 2317
+168992 2316
+168991 2316
+168989 2316
+168988 2316
+168984 2316
+168834 2315
+168833 2315
+168832 2315
+168831 2315
+168828 2315
+168826 2315
+168777 2314
+168514 2309
+168512 2309
+168511 2309
+168509 2309
+168467 2308
+168466 2308
+168464 2308
+168463 2308
+168462 2308
+168461 2308
+168460 2308
+168458 2308
+168362 2305
+168361 2305
+168360 2305
+168359 2305
+168358 2305
+168356 2305
+168354 2305
+168352 2305
+168342 2305
+168341 2305
+168325 2304
+168322 2304
+168321 2304
+168318 2304
+168315 2304
+168314 2304
+168313 2304
+168312 2304
+168311 2304
+168310 2304
+168213 2303
+168212 2303
+168208 2303
+168207 2303
+168206 2303
+168205 2303
+168204 2303
+168203 2303
+168202 2303
+168201 2303
+168181 2302
+168179 2302
+168177 2302
+168176 2302
+168175 2302
+168174 2302
+168173 2302
+168172 2302
+168171 2302
+168115 2301
+168108 2301
+168107 2301
+168106 2301
+168105 2301
+168104 2301
+168103 2301
+168102 2301
+168101 2301
+168076 2300
+168071 2300
+168069 2300
+168068 2300
+168066 2300
+168065 2300
+168064 2300
+168062 2300
+168059 2300
+168058 2300
+168057 2300
+167988 2297
+167987 2297
+167986 2297
+167985 2297
+167983 2297
+167982 2297
+167981 2297
+167980 2297
+167979 2297
+167921 2294
+167920 2294
+167915 2294
+167914 2294
+167909 2294
+167903 2294
+167902 2294
+167901 2294
+167818 2292
+167814 2292
+167813 2292
+167812 2292
+167811 2292
+167810 2292
+167809 2292
+167808 2292
+167807 2292
+167806 2292
+167713 2290
+167712 2290
+167711 2290
+167706 2290
+167703 2290
+167699 2290
+167693 2290