#include "IBasicHeaderModule.hxx" #include "IG4PrimaryParticle.hxx" #include "IG4PrimaryVertex.hxx" #include "IRealDatum.hxx" #include "IIntegerDatum.hxx" #include "ISIMG4Header.hxx" // include to get environment variables for software version #include ClassImp(COMET::IBasicHeaderModule); #define CVSTAG "\ $Name: v5r19 $" #define CVSID "\ $Id: IBasicHeaderModule.cxx,v 1.27 2012/05/11 18:40:05 wilking Exp $" COMET::IBasicHeaderModule::IBasicHeaderModule(const char *name, const char *title) { SetNameTitle(name, title); // Enable this module by default: fIsEnabled = kTRUE; fDescription = "Standard module which fills the standard header information about an event"; fCVSTagName = CVSTAG; fCVSID = CVSID; fSoftware = false; // Set fEventTRef = new TRef; } COMET::IBasicHeaderModule::~IBasicHeaderModule() {} Bool_t COMET::IBasicHeaderModule::Configure(std::string &option){ if(option.find("version")!=std::string::npos){ fSoftware = true; } return true; } void COMET::IBasicHeaderModule::InitializeBranches() { //HEADER INFO fOutputTree->Branch("EventTRef", "TRef", &fEventTRef, fBufferSize, 0); fOutputTree->Branch("EventTime", &fEventTime, "EventTime/i", fBufferSize); fOutputTree->Branch("TriggerWord",&fTriggerWord,"TriggerWord/l", fBufferSize); fOutputTree->Branch("FGDCosmicEvent",&fFGDCosmicEvent,"FGDCosmicEvent/O", fBufferSize); fOutputTree->Branch("TripTCosmicEvent",&fTripTCosmicEvent,"TripTCosmicEvent/O", fBufferSize); fOutputTree->Branch("CTMTriggerPattern",fCTMTriggerPattern,"CTMTriggerPattern[3]/l", fBufferSize); fOutputTree->Branch("TripTCosmicTriggerType", &fTripTCosmicTriggerType, "TripTCosmicTriggerType/I", fBufferSize); fOutputTree->Branch("TripTCosmicTriggerUpward", &fTripTCosmicTriggerUpward, "TripTCosmicTriggerUpward/I", fBufferSize); fOutputTree->Branch("CosmicPrescaleWeight", &fCosmicPrescaleWeight, "CosmicPrescaleWeight/D", fBufferSize); fOutputTree->Branch("SoftwareVersion", fSoftwareVersion, "SoftwareVersion/C", fBufferSize); //Get context info fOutputTree->Branch("Partition", &fPartition, "Partition/I", fBufferSize); fOutputTree->Branch("Spill", &fSpill, "Spill/I", fBufferSize); fOutputTree->Branch("TimeStamp", &fTimeStamp, "TimeStamp/I", fBufferSize); fOutputTree->Branch("IsDetector", &fIsDetector, "IsDetector/B", fBufferSize); fOutputTree->Branch("IsMC", &fIsMC, "IsMC/B", fBufferSize); fOutputTree->Branch("P0DWaterStatus", &fP0DWaterStatus, "P0DWaterStatus/B", fBufferSize); fOutputTree->Branch("GeometryHash", fGeometryHash, "GeometryHash[5]/i", fBufferSize); fOutputTree->Branch("AlignmentId", fAlignmentId, "fAlignmentId[5]/i", fBufferSize); // MC header information fOutputTree->Branch("Intensity", &fMCIntensity, "Intensity/F", fBufferSize); } bool COMET::IBasicHeaderModule::FillTree(COMET::ICOMETEvent& event) { //a reference back to the original event (does currently not work for me) // *fEventTRef = fEvent; //TEMP COMET::ICOMETContext context = event.GetContext(); fPartition = context.GetPartition(); fSpill = context.GetSpill(); fTimeStamp = context.GetTimeStamp(); fIsDetector = context.IsDetector(); fIsMC = context.IsMC(); fP0DWaterStatus = this->P0DWaterStatus(); COMET::ISHAHashValue geoHash = event.GetGeometryHash(); COMET::IAlignmentId alignId = event.GetAlignmentId(); for (std::size_t i = 0; i < 5; ++i){ fGeometryHash[i] = geoHash(i); fAlignmentId[i] = alignId(i); } fMCIntensity = 0; if(event.Get("truth/mcHeader")){ fMCIntensity = event.Get("truth/mcHeader")->GetIntensity(); } if(fSoftware){ char * softwareVersionChar = getenv("COMETROOT"); if(softwareVersionChar == NULL){ strcpy(fSoftwareVersion, "NULL"); COMETWarn("Couldn't find COMETROOT, setting fSoftwareVersion to \"0\""); } else{ std::string softwareVersionString = softwareVersionChar; size_t lastSlash = softwareVersionString.find_last_of("/"); softwareVersionString = softwareVersionString.substr(lastSlash+1); strcpy(fSoftwareVersion, softwareVersionString.c_str()); } } else{ strcpy(fSoftwareVersion, "NULL"); COMETWarn("Software version command line option not set, setting fSoftwareVersion to \"0\""); } fEventTime = event.GetHeader().GetMCMSecond(); fTriggerWord = event.GetHeader().GetTriggerWord(); ULong64_t one = 1; ULong64_t shift = one<<55; fTripTCosmicEvent = shift&fTriggerWord; shift = one<< 56; fFGDCosmicEvent = shift&fTriggerWord; for (int i=0; i<3; i++) { fCTMTriggerPattern[i] = event.GetHeader().GetCTMTriggerPattern(i); } fTripTCosmicTriggerType = -1; if (event.Has("triptCosmicTriggerType")) { fTripTCosmicTriggerType = event.Get("triptCosmicTriggerType")->GetValue(); } fTripTCosmicTriggerUpward = -1; if (event.Has("triptCosmicTriggerUpward")) { fTripTCosmicTriggerUpward = event.Get("triptCosmicTriggerUpward")->GetValue(); } fCosmicPrescaleWeight = 1; if (event.Has("CosmicPrescaleWeight")) { fCosmicPrescaleWeight = event.Get("CosmicPrescaleWeight")->GetValue(); } return true; } Bool_t COMET::IBasicHeaderModule::ProcessFirstEvent(COMET::ICOMETEvent&) { return true; } bool COMET::IBasicHeaderModule::P0DWaterStatus() { double depth = COMET::IGeomInfo::Get().P0D().TargetDepth(); if (depth < 1000.0) { return false; } else { return true; } return false; }