StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
pi0nsweeper.C
1 //
2 // minesweeper.C
3 //
4 // Runs the EEmc tower-only cluster finder.
5 //
6 
7 
8 
9 void pi0nsweeper( int nEve = 10,
10  char *file = "/star/data04/sim/MuDst/minbias_pp200_pythia6.203_2003_hadronicon_trsic/rcf1200_2576_2000evts.MuDst.root",
11  Int_t nFiles = 1,
12  char *inDir = "NONE",
13  char *dbFlavor = "NONE",
14  char *outfile = "pi0ns.hist.root",
15  float scaleFactor = 0.8
16  ) {
17 
18  // Output an initial summary of what we're doing...
19  std::cout << "Running EEMC Tower Only pi0 Finder" << std::endl;
20  std::cout << "Processing: " << nEve << " events" << std::endl;
21  std::cout << "Input file: " << file << std::endl;
22  std::cout << "DB Flavor: " << dbFlavor << std::endl;
23  std::cout << "Output file: " << outfile << std::endl;
24  std::cout << "scaleFactor: " << scaleFactor << std::endl;
25  std::cout << std::flush;
26 
27  // Load dynamic libraries
28  LoadLibs();
29 
30  // Create the Analysis Chain
31  chain = new StChain("StChain");
32 
33  // Some histograms for study, not compiled into our makers
34  TH1F *nclust = new TH1F("nclust","Number of clusters",10,0,10);
35 
36  // Now we add Makers to the chain...
37 
38 
39  // The cluster maker is designed to run on micro dst's rather
40  // than StEvent files. We initialize w/ default "MuDst" name...
41  std::cout << "Instantiating muDstMk: " << file << std::endl;
42  StMuDstMaker *muDstMk = new StMuDstMaker(0,0,"",file,"",nFiles);
43  StMuDbReader *muDb = StMuDbReader::instance();
44 
45  //
46  // Configure the database, based on user input. We default to
47  // "NONE" here, which will skip the database and (for the
48  // time being) the cluster maker defaults to idealized gains
49  // in use in the Monte Carlo.
50  //
51  if ( dbFlavor != "NONE" &&
52  dbFlavor != "none" ) {
53 
54  // Database Makers
55  St_db_Maker *dbMk = new St_db_Maker("StarDb", "MySQL:StarDb");
56  StEEmcDbMaker *myMk = new StEEmcDbMaker("eemcDb");
57  // Force a timestamp here, so as not to run afoul of an assert
58  dbMk -> setTimeStampDay(20030516);
59 
60  }
61 
62 
63  // Cluster maker
64  StMuEETowerClusterMaker
65  *muEEClusterMaker = new StMuEETowerClusterMaker("muEEClusterMaker","MuDst");
66  // Set seed threshold of 0.6 GeV, and a user specified "scale factor".
67  // The default on this is 1.0, but should be 0.8 for Monte Carlo events,
68  // as this is needed to reconstruct the pi0 mass in the Monte Carlo...
69  muEEClusterMaker -> setSeedThreshold(0.6);
70  muEEClusterMaker -> setScaleFactor(scaleFactor);
71 
72 
73  // After the cluster maker, we add the pi0n finder to the
74  // chain. This pi0n finder requires that the two seed
75  // towers identified by the cluster finder be separated
76  // by at least 1 tower. Combinatoric backgrounds are
77  // estimated by randomly mixing clusters from previous
78  // events.
79 
80  // NOTE: At present, the combinatoric background has problems.
81  // This is probably due to a combination of factors,
82  // including not quite getting the 1-tower separation
83  // correct for mixed events. The net pi0 yields should
84  // only be trusted at about the 20% level right now...
85 
86  StMuEETowerPi0nMaker *muPi0nMaker =
87  new StMuEETowerPi0nMaker("muPi0nMaker","MuDst","muEEClusterMaker");
88 
89 
90  // Initialize the chain
91  chain->Init();
92  chain->ls(3);
93 
94  StEEmcDb *eemcDb = (StEEmcDb*)chain->GetDataSet("StEEmcDb");
95  // Only look at the bottom (aka "first") 1/3 of the endcap
96  eemcDb -> setSectors(5,8);
97  // Setup default flavor
98  eemcDb -> setPreferedFlavor( dbFlavor, "eemcPMTcal" );
99 
100  int eventCounter=0;
101  int stat=0;
102 
103  //---------------------------------------------------
104  while ( stat==0 ) {// loop over events
105 
106  if(eventCounter>=nEve) break;
107  chain->Clear();
108 
109  std::cout << "Processing event number " << eventCounter << std::endl;
110  stat = chain->Make();
111 
112  // Fill histograms if you really want to
113  nclust -> Fill( muEEClusterMaker -> getNClusters() );
114 
115  // Print a summary of the cluster finder
116  // and pi0n candidates
117 
118  if ( muEEClusterMaker -> getNClusters() > 1 ) {
119  muEEClusterMaker -> Print();
120  muPi0nMaker -> Print();
121  }
122 
123  eventCounter++;
124 
125  }
126 
127  // Tell us what happened if we terminated earlyx
128  if ( stat != 0 ) std::cout << "Loop terminated w/ stat = " << stat << std::endl;
129 
130  TFile f( outfile, "RECREATE" );
131  f.cd();
132 
133  // Output a selection of the many histograms
134  // created by the pi0 finder...
135  muPi0nMaker -> GetHistList() -> FindObject("mEventStats") -> Write();
136  muPi0nMaker -> GetHistList() -> FindObject("mMass_real_int") -> Write();
137  muPi0nMaker -> GetHistList() -> FindObject("mMass_mixed_int") -> Write();
138  muPi0nMaker -> GetHistList() -> FindObject("mEnergy_real_int") -> Write();
139  muPi0nMaker -> GetHistList() -> FindObject("mEnergy_mixed_int") -> Write();
140  muPi0nMaker -> GetHistList() -> FindObject("mZ_real_int") -> Write();
141  muPi0nMaker -> GetHistList() -> FindObject("mZ_mixed_int") -> Write();
142 
143 
144 
146 
147 }
148 
149 
150 void LoadLibs() {
151 
152  std::cout << "Loading libraries" << std::endl;
153 
154  if (gClassTable->GetID("TTable") < 0)
155  gSystem->Load("libStar");
156  gSystem->Load("St_base");
157  gSystem->Load("StChain");
158  gSystem->Load("St_Tables");
159  gSystem->Load("StMagF");
160  gSystem->Load("StUtilities"); // new addition 22jul99
161  gSystem->Load("StTreeMaker");
162  gSystem->Load("StIOMaker");
163  gSystem->Load("StarClassLibrary");
164  gSystem->Load("StTpcDb");
165  gSystem->Load("StDbUtilities");
166  gSystem->Load("StEvent");
167  gSystem->Load("StEventUtilities");
168  gSystem->Load("StMcEvent");
169  gSystem->Load("StMcEventMaker");
170  gSystem->Load("StAssociationMaker");
171  gSystem->Load("StMcAnalysisMaker");
172  gSystem->Load("StStrangeMuDstMaker");
173  gSystem->Load("StDbLib");
174  gSystem->Load("StDbBroker");
175  gSystem->Load("St_db_Maker");
176  gSystem->Load("libgeometry_Tables");
177  gSystem->Load("StDaqLib");
178  gSystem->Load("StEmcUtil");
179  gSystem->Load("StEmcADCtoEMaker");
180  gSystem->Load("StPreEclMaker");
181  gSystem->Load("StEpcMaker");
182 
183  assert(gSystem->Load("StMuDSTMaker")==0);
184  assert(gSystem->Load("StEEmcUtil")==0);
185  assert(gSystem->Load("StEEmcPoolmuDst")==0 );
186  assert(gSystem->Load("StEEmcPoolTowerOnly")==0 );
187 
188 }
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StChain.cxx:77
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
virtual Int_t Make()
Definition: StChain.cxx:110