StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
makeCosmicPeds.C
1 /***************************************************************************
2  *
3  * $Id: makeCosmicPeds.C,v 1.1 2012/01/31 08:52:51 sgliske Exp $
4  * Author: S. Gliske, Sept 2011
5  *
6  ***************************************************************************
7  *
8  * Description: Compute peds for cosmic data and write to a file
9  *
10  ***************************************************************************
11  *
12  * $Log: makeCosmicPeds.C,v $
13  * Revision 1.1 2012/01/31 08:52:51 sgliske
14  * StFgtPedMaker moved to StFgtPool
15  *
16  * Revision 1.6 2011/11/14 15:38:50 ckriley
17  * made macro to work with new containers
18  *
19  * Revision 1.5 2011/10/04 18:45:49 sgliske
20  * made cut on short events optional
21  *
22  * Revision 1.4 2011/09/30 19:08:45 sgliske
23  * general update
24  *
25  * Revision 1.3 2011/09/26 16:55:52 sgliske
26  * Continued work on cosmic QA plots
27  *
28  * Revision 1.2 2011/09/22 21:21:12 sgliske
29  * first working version
30  *
31  * Revision 1.1 2011/09/22 14:10:13 sgliske
32  * minor update
33  *
34  *
35  **************************************************************************/
36 
37 // forward declarations
38 class StChain;
39 class StFgtCosmicMaker;
40 class StFgtEvent;
41 class StFgtPedMaker;
42 
43 StChain *analysisChain = 0;
44 StFgtCosmicMaker *cosmicMkr = 0;
45 StFgtPedMaker *pedMkr = 0;
46 
47 int makeCosmicPeds( const Char_t *filenameIn = "testfile.sfs",
48  const Char_t *filenameOut = "testfile.Ped.txt",
49  Int_t nevents = 199,
50  Short_t timeBinMask = 0x10,
51  Bool_t cutShortEvents = 1 ){
52 
53 
54  LoadLibs();
55  Int_t ierr = 0;
56 
57  cout << "Constructing the chain" << endl;
58  analysisChain = new StChain("eemcAnalysisChain");
59 
60  cout << "Constructing the cosmic maker" << endl;
61  cosmicMkr = new StFgtCosmicMaker( "cosmicMaker", filenameIn );
62  cosmicMkr->cutShortEvents( cutShortEvents );
63 
64  cout << "Constructing the Ped Maker" << endl;
65  pedMkr = new StFgtPedMaker( "FgtPedMaker" );
66  pedMkr->setToSaveToDb( 0 );
67  pedMkr->setToSaveToFile( filenameOut );
68  pedMkr->setTimeBinMask( timeBinMask ); // 0x18 = 11000 = bins 3 & 4
69 
70  cout << "Initializing" << endl;
71  ierr = analysisChain->Init();
72 
73  if( ierr ){
74  cout << "Error initializing" << endl;
75  return;
76  };
77 
78  if( nevents < 0 )
79  nevents = 1<<30; // a big number
80 
81  cout << "max nevents = " << nevents << endl;
82  for( int i=0; i<nevents && !ierr; ++i ){
83 
84  //cout << "event number " << i << endl;
85 
86  //cout << "clear" << endl;
87  analysisChain->Clear();
88 
89  //cout << "make" << endl;
90  ierr = analysisChain->Make();
91 
92  };
93 
94  //
95  // Calls the ::Finish() method on all makers
96  //
97  cout << "finish" << endl;
98  analysisChain->Finish();
99 
100  cerr << "\tall done" << endl;
101  return;
102 };
103 
104 
105 // load the shared libraries
106 void LoadLibs() {
107  // common shared libraries
108 
109  gSystem->Load("libPhysics");
110  gSystem->Load("St_base");
111  gSystem->Load("StChain");
112  gSystem->Load("StFgtUtil");
113  gSystem->Load("StUtilities");
114  gSystem->Load("StEvent");
115  cout << "loaded StEvent library" << endl;
116 
117  gSystem->Load("StFgtUtil");
118  gSystem->Load("StFgtRawMaker");
119  gSystem->Load("RTS");
120  gSystem->Load("StFgtPedMaker");
121 };
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StChain.cxx:77
virtual Int_t Finish()
Definition: StChain.cxx:85
virtual Int_t Make()
Definition: StChain.cxx:110