]>
Commit | Line | Data |
---|---|---|
fa6e7866 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | /* $Id$ */ | |
17 | ||
18 | // A. De Falco, H. Woehri, INFN Cagliari, July 2006 | |
19 | // This macro merges several files built with DecodeRecoCocktail.C into | |
20 | // a single one. | |
21 | // Arguments: foutname = name of the output file | |
22 | // flistname = name of a text file containing the list of files | |
23 | // to be merged | |
24 | void MergeMuonLight(char *foutname="MuonLightMerged.root",char *flistname="lista.lis"){ | |
25 | // up to 2000 input files | |
26 | ||
27 | TFile *file[2000]; | |
28 | TClonesArray *muonArray = new TClonesArray("AliMUONTrackLight",2); | |
29 | TClonesArray *dimuonArray = new TClonesArray("AliMUONPairLight",1); | |
30 | ||
31 | // open output file | |
32 | TFile *fout = new TFile (foutname,"recreate"); | |
33 | TTree *treeOut = new TTree("tree","tree"); | |
34 | treeOut->Branch("muons",&muonArray); | |
35 | treeOut->Branch("dimuons",&dimuonArray); | |
36 | ||
37 | char *filename = new char[100]; | |
38 | // read the list of input files | |
39 | FILE *pf= fopen(flistname,"r"); | |
40 | Int_t nfiles=0; | |
41 | Int_t outflag=0; | |
42 | // open the n input files | |
43 | while (!outflag) { | |
44 | if (fscanf(pf,"%s",filename)==1) { | |
45 | file[nfiles++] = new TFile (filename); | |
46 | cout << "Opening for input " << filename << endl; | |
47 | } | |
48 | else outflag = 1; | |
49 | } | |
50 | fclose(pf); | |
51 | ||
52 | ||
53 | for (Int_t ifile=0; ifile<nfiles; ifile++) { | |
54 | printf ("Scanning file %d: %s\n",ifile, file[ifile]->GetName()); | |
55 | TTree *tree = (TTree*) file[ifile]->Get("tree"); | |
56 | tree->SetBranchAddress("muons",&muonArray); | |
57 | tree->SetBranchAddress("dimuons",&dimuonArray); | |
58 | Int_t nev = tree->GetEntriesFast(); | |
59 | printf ("Scanning file %d: %s containing %d events\n", | |
60 | ifile, file[ifile]->GetName(),nev); | |
61 | for (Int_t iev=0; iev<nev; iev++) { | |
62 | tree->GetEvent(iev); | |
63 | treeOut->Fill(); | |
64 | } | |
65 | } | |
66 | fout->cd(); | |
67 | treeOut->Write(); | |
68 | } |