StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StEmcOfflineCalibrationMaker.cxx
1 /*
2  * StEmcOfflineCalibrationMaker.cxx
3  * Update Author: J. Kevin Adkins, University of Kentucky
4  * June 17, 2014
5  *
6  * This was previously updated for the 2009 calibration.
7  * For 2012, I updated to use the new setting functions in
8  * the event class. Triggers were updated over the last calibration
9  * to have indepenent triggers, similar to what's done in the jet
10  * trees. There are no methods for TOF triggers implemented as of
11  * June 2014. This should be changed, and the TOF setting information
12  * uncommented if information from TOF is desired.
13  */
14 
15 #include <math.h>
16 #include <vector>
17 #include <stdio.h>
18 
19 #include "TFile.h"
20 #include "TTree.h"
21 #include "TH2.h"
22 #include "TChain.h"
23 #include "TCanvas.h"
24 
25 //StMuDstMaker
26 #include "StMuDSTMaker/COMMON/StMuDst.h"
27 #include "StMuDSTMaker/COMMON/StMuEvent.h"
28 #include "StMuDSTMaker/COMMON/StMuDstMaker.h"
29 #include "StMuDSTMaker/COMMON/StMuEmcCollection.h"
30 #include "StMuDSTMaker/COMMON/StMuEmcUtil.h"
31 #include "StMuDSTMaker/COMMON/StMuTrack.h"
32 #include "StMuDSTMaker/COMMON/StMuPrimaryVertex.h"
33 
34 #include "StEvent/StTriggerId.h"
35 #include "StEvent/StEvent.h"
36 #include "StEventTypes.h"
37 
38 #include "StDetectorDbMaker/StDetectorDbTriggerID.h"
39 #include "StEvent/StL0Trigger.h"
40 
41 #include "StDaqLib/TRG/trgStructures2005.h"
42 #include "StarClassLibrary/StPhysicalHelixD.hh"
43 
44 //StEmc
45 #include "StEmcUtil/database/StBemcTables.h"
46 #include "StEmcUtil/geometry/StEmcGeom.h"
47 #include "StEmcUtil/projection/StEmcPosition.h"
48 #include "StEmcADCtoEMaker/StBemcData.h"
49 #include "StEmcADCtoEMaker/StEmcADCtoEMaker.h"
50 #include "StEmcRawMaker/StBemcRaw.h"
51 #include "StEmcRawMaker/defines.h"
52 #include "StEmcRawMaker/StBemcTables.h"
53 #include "StEmcTriggerMaker/StEmcTriggerMaker.h"
54 #include "StTriggerUtilities/StTriggerSimuMaker.h"
55 #include "StTriggerUtilities/Bemc/StBemcTriggerSimu.h"
56 
57 #include "StEvent/StBTofHeader.h"
58 
59 //logger
60 #include "StMessMgr.h"
61 
62 //my files
63 #include "StEmcOfflineCalibrationEvent.h"
64 #include "StEmcOfflineCalibrationMaker.h"
65 
66 //use this to get kBarrelEmcTowerId defined
67 #include "StEnumerations.h"
68 
69 using namespace std;
70 
72 
73 StEmcOfflineCalibrationMaker::StEmcOfflineCalibrationMaker(const char* name, const char* file)
74 {
75  filename = file;
76  muDstMaker = NULL;
77  mEmcPosition = new StEmcPosition();
78 
79  towerSlopes = NULL;
80  smdeSlopes=NULL;
81  smdpSlopes=NULL;
82  preshowerSlopes = NULL;
83  mapcheck = NULL;
84  htTriggers.clear();
85 }
86 
87 StEmcOfflineCalibrationMaker::~StEmcOfflineCalibrationMaker() { }
88 
89 Int_t StEmcOfflineCalibrationMaker::Init()
90 {
91  myFile = new TFile(filename,"RECREATE");
92  calibTree = new TTree("calibTree","BTOW calibration tree");
93  myEvent = new StEmcOfflineCalibrationEvent();
94  calibTree->Branch("event_branch","StEmcOfflineCalibrationEvent",&myEvent);
95  calibTree->SetAutoSave(1000000000);
96 
97  muDstMaker = dynamic_cast<StMuDstMaker*>(GetMaker("MuDst")); assert(muDstMaker);
98  mADCtoEMaker = dynamic_cast<StEmcADCtoEMaker*>(GetMaker("Eread")); assert(mADCtoEMaker);
99  emcTrigSimu = dynamic_cast<StTriggerSimuMaker*>(GetMaker("StarTrigSimu")); assert(emcTrigSimu);
100 
101  mTables = mADCtoEMaker->getBemcData()->getTables();
102  mEmcGeom = StEmcGeom::instance("bemc");
103  mSmdEGeom=StEmcGeom::instance("bsmde");
104  mSmdPGeom=StEmcGeom::instance("bsmdp");
105 
106  return StMaker::Init();
107 }
108 
109 Int_t StEmcOfflineCalibrationMaker::InitRun(Int_t run)
110 {
111  mHT0threshold = emcTrigSimu->bemc->barrelHighTowerTh(0);
112  mHT1threshold = emcTrigSimu->bemc->barrelHighTowerTh(1);
113  mHT2threshold = emcTrigSimu->bemc->barrelHighTowerTh(2);
114  mHT3threshold = emcTrigSimu->bemc->barrelHighTowerTh(3);
115 
116  LOG_INFO << "HT thresholds: " << mHT0threshold << " " << mHT1threshold << " " << mHT2threshold << " " << mHT3threshold << endm;
117 
118  //Initialize histograms after TFile initialization
119  towerSlopes = new TH2F("towerSlopes","ADC vs. towerID",4800,0.5,4800.5,250,-49.5,200.5);
120  preshowerSlopes = new TH2F("preshowerSlopes","ADC vs. cap vs. towerID",4800,0.5,4800.5,500,-49.5,450.5);
121  smdeSlopes=new TH2F("smdeSlopes","ADC vs. stripID",18000,0.5,18000.5,1223,-199.5,1023.5);
122  smdpSlopes=new TH2F("smdpSlopes","ADC vs. stripID",18000,0.5,18000.5,1223,-199.5,1023.5);
123  mapcheck = new TH2F("mapcheck","Track Projection vs EMC hit",4800,0.5,4800.5,4800,0.5,4800.5);
124 
125  //pedestals, rms, status
126  Float_t pedestal, rms;
127  Int_t status;
128  Int_t pedstatus;
129  for (Int_t id=1; id<=4800; id++){
130  mTables->getPedestal(BTOW, id, 0, pedestal, rms);
131  mTables->getStatus(BTOW, id, pedstatus, "pedestal");
132  mTables->getStatus(BTOW, id, status);
133  mPedestal[BTOW-1][id-1] = pedestal;
134  mPedRMS[BTOW-1][id-1] = rms;
135  mStatus[BTOW-1][id-1] = status*pedstatus;
136 
137  mTables->getPedestal(BPRS, id, 0, pedestal, rms);
138  mTables->getStatus(BPRS, id, status);
139  mPedestal[BPRS-1][id-1] = pedestal;
140  mPedRMS[BPRS-1][id-1] = rms;
141  mStatus[BPRS-1][id-1] = status;
142  }
143 
144  for(Int_t sid=1;sid<=18000;sid++){
145  mTables->getPedestal(BSMDE, sid, 0, pedestal, rms);
146  mTables->getStatus(BSMDE, sid, status);
147  mPedestalSmd[BSMDE-3][sid-1] = pedestal;
148  mPedRMSSmd[BSMDE-3][sid-1] = rms;
149  mStatusSmd[BSMDE-3][sid-1] = status;
150 
151  mTables->getPedestal(BSMDP, sid, 0, pedestal, rms);
152  mTables->getStatus(BSMDP, sid, status);
153  mPedestalSmd[BSMDP-3][sid-1] = pedestal;
154  mPedRMSSmd[BSMDP-3][sid-1] = rms;
155  mStatusSmd[BSMDP-3][sid-1] = status;
156  }
157 
158  LOG_INFO << "StEmcOfflineCalibrationMaker::Init() == kStOk" << endm;
159  return StMaker::InitRun(run);
160 }
161 
163 {
164  LOG_DEBUG<<"StEmcOfflineCalibrationMaker::Make()"<<endm;
165  //get pointers to useful objects
166  StMuDst* muDst = muDstMaker->muDst(); assert(muDst);
167  StMuEvent* event = muDst->event(); assert(event);
168  StRunInfo* runInfo = &(event->runInfo()); assert(runInfo);
169 
170  LOG_DEBUG << "General pointer assertions okay" << endm;
171 
172  // Store basic event parameters
173  Bool_t fillQA = (runInfo->beamFillNumber(blue)==runInfo->beamFillNumber(yellow));
174  if (fillQA)
175  myEvent->setFill((Int_t)runInfo->beamFillNumber(blue));
176  else
177  myEvent->setFill(0);
178  myEvent->setRunNum(event->runNumber());
179  myEvent->setEventId(event->eventNumber());
180  myEvent->setDate(GetDate());
181  myEvent->setTime(GetTime());
182  myEvent->setHighTowerTh(0, mHT0threshold);
183  myEvent->setHighTowerTh(1, mHT1threshold);
184  myEvent->setHighTowerTh(2, mHT2threshold);
185  myEvent->setHighTowerTh(3, mHT3threshold);
186 
187  //fill ADC values from StEmcCollection obtained from MuDst
188  mEmcCollection = mADCtoEMaker->getEmcCollection();
189  for(Int_t p=0;p<2;p++)
190  for(Int_t q=0;q<18000;q++)
191  mADCSmd[p][q]=0;
192 
193  getADCs(BTOW);
194  getADCs(BPRS);
195  getADCs(BSMDP);
196  getADCs(BSMDE);
197  for(Int_t id=1; id<=4800; id++){
198  if((mADC[BTOW-1][id-1] != 0))
199  towerSlopes->Fill(id,mADC[BTOW-1][id-1]-mPedestal[BTOW-1][id-1]);
200  if(mADC[BPRS-1][id-1] != 0 && mCapacitor[id-1]!= CAP1 && mCapacitor[id-1]!=CAP2)
201  preshowerSlopes->Fill(id, mADC[BPRS-1][id-1]-mPedestal[BPRS-1][id-1]);
202  }
203 
204  for(Int_t id=1; id<=18000; id++){
205  if((mADCSmd[BSMDE-3][id-1] != 0) && mCapacitorSmd[BSMDE-3][id-1] != CAP1 && mCapacitorSmd[BSMDE-3][id-1] != CAP2)
206  smdeSlopes->Fill(id,mADCSmd[BSMDE-3][id-1]);
207  if(mADCSmd[BSMDP-3][id-1] != 0 && mCapacitorSmd[BSMDP-3][id-1] != CAP1 && mCapacitorSmd[BSMDP-3][id-1] != CAP2)
208  smdpSlopes->Fill(id, mADCSmd[BSMDP-3][id-1]);
209  }
210 
211  LOG_DEBUG << "Got ADCs" << endm;
212 
213  // Add triggers and set information for HT triggers
214  for(UInt_t htTrig = 0; htTrig < htTriggers.size(); ++htTrig){
215  Int_t trigId = htTriggers.at(htTrig);
216 
217  // Store HT trigger if it fire in hardware or software
218  if (event->triggerIdCollection().nominal().isTrigger(trigId) || emcTrigSimu->isTrigger(trigId) > 0){
219  StEmcOfflineCalibrationTrigger *myTrigger = myEvent->addTrigger();
220  myTrigger->setTrigId(trigId);
221 
222  // Hardware fire
223  if (event->triggerIdCollection().nominal().isTrigger(trigId))
224  myTrigger->setDidFire(true);
225  else
226  myTrigger->setDidFire(false);
227 
228  // Software fire
229  if (emcTrigSimu->isTrigger(trigId) > 0)
230  myTrigger->setShouldFire(true);
231  else
232  myTrigger->setShouldFire(false);
233  }
234  else
235  continue;
236  }
237 
238  const StEventSummary& evtSummary = muDstMaker->muDst()->event()->eventSummary();
239  Double_t mField = evtSummary.magneticField()/10;
240 
241  //now for the tracks
242  vector<Int_t> track_ids;
243 
244  Int_t nPrimVerts = muDst->numberOfPrimaryVertices();
245  Int_t vertIndex = 0;
246  for(Int_t iVertex=0; iVertex < nPrimVerts; ++iVertex){
247  if (iVertex > 9) continue; // Only store 10 vertices
248  StMuPrimaryVertex *muVertex = muDst->primaryVertex(iVertex);
249  assert(muVertex);
250  muDst->setVertexIndex(iVertex);
251  if (muVertex->ranking() < 0) continue;
252  StEmcOfflineCalibrationVertex *myVertex = myEvent->addVertex();
253  myVertex->setRanking(muVertex->ranking());
254  myVertex->setX(muVertex->position().x());
255  myVertex->setY(muVertex->position().y());
256  myVertex->setZ(muVertex->position().z());
257 
258  const StMuTrack* track;
259  const StMuTrack* primarytrack;
260 
261  Int_t nPrimTracks = muDst->numberOfPrimaryTracks();
262  pair<UInt_t, pair<Float_t,Float_t> > smd_eta_center;
263  pair<UInt_t, pair<Float_t,Float_t> > smd_phi_center;
264 
265  for(Int_t iTrack = 0; iTrack < nPrimTracks; ++iTrack){
266  track = NULL;
267  primarytrack = muDst->primaryTracks(iTrack);
268 
269  track = primarytrack->globalTrack();
270  if(!track)track = primarytrack;
271 
272  Double_t p;
273  StPhysicalHelixD outerhelix;
274  pair<UInt_t, pair<Float_t,Float_t> > center_tower;
275  outerhelix = track->outerHelix();
276  p = outerhelix.momentum(mField*tesla).mag();
277  center_tower = getTrackTower(track, false,1);
278  smd_eta_center=getTrackTower(track,false,3);
279  smd_phi_center=getTrackTower(track,false,4);
280 
281  //project track to BEMC
282  Int_t id = center_tower.first;
283  Int_t exitid = (getTrackTower(track, true)).first;
284 
285  if (id == 0) continue; // Don't store tracks that had a bad projection on the EMC
286  if (p < 1.) continue;
287 
288  StEmcOfflineCalibrationTrack *myTrack = myEvent->addTrack();
289  myVertex->addTrack(myTrack);
290  myTrack->setFlag(track->flag());
291  myTrack->setBad(track->bad());
292  myTrack->setCharge(track->charge());
293  myTrack->setEta(track->eta());
294  myTrack->setPhi(track->phi());
295  myTrack->setVertexIndex(vertIndex);
296  myTrack->setMomentum(outerhelix.momentum(mField*tesla));
297 
298  if (id == exitid)track_ids.push_back(id);
299  Int_t etaid=smd_eta_center.first;
300  Int_t phiid=smd_phi_center.first;
301  LOG_DEBUG<<"using track projection to the SMD, we get strips eta: "<<etaid<<" and phi: "<<phiid<<endm;
302  if(etaid>0){
303  Int_t smdeids[11];
304  smdeids[0] = etaid;
305  smdeids[1] = mEmcPosition->getNextId(3,etaid,1,0);
306  smdeids[2] = mEmcPosition->getNextId(3,etaid,2,0);
307  smdeids[3] = mEmcPosition->getNextId(3,etaid,3,0);
308  smdeids[4] = mEmcPosition->getNextId(3,etaid,4,0);
309  smdeids[5] = mEmcPosition->getNextId(3,etaid,5,0);
310  smdeids[6] = mEmcPosition->getNextId(3,etaid,-1,0);
311  smdeids[7] = mEmcPosition->getNextId(3,etaid,-2,0);
312  smdeids[8] = mEmcPosition->getNextId(3,etaid,-3,0);
313  smdeids[9] = mEmcPosition->getNextId(3,etaid,-4,0);
314  smdeids[10] = mEmcPosition->getNextId(3,etaid,-5,0);
315 
316  for(Int_t i = 0; i < 11; i++){
317  myTrack->setSmdeId(i,smdeids[i]);
318  myTrack->setSmdeAdc(i,mADCSmd[0][smdeids[i]-1]);
319  myTrack->setSmdeStatus(i,mStatusSmd[0][smdeids[i]-1]);
320  myTrack->setSmdePedestal(i,mPedestalSmd[0][smdeids[i]-1]);
321  myTrack->setSmdePedestalRms(i,mPedRMSSmd[0][smdeids[i]-1]);
322  }
323  }else{
324  for(Int_t i=0;i<11;i++){
325  myTrack->setSmdeId(i,0);
326  myTrack->setSmdeAdc(i,0);
327  myTrack->setSmdeStatus(i,0);
328  myTrack->setSmdePedestal(i,0.);
329  myTrack->setSmdePedestalRms(i,0.);
330  }
331  }
332  if(phiid>0){
333  Int_t smdpids[11];
334  smdpids[0] = phiid;
335  smdpids[1] = mEmcPosition->getNextId(4,phiid,0,1);
336  smdpids[2] = mEmcPosition->getNextId(4,phiid,0,2);
337  smdpids[3] = mEmcPosition->getNextId(4,phiid,0,3);
338  smdpids[4] = mEmcPosition->getNextId(4,phiid,0,4);
339  smdpids[5] = mEmcPosition->getNextId(4,phiid,0,5);
340  smdpids[6] = mEmcPosition->getNextId(4,phiid,0,-1);
341  smdpids[7] = mEmcPosition->getNextId(4,phiid,0,-2);
342  smdpids[8] = mEmcPosition->getNextId(4,phiid,0,-3);
343  smdpids[9] = mEmcPosition->getNextId(4,phiid,0,-4);
344  smdpids[10] = mEmcPosition->getNextId(4,phiid,0,-5);
345 
346  for(Int_t i = 0; i < 11; i++){
347  myTrack->setSmdpId(i,smdpids[i]);
348  myTrack->setSmdpAdc(i,mADCSmd[1][smdpids[i]-1]);
349  myTrack->setSmdpStatus(i,mStatusSmd[1][smdpids[i]-1]);
350  myTrack->setSmdpPedestal(i,mPedestalSmd[1][smdpids[i]-1]);
351  myTrack->setSmdpPedestalRms(i,mPedRMSSmd[1][smdpids[i]-1]);
352  }
353  }else{
354  for(Int_t i=0;i<11;i++){
355  myTrack->setSmdpId(i,0);
356  myTrack->setSmdpAdc(i,0);
357  myTrack->setSmdpStatus(i,0);
358  myTrack->setSmdpPedestal(i,0.);
359  myTrack->setSmdpPedestalRms(i,0.);
360  }
361  }
362 
363  //find neighboring towers
364  Int_t softid[9];
365  softid[0] = id;
366  softid[1] = mEmcPosition->getNextTowerId(id,-1,-1);
367  softid[2] = mEmcPosition->getNextTowerId(id,0,-1);
368  softid[3] = mEmcPosition->getNextTowerId(id,1,-1);
369  softid[4] = mEmcPosition->getNextTowerId(id,-1,0);
370  softid[5] = mEmcPosition->getNextTowerId(id,1,0);
371  softid[6] = mEmcPosition->getNextTowerId(id,-1,1);
372  softid[7] = mEmcPosition->getNextTowerId(id,0,1);
373  softid[8] = mEmcPosition->getNextTowerId(id,1,1);
374 
375  //save EMC info for 3x3 tower block around track
376  for(Int_t tower = 0; tower < 9; ++tower){
377  myTrack->setTowerId(tower, softid[tower]);
378  if (tower > 0 && softid[tower] == 0){
379  myTrack->setTowerAdc(tower,0);
380  myTrack->setTowerStatus(tower,0);
381  myTrack->setTowerPedestal(tower,0.);
382  myTrack->setTowerPedestalRms(tower,0.);
383  myTrack->setPreshowerAdc(tower,0);
384  myTrack->setPreshowerStatus(tower,0);
385  myTrack->setPreshowerPedestal(tower,0.);
386  myTrack->setPreshowerPedestalRms(tower,0.);
387  continue;
388  }
389  myTrack->setTowerAdc(tower, mADC[BTOW-1][softid[tower]-1]);
390  myTrack->setTowerPedestal(tower, mPedestal[BTOW-1][softid[tower]-1]);
391  myTrack->setTowerPedestalRms(tower, mPedRMS[BTOW-1][softid[tower]-1]);
392  myTrack->setTowerStatus(tower, mStatus[BTOW-1][softid[tower]-1]);
393  myTrack->setPreshowerAdc(tower, mADC[BPRS-1][softid[tower]-1]);
394  myTrack->setPreshowerPedestal(tower, mPedestal[BPRS-1][softid[tower]-1]);
395  myTrack->setPreshowerPedestalRms(tower, mPedRMS[BPRS-1][softid[tower]-1]);
396  myTrack->setPreshowerStatus(tower, mStatus[BPRS-1][softid[tower]-1]);
397  myTrack->setPreshowerCap(tower, mCapacitor[softid[tower]-1]);
398  }
399 
400  myTrack->setP(p);
401  myTrack->setDeta(center_tower.second.first);
402  myTrack->setDphi(center_tower.second.second);
403  myTrack->setTowerExitId((getTrackTower(track, true)).first);
404  myTrack->setHighestNeighbor(highestNeighbor(softid[0]));
405 
406  myTrack->setNSigmaElectron(track->nSigmaElectron());
407  myTrack->setNSigmaPion(track->nSigmaPion());
408  myTrack->setNSigmaProton(track->nSigmaProton());
409  myTrack->setNSigmaKaon(track->nSigmaKaon());
410 
411  myTrack->setNHits(track->nHits());
412  myTrack->setNFitPoints(track->nHitsFit());
413  myTrack->setNDedxPoints(track->nHitsDedx());
414  myTrack->setNHitsPossible(track->nHitsPoss());
415  myTrack->setDeDx(track->dEdx());
416 
417  /*
418  // store TOF information
419 
420  // save these for track QA cuts
421  myTrack->setVpdVz((Float_t)(muDst->btofHeader()->vpdVz(0)));
422  myTrack->setDcaGlobal((Float_t)(track->dcaGlobal().mag()));
423 
424  StMuBTofPidTraits tofTraits = track->btofPidTraits();
425  myTrack->SetTofMatchedFlag((Int_t)tofTraits.matchFlag());
426  myTrack->setTofTime(tofTraits.timeOfFlight());// some tof hits pass matchflag = 1 with -999 time of flight value
427  myTrack->setTofBeta(tofTraits.beta());// some tof hits pass matchflag = 1 with -999 beta value
428  myTrack->setTofPathlength(tofTraits.pathLength());
429  myTrack->setTofSigmaElectron(tofTraits.sigmaElectron());
430  myTrack->setTofProbElectron(tofTraits.probElectron());
431  */
432  }
433  vertIndex++;
434  }
435 
436  for(Int_t i = 0; i < 4800; i++){
437  if((mADC[BTOW-1][i]-mPedestal[BTOW-1][i]) < 5 || (mADC[BTOW-1][i]-mPedestal[BTOW-1][i]) > 100)continue;
438  for(UInt_t j = 0; j < track_ids.size(); j++){
439  mapcheck->Fill(track_ids[j],i+1);
440  }
441  }
442 
443  calibTree->Fill();
444  myEvent->Clear();
445  LOG_DEBUG << "StEmcOfflineCalibrationMaker::Make() == kStOk" << endm;
446  return kStOK;
447 }
448 
450 {
451  if(myEvent)
452  myEvent->Clear();
453  for(Int_t i=0; i<2; i++){
454  for(Int_t j=0; j<4800; j++){
455  mADC[i][j] = 0;
456  }
457  }
458  for(Int_t i=0; i<2; i++){
459  for(Int_t j=0; j<18000; j++){
460  mADCSmd[i][j] = 0;
461  }
462  }
463 }
464 
466 {
467  myFile->Write();
468  myFile->Close();
469  delete myFile;
470 
471  return kStOk;
472 }
473 
474 void StEmcOfflineCalibrationMaker::getADCs(Int_t det) //1==BTOW, 2==BPRS, 3=BSMDE, 4=BSMDP
475 {
476  det--;
477  StDetectorId detectorid = static_cast<StDetectorId>(kBarrelEmcTowerId + det);
478  StEmcDetector* detector=mEmcCollection->detector(detectorid);
479  if(detector){
480  for(Int_t m=1;m<=120;m++){
481  StEmcModule* module = detector->module(m);
482  if(module){
483  StSPtrVecEmcRawHit& rawHit=module->hits();
484  for(UInt_t k=0;k<rawHit.size();k++){
485  if(rawHit[k]){
486  Int_t module = rawHit[k]->module();
487  Int_t eta = rawHit[k]->eta();
488  Int_t submodule = TMath::Abs(rawHit[k]->sub());
489  Int_t ADC = rawHit[k]->adc();
490  Int_t hitid;
491  Int_t stat=-9;
492  if(det<2) stat = mEmcGeom->getId(module,eta,submodule,hitid);
493  else if(det==2) stat=mSmdEGeom->getId(module,eta,submodule,hitid);
494  else if(det==3) stat=mSmdPGeom->getId(module,eta,submodule,hitid);
495  if(det == 0 && stat == 0){
496  Int_t adc6 = emcTrigSimu->bemc->barrelHighTowerAdc(hitid);
497  myEvent->setHighTowerAdc(hitid,adc6);
498  }
499  if(stat==0){
500  if(det<2) mADC[det][hitid-1] = ADC;
501  else{
502  mADCSmd[det-2][hitid-1]=ADC;
503  }
504  }
505  if(det==1){
506  UChar_t CAP = rawHit[k]->calibrationType();
507  if(CAP > 127) CAP -= 128;
508  mCapacitor[hitid-1] = CAP;
509  }
510  if(det>1){
511  UChar_t CAP=rawHit[k]->calibrationType();
512  if(CAP>127) CAP-=128;
513  mCapacitorSmd[det-2][hitid-1]=CAP;
514  }
515  }
516  }
517  }
518  else { LOG_WARN<<"couldn't find StEmcModule "<<m<<" for detector "<<det<<endm; }
519  }
520  }
521  else { LOG_WARN<<"couldn't find StEmcDetector for detector "<<det<<endm; }
522 }
523 
524 pair<Int_t, pair<Float_t,Float_t> > StEmcOfflineCalibrationMaker::getTrackTower(const StMuTrack* track, Bool_t useExitRadius, Int_t det){ //1=BTOW, 3=BSMDE, 4=BSMDP
525  pair<Int_t, pair<Float_t,Float_t> > tower;
526  tower.first = 0;
527  tower.second.first = 1000.;
528  tower.second.second = 1000.;
529 
530  StThreeVectorD momentum,position;
531  Double_t radius;
532  if(det==1) radius = mEmcGeom->Radius();
533  if(det==2) radius = mEmcGeom->Radius();
534  if(det==3) radius = mSmdEGeom->Radius();
535  if(det==4) radius = mSmdPGeom->Radius();
536 
537  const StEventSummary& evtSummary = muDstMaker->muDst()->event()->eventSummary();
538  Double_t mField = evtSummary.magneticField()/10;
539 
540  //add 30 cm to radius to find out if track left same tower
541  if(useExitRadius) radius += 30.0;
542 
543  bool goodProjection = mEmcPosition->trackOnEmc(&position,&momentum,track,mField,radius);
544  if(goodProjection){
545  Int_t m,e,s,id=0;
546  Float_t eta=position.pseudoRapidity();
547  Float_t phi=position.phi();
548  if(det==1){
549  mEmcGeom->getBin(phi,eta,m,e,s);
550  s = abs(s);
551 
552  if(mEmcGeom->getId(m,e,s,id)==0){
553  tower.first = id;
554  tower.second = getTrackDetaDphi(eta, phi, id, det);
555  }
556  }
557  else if(det==3){
558  Int_t check=mSmdEGeom->getBin(phi,eta,m,e,s);
559  if(!check){
560  s = abs(s);
561  if(mSmdEGeom->getId(m,e,s,id)==0){
562  tower.first = id;
563  tower.second = getTrackDetaDphi(eta, phi, id, det);
564  }
565  }
566  }
567  else if(det==4){
568  Int_t check=mSmdPGeom->getBin(phi,eta,m,e,s);
569  s = abs(s);
570  if(!check){
571  if(mSmdPGeom->getId(m,e,s,id)==0){
572  tower.first = id;
573  tower.second = getTrackDetaDphi(eta, phi, id, det);
574  }
575  }
576  }
577  }
578 
579  return tower;
580 }
581 
582 pair<Float_t,Float_t> StEmcOfflineCalibrationMaker::getTrackDetaDphi(Float_t track_eta, Float_t track_phi, Int_t id, Int_t det){
583  Float_t eta_tower, phi_tower;
584  eta_tower = phi_tower = -999.;
585  pair<Float_t, Float_t> dtow;
586  if(det==1){
587  mEmcGeom->getEtaPhi(id,eta_tower,phi_tower);
588 
589  //now calculate distance from center of tower:
590  Float_t dphi = phi_tower - track_phi;
591  while(dphi > M_PI) {dphi -= 2.0 * M_PI;}
592  while(dphi < -1.*M_PI) {dphi += 2.0 * M_PI;}
593 
594  dtow.first = eta_tower - track_eta;
595  dtow.second = dphi;
596  }
597  if(det==3){
598  mSmdEGeom->getEtaPhi(id,eta_tower,phi_tower);
599 
600  //now calculate distance from center of strip:
601  Float_t dphi = phi_tower - track_phi;
602  while(dphi > M_PI) {dphi -= 2.0 * M_PI;}
603  while(dphi < -1.*M_PI) {dphi += 2.0 * M_PI;}
604 
605  dtow.first = eta_tower - track_eta;
606  dtow.second = dphi;
607  }
608  if(det==4){
609  mSmdPGeom->getEtaPhi(id,eta_tower,phi_tower);
610 
611  //now calculate distance from center of strip:
612  Float_t dphi = phi_tower - track_phi;
613  while(dphi > M_PI) {dphi -= 2.0 * M_PI;}
614  while(dphi < -1.*M_PI) {dphi += 2.0 * M_PI;}
615 
616  dtow.first = eta_tower - track_eta;
617  dtow.second = dphi;
618  }
619  return dtow;
620 }
621 
622 Double_t StEmcOfflineCalibrationMaker::highestNeighbor(Int_t id){
623  Double_t nSigma=0.;
624 
625  for(Int_t deta=-1; deta<=1; deta++){
626  for(Int_t dphi=-1; dphi<=1; dphi++){
627  if(deta==0 && dphi==0) continue;
628  Int_t nextId = mEmcPosition->getNextTowerId(id,deta,dphi);
629  if(nextId<1 || nextId>4800) continue;
630  if((mADC[BTOW-1][nextId-1]-mPedestal[BTOW-1][nextId-1]) > nSigma*mPedRMS[BTOW-1][nextId-1]){
631  nSigma = (mADC[BTOW-1][nextId-1] - mPedestal[BTOW-1][nextId-1])/mPedRMS[BTOW-1][nextId-1];
632  }
633  }
634  }
635  return nSigma;
636 }
637 
638 void StEmcOfflineCalibrationMaker::addHighTowerTrigger(UInt_t trigId){
639  htTriggers.push_back(trigId);
640 }
static StMuPrimaryVertex * primaryVertex()
return pointer to current primary vertex
Definition: StMuDst.h:322
StMuDst * muDst()
Definition: StMuDstMaker.h:425
UShort_t nHitsDedx() const
Return number of hits used for dEdx.
Definition: StMuTrack.h:238
UShort_t nHitsFit() const
Return total number of hits used in fit.
Definition: StMuTrack.h:239
short flag() const
Returns flag, (see StEvent manual for type information)
Definition: StMuTrack.h:230
Short_t charge() const
Returns charge.
Definition: StMuTrack.h:255
Double_t nSigmaPion() const
Returns Craig&#39;s distance to the calculated dE/dx band for pions in units of sigma.
Definition: StMuTrack.h:245
Double_t eta() const
Returns pseudo rapidity at point of dca to primary vertex.
Definition: StMuTrack.h:257
virtual void Clear(Option_t *option="")
User defined functions.
static TObjArray * primaryTracks()
returns pointer to a list of tracks belonging to the selected primary vertex
Definition: StMuDst.h:301
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
UShort_t nHitsPoss() const
Return number of possible hits on track.
Definition: StMuTrack.cxx:242
static StMuEvent * event()
returns pointer to current StMuEvent (class holding the event wise information, e.g. event number, run number)
Definition: StMuDst.h:320
Definition: Stypes.h:40
UShort_t nHits() const
Bingchu.
Definition: StMuTrack.h:237
Double_t dEdx() const
Returns measured dE/dx value.
Definition: StMuTrack.h:248
Double_t phi() const
Returns phi at point of dca to primary vertex.
Definition: StMuTrack.h:258
Double_t nSigmaProton() const
Returns Craig&#39;s distance to the calculated dE/dx band for protons in units of sigma.
Definition: StMuTrack.h:247
const StMuTrack * globalTrack() const
Returns pointer to associated global track. Null pointer if no global track available.
Definition: StMuTrack.h:272
Double_t nSigmaKaon() const
Returns Craig&#39;s distance to the calculated dE/dx band for kaons in units of sigma.
Definition: StMuTrack.h:246
StPhysicalHelixD outerHelix() const
Returns outer helix (last measured point)
Definition: StMuTrack.cxx:412
static void setVertexIndex(Int_t vtx_id)
Set the index number of the current primary vertex (used by both primaryTracks() functions and for St...
Definition: StMuDst.cxx:273
Definition: Stypes.h:41