]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/MergeMuonLight.C
adding eta:phi tracks and clusters histograms
[u/mrichter/AliRoot.git] / MUON / MergeMuonLight.C
CommitLineData
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
e54bf126 18/// \ingroup macros
19/// \file MergeMuonLight.C
20/// \brief This macro merges several files built with DecodeRecoCocktail.C into
21/// a single one
22///
23/// \author A. De Falco, H. Woehri, INFN Cagliari, July 2006
3c226639 24
25#if !defined(__CINT__) || defined(__MAKECINT__)
26#include "TFile.h"
27#include "TTree.h"
28#include "TClonesArray.h"
29#include "AliMUONTrackLight.h"
30#include "AliMUONPairLight.h"
31#endif
32
33
e54bf126 34void MergeMuonLight(char *foutname="MuonLightMerged.root",char *flistname="lista.lis", Bool_t saveAll = kTRUE)
35{
36/// \param foutname name of the output file
37/// \param flistname name of a text file containing the list of files
38/// to be merged
39/// \param saveAll boolian that allows/forbids saving of events with no muons
40
fa6e7866 41 // up to 2000 input files
42
43 TFile *file[2000];
44 TClonesArray *muonArray = new TClonesArray("AliMUONTrackLight",2);
45 TClonesArray *dimuonArray = new TClonesArray("AliMUONPairLight",1);
46
47 // open output file
48 TFile *fout = new TFile (foutname,"recreate");
49 TTree *treeOut = new TTree("tree","tree");
50 treeOut->Branch("muons",&muonArray);
51 treeOut->Branch("dimuons",&dimuonArray);
52
53 char *filename = new char[100];
54 // read the list of input files
55 FILE *pf= fopen(flistname,"r");
56 Int_t nfiles=0;
57 Int_t outflag=0;
58 // open the n input files
59 while (!outflag) {
60 if (fscanf(pf,"%s",filename)==1) {
61 file[nfiles++] = new TFile (filename);
3c226639 62 printf("Opening for input %s", filename);
fa6e7866 63 }
64 else outflag = 1;
65 }
66 fclose(pf);
67
68
69 for (Int_t ifile=0; ifile<nfiles; ifile++) {
70 printf ("Scanning file %d: %s\n",ifile, file[ifile]->GetName());
71 TTree *tree = (TTree*) file[ifile]->Get("tree");
72 tree->SetBranchAddress("muons",&muonArray);
73 tree->SetBranchAddress("dimuons",&dimuonArray);
74 Int_t nev = tree->GetEntriesFast();
75 printf ("Scanning file %d: %s containing %d events\n",
76 ifile, file[ifile]->GetName(),nev);
77 for (Int_t iev=0; iev<nev; iev++) {
78 tree->GetEvent(iev);
4d309390 79 Int_t nMu = muonArray->GetEntriesFast();
80 if(!saveAll)
81 if(nMu < 1) continue;
fa6e7866 82 treeOut->Fill();
83 }
4d309390 84 file[ifile]->Close();
85 }//end of scanning incoming file
fa6e7866 86 fout->cd();
87 treeOut->Write();
88}