StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
runEEmcPreCluster.C
1 //
2 // Runs StMuEEmcPreCluster maker, performs a (trivial) clustering
3 // around the high-tower in each event, and generates some histograms
4 // of tower, preshower and postshower response, and SMD response...
5 //
6 // Binning on the histograms may not be optimal...
7 //
8 
9 
10 // forward declarations
11 class StChain;
12 class StIOMaker;
13 class StMuDstMaker;
14 class StMuEEmcPreAnalysisMaker;
15 class StMuEEmcPreClusterMaker;
16 class StMuDbReader;
17 class StEEmcDb;
18 class St_db_Maker;
19 
20 StChain *chain;
21 StIOMaker *ioMaker;
22 StMuDstMaker *muDstMaker;
23 StMuEEmcPreAnalysisMaker *muEEmcAnal;
24 StMuEEmcPreClusterMaker *muEEmcClust;
25 StMuDbReader *muDb;
26 StEEmcDb *eemdDb;
27 St_db_Maker *starDb;
28 
29 #include <iomanip>
30 #include <vector>
31 
32 void runEEmcPreCluster ( Int_t nevents = 100, // Number of events
33  Char_t *muDst = "MuDst/mcPi0n_field_onelectron_10000_06TC05_20.MuDst.root",
34  Char_t *output = "output.root" // Output file
35  );
36 
38 
39 void runEEmcPreCluster ( Int_t nevents,
40  Char_t *muDst,
41  Char_t *output ) {
42 
43  if ( output != "" )
44  TFile *f = new TFile( output, "RECREATE" );
45 
47  //
48  // Preshower, postshower and tower 2D histos
49  //
50  TH2F *hPre1VsTow = new TH2F("hPre1VsTow", "Preshower(1) energy deposit vs reco tower E", 100, 0., 20., 500, 0., 0.08);
51  TH2F *hPre2VsTow = new TH2F("hPre2VsTow", "Preshower(2) energy deposit vs reco tower E", 100, 0., 20., 500, 0., 0.08);
52  TH2F *hPostVsTow = new TH2F("hPostVsTow", "Postshower energy deposit vs reco tower E", 100, 0., 20., 500, 0., 0.08);
53  TH2F *hPre1VsPre2 = new TH2F("hPre1VsPre2","Preshower(1) energy deposit vs preshower(2) energy deposit", 500, 0., 0.08, 500, 0., 0.08);
54 
55 
57  //
58  // Load shared libraries
59  //
60  gROOT -> LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
61  loadSharedLibraries();
62  gSystem->Load("StEEmcUtil");
63  gSystem->Load("StMuEEmcPreAnalysisMaker.so");
64  gSystem->Load("StDbLib");
65  gSystem->Load("StDbBroker");
66  gSystem->Load("St_db_Maker");
67  gSystem->Load("StEEmcDbMaker");
68 
69 
71  //
72  // Create the chain and add the muDst maker
73  //
74  chain = new StChain("StChain");
75  muDstMaker = new StMuDstMaker(0,0,"",muDst,"MuDst.root",1);
76  muDb = StMuDbReader::instance();
77 
78  starDb = new St_db_Maker("StarDb", "MySQL:StarDb");
79  new StEEmcDbMaker("eemcDb");
80 
81  muEEmcAnal = new StMuEEmcPreAnalysisMaker();
82  muEEmcClust = new StMuEEmcPreClusterMaker();
83 
85  //
86  // Initialize the chain in preparation to loop over events
87  //
88  chain -> Init();
89  chain -> ls(3);
90  eemcDb = (StEEmcDb*)chain->GetDataSet("StEEmcDb");
91  assert(eemcDb);
92  // starDb -> setTimeStampDay(20030516);
93  eemcDb -> setTimeStampDay(20040101);
94  eemcDb -> setPreferedFlavor( "set492", "eemcPMTcal" );
95 
97  //
98  // Event Loop
99  //
100 
101  Int_t status = 0;
102  Int_t ievent = 0;
103  while ( !status && ievent < nevents ) {
104 
105  // if ( !ievent % 100 )
106  std::cout << "Processing event number " << ievent << std::endl;
107 
108  // Clear all makers on the chain
109  chain -> Clear();
110 
111  // Call all of the makers on the chain
112  status = chain -> Make();
113 
114  for ( Int_t i = 0; i < muEEmcClust -> getNumClusters(); i++ ) {
115 
116  StMuEEmcCluster cluster = muEEmcClust -> getCluster(i);
117 
118  Float_t energy_tow = cluster.getEnergy(0);
119  Float_t energy_pre1 = cluster.getEnergy(1);
120  Float_t energy_pre2 = cluster.getEnergy(2);
121  Float_t energy_post = cluster.getEnergy(3);
122 
123  hPre1VsTow -> Fill( energy_tow, energy_pre1 );
124  hPre2VsTow -> Fill( energy_tow, energy_pre2 );
125  hPostVsTow -> Fill( energy_tow, energy_post );
126  hPre1VsPre2 -> Fill ( energy_pre2, energy_pre1 );
127 
128  }
129 
130  // Increment the event counter
131  ievent++;
132 
133  }
134 
135  f->cd();
136  muEEmcClust -> GetHistList() -> Write();
137 
138  f -> Write();
139 
140 }
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