StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
EdMu.C
Go to the documentation of this file.
1 // $Id: EdMu.C,v 1.18 2010/04/02 22:52:31 fine Exp $
2 // *-- Author : Valery Fine(fine@bnl.gov) 25/02/2009
3 
4 // Additions to use BEMC towers (for display of upsilon events) by Manuel Calderon de la Barca. Feb 2010.
5 
6 class StMuEmcHit;
7 class StMuDst;
8 StMuDst* muDst = 0; //< The pointer to the current instanse fo the StMuDst object
9 class StMuEvent;
10 StMuEvent* muEvent = 0; //< The pointer to the \a StMuEvent object
11 class StMuDstMaker;
12 StMuDstMaker* muDstMaker = 0;
13 class StChain;
14 StChain *chain = 0;
15 class St_db_Maker;
16 class StuDraw3DMuEvent;
17 StuDraw3DMuEvent *gEd = 0; //< The pointer to the current instance of the Event Display. You may want it to change the the drawing option
18 class StBemcTables;
19 StBemcTables* mBemcTables = 0;
20 bool gRotationIsOn = false; //< Flag whether the animated rotation was initialized to do it at once
21 
23 
71 //____________________________________________________________________________________
73 
93 //____________________________________________________________________________________
94 void addEmcHits(bool cuts=false) {
95  if (!cuts) gEd->Endcaps();
96  //TClonesArray *emcs = StMuDst::emcArray(1);
97  //TIter next(emcs);
98  //StMuEmcHit *hit = 0;
99  //while (hit = (StMuEmcHit *)next() ) {
100  for (int softId = 1; softId<=4800; ++softId) {
101  int adc = StMuDst::muEmcCollection()->getTowerADC(softId);
102  Color_t colorResponce=kWhite;
103  int status;
104  mBemcTables->getStatus(1, softId, status);
105  if (status != 1) continue;
106  float ped, rms;
107  mBemcTables->getPedestal(1, softId, 0, ped, rms);
108  if (adc < ped + 3 * rms) continue;
109  float calib;
110  mBemcTables->getCalib(1, softId, 1, calib);
111  float energy = calib * (adc - ped);
112  //energy = (adc/285.0*3.7);
113  if (softId==1) {
114  cout << "id =" << softId << " energy =" << energy << endl;
115  cout << " adc = " << adc << endl;
116  cout << " status = " << status << endl;
117  cout << " ped = " << ped << endl;
118  cout << " rms = " << rms << endl;
119  cout << " calib = " << calib << endl;
120  }
121  if (energy > 0 && energy < 30) {
122  // If edep less then MIP (~300 MeV), 60GeV <-> 4096 ADC counts
123  if ( energy < 0.3 ) { colorResponce = kBlue;
124  // style = 4001; //wireframe
125  // If edep larger than MIP but less then 1 GeV
126  } else if (energy < 1.0 ) colorResponce = kGreen;
127 
128  // If between 1 GeV and lowest HT threshold (4 GeV for Run7)
129  else if ( energy < 4.0 && energy>1.0) colorResponce = kYellow;
130  // If above lowest HT thershold
131  else colorResponce = kRed;
132 
133  const double maxSize = 400.; // (cm)
134  const double scale = 10.; // (cm/Gev)
135  float size =(scale)*energy;
136  if (size > maxSize) size = maxSize ;
137  if (!cuts || (cuts && energy>1.0)) {
138  gEd->EmcHit(softId,colorResponce, 0, size);
139  gEd->AddComment(Form("energy = %f size=%f ",energy,size));
140  }
141  // gEd->EmcHit(softId, adc*0.1);
142  }
143  }
144 }
145 
146 //____________________________________________________________________________________
148 
161 void addTracks(bool cuts=false) {
162  cout << "Adding tracks ----------------------------- " << endl;
163  cout << "Run / Event Number: " << muDstMaker->muDst()->event()->runNumber() << " / " << muDstMaker->muDst()->event()->eventNumber() << endl;
164 
165  size_t n_prim=StMuDst::GetNPrimaryTrack();
166 
167  int counter = 0;
168  for (size_t i_track=0; i_track < n_prim; ++i_track) {
169  StMuTrack &track = *(StMuDst::primaryTracks(i_track));
170  double pt =track.pt();
171  short charge= track.charge();
172  double nSigmaE = track.nSigmaElectron();
173  if (!cuts || (cuts && (pt>2 && nSigmaE>-0.5))) {
174  Style_t sty = gEd->Style(kPrimaryTrack).Sty();
175  Size_t siz = gEd->Style(kPrimaryTrack).Siz();
176  gEd->Track(track,StDraw3DStyle::Pt2Color(pt),sty,siz);
177  gEd->AddComment(Form("pT = %f charge=%d ",pt,charge));
178  ++counter;
179  }
180  }
181  cout << counter << " primary tracks have been rendered" << endl;
182 }
183 //____________________________________________________________________________________
185 
207 //____________________________________________________________________________________
208 void mrd(bool doTowerCuts=false, bool doTrackCuts=false, bool clear=true)
209 {
210  // redraw the event
211  if (muEvent) {
212  if (clear) gEd->Clear();
213  addEmcHits(doTowerCuts);
214  addTracks(doTrackCuts);
215 
216  }
217  }
218 
219 //____________________________________________________________________________________
221 
245 //____________________________________________________________________________________
246 void mae(bool rotation=false, bool doTowerCuts=false, bool doTrackCuts=false, int skipEvent = 205 )
247 {
248  // Advance till next "good" event
249  // One may want to replace the "plain" "if" clause below
250  // with the full-flegded filter
251  gEd->Clear();
252 
253  chain->Skip(skipEvent); // want to get to event 42752, skip 205 events in file
254  newevent:
255  chain->Make();
256  mBemcTables->loadTables(chain);
257 
258  if (muEvent = muDstMaker->muDst()->event()) {
259  cout << "Run / Event Number: " << muDstMaker->muDst()->event()->runNumber() << " / " << muDstMaker->muDst()->event()->eventNumber() << endl;
260  mrd(doTowerCuts,doTrackCuts); // Draw the tracks and towers
261  // The file rotation.iv should be in the StRoot/macros/graphics directory
262  // It can be used to set up a rotation of the coordinates. The orientation,
263  // rotation angles and the angular velocity are set in that file. MCBS.
264  if (rotation && !gRotationIsOn ) {
265  gEd->SetDrawOption("{file:rotation.iv}");
266  gRotationIsOn = true;
267  }
268  } else {
269  printf(" muEvent is empty\n");
270  goto newevent;
271  }
272  }
273 //____________________________________________________________________________________
274 //____________________________________________________________________________________
276 
290 //____________________________________________________________________________________
291  void EdMu(const char* file =
292  "/star/institutions/bnl/fine/testfiles/st_upsilon_8112020_raw_1130030.MuDst.root"
293  , const char * detectorNames="TPC,StarBeam")
294  {
295  // Start application open the file provided.
296  if ( gSystem->AccessPathName(file)) {
297  cout << endl << endl
298  << "** Error ** : The input file: <"<< file << "> does not exist !!!"
299  << endl << endl
300  << " Please select the existing one and re-call the function: "
301  << endl
302  << endl << " root [0] EdMu(\"new file ROOT file name\")"
303  << endl
304  << endl << "To draw the StEvent components with no detector geometry, use: "
305  << endl
306  << endl << " root [0] EdMu(\"new file ROOT file name\",0)"
307  << endl
308  << endl;
309  return;
310  }
311  TString muDstFile=file;
312  gROOT->Macro("loadMuDst.C");
313  gSystem->Load("St_Tables.so");
314  gSystem->Load("St_db_Maker.so");
315  gSystem->Load("StTpcDb");
316  gSystem->Load("StDetectorDbMaker");
317  gSystem->Load("StDbUtilities");
318  gSystem->Load("StDbLib");
319  gSystem->Load("StDbBroker");
320 
321  gSystem->Load("StEEmcUtil");
322  chain = new StChain();
323  St_db_Maker* dbMaker = new St_db_Maker("dbName","$STAR/StarDb","MySQL:StarDb");
324  muDstMaker = new StMuDstMaker(0,0,muDstFile.Data());
325  chain->Init();
326  //chain->InitRun(8112020);//hardwired...
327  mBemcTables = new StBemcTables;
328  delete gEd; // destroy the built-in display
329  gEd = new StuDraw3DMuEvent(detectorNames); // create our own one (with no detector geometry)
330  gEd->SetBkColor(kBlack);
331  printf("\n The display is ready!\n");
332  printf(" calling:\n");
333  printf("\t---\n");
334  printf("\tmae()\n");
335  printf("\t---\n");
336  printf("method to read and show the next event\n");
337  mae();
338  printf(" call:\n");
339  printf("\t---\n");
340  printf("\tmae() - to advance the event \n");
341  printf("\tmrd() - to redraw the event\n");
342  printf("\t---\n");
343  gEd->SetDrawOption("{view:all}");
344  }
StMuDst * muDst()
Definition: StMuDstMaker.h:425
void mae(bool rotation=false, bool doTowerCuts=false, bool doTrackCuts=false, int skipEvent=205)
This mae (AdvanceEvent) function is to search for the next non-empty event and draw it by looping ove...
Definition: EdMu.C:246
Double_t pt() const
Returns pT at point of dca to primary vertex.
Definition: StMuTrack.h:256
StBemcTables(Bool_t btowMapFix=kFALSE, Bool_t bprsMapFix=kFALSE)
StBemcTables constructor.
int status(int det, int softId, const char *option="") const
virtual const StDraw3DStyle & Style(EDraw3DStyle type) const
Return the reference to the predefined StDraw3DStyle object.
Definition: StDraw3D.cxx:482
Class StuDraw3DMuEvent - to draw the StMuDst primitives like StMuTrack as 3D points and 3D lines deco...
virtual void SetBkColor(Color_t newBkColor)
Set the ROOT color as the widget background.
Definition: StDraw3D.cxx:447
static Color_t Pt2Color(double pt)
Maps the track pt to the STAR StTrack track color code.
Definition: StDraw3D.cxx:78
void getPedestal(Int_t det, Int_t softId, Int_t cap, Float_t &ped, Float_t &rms) const
Return pedestal mean and rms.
Short_t charge() const
Returns charge.
Definition: StMuTrack.h:255
void loadTables(StMaker *anyMaker)
load tables.
void EdMu(const char *file="/star/institutions/bnl/fine/testfiles/st_upsilon_8112020_raw_1130030.MuDst.root", const char *detectorNames="TPC,StarBeam")
Main entry point to initialize the primitive &quot;Event Display&quot; and the STAR bfc chain.
Definition: EdMu.C:291
virtual TObject * Track(const StMuTrack &track, Color_t col, Style_t sty=Style_t(-1), Size_t siz=Size_t(-1))
Add track to the display list with the col color, sty style, and siz size if provided.
void addEmcHits(bool cuts=false)
Add emc hits to the list of the rendered objects.
Definition: EdMu.C:94
static TObjArray * primaryTracks()
returns pointer to a list of tracks belonging to the selected primary vertex
Definition: StMuDst.h:301
void mrd(bool doTowerCuts=false, bool doTrackCuts=false, bool clear=true)
This mrd (RedrawEvent) function redraws all hits and/or tracks from the current event.
Definition: EdMu.C:208
Double_t nSigmaElectron() const
Returns Craig&#39;s distance to the calculated dE/dx band for electrons in units of sigma.
Definition: StMuTrack.h:244
virtual Int_t Make()
Definition: StChain.cxx:110
static StMuEmcCollection * muEmcCollection()
returns pointer to current StMuEmcCollection
Definition: StMuDst.h:389
static StMuEvent * event()
returns pointer to current StMuEvent (class holding the event wise information, e.g. event number, run number)
Definition: StMuDst.h:320
void getCalib(Int_t det, Int_t softId, Int_t power, Float_t &calib) const
Return calibration constant.
void getStatus(Int_t det, Int_t softId, Int_t &status, const char *option="") const
Return status.
virtual void SetDrawOption(Option_t *option="")
Set the varous drawing option. The method passes the input options to TQtCoinWidget::SetDrawOption me...
Definition: StDraw3D.cxx:1097
virtual TObject * EmcHit(Int_t emcHitsSoftId, Color_t col, Style_t sty, Size_t siz, const char *detIdt="bemc")
Add EMC hit defined emcHitsSoftId to the display list with the col color sty and size if provided...
void addTracks(bool cuts=false)
Add tracks to the list of the rendered objects from current MuDst event.
Definition: EdMu.C:161
virtual void Clear(Option_t *opt="update")
Remove all objects from the list and update the screen if opt is &quot;update&quot;.
Definition: StDraw3D.cxx:398
virtual void Endcaps(Style_t sty=0)
Add the endcap towers to the list to display.