StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StPreEclMaker.cxx
1 #include "StPreEclMaker.h"
2 #include "StEvent.h"
3 #include "StEmcSimulatorMaker/StEmcSimulatorMaker.h"
4 #include "StEmcADCtoEMaker/StEmcADCtoEMaker.h"
5 #include "Stiostream.h"
6 #include "TStopwatch.h"
7 #include "StEmcUtil/others/emcDetectorName.h"
8 ClassImp(StPreEclMaker)
9 
10 //_____________________________________________________________________________
11 StPreEclMaker::StPreEclMaker(const char *name, const char *title):StMaker(name,title)
12 {
13  mFinder = NULL;
14  mAlg = kEmcClDefault;
15 }
16 //_____________________________________________________________________________
17 StPreEclMaker::~StPreEclMaker()
18 {
19  if(mFinder)
20  delete mFinder;
21 }
22 //_____________________________________________________________________________
23 Int_t StPreEclMaker::Init()
24 {
25  if(!mFinder)
26  {
27  if(mAlg == kEmcClOld)
28  mFinder = new StEmcOldFinder();
29  }
30 
31  if(!mFinder)
32  {
33  mFinder = new StEmcOldFinder(); // this is the default
34  mAlg = kEmcClOld;
35  }
36  return StMaker::Init();
37 }
38 //_____________________________________________________________________________
40 {
41  TStopwatch clock;
42  clock.Start();
43  LOG_DEBUG << "StPreEclMaker::Make()***********************************************************"<<endm;
44 
45  StEvent *ev = getEvent();
46  if(!ev)
47  return kStOk;
48 
49  if(mFinder)
50  {
51  mFinder->clear(); // clear last event information
52  mFinder->clear(ev); // clear clusters and points in StEvent
53  mFinder->findClusters(ev); // find new clusters
54  mFinder->fillStEvent(ev); // fill StEvent with new clusters
55  mFinder->fillHistograms(ev); // fill QA histograms
56  }
57 
58  clock.Stop();
59  LOG_DEBUG <<"Time to run StPreEclMaker::Make() real = "<<clock.RealTime()<<" cpu= "<<clock.CpuTime()<<endm;
60  LOG_DEBUG << "*******************************************************************************"<<endm;
61  return kStOK;
62 }
63 //_____________________________________________________________________________
65 {
66  return kStOK;
67 }
68 StEvent* StPreEclMaker::getEvent()
69 {
70  // First of all, try to get StEvent Pointer
71  StEvent *ev = (StEvent*)GetInputDS("StEvent");
72  if(!ev)
73  return NULL;
74 
75  // check if there is a collection
76  StEmcCollection *emc = ev->emcCollection();
77  if(emc)
78  return ev;
79 
80  // no emcCollection. Will try from other sources.
81 
82  // first try from simulation
83  StEmcSimulatorMaker* sim = (StEmcSimulatorMaker*)GetMaker("EmcSimulator");
84  if(sim)
85  {
86  emc = (StEmcCollection*)sim->getEmcCollection();
87  //sim->clearStEventStaf();
88  if(emc)
89  {
90  ev->setEmcCollection(emc);
91  return ev;
92  }
93  }
94 
95  // no emc collection yet. Try ADCtoE
96  StEmcADCtoEMaker *adc =(StEmcADCtoEMaker*)GetMaker("Eread");
97  if(adc)
98  {
99  emc = (StEmcCollection*)adc->getEmcCollection();
100  // StEmcADCtoEMaker::clearStEventStaf() has been a NO-OP since 2004
101  // and is no longer supported as of 2017-06-02
102  //adc->clearStEventStaf();
103  if(emc)
104  {
105  ev->setEmcCollection(emc);
106  return ev;
107  }
108  }
109  return NULL;
110 }
111 void StPreEclMaker::SetClusterConditions(char *cdet,Int_t sizeMax,
112  Float_t energySeed,
113  Float_t energyAdd,
114  Float_t energyThresholdAll,
115  Bool_t kCheckClustersOk)
116 {
117  if(mAlg!=kEmcClOld)
118  return;
119 
120  for(Int_t i=0;i<4;i++)
121  {
122  if(!strcmp(cdet,detname[i].Data()))
123  {
124  ((StEmcOldFinder*)mFinder)->setEnergySeed(i+1,energySeed);
125  ((StEmcOldFinder*)mFinder)->setEnergyAdd(i+1,energyAdd);
126  ((StEmcOldFinder*)mFinder)->setEnergyThresholdAll(i+1,energyThresholdAll);
127  ((StEmcOldFinder*)mFinder)->setSizeMax(i+1,sizeMax);
128  break;
129  }
130  }
131 }
virtual Bool_t fillStEvent(StEvent *)
fills the StEvent object with the StEmcPreCluster objects in the collections
virtual Int_t Finish()
virtual Bool_t fillHistograms(StEvent *)
fills the QA histograms
StEmcCollection * getEmcCollection()
StEmcCollection * getEmcCollection()
Return emcCollection.
void SetClusterConditions(char *, Int_t, Float_t, Float_t, Float_t, Bool_t=kFALSE)
this is for background compatibility with the old finder
virtual Int_t Make()
virtual Bool_t findClusters(StEvent *)
finds clusters in a StEvent object
Definition: Stypes.h:40
virtual Bool_t clear(StEvent *)
removes clusters and points from the StEvent object
Definition: Stypes.h:41