11 #include "StEmcClusterCollection.h"
12 #include "StEmcPoint.h"
13 #include "StEmcUtil/geometry/StEmcGeom.h"
14 #include "StEmcUtil/others/emcDetectorName.h"
15 #include "StEmcADCtoEMaker/StBemcData.h"
16 #include "StEmcADCtoEMaker/StEmcADCtoEMaker.h"
17 #include "StEmcTriggerMaker/StEmcTriggerMaker.h"
20 #include "StDetectorDbMaker/StDetectorDbTriggerID.h"
26 #include "St_db_Maker/St_db_Maker.h"
29 #include "StMuDSTMaker/COMMON/StMuDst.h"
30 #include "StMuDSTMaker/COMMON/StMuEvent.h"
31 #include "StMuDSTMaker/COMMON/StMuDstMaker.h"
32 #include "StMuDSTMaker/COMMON/StMuPrimaryVertex.h"
33 #include "StMuDSTMaker/COMMON/StMuTrack.h"
36 #include "StSpinPool/StSpinDbMaker/StSpinDbMaker.h"
39 #include "StJetMaker/StJetSkimEventMaker.h"
42 #include "StSpinPool/StJetSkimEvent/StJetSkimEvent.h"
45 #include "StSpinPool/StMCAsymMaker/StPythiaEvent.h"
46 #include "StSpinPool/StMCAsymMaker/StMCAsymMaker.h"
49 #include "StTriggerUtilities/StTriggerSimuMaker.h"
50 #include "StTriggerUtilities/StTriggerSimuResult.h"
51 #include "StTriggerUtilities/Bemc/StBemcTriggerSimu.h"
52 #include "StTriggerUtilities/Eemc/StEemcTriggerSimu.h"
53 #include "StTriggerUtilities/Emc/StEmcTriggerSimu.h"
56 #include "StBTofHeader.h"
64 :
StMaker(name), muDstMaker(uDstMaker), outName(outputName), mOutfile(0), mTree(0), mEvent(0), isRealData(true)
69 StJetSkimEventMaker::~StJetSkimEventMaker()
73 Int_t StJetSkimEventMaker::Init()
77 printf(
"StJetSkimEventMaker::Init(): open file:\t%s\t for writing\n",outName);
78 mOutfile =
new TFile(outName,
"RECREATE");
84 StJetSkimTrig::Class()->IgnoreTObjectStreamer();
85 StPythiaEvent::Class()->IgnoreTObjectStreamer();
88 mTree =
new TTree(
"jetSkimTree",
"StJetSkimEvent Tree",99);
91 mTree->Branch (
"skimEventBranch",
"StJetSkimEvent", &mEvent, 64000, 99);
94 mcAsymMaker =
dynamic_cast<StMCAsymMaker*
>(GetMaker(
"MCAsym"));
95 if(mcAsymMaker != NULL) {
96 mEvent->setMcEvent(mcAsymMaker->pythiaEvent());
103 Int_t StJetSkimEventMaker::InitRun(
int runnumber) {
108 TList *headerList = mTree->GetUserInfo();
109 bool insertHeader =
true;
112 for(
int i=0; i<headerList->GetEntries(); i++) {
113 TClonesArray *tmp = (TClonesArray*)headerList->At(i);
115 if(h->runId == runnumber){
116 insertHeader =
false;
117 mCurrentHeaderRef = tmp;
122 TClonesArray *trigHeaderArray =
new TClonesArray(
"StJetSkimTrigHeader",50);
128 for(map<int,float>::const_iterator it=prescaleMap.begin(); it!=prescaleMap.end(); it++) {
129 header->runId = runnumber;
130 header->trigId = it->first;
131 header->prescale = it->second;
132 fillThresholds(*header);
137 for(
unsigned i=0; i<mSimuTrigIds.size(); i++) {
138 header->runId = runnumber;
139 header->trigId = mSimuTrigIds[i];
140 header->prescale = 1.0;
141 fillThresholds(*header);
146 headerList->Add(trigHeaderArray);
147 mCurrentHeaderRef = headerList->Last();
150 return StMaker::InitRun(runnumber);
167 StRunInfo* runInfo = &(muEvent->runInfo()); assert(runInfo);
173 mEvent->setTrigHeaderArray(mCurrentHeaderRef);
177 for (map<int,float>::iterator it=prescaleMap.begin(); it!=prescaleMap.end(); ++it) {
178 skimTrig.setTrigId((*it).first);
179 if (muEvent->triggerIdCollection().nominal().isTrigger(skimTrig.trigId())) {
180 skimTrig.setDidFire(
true);
183 skimTrig.setDidFire(
false);
185 fillTriggerSimulationInfo(skimTrig);
186 if(skimTrig.didFire() || (skimTrig.shouldFire() > 0)) mEvent->setTrig(skimTrig);
192 int theYear=mydb->GetDateTime().GetYear();
196 if(muEvent->L2Result().GetSize() > 0) mEvent->setL2Result(muEvent->L2Result().GetArray());
201 for(
unsigned i=0; i<mSimuTrigIds.size(); i++) {
202 skimTrig.setTrigId(mSimuTrigIds[i]);
203 skimTrig.setDidFire(
false);
204 fillTriggerSimulationInfo(skimTrig);
205 if(skimTrig.shouldFire() > 0) mEvent->setTrig(skimTrig);
211 mEvent->setFill( runInfo->beamFillNumber(blue));
212 mEvent->setRunId( muEvent->runId() );
213 mEvent->setEventId( muEvent->eventId() );
214 TChain* chain = muDstMaker->
chain();
216 TObjString inputfile(chain->GetFile()->GetName());
217 mEvent->setMudstFileName(inputfile);
218 mEvent->setDateTime(GetDateTime());
221 mEvent->setBbcTimeBin( muEvent->bbcTriggerDetector().onlineTimeDifference() );
222 int Npmt=bbc->numberOfPMTs();
223 for (
int pmt=0;pmt<Npmt;pmt++){
224 if(bbc->adc(pmt) > 5) {
225 if(pmt<16) mEvent->setEbbc(1);
226 if(pmt>23 && pmt<40) mEvent->setWbbc(1);
231 mEvent->setZdcWestRate(muEvent->runInfo().zdcWestRate());
232 mEvent->setZdcEastRate(muEvent->runInfo().zdcEastRate());
233 mEvent->setZdcCoincidenceRate(muEvent->runInfo().zdcCoincidenceRate());
234 mEvent->setBbcWestRate(muEvent->runInfo().bbcWestRate());
235 mEvent->setBbcEastRate(muEvent->runInfo().bbcEastRate());
236 mEvent->setBbcCoincidenceRate(muEvent->runInfo().bbcCoincidenceRate());
240 mEvent->setVpdTdiff(muDst->
btofHeader()->tDiff());
241 mEvent->setVpdZvertex(muDst->
btofHeader()->vpdVz());
242 mEvent->setVpdEastHits(muDst->
btofHeader()->numberOfVpdHits(east));
243 mEvent->setVpdWestHits(muDst->
btofHeader()->numberOfVpdHits(west));
245 mEvent->setNVpdEGoodHits(muDst->
btofHeader()->vpdEGoodHits());
246 mEvent->setNVpdWGoodHits(muDst->
btofHeader()->vpdWGoodHits());
247 mEvent->setEarliestVpdEHit(muDst->
btofHeader()->earliestVpdEHit());
248 mEvent->setEarliestVpdWHit(muDst->
btofHeader()->earliestVpdWHit());
249 mEvent->setClosestVpdEHit(muDst->
btofHeader()->closestVpdEHit());
250 mEvent->setClosestVpdWHit(muDst->
btofHeader()->closestVpdWHit());
251 mEvent->setLatestVpdEHit(muDst->
btofHeader()->latestVpdEHit());
252 mEvent->setLatestVpdWHit(muDst->
btofHeader()->latestVpdWHit());
254 mEvent->setTstart(muDst->
btofHeader()->tStart());
255 mEvent->setNTzero(muDst->
btofHeader()->nTzero());
256 mEvent->setNTzeroCan(muDst->
btofHeader()->nTzeroCan());
257 mEvent->setTCanFirst(muDst->
btofHeader()->tCanFirst());
258 mEvent->setTCanLast(muDst->
btofHeader()->tCanLast());
261 LOG_INFO <<
"BAD BTOFHEADER" << endm;
262 mEvent->setVpdTdiff(-999.);
263 mEvent->setVpdZvertex(-999.);
264 mEvent->setVpdEastHits(-1);
265 mEvent->setVpdWestHits(-1);
266 mEvent->setNVpdEGoodHits(0);
267 mEvent->setNVpdWGoodHits(0);
269 mEvent->setEarliestVpdEHit(99999.);
270 mEvent->setEarliestVpdWHit(99999.);
271 mEvent->setClosestVpdEHit(99999.);
272 mEvent->setClosestVpdWHit(99999.);
273 mEvent->setLatestVpdEHit(-99999.);
274 mEvent->setLatestVpdWHit(-99999.);
276 mEvent->setTstart(-999.);
277 mEvent->setNTzero(0);
278 mEvent->setNTzeroCan(0);
279 mEvent->setTCanFirst(99999.);
280 mEvent->setTCanLast(-99999.);
284 int bx7 = muEvent->l0Trigger().bunchCrossingId7bit(muEvent->runId());
285 int bx48 = muEvent->l0Trigger().bunchCrossingId();
286 mEvent->setBx7( bx7 );
287 mEvent->setBx48( bx48 );
288 mEvent->setSpinBits( muEvent->l0Trigger().spinBits( muEvent->runId() ) );
294 mEvent->setIsValid( spDbMaker->
isValid() );
297 int isMasked = (spDbMaker->isMaskedUsingBX48(bx48)) ? 1 : 0;
298 mEvent->setIsMaskedUsingBx48( isMasked );
299 mEvent->setOffsetBx48minusBX7( spDbMaker->offsetBX48minusBX7(bx48, bx7) );
305 int nVertices = muDst->numberOfPrimaryVertices();
306 for(
int i=0; i<nVertices; ++i){
312 copyVertex(*muVert, skimVert);
313 mEvent->setVert(skimVert);
317 mEvent->setBestVert(0);
323 if (
StTriggerSimuMaker* trigSimu = dynamic_cast<StTriggerSimuMaker*>(GetMakerInheritsFrom(
"StTriggerSimuMaker"))) {
324 if (trigSimu->bemc) {
331 for (
int i = 0; i < 4; ++i)
333 mEvent->setBarrelJetPatchTh(i,trigSimu->bemc->barrelJetPatchTh(i));
334 if(i == 3) mEvent->setBarrelJetPatchTh(i,trigSimu->bemc->barrelJetPatchTh(i+1));
336 for (
int i = 0; i < 4; ++i) mEvent->setBarrelHighTowerTh(i,trigSimu->bemc->barrelHighTowerTh(i));
337 for (
int jp = 0; jp < 18; ++jp) mEvent->setBarrelJetPatchAdc(jp,trigSimu->bemc->barrelJetPatchAdc(jp));
340 if (trigSimu->eemc) {
347 for (
int i = 0; i < 4; ++i)
349 mEvent->setEndcapJetPatchTh(i,trigSimu->eemc->endcapJetPatchTh(i));
351 for (
int i = 0; i < 2; ++i) mEvent->setEndcapHighTowerTh(i,trigSimu->eemc->endcapHighTowerTh(i));
352 for (
int jp = 0; jp < 6; ++jp) mEvent->setEndcapJetPatchAdc(jp,trigSimu->eemc->endcapJetPatchAdc(jp));
356 for (
int i = 0; i < 3; ++i) mEvent->setOverlapJetPatchTh(i,trigSimu->emc->overlapJetPatchTh(i));
357 for (
int jp = 0; jp < 6; ++jp) mEvent->setOverlapJetPatchAdc(jp, trigSimu->emc->overlapJetPatchAdc(jp));
360 mEvent->setEmcLayer2(trigSimu->emc->EM201output());
385 sv.setVertexFinderId( v.vertexFinderId());
386 sv.setRanking( v.ranking() );
387 sv.setNTracksUsed( v.nTracksUsed());
388 sv.setNBTOFMatch( v.nBTOFMatch());
389 sv.setNCTBMatch( v.nCTBMatch());
390 sv.setNBEMCMatch( v.nBEMCMatch());
391 sv.setNEEMCMatch( v.nEEMCMatch());
392 sv.setNCrossingCentralMembrane( v.nCrossCentralMembrane() );
393 sv.setSumTrackPt( v.sumTrackPt());
394 sv.setMeanDip( v.meanDip() );
395 sv.setChiSquared( v.chiSquared() );
396 sv.setRefMultNeg( v.refMultNeg() );
397 sv.setRefMultPos( v.refMultPos() );
398 sv.setRefMultFtpcWest( v.refMultFtpcWest() );
399 sv.setRefMultFtpcEast( v.refMultFtpcEast() );
403 void StJetSkimEventMaker::fillTriggerSimulationInfo(
StJetSkimTrig &skimTrig)
411 skimTrig.setShouldFire(trigSimu->isTrigger(skimTrig.trigId()));
412 skimTrig.setShouldFireBBC(trigResult.bbcDecision());
413 skimTrig.setShouldFireBemc(trigResult.bemcDecision());
414 skimTrig.setShouldFireEemc(trigResult.eemcDecision());
415 skimTrig.setShouldFireL2(trigResult.l2Decision());
417 if (trigResult.bemcDecision()==1){
418 vector<short> towerId = trigResult.highTowerIds();
419 for (
unsigned i=0; i<towerId.size(); i++) {
420 skimTrig.addTowerAboveThreshold(0,towerId[i],trigResult.
highTowerAdc(towerId[i]));
423 vector<short> tpId = trigResult.triggerPatchIds();
424 for (
unsigned i=0; i<tpId.size(); i++) {
425 skimTrig.addTriggerPatchAboveThreshold(0,tpId[i],trigResult.
triggerPatchAdc(tpId[i]));
428 vector<short> jpId = trigResult.jetPatchIds();
429 for (
unsigned i=0; i<jpId.size(); i++) {
430 skimTrig.addJetPatchAboveThreshold(0,jpId[i],trigResult.
jetPatchAdc(jpId[i]));
434 if (trigResult.l2Decision()==1) {
436 int year = GetDBTime().GetYear();
437 const int* L2ResultEmulated = (
int*)trigResult.
l2Result(kJet,year);
438 if (L2ResultEmulated) {
439 skimTrig.setL2ResultEmulated(L2ResultEmulated);
442 LOG_WARN <<
"No emulated L2 result for trigger ID = " << skimTrig.trigId() <<
" of year = " << year << endm;
445 }
else if (emcTrigMaker) {
446 skimTrig.setShouldFire(emcTrigMaker->
isTrigger(skimTrig.trigId()));
449 for(map<int,int>::const_iterator it=towerMap.begin(); it!=towerMap.end(); it++) {
450 skimTrig.addTowerAboveThreshold(0,it->first, it->second);
453 towerMap = emcTrigMaker->endcapTowersAboveThreshold(skimTrig.trigId());
454 for(map<int,int>::const_iterator it=towerMap.begin(); it!=towerMap.end(); it++) {
455 skimTrig.addTowerAboveThreshold(1,it->first, it->second);
459 for(map<int,int>::const_iterator it=triggerPatchMap.begin(); it!=triggerPatchMap.end(); it++) {
460 skimTrig.addTriggerPatchAboveThreshold(0,it->first, it->second);
463 triggerPatchMap = emcTrigMaker->endcapTriggerPatchesAboveThreshold(skimTrig.trigId());
464 for(map<int,int>::const_iterator it=triggerPatchMap.begin(); it!=triggerPatchMap.end(); it++) {
465 skimTrig.addTriggerPatchAboveThreshold(1,it->first, it->second);
469 for(map<int,int>::const_iterator it=jetPatchMap.begin(); it!=jetPatchMap.end(); it++) {
470 skimTrig.addJetPatchAboveThreshold(0,it->first, it->second);
473 jetPatchMap = emcTrigMaker->endcapJetPatchesAboveThreshold(skimTrig.trigId());
474 for(map<int,int>::const_iterator it=jetPatchMap.begin(); it!=jetPatchMap.end(); it++) {
475 skimTrig.addJetPatchAboveThreshold(1,it->first, it->second);
478 skimTrig.setTotalEnergy(emcTrigMaker->
totalEnergy());
481 LOG_WARN <<
"StJetSkimEventMaker::fillTriggerSimulationInfo --- no StTriggerSimuMaker or StEmcTriggerMaker" << endm;
491 if (trigSimu && trigSimu->bemc) {
492 header.eastBarrelTowerThreshold = (trigSimu->bemc)->getTowerThreshold(header.trigId,15);
493 header.eastBarrelTriggerPatchThreshold = (trigSimu->bemc)->getTriggerPatchThreshold(header.trigId,15);
494 header.eastBarrelJetPatchThreshold = (trigSimu->bemc)->getJetPatchThreshold(header.trigId,15);
495 header.westBarrelTowerThreshold = (trigSimu->bemc)->getTowerThreshold(header.trigId,0);
496 header.westBarrelTriggerPatchThreshold = (trigSimu->bemc)->getTriggerPatchThreshold(header.trigId,0);
497 header.westBarrelJetPatchThreshold = (trigSimu->bemc)->getJetPatchThreshold(header.trigId,0);
498 }
else if (emcTrigMaker) {
505 header.endcapTowerThreshold = emcTrigMaker->endcapTowerThreshold(header.trigId);
506 header.endcapTriggerPatchThreshold = emcTrigMaker->endcapTriggerPatchThreshold(header.trigId);
507 header.endcapJetPatchThreshold = emcTrigMaker->endcapJetPatchThreshold(header.trigId);
510 LOG_WARN <<
"StTriggerSimuMaker/StEmcTriggMaker not in Chain..." << endm;
524 void StJetSkimEventMaker::Clear(
const Option_t* c)
map< Int_t, Float_t > getTotalPrescales()
static StMuPrimaryVertex * primaryVertex()
return pointer to current primary vertex
bool isPolDirTrans()
true if all needed DB tables were found
bool isValid()
dump spinDb content for current time stamp
int jetPatchAdc(short jetPatchId) const
returns DSM ADC if above trigger threshold, otherwise -1
int highTowerAdc(short towerId) const
returns DSM ADC if above trigger threshold, otherwise -1
int totalEnergyThreshold(int trigId)
DSM ADC threshold for ETOT trigger. ADC > threshold required to fire trigger.
int spin4usingBX48(int bx48)
8bit spin information
map< int, int > barrelTriggerPatchesAboveThreshold(int trigId)
map contains (key,value) = (patchId,ADC) of all TP above DSM threshold. map is empty if threshold = 0...
int barrelJetPatchThreshold(int trigId, int patchId=1)
Jet Patch ADC > threshold required to fire trigger.
Accessor to the database for trigger id information.
int totalEnergy()
ADC calculated for ETOT trigger.
int barrelTowerThreshold(int trigId, int softId=1)
Tower ADC > threshold required to fire trigger.
int barrelTriggerPatchThreshold(int trigId, int patchId=1)
Trigger Patch ADC > threshold required to fire trigger.
map< int, int > barrelJetPatchesAboveThreshold(int trigId)
map contains (key,value) = (patchId,ADC) of all JP above DSM threshold. map is empty if threshold = 0...
static StMuEvent * event()
returns pointer to current StMuEvent (class holding the event wise information, e.g. event number, run number)
TChain * chain()
In read mode, returns pointer to the chain of .MuDst.root files that where selected.
map< int, int > barrelTowersAboveThreshold(int trigId)
map contains (key,value) = (softId,ADC) of all towers above DSM threshold. map is empty if threshold ...
static StBTofHeader * btofHeader()
returns pointer to the btofHeader - dongx
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
const unsigned int * l2Result(L2ResultType algo, int year=2006) const
returns address of specific L2 result struct – cast it yourself
int isTrigger(int trigId)
1==Yes,0==No,-1==Don't Know. Same convention holds for other methods where appropriate.
bool isPolDirLong()
Returns true if beams are transversely polarized, false otherwise.