StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
makeEEmcTreePartMC.C
1 /*
2  * Created Mar 2013, by S. Gliske
3  *
4  * Macro to write only McEEmcTree part of the EEmcTree
5  *
6  */
7 
8 // forward declarations
9 class StChain;
10 class StMuDstMaker;
12 
13 //
14 // some variables that others tend to make global
15 //
16 StChain *analysisChain = 0;
17 StMuDstMaker *muDstMaker = 0;
18 StMcEEmcTreeMaker_t *mcTreeMakerPtr = 0;
19 
20 //
21 // the main routine
22 //
23 void makeEEmcTreePartMC( Long_t neventsIn = -1,
24  const Char_t *inputFileName = "",
25  const Char_t *outputFileName = "McEEmcTree.root",
26  Int_t displayFreq = 1000 ){
27 
28  Bool_t isMC = 1;
29 
30  std::cout << "***** Loading libraries *****" << endl;
31 
32  gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
33  loadSharedLibraries();
34  assert( !gSystem->Load("StEEmcUtil"));
35  assert( !gSystem->Load("StMcEvent"));
36  assert( !gSystem->Load("StMcEventMaker"));
37  assert( !gSystem->Load("StSpinDbMaker") );
38  assert( !gSystem->Load("StEEmcPoolEEmcTreeContainers") );
39  assert( !gSystem->Load("StEEmcPointMap") );
40  assert( !gSystem->Load("StEEmcTreeMaker") );
41 
42  //gDebug=5;
43 
44  std::cout << "***** Done loading libraries *****" << endl;
45  std::cout << "***** Instanciating all the classes *****" << endl;
46 
47  //
48  // Create the analysis chain
49  //
50  analysisChain = new StChain("eemcAnalysisChain");
51 
52  //
53  // IO Maker to read the geant file
54  //
55  if( isMC ){
56  ioMaker = new StIOMaker();
57 
58  TString geantFileName = inputFileName;
59  geantFileName.ReplaceAll("MuDst","geant");
60  ioMaker->SetFile(geantFileName);
61 
62  ioMaker->SetIOMode("r");
63  ioMaker->SetBranch("*",0,"1"); //deactivate all branches
64  ioMaker->SetBranch("geantBranch",0,"r"); //activate geant Branch
65  ioMaker->SetBranch("minimcBranch",0,"r"); //activate geant Branch
66  };
67 
68  //
69  // MuDst maker for reading input
70  //
71  Int_t nfiles = 10000;
72  muDstMaker = new StMuDstMaker( 0, 0, "", inputFileName, "MuDst", nfiles );
73  muDstMaker->SetStatus("*",0);
74  muDstMaker->SetStatus("*Event*",1);
75  muDstMaker->SetStatus("PrimaryVertices",1);
76  muDstMaker->SetStatus("EmcAll",1);
77 
78  //
79  // Maker for StMcEvent
80  //
81  StMcEventMaker *mcEventMaker = new StMcEventMaker();
82  mcEventMaker->doPrintEventInfo = false;
83  mcEventMaker->doPrintMemoryInfo = false;
84 
85  // this is the interface to the STAR logger
86  // SwitchOn("D") turns on debugging
87  // SwitchOff("D") turns off debuggin
88  // "I" is info and "W" is warn
89  gMessMgr->SwitchOff("D");
90  gMessMgr->SwitchOff("I");
91  //gMessMgr->SetLevel(2);
92 
93  // McTree Maker
94  mcTreeMakerPtr = new StMcEEmcTreeMaker_t( "McEEmcTreeMkr" );
95  mcTreeMakerPtr->setEnergyThreshold( 0.0 );
96  mcTreeMakerPtr->addTrigger( -999 );
97  mcTreeMakerPtr->setTreeStatus( StMcEEmcTreeMaker_t::WRITE, outputFileName );
98 
99  // debugging info
100  std::cout << "***** Done instanciating all the classes *****" << endl;
101  analysisChain->ls(3);
102 
103  //
104  // Initialize all makers
105  //
106 
107  std::cout << "***** Initializing all makers in the analysis chain *****" << std::endl;
108 
109  analysisChain->Init();
110 
111  std::cout << "***** Initialization done *****" << std::endl;
112 
113  //
114  // Finally ready to loop over the events
115  //
116 
117  // If neventsIn/Out is negative, reset to a large value
118  // for an Int_t
119  if( neventsIn < 0 )
120  neventsIn = 1<<30-1;
121 
122  Int_t ierr = kStOK; // err flag
123  Long_t nevents = 1; // cumulative number of events in
124  for( ; nevents <= neventsIn && !ierr; ++nevents ){
125  // clear
126  analysisChain->Clear();
127 
128  // make
129  ierr = analysisChain->Make();
130 
131  // Print every so many events
132  if( (nevents+1) % displayFreq == 1 )
133  std::cout << "***** finished event number " << nevents << " *****" << std::endl;
134 
135  if( ierr )
136  std::cout << "***** ERROR FLAG " << ierr << " on event number " << nevents << " *****" << endl;
137  };
138 
139  //---------------------------------------------------------------
140 
141 
142  //
143  // Calls the ::Finish() method on all makers
144  //
145  analysisChain->Finish();
146 
147  //
148  // Delete the chain
149  //
150  // analysisChain->Delete();
151 
152  return;
153 };
154 
155 /*
156  * $Id: makeEEmcTreePartMC.C,v 1.1 2013/03/19 18:48:46 sgliske Exp $
157  * $Log: makeEEmcTreePartMC.C,v $
158  * Revision 1.1 2013/03/19 18:48:46 sgliske
159  * creation
160  *
161  *
162  */
virtual void SetIOMode(Option_t *iomode="w")
number of transactions
Definition: StIOInterFace.h:35
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StChain.cxx:77
void setTreeStatus(iostatus_t iostatus, const Char_t *fileName)
modifiers
virtual Int_t Finish()
Definition: StChain.cxx:85
Filling of all StMcEvent classes from g2t tables Transform all the data in the g2t tables into the co...
StMcEEmcTreeMaker_t(const Char_t *myName)
constructor
virtual void ls(Option_t *option="") const
Definition: TDataSet.cxx:495
Bool_t doPrintMemoryInfo
lots of screen output
virtual Int_t Make()
Definition: StChain.cxx:110
Definition: Stypes.h:40
void SetStatus(const char *arrType, int status)