StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
simpleTestStandTest.C
1 /***************************************************************************
2  *
3  * $Id: simpleTestStandTest.C,v 1.1 2012/01/31 09:26:18 sgliske Exp $
4  * Author: S. Gliske, Sept 2011
5  *
6  ***************************************************************************
7  *
8  * Description: Simple test macro to read in test stand data and make
9  * plot of ADC values.
10  *
11  ***************************************************************************
12  *
13  * $Log: simpleTestStandTest.C,v $
14  * Revision 1.1 2012/01/31 09:26:18 sgliske
15  * StFgtQaMakers moved to StFgtPool
16  *
17  * Revision 1.3 2011/09/24 02:14:10 sgliske
18  * updated FGT cosmic QA
19  *
20  * Revision 1.2 2011/09/22 14:10:13 sgliske
21  * minor update
22  *
23  * Revision 1.1 2011/09/21 20:26:47 sgliske
24  * creation
25  *
26  *
27  **************************************************************************/
28 
29 // forward declarations
30 class StChain;
31 class StFgtCosmicMaker;
32 class StFgtEvent;
34 
35 StChain *analysisChain = 0;
36 StFgtCosmicMaker *cosmicMkr = 0;
37 StFgtQaAdcVsChannel *adcVsChan1 = 0;
38 StFgtQaAdcVsChannel *adcVsChan2 = 0;
39 StFgtQaAdcVsChannel *adcVsChan3 = 0;
40 
41 int simpleTestStandTest( const Char_t *filename = "testfile.sfs",
42  const Char_t *outputKey = "test",
43  Int_t nevents = 1999,
44  const Char_t *quadname1 = "010",
45  const Char_t *quadname2 = "011",
46  const Char_t *quadname3 = "013",
47  Bool_t pedSub = 1,
48  const Char_t *pedFile = "testfile.Ped.txt",
49  Int_t timeBin = 4,
50  Bool_t vsStrips = 1,
51  Int_t numDiscs = 3 ){
52 
53  LoadLibs();
54  Int_t ierr = 0;
55 
56  cout << "Constructing the chain" << endl;
57  analysisChain = new StChain("eemcAnalysisChain");
58 
59  cout << "Constructing the cosmic maker" << endl;
60  cosmicMkr = new StFgtCosmicMaker( "cosmicMaker", filename );
61  cosmicMkr->setNumDiscs( numDiscs );
62 
63  cout << "Constructing the QA makers" << endl;
64 
65  adcVsChan1 = new StFgtQaAdcVsChannel( "fgtQaAdc_1", "cosmicMaker", 0, 0, quadname1 );
66 
67  adcVsChan1->setTimeBin( timeBin );
68  adcVsChan1->setFilenameBase( outputKey );
69  adcVsChan1->setToPlotVsStrip( vsStrips );
70  adcVsChan1->setToSubtrPeds( pedSub );
71  adcVsChan1->setPedReaderFile( pedFile );
72  adcVsChan1->setPedThres( 3.0 );
73 
74  adcVsChan2 = new StFgtQaAdcVsChannel( "fgtQaAdc_2", "cosmicMaker", 1, 0, quadname2 );
75 
76  adcVsChan2->setTimeBin( timeBin );
77  adcVsChan2->setFilenameBase( outputKey );
78  adcVsChan2->setToPlotVsStrip( vsStrips );
79  adcVsChan2->setToSubtrPeds( pedSub );
80  adcVsChan2->setPedReaderFile( pedFile );
81  adcVsChan2->setPedThres( 3.0 );
82 
83  adcVsChan3 = new StFgtQaAdcVsChannel( "fgtQaAdc_3", "cosmicMaker", 2, 0, quadname3 );
84 
85  adcVsChan3->setTimeBin( timeBin );
86  adcVsChan3->setFilenameBase( outputKey );
87  adcVsChan3->setToPlotVsStrip( vsStrips );
88  adcVsChan3->setToSubtrPeds( pedSub );
89  adcVsChan3->setPedReaderFile( pedFile );
90  adcVsChan3->setPedThres( 3.0 );
91 
92  cout << "Initializing" << endl;
93  ierr = analysisChain->Init();
94 
95  if( ierr ){
96  cout << "Error initializing" << endl;
97  return;
98  };
99 
100  if( nevents < 0 )
101  nevents = 1e100; // a big number
102 
103  for( int i=0; i<nevents && !ierr; ++i ){
104 
105  //cout << "event number " << i << endl;
106 
107  //cout << "clear" << endl;
108  analysisChain->Clear();
109 
110  //cout << "make" << endl;
111  ierr = analysisChain->Make();
112 
113  };
114 
115  //
116  // Calls the ::Finish() method on all makers
117  //
118  cout << "finish" << endl;
119  //analysisChain->Finish(); // bug in LOG_ prevents this
120  adcVsChan1->Finish();
121  adcVsChan2->Finish();
122  adcVsChan3->Finish();
123 
124  cout << "all done" << endl;
125  return;
126 };
127 
128 
129 // load the shared libraries
130 void LoadLibs() {
131  // common shared libraries
132 
133  gSystem->Load("libPhysics");
134  gSystem->Load("St_base");
135  gSystem->Load("StChain");
136  gSystem->Load("StEvent");
137  cout << "loaded StEvent library" << endl;
138 
139  gSystem->Load("StFgtUtil");
140  gSystem->Load("StFgtRawMaker");
141  gSystem->Load("RTS");
142  gSystem->Load("StFgtPedMaker");
143  gSystem->Load("StFgtQaMakers");
144 };
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StChain.cxx:77
virtual Int_t Make()
Definition: StChain.cxx:110