/////////////////////////////////////////////////////////////////////////////// // STNTUPLE trigger block stores all the trigger banks of interest // P.Murat (CDF/FNAL) /////////////////////////////////////////////////////////////////////////////// #include "BaBar/Experiment.hh" #include "Edm/EventRecord.hh" #include "Edm/ConstHandle.hh" #include "AbsEnv/AbsEnv.hh" #include "TriggerObjects/TL2D_StorableBank.hh" #include "TriggerObjects/TL3D_StorableBank.hh" #include "Level3Objects/Level3ModuleResults.hh" #include "Bbos/bank_interface.hh" #include "Stntuple/mod/InitStntupleDataBlocks.hh" #include "Stntuple/mod/StntupleUtilities.hh" #include "Stntuple/obj/TStnTriggerBlock.hh" #include "Stntuple/obj/TStnDBManager.hh" Int_t StntupleUnpackTL1DBank(TRYBOS_BANK* bank, TTl1d* tl1d); //_____________________________________________________________________________ Int_t StntupleInitTriggerBlock(TStnDataBlock* block, AbsEvent* event, int mode) { // initialize trigger data block with the `event' data // return -1, if bank doesn't exist, 0, if everything is OK TTl3d* tl3d; int npaths, l3_source, run_num, use_tl3d; run_num = AbsEnv::instance()->runNumber(); TStnTriggerBlock* trig_block = (TStnTriggerBlock*) block; trig_block->Clear(); EventRecord::ConstIterator ci; //----------------------------------------------------------------------------- // TSID //----------------------------------------------------------------------------- ci = StntupleGetIterator(event,"TSID_StorableBank","RAW",0); if (ci.is_valid()) { TRYBOS_BANK* tsid = (TRYBOS_BANK*) ci.operator->(); memcpy(trig_block->Tsid()->Data(),tsid->data(),4*sizeof(int)); } //----------------------------------------------------------------------------- // TFRD //----------------------------------------------------------------------------- ci = StntupleGetIterator(event,"TFRD_StorableBank","RAW",0); if (ci.is_valid()) { TRYBOS_BANK* tfrd = (TRYBOS_BANK*) ci.operator->(); memcpy(trig_block->Tfrd()->Data(),tfrd->data()+6,11*sizeof(int)); } //----------------------------------------------------------------------------- // TL1D //----------------------------------------------------------------------------- ci = StntupleGetIterator(event,"TL1D_StorableBank","RAW",0); if (ci.is_valid()) { TRYBOS_BANK* tl1d = (TRYBOS_BANK*) ci.operator->(); StntupleUnpackTL1DBank(tl1d,trig_block->Tl1d()); } //----------------------------------------------------------------------------- // TL2D //----------------------------------------------------------------------------- ci = StntupleGetIterator(event,"TL2D_StorableBank","RAW",0); if (ci.is_valid()) { TRYBOS_BANK* tl2d = (TRYBOS_BANK*) ci.operator->(); TStnArrayI* data = trig_block->Tl2d()->Data(); int offset = 2 + tl2d->data()[0]; int nw = tl2d->data_size()-offset; // assuming 'data' is empty data->Append(tl2d->data()+offset,nw); } //----------------------------------------------------------------------------- // TCMD //----------------------------------------------------------------------------- ci = StntupleGetIterator(event,"TCMD_StorableBank","RAW",0); if (ci.is_valid()) { TRYBOS_BANK* tcmd = (TRYBOS_BANK*) ci.operator->(); TStnArrayI* data = trig_block->Tcmd()->Data(); int nw = tcmd->data_size()-3; // assuming 'data' is empty data->Append(tcmd->data()+3,nw); } //----------------------------------------------------------------------------- // Jun 03 2003 P.Murat // Level3 history: we started from using TL3D bank, some time after // Level3ModuleResults has been implemented. For a while both were present // in the event record and one could use either of them. When we moved to // 4.8.4-based L3 executable (trig table PHYSICS_1_04, first good run - 155368) // TL3D contents has changed, so despite its presence, L3 bit info could only // be retrieved from Level3ModuleResults. // Finally TL3D has been dropped. So do as Level3 was doing: // for runs < 155368 prefer TL3D, for later runs use L3ModuleResults // l3_source = 2: force use of L3ModuleResults for the runs < 155368 //----------------------------------------------------------------------------- tl3d = trig_block->Tl3d(); l3_source = trig_block->L3Source(); EventRecord::ConstIterator iter (event,"TL3D_StorableBank" ); EventRecord::ConstIterator l3r_iter(event,"Level3ModuleResults"); if (run_num < 155368) use_tl3d = 1; else use_tl3d = 0; if (l3_source == 2) use_tl3d = 0; if (use_tl3d) { //----------------------------------------------------------------------------- // use TL3D requested, use it if it is present - the code should not crash //----------------------------------------------------------------------------- if (iter.is_valid()) { ConstHandle tl3d_bank(iter); npaths = tl3d_bank->nPaths(); tl3d->Init(npaths); // now loop over the paths and fill path // bits (one bit per path, 1=passed) for (Int_t i=0; ididPathPass(i)) { tl3d->Paths()->SetBit(i); } } } } else if (l3r_iter.is_valid()) { //----------------------------------------------------------------------------- // Level3ModuleResults is present, use it //----------------------------------------------------------------------------- ConstHandle l3r(l3r_iter); npaths = l3r->numberOfPath(); tl3d->Init(npaths); // now loop over the paths and fill path // bits (one bit per path, 1=passed) for (Int_t i=0; ithisEventPassedPath(i)) { tl3d->Paths()->SetBit(i); } } } if (iter.is_valid()) { //----------------------------------------------------------------------------- // N(paths) etc information is only available in TL3D - I dont' know how to // find it otherwise //----------------------------------------------------------------------------- ConstHandle tl3d_bank(iter); tl3d->SetNModSeq (tl3d_bank->nModuleSequences()); tl3d->SetL3ExeVersion(tl3d_bank->getExeVersion()); tl3d->SetPhysTable (tl3d_bank->getPhysicsTable()); tl3d->SetCalibJobSet (tl3d_bank->getCalibJobSet()); } //----------------------------------------------------------------------------- // SVT beamline // ------------------------------------------- float beam3D[4]; UnpackSvtBeamline(event,beam3D); trig_block->SetBeamSpot(beam3D); //----------------------------------------------------------------------------- // initialize L*Info bits - this is an example // ------------------------------------------- // L1 "generic" bits: // electron word: // bit 0: one of "L1_CEM" triggers is fired // jet word: // bit 0: one of "L1_JET" triggers is fired // // Note: L2 and L3 bits can be handled exactly the same //----------------------------------------------------------------------------- TObjArray* list = new TObjArray(200); // get trigger table TStnDBManager* dbm = TStnDBManager::Instance(); TStnTriggerTable* tbl = (TStnTriggerTable*) dbm->GetTable("TriggerTable"); int ntrig; // electron L1 triggers ntrig = trig_block->GetListOfPassedTriggers(tbl,"L1_CEM",1,list); if (ntrig > 0) trig_block->L1Info()->SetElectronBit(0); // jet L1 triggers ntrig = trig_block->GetListOfPassedTriggers(tbl,"L1_JET",1,list); if (ntrig > 0) trig_block->L1Info()->SetJetBit(0); // Photon Triggers... //EM8 ntrig = trig_block->GetListOfPassedTriggers(tbl,"Photon_L3tag_L3PS20",3,list) + trig_block->GetListOfPassedTriggers(tbl,"Photon_L3PS200_L1_EM8",3,list); if (ntrig > 0) trig_block->L3Info()->SetPhotonBit(0); //EM12 ntrig = trig_block->GetListOfPassedTriggers(tbl,"Photon_L1_EM12_L3PS20",3,list) + trig_block->GetListOfPassedTriggers(tbl,"Photon_L3PS40_L1_EM12",3,list); if (ntrig > 0) trig_block->L3Info()->SetPhotonBit(1); //25 No Iso ntrig = trig_block->GetListOfPassedTriggers(tbl,"Photon_25:",3,list); if (ntrig > 0) trig_block->L3Info()->SetPhotonBit(2); //25 Iso ntrig = trig_block->GetListOfPassedTriggers(tbl,"Photon_25_ISO",3,list); if (ntrig > 0) trig_block->L3Info()->SetPhotonBit(3); //35 Iso ntrig = trig_block->GetListOfPassedTriggers(tbl,"Photon_35_ISO",3,list); if (ntrig > 0) trig_block->L3Info()->SetPhotonBit(4); //50 NoIso ntrig = trig_block->GetListOfPassedTriggers(tbl,"Photon_50",3,list); if (ntrig > 0) trig_block->L3Info()->SetPhotonBit(5); // ... and so on list->Clear(); delete list; return 0; }