StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
clusterChargePerAPV.C
1 /***************************************************************************
2  *
3  * $Id: clusterChargePerAPV.C,v 1.1 2012/01/31 09:26:17 sgliske Exp $
4  * Author: S. Gliske, Oct 2011
5  *
6  ***************************************************************************
7  *
8  * Description: Script to make cluster charge per apv histograms.
9  *
10  ***************************************************************************
11  *
12  * $Log: clusterChargePerAPV.C,v $
13  * Revision 1.1 2012/01/31 09:26:17 sgliske
14  * StFgtQaMakers moved to StFgtPool
15  *
16  * Revision 1.1 2011/10/10 17:42:06 sgliske
17  * creation
18  *
19  *
20  **************************************************************************/
21 
22 // forward declarations
23 class StChain;
24 class StFgtCosmicMaker;
25 class StFgtCorAdcMaker;
27 class StFgtClusterMaker;
29 
30 StChain *analysisChain = 0;
31 StFgtCosmicMaker *cosmicMkr = 0;
32 StFgtCorAdcMaker *adcCorrector = 0;
33 StFgtMaxClusterAlgo *clusAlgo = 0;
34 StFgtClusterMaker *clusMkr = 0;
35 StFgtQaClusterChargePerAPV *histMkr = 0;
36 
37 TCanvas *can = 0;
38 
39 Int_t clusterChargePerAPV( const Char_t *filename = "testfile.sfs",
40  const Char_t *pedfilename = "testfile.Ped.txt",
41  Int_t disc = 0,
42  Int_t quad = 0,
43  const Char_t *runname = "testrun",
44  const Char_t *quadname = "010",
45  Int_t nevents = -1,
46  Int_t timeBin = 4,
47  Bool_t cutShortEvents = 1 ){
48  LoadLibs();
49  Int_t ierr = 0;
50 
51  // hardcoded options
52  Int_t numDiscs = 3;
53  Int_t nBins_ChPerAPV = 160;
54  Float_t min_ChPerAPV = -512;
55  Float_t max_ChPerAPV = 2048;
56 
57  // canvas size
58  Int_t canWidth = 850, canHeight = 1100;
59 
60  Short_t timeBinMask = (1<<timeBin);
61  cout << "Constructing the chain" << endl;
62  analysisChain = new StChain("eemcAnalysisChain");
63 
64  cout << "Constructing the cosmic maker" << endl;
65  cosmicMkr = new StFgtCosmicMaker( "cosmicMaker", filename );
66  cosmicMkr->setNumDiscs( numDiscs );
67 
68  cout << "Constructing the corrector" << endl;
69  adcCorrector = new StFgtCorAdcMaker( "adcCorrector", "cosmicMaker" );
70  adcCorrector->setPedReaderFile( pedfilename );
71  adcCorrector->setTimeBinMask( timeBinMask );
72  adcCorrector->setAbsThres( -10000 ); // set below -4096 to skip cut
73  adcCorrector->setRelThres( 5 ); // set to zero to skip cut
74  adcCorrector->doSubtrPeds( 1 );
75  adcCorrector->doRemoveOtherTimeBins( 1 );
76 
77  cout << "Constructing the cluster maker" << endl;
78  clusAlgo = new StFgtMaxClusterAlgo();
79  clusMkr = new StFgtClusterMaker( "cosmicMaker", "clusMkr" );
80  clusMkr->setClusterAlgo( clusAlgo );
81 
82  cout << "Constructing the histogram maker" << endl;
83  histMkr = new StFgtQaClusterChargePerAPV( "histMkr", "cosmicMaker", disc, quad, 0, quadname );
84 
85  cout << "Initializing" << endl;
86  ierr = analysisChain->Init();
87  cout << "\t done initializing" << endl;
88 
89  if( ierr ){
90  cout << "Error initializing" << endl;
91  return;
92  };
93 
94  if( nevents < 0 )
95  nevents = 1<<30; // a big number
96 
97  cout << "Looping over events..." << endl;
98  for( int i=0; i<nevents && !ierr; ++i ){
99 
100  if( i%1000 == 1 )
101  cout << "event number " << i << endl;
102 
103  //cout << "clear" << endl;
104  analysisChain->Clear();
105 
106  //cout << "make" << endl;
107  ierr = analysisChain->Make();
108 
109  };
110 
111  //
112  // Calls the ::Finish() method on all makers
113  //
114  cout << "finish" << endl;
115  analysisChain->Finish();
116 
117  cout << "Making plots..." << endl;
118 
119 
120 
121 
122 
123  cout << "all done" << endl;
124  return;
125 };
126 
127 
128 // load the shared libraries
129 void LoadLibs() {
130  // common shared libraries
131 
132  gSystem->Load("libPhysics");
133  gSystem->Load("St_base");
134  gSystem->Load("StChain");
135  gSystem->Load("StEvent");
136  gSystem->Load("StUtilities");
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  gSystem->Load("StFgtPedPlotter");
145  gSystem->Load("StFgtCorAdcMaker");
146  gSystem->Load("StFgtClusterMaker");
147 };
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StChain.cxx:77
virtual Int_t Finish()
Definition: StChain.cxx:85
Int_t setClusterAlgo(StFgtIClusterAlgo *)
clear function is empty at the moment
virtual Int_t Make()
Definition: StChain.cxx:110