#include #include #include #include "TROOT.h" #include "TFolder.h" #include "TNamed.h" #include #include "RawDataBanks/CLLD_StorableBank.hh" #include "RawDataBanks/CTMD_StorableBank.hh" #include "CosmicObjects/CosmicRayInfo.hh" #include #include "MuonObjects/CdfMuonColl.hh" #include "ElectronObjects/CdfEmObjectColl.hh" #include #include #include #include #include //_____________________________________________________________________________ Int_t StntupleInitHeaderBlock(TStnDataBlock* block, AbsEvent* event, int mode) { // Run II version, section number is defined static TFolder* fol = NULL; static TNamed* processName = NULL; static TNamed* muonCollName = NULL; static TNamed* electronCollName = NULL; static TNamed* tauCollName = NULL; if (! fol) { //----------------------------------------------------------------------------- // initialize local static variables //----------------------------------------------------------------------------- fol = (TFolder*) gROOT->GetRootFolder()->FindObject("StntupleFolder"); processName = (TNamed*) fol->FindObject("ProcessName"); muonCollName = (TNamed*) fol->FindObject("MuonCollName"); electronCollName = (TNamed*) fol->FindObject("ElectronCollName"); tauCollName = (TNamed*) fol->FindObject("TauCollName"); } TStnHeaderBlock* header = (TStnHeaderBlock*) block; header->fEventNumber = gblEnv->trigNumber(); header->fRunNumber = gblEnv->runNumber(); header->fSectionNumber = gblEnv->sectionNumber(); header->fMcFlag = gblEnv->monteFlag(); header->fNLCent = -1; header->fNLPlug = -1; header->fNLepton = -1; header->fInstLum = -1; header->fNTracks = -1; header->fNCdfMuons = -1; header->fNCdfEmObjects = -1; header->fNCdfTaus = -1; header->fEOut = TStnDataBlock::kUndefined; header->fPressure = TStnDataBlock::kUndefined; header->fEmFraction = TStnDataBlock::kUndefined; header->fChFraction = TStnDataBlock::kUndefined; header->fNTowersOot = -1; //----------------------------------------------------------------------------- // define number of tracks, muons, em objects, taus etc //----------------------------------------------------------------------------- CdfTrackView_h track_hndl; CdfTrackView::Error trackStatus; trackStatus = CdfTrackView::defTracks(track_hndl,processName->GetTitle()); if (trackStatus == CdfTrackView::OK) { header->fNTracks=track_hndl->contents().size(); } EventRecord::ConstIterator itr_muon; itr_muon = StntupleGetIterator(event,"CdfMuonColl", processName->GetTitle(), muonCollName->GetTitle()); if(itr_muon.is_valid()){ CdfMuonColl_ch muon_hndl(itr_muon); header->fNCdfMuons=muon_hndl->contents().size(); } EventRecord::ConstIterator itr_electron; itr_electron = StntupleGetIterator(event,"CdfEmObjectColl", processName->GetTitle(), electronCollName->GetTitle()); if(itr_electron.is_valid()){ CdfEmObjectColl_ch electron_hndl(itr_electron); header->fNCdfEmObjects= electron_hndl->contents().size(); } EventRecord::ConstIterator itr_tau; itr_tau = StntupleGetIterator(event,"CdfTauCollection", processName->GetTitle(), tauCollName->GetTitle()); if(itr_tau.is_valid()){ ConstHandle tau_hndl(itr_tau); header->fNCdfTaus= tau_hndl->contents().size(); } CosmicRayInfo_ch cosmic; CosmicRayInfo::Error cosmicStatus = CosmicRayInfo::find(cosmic); if (cosmicStatus != CosmicRayInfo::ERROR) { header->fEOut = cosmic->outOfTimeEmEnergy()+cosmic->outOfTimeHadronEnergy(); header->fEmFraction = cosmic->eventEmFraction(); header->fChFraction = cosmic->eventChargeFraction(); header->fNTowersOot = cosmic->outOfTimeTowers(); } //----------------------------------------------------------------------------- // instantaneous luminosity //----------------------------------------------------------------------------- EventRecord::ConstIterator clld_iter(event, "CLLD_StorableBank"); if (clld_iter.is_valid()) { ConstHandle clld(clld_iter); header->fInstLum = clld->get_l_inst(); } // air pressue EventRecord::ConstIterator ictmd(event,"CTMD_StorableBank"); if(ictmd.is_valid()) { ConstHandle hCTMD(ictmd); header->fPressure = hCTMD->average_pressure(); } return 0; } //_____________________________________________________________________________ Int_t StntupleHeaderBlockLinks(TStnDataBlock* Block, AbsEvent* Event, int Mode) { // Run II version, section number is defined Int_t ev_number, rn_number; ev_number = AbsEnv::instance()->trigNumber(); rn_number = AbsEnv::instance()->runNumber(); if (! Block->Initialized(ev_number,rn_number)) return -1; // do not do initialize links 2nd time if (Block->LinksInitialized()) return 0; TStnHeaderBlock* header = (TStnHeaderBlock*) Block; TStnEvent* ev = header->GetEvent(); TObjArray* hptl = (TObjArray*) ev->FindObject("StntupleHptl"); int nhptl = hptl->GetEntriesFast(); header->fNLCent = nhptl; //----------------------------------------------------------------------------- // mark links as initialized //----------------------------------------------------------------------------- header->fLinksInitialized = 1; return 0; }