2 #include "StMuDSTMaker/COMMON/StMuDst.h"
3 #include "StMuDSTMaker/COMMON/StMuEvent.h"
4 #include "StMuDSTMaker/COMMON/StMuDstMaker.h"
5 #include "StMuDSTMaker/COMMON/StMuEmcCollection.h"
6 #include "StMuDSTMaker/COMMON/StMuEmcUtil.h"
7 #include "StMuDSTMaker/COMMON/StMuTrack.h"
8 #include "StMuDSTMaker/COMMON/StMuPrimaryVertex.h"
10 #include "StEvent/StTriggerId.h"
11 #include "StEvent/StEvent.h"
12 #include "StEventTypes.h"
14 #include "StDetectorDbMaker/StDetectorDbTriggerID.h"
15 #include "StEvent/StL0Trigger.h"
17 #include "StDaqLib/TRG/trgStructures2005.h"
20 #include "StEmcUtil/database/StBemcTables.h"
21 #include "StEmcUtil/database/StEmcDecoder.h"
22 #include "StEmcUtil/geometry/StEmcGeom.h"
23 #include "StEmcUtil/projection/StEmcPosition.h"
24 #include "StEmcADCtoEMaker/StBemcData.h"
25 #include "StEmcADCtoEMaker/StEmcADCtoEMaker.h"
26 #include "StEmcRawMaker/StBemcRaw.h"
27 #include "StEmcRawMaker/defines.h"
28 #include "StEmcRawMaker/StBemcTables.h"
29 #include "StEmcTriggerMaker/StEmcTriggerMaker.h"
32 #include "StMessMgr.h"
35 #include "StTriggerStudyMaker.h"
36 #include "StDetectorDbMaker/StDetectorDbBeamInfo.h"
37 #include "StSpinPool/StTriggerFilterMaker/StTriggerFilterMaker.h"
38 #include "StTriggerStudyEvent.h"
40 #include "StTriggerUtilities/StTriggerSimuMaker.h"
41 #include "StTriggerUtilities/StTriggerSimuResult.h"
52 mTriggerSimuMaker = NULL;
58 Int_t StTriggerStudyMaker::Init()
60 int trigarray[12] = {117001,137221,137222,137822,117300,137571,137575,137585,137586,137611,137501,137622};
61 for(
int i = 0; i < nTriggers; i++){
62 triggers[i] = trigarray[i];
63 trigmap[triggers[i]] = i;
66 mFile =
new TFile(mName,
"RECREATE");
68 mTree =
new TTree(
"trigStudyTree",
"Trigger Study Tree");
69 mTree->Branch(
"event_branch",
"StTriggerStudyEvent",&mTSEvent);
70 mTree->SetAutoSave(1000000000);
72 muDstMaker =
dynamic_cast<StMuDstMaker*
>(GetMaker(
"MuDst"));
74 mADCtoEMaker =
dynamic_cast<StEmcADCtoEMaker*
>(GetMaker(
"Eread")); assert(mADCtoEMaker);
78 mEmcGeom = StEmcGeom::instance(
"bemc");
81 zvertall =
new TH1F(
"zvertall",
"Z Vertex Distribution",280,-139.5,140.5);
82 bbctall =
new TH1F(
"bbctall",
"BBC Time Bins",18,-1.5,16.5);
83 jp1et =
new TH1F(
"jp1et",
"JP1 Et Distribution",70,17.9,31.9);
84 jp2et =
new TH1F(
"jp2et",
"JP2 Et Distribution",70,17.9,31.9);
85 jp1et0 =
new TH1F(
"jp1et0",
"JP1 Et Distribution",70,3.9,17.9);
86 jp0et0 =
new TH1F(
"jp0et0",
"JP0 Et Distribution",70,3.9,17.9);
87 for(
int i = 0; i < nTriggers; i++){
88 trigmap[triggers[i]] = i;
90 sprintf(namez,
"zvert%i",triggers[i]);
91 zverttrig[i] =
new TH1F(namez,
"Z Vertex Distribution",280,-139.5,140.5);
93 sprintf(nameb,
"bbct%i",triggers[i]);
94 bbcttrig[i] =
new TH1F(nameb,
"BBC Time Bins",18,-1.5,16.5);
97 return StMaker::Init();
100 Int_t StTriggerStudyMaker::InitRun(
int run)
103 LOG_ERROR<<
"Attempting to change run: check file list"<<endm;
106 LOG_INFO<<
"Now starting Run#"<<run<<endm;
121 for(
int i = 0; i < nTriggers; i++){
122 zverttrig[i]->Write();
123 bbcttrig[i]->Write();
135 void StTriggerStudyMaker::fillTree()
141 int bbctimebin = muevent->bbcTriggerDetector().onlineTimeDifference();
142 mTSEvent->setBbcTimeBin(bbctimebin);
143 bbctall->Fill(bbctimebin/32);
148 if(vertmag > 1e-7)zvertall->Fill(vertz);
153 float jpEt[12] = {0,0,0,0,0,0,0,0,0};
156 StDetectorId detectorid =
static_cast<StDetectorId
>(kBarrelEmcTowerId);
157 StEmcDetector* detector=mEmcCollection->detector(detectorid);
159 for(
int m=1;m<=120;m++){
162 StSPtrVecEmcRawHit& rawHit=module->hits();
163 for(
unsigned int k=0;k<rawHit.size();k++){
165 int module = rawHit[k]->module();
166 int eta = rawHit[k]->eta();
167 int submodule = abs(rawHit[k]->sub());
168 int ADC = rawHit[k]->adc();
170 int stat = mEmcGeom->getId(module,eta,submodule,hitid);
172 mBemcTables->
getStatus(BTOW,hitid,status);
174 mBemcTables->
getPedestal(BTOW,hitid,0,pedestal,rms);
175 if(stat==0&&status==1&&((
float)ADC-pedestal) > 2*rms){
178 mEmcGeom->getTheta(hitid,theta);
179 float calib = mBemcTables->calib(BTOW,hitid);
180 float energy = calib * (float)(ADC-pedestal);
181 float et = energy*sin(theta);
191 else { LOG_WARN<<
"couldn't find StEmcModule "<<m<<
" for detector "<<BTOW<<endm;}
195 const StTriggerId& trigs = muevent->triggerIdCollection().nominal();
196 vector<unsigned int>triggers = trigs.triggerIds();
197 vector<unsigned int>prescales;
198 vector<unsigned int>simutriggers;
200 mTSEvent->setTriggers(triggers);
202 for(
unsigned int i = 0; i < triggers.size(); i++){
204 prescales.push_back(prs);
206 if(triggers[i] == 137222)isjp1 = 1;
207 if(triggers[i] == 137501)isjp0 = 1;
208 if(triggers[i] == 137585)isjp2 = 1;
209 map<int,int>::iterator iter = trigmap.find(triggers[i]);
210 if(iter!=trigmap.end()){
211 int tr = iter->second;
212 if(vertmag > 1e-7)zverttrig[tr]->Fill(vertz);
213 bbcttrig[tr]->Fill(bbctimebin/32);
215 if(mTriggerSimuMaker && mTriggerSimuMaker->isTrigger(triggers[i])){
216 simutriggers.push_back(triggers[i]);
218 vector<short> towers = trigsimuresult.highTowerIds();
219 for(
unsigned int j = 0; j < towers.size(); j++){
223 vector<short> jpatches = trigsimuresult.jetPatchIds();
224 for(
unsigned int j = 0; j < jpatches.size(); j++){
226 if(dsm > 0)mTSEvent->addJPatchDSM(jpatches[j],dsm);
228 vector<short> tpatches = trigsimuresult.triggerPatchIds();
229 for(
unsigned int j = 0; j < tpatches.size(); j++){
231 if(dsm > 0)mTSEvent->addTPatchDSM(tpatches[j],dsm);
235 vector<float> jpetvec;
236 for(
int k = 0; k < 12; k++){
237 if(jpEt[k] > maxjpEt)maxjpEt = jpEt[k];
238 jpetvec.push_back(jpEt[k]);
240 if(isjp1) jp1et->Fill(maxjpEt);
241 if(isjp1 && isjp2)jp2et->Fill(maxjpEt);
242 if(isjp0) jp0et0->Fill(maxjpEt);
243 if(isjp0 && isjp1)jp1et0->Fill(maxjpEt);
245 mTSEvent->setJPEt(jpetvec);
246 mTSEvent->setPrescales(prescales);
247 mTSEvent->setSimuTriggers(simutriggers);
StThreeVectorF primaryVertexPosition(int vtx_id=-1) const
The StMuDst is supposed to be structured in 'physical events'. Therefore there is only 1 primary vert...
int GetJetPatchFromTowerId(int softId, int &jetPatch) const
Get jet patch that contains software Id.
int jetPatchAdc(short jetPatchId) const
returns DSM ADC if above trigger threshold, otherwise -1
StBemcData * getBemcData()
Return the StBemcData pointer.
int highTowerAdc(short towerId) const
returns DSM ADC if above trigger threshold, otherwise -1
StBemcTables * getTables()
Return the StBemcTable pointer.
void getPedestal(Int_t det, Int_t softId, Int_t cap, Float_t &ped, Float_t &rms) const
Return pedestal mean and rms.
Accessor to the database for trigger id information.
static StMuEvent * event()
returns pointer to current StMuEvent (class holding the event wise information, e.g. event number, run number)
static StEmcCollection * emcCollection()
returns pointer to current StEmcCollection
void getStatus(Int_t det, Int_t softId, Int_t &status, const char *option="") const
Return status.
Float_t getTotalPrescaleByTrgId(Int_t trgId)
const StTriggerSimuResult & detailedResult(int trigId)
returns object containing detailed information about simulation of given trigger
int triggerPatchAdc(short patchId) const
returns DSM ADC if above trigger threshold, otherwise -1