StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ezMuDstMc.C
1 //
3 // ezMuDstMc.C
4 //
5 // Author: Jason C. Webb <jwebb@iucf.indiana.edu>
6 //
7 // Example macro for running the StMuEEmcSimuReMaker.
8 //
9 // 1. Checkout and compile the code needed to run this example:
10 //
11 // $ cvs co StRoot/StEEmcSimulatorMaker
12 // $ cvs co StRoot/StEEmcPool/StMuEEmcClusterMaker
13 // $ cons
14 //
15 // (produces 1 warning on EEezCluster)
16 //
17 // 2. Run the code
18 //
19 // $ root4star -q -b ezMuDstMc.C
20 //
21 // 3. Output will be in a file named according to the input file,
22 // MuDst replaced with hist.
23 
24 class StChain;
25 class StEEmcDb;
26 class StMuEmcCollection;
27 class St_db_Maker;
28 
29 StChain *chain=0;
30 StEEmcDb *eemcDb=0;
31 St_db_Maker *starDb=0;
32 
33 // eemc5090009.lis
34 
35 void ezMuDstMc( Int_t nevents = 10,
36  Char_t *file = "mcgamma_5000_06TC05_10.MuDst.root",
37  Int_t nfiles = 1,
38  Char_t *inDir = "/star/data04/sim/jwebb/MonteCarlo/single_gamma/" ) {
39 
40 
41  //-- Load in shared libraries
42  gROOT -> LoadMacro("StRoot/StEEmcPool/StMuEEmcClusterMaker/macros/StMuEEmcClusterMakerUtils.C");
43  loadLibraries();
44 
45  gSystem -> Load("StEEmcSimulatorMaker");
46 
47  //-- Create the analysis chain
48  chain = new StChain("StChain");
49 
50  //-- Add the muDst maker
51  muDst = new StMuDstMaker(0,0,inDir,file,"MuDst.root",nfiles);
52 
53  //-- EEMC database goes here
54  starDb = new St_db_Maker("StarDb","MySQL:StarDb");
55  new StEEmcDbMaker("eemcDb");
56 
57  //-- override timestamp just so something happens...
58  starDb -> setTimeStampDay(20040320); // format: yyyymmdd
59 
60  //-- Create an instance of the EEMC "slow" muDst simulator,
61  StMuEEmcSimuReMaker *muSim = new StMuEEmcSimuReMaker("muSim");
62  muSim -> setDbName( "eemcDb" );
63 
64  //-- Add the EEMC cluster maker
65  TString myname = file;
66  myname.ReplaceAll("MuDst","clusters");
67  TFile *myFile1 = new TFile(myname,"RECREATE");
68  myFile1 -> cd();
69  muCluster = new StMuEEmcClusterMaker();
70  muCluster -> setSeedEnergy(0.7);
71  muCluster -> setShapeLimit(0.75);
72  myFile1 -> cd("..");
73 
74  //-- Initialize the chain
75  chain -> Init();
76  chain -> ls(3);
77 
78  eemcDb = (StEEmcDb*)chain->GetDataSet("StEEmcDb");
79  //$$$cDb -> setThreshold(5.0);
80  eemcDb -> setPreferredFlavor( "onlped", "eemcPMTped" );
81  eemcDb -> setPreferredFlavor( "highStrip1", "eemcPIXcal" );
82  //$$$eemcDb -> requestDataBase(20040320,1,12);
83  //--
84  //-- At this point, one could override the database
85  //-- values by reading in an ascii file.
86  //--
87  //$$$ eemcDb -> setAsciiDatabase("eemc-database-smd.dat");
88 
89 
90 
91  //-- Loop over all requested events, or until we hit an error--
92  Int_t stat = 0;
93  Int_t event = 0;
94  Int_t first = 0;
95 
96 
97  for ( event = first; event < nevents; event++ ) {
98 
99  // if ( event++ >= nevents ) break;
100  if ( stat != 0 ) break;
101 
102  //-- Clear the chain from the previous event
103  chain -> Clear();
104 
105  std::cout << "Processing event number " << event << std::endl;
106 
107  //-- Call ::Make() on all makers
108  stat = chain -> Make();
109 
110  //-- Print out number of seed towers found (causes seg fault for some reason?)
111  std::cout << "N seed = " << muCluster -> ezAnalysis() -> getNSeedTowers() << std::endl;
112  std::cout << "N cluster = " << muCluster -> ezClusters() -> getNClusters() << std::endl;
113  std::cout << std::endl;
114 
115 
116  }
117 
118  eemcDb -> exportAscii("test.db");
119  myFile1 -> Write();
120 
121 }
122 
123 
virtual void Clear(Option_t *opt="")
User defined functions.
virtual Int_t Make()
virtual Int_t Write(const char *name=0, Int_t option=0, Int_t bufsize=0)
Definition: TDataSet.cxx:893
virtual void ls(Option_t *option="") const
Definition: TDataSet.cxx:495