StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StFcsMIPMaker.cxx
1 #include "StFcsMIPMaker.h"
2 #include "TDataSetIter.h"
3 #include "StDAQMaker/StDAQReader.h"
4 
5 #include "StRoot/StEvent/StEvent.h"
6 #include "StRoot/St_base/StMessMgr.h"
7 #include "StRoot/StEvent/StTriggerData.h"
8 #include "StRoot/StEvent/StFcsCollection.h"
9 #include "StRoot/StEvent/StFcsHit.h"
10 #include "StRoot/StEvent/StFcsCluster.h"
11 #include "StRoot/StFcsDbMaker/StFcsDb.h"
12 #include "StRoot/StSpinPool/StFcsRawDaqReader/StFcsRawDaqReader.h"
13 
14 #include "TH1F.h"
15 #include "TH2F.h"
16 #include "TString.h"
17 #include "TFile.h"
18 #include "TCanvas.h"
19 
20 #include <string.h>
21 #include <time.h>
22 
23 //ClassImp(StFcsMIPMaker)
24 
25 //_____________________________________________________________________________
27 
28 StFcsMIPMaker::StFcsMIPMaker(const char *name):StMaker(name){
29 
30 }
31 
32 //_____________________________________________________________________________
34 
36 
37 
38 //_____________________________________________________________________________
41 
42 
43  mFcsDb = static_cast<StFcsDb*>(GetDataSet("fcsDb"));
44 
45  if(mPedSub>0) mFcsDb->readPedFromText();
46 
47  sprintf(mFilename,"%d_%d.root",mRun,mSub);
48  printf("StFcsMIPMaker::Init - Opening %s\n",mFilename);
49  mFile=new TFile(mFilename,"RECREATE");
50 
51  const char* nameEHP[kFcsEHP] = {"Ecal","Hcal","Pres"};
52  const char* nameNS[kFcsNorthSouth] = {"N","S"};
53  char f[100], t[100]; //histogram file names
54  char adcsum_name[100];//1D hist names
55  char adcsum_title[100]; //1D hist titles
56 
57  hitsperevent= new TH1F("hitsperevent","EventHits",100,0,200);
58 
59  for(int det=0; det<kFcsNDet; det++){
60  int ns = mFcsDb->northSouth(det);
61  int ehp = mFcsDb->ecalHcalPres(det);
62  int maxid = mFcsDb->maxId(det);
63 
64  if(maxid==0) continue;
65 
66  for(int id=0; id<maxid; id++){
67 
68  int ehp2,ns2,crt,sub,dep,ch;
69 
70  mFcsDb->getDepfromId(det,id,ehp2,ns2,crt,sub,dep,ch);
71  sprintf(f,"%4s_%1s_TbinAdc_id%03d",nameEHP[ehp],nameNS[ns],id);
72  sprintf(t,"%4s_%1s_TbinAdc_id%03d",nameEHP[ehp],nameNS[ns],id);
73 
74  //declare hist to count # of minbias events
75  minbias_events= new TH1F("minbias","minbias events",5,0,5);
76 
77  //DEFINE ADC SUM HISTS -- FOR MIPS
78  sprintf(adcsum_title,"adcsum det%d_id%d",det,id);
79  sprintf(adcsum_name, "adcsum_det%d_id%d",det,id);
80  towadcsum[det][id]= new TH1F(adcsum_name,adcsum_title,7000,0,5000);
81  towadcsum[det][id]->Sumw2();
82 
83  }
84  }
85 
86  return kStOk;
87 }
88 
89 
90 
91 
92 //_____________________________________________________________________________
95 
96  mFcsCollection=0;
97  StTriggerData* trg=0;
98 
99  //Getting StFcsRawDaqReader and TriggerData
100  StFcsRawDaqReader* fcsraw=(StFcsRawDaqReader*)GetMaker("daqReader");
101  StEvent* event= (StEvent*)GetInputDS("StEvent");
102  if(fcsraw){
103  //Getting trigger data (if daq file)
104  trg = fcsraw->trgdata();
105  if(!trg){
106  LOG_INFO << "Cannot find Trigger Data from StFcsRawDaqReader" << endm;
107  }
108  }else if(event){
109  trg=event->triggerData();
110  if(!trg){
111  LOG_INFO << "Cannot find Trigger Data from StEvent" << endm;
112  }
113  }
114 
115  if(!event) {
116  LOG_INFO << "No StEvent found" << endm;
117  }else{
118  mFcsCollection=event->fcsCollection();
119  }
120  if(!mFcsCollection){
121  LOG_INFO << "No StFcsCollection found" << endm;
122  return kStErr;
123  }
124 
125  minbias_events->Fill(1);//count # of minbias events
126 
127  int nh[kFcsNDet]; memset(nh,0,sizeof(nh));
128  int sum[kFcsNDet][kFcsEcalMaxId]; memset(sum,0,sizeof(sum));
129  float etot[kFcsNDet]; memset(etot,0,sizeof(etot));
130  memset(Hcal_array,0,sizeof(Hcal_array)); //initialize hcal array
131 
132 
134  //FIND A MIP
135 
136  //Appy nhits cut on Ecal
137  if (mFcsCollection-> numberOfHits(1) < 50)// <---multiplicity/nhit cut
138  {
139  StSPtrVecFcsCluster& clusters= mFcsCollection->clusters(1);
140  int nEclu=mFcsCollection->numberOfClusters(1);
141 
142  //loop over Ecal clusters
143  for(int i=0; i<nEclu;i++){
144  StFcsCluster* clusterE=clusters[i];
145  StThreeVectorF xyzE=mFcsDb->getStarXYZfromColumnRow(1,clusterE->x(),clusterE->y());
146  int ntow=clusterE->nTowers();
147  int nnei=clusterE->nNeighbor();
148 
149  //apply cluster cuts
150  if(ntow==1 and nnei==0){
151 
152  //associate Hcal/Ecal clusters by finding shortest dist btwn cals (deltarmin)
153  deltarmin=1000000;
154  matchHcalClusE=0;
155 
156  //get corresponding Hcal cluster
157  int nHclu=mFcsCollection->numberOfClusters(3);//<--- det=3, Hcal
158  StSPtrVecFcsCluster& Hclusters=mFcsCollection->clusters(3);
159 
160  //loop over Hcal clusters
161  for(int j=0; j<nHclu; j++){
162  StFcsCluster* clusterH=Hclusters[j];
163  StThreeVectorF xyzH=mFcsDb->getStarXYZfromColumnRow(3,clusterH->x(),clusterH->y());
164  deltax=xyzH.x()-xyzE.x();
165  deltay=xyzH.y()-xyzE.y();
166  deltar=pow(pow(deltax,2)+pow(deltay,2),0.5);
167 
168  if(deltar<deltarmin){
169  matchHcalClusE=clusterH->energy();
170 
171  deltar=deltarmin;
172  }
173  }
174 
175  StPtrVecFcsHit &EClusterHits=clusterE->hits();
176 
177  if(matchHcalClusE>6){//only keep events w/ Hcal energy>6GeV
178  for(size_t j=0; j<EClusterHits.size(); j++)//loop over # hits/clust
179  {
180  int id=EClusterHits[j]->id();
181  float adc=EClusterHits[j]->adcSum();
182 
183  towadcsum[1][id]->Fill(adc);//fill adcsum 1D histogram for MIPs
184  }
185  }
186  }
187  }
188  }
189 
190  return kStOK;
191 }
192 
194  mFile->Write();
195  mFile->Close();
196  printf("StFcsMIPMaker::Finish - Closing %s\n",mFilename);
197  return kStOK;
198 };
199 
200 ClassImp(StFcsMIPMaker);
201 
int northSouth(int det) const
Ecal=0, Hcal=1, Pres=2.
Definition: StFcsDb.cxx:430
StThreeVectorD getStarXYZfromColumnRow(int det, float col, float row, float FcsZ=-1.0) const
get the STAR frame cooridnates from other way
Definition: StFcsDb.cxx:863
void readPedFromText(const char *file="fcsped.txt")
setting pedestal
Definition: StFcsDb.cxx:2124
StFcsMIPMaker(const char *name="FcsMIP")
constructor
int ecalHcalPres(int det) const
Ecal North=0, Ecal South=1, Hcal North=2, Hcal South=3, Pres=4/5.
Definition: StFcsDb.cxx:423
virtual Int_t Make()
Make - this method is called in loop for each event.
virtual Int_t Init()
Init - the top level StChain calls to initialize all its makers.
Definition: Stypes.h:40
virtual ~StFcsMIPMaker()
destructor
virtual Int_t Finish()
int maxId(int det) const
number of column
Definition: StFcsDb.cxx:468
Definition: Stypes.h:44
Definition: Stypes.h:41
void getDepfromId(int detectorId, int id, int &ehp, int &ns, int &crt, int &slt, int &dep, int &ch) const
print ET gain
Definition: StFcsDb.cxx:1018