#include #include "cometEventLoop.hxx" #include "ICosmicTrigger.hxx" #include "IRealDatum.hxx" #include "IIntegerDatum.hxx" #include #include /// Program to run the cosmic trigger simulation and save output. class IRunCosmicTriggerLoop: public COMET::ICOMETEventLoopFunction { protected: ICosmicTrigger *fTrigger; ULong64_t wordsseen[100]; int ntimesseen[100]; int nwordsseen; int ntriggers; int CPWeight; public: IRunCosmicTriggerLoop() {fTrigger = 0;}; virtual ~IRunCosmicTriggerLoop() {delete fTrigger;}; bool operator () (COMET::ICOMETEvent& event) { COMET::ICOMETEvent::Header myHeader = event.GetHeader(); ULong64_t triggerBits = myHeader.GetTriggerBits(); // Get the words containing which trigger primitives fired ULong64_t CTMword[3]; for(int i=0; i<3;++i){ CTMword[i] = myHeader.GetCTMTriggerPattern(i); // std::cout << CTMword[i] << std::endl; } //std::cout << CTMword[2] << std::endl; COMET::IHandle trigtype = event.Get("triptCosmicTriggerType"); COMET::IHandle trigupward = event.Get("triptCosmicTriggerUpward"); COMET::IHandle preweight = event.Get("CosmicPrescaleWeight"); std::cout << "prescale weight = " << preweight->GetValue() << std::endl; double tt = 0; if(trigtype){ tt = trigtype->GetValue(); // std::cout << tt << std::endl; htrigtype->Fill(tt); hupdown->Fill(trigupward->GetValue()); ntriggers++; } ULong64_t testbit; for(int i=0;i<32;++i){ // fill P0D primitives histogram testbit = 1; testbit = testbit<Fill(i); //std::cout << "P0D bit " << i << " " << testbit << std::endl; if(tt==12||tt==8||tt==10||tt==14||tt==6){ hprimtrigP0D->SetBinContent(i,hprimtrigP0D->GetBinContent(i)+1); }else{ hprimnotP0D->SetBinContent(i,hprimnotP0D->GetBinContent(i)+1); } } testbit = testbit<<32; if(CTMword[2]&(testbit)){ hprimitivesECAL->SetBinContent(i,hprimitivesECAL->GetBinContent(i)+1); //std::cout << "ECAL bit " << i << " " << testbit << std::endl; if(tt==13||tt==9||tt==11||tt==14||tt==7){ hprimtrigECAL->SetBinContent(i,hprimtrigECAL->GetBinContent(i)+1); }else{ hprimnotECAL->SetBinContent(i,hprimnotECAL->GetBinContent(i)+1); } } } // ULong64_t triggerWord = (myHeader.GetTriggerWord() & 0x03ff000000000000) >> 48; if (trigtype) { // std::cout << "trigtype, trigupward = " << trigtype->GetValue() << ", " << trigupward->GetValue() << std::endl; } bool seen = false; for (int i=0; iSetBinContent(i,0); hprimitivesP0D->SetBinContent(i,0); hprimtrigECAL->SetBinContent(i,0); hprimtrigP0D->SetBinContent(i,0); hprimnotECAL->SetBinContent(i,0); hprimnotP0D->SetBinContent(i,0); if(i<=21)htrigtype->SetBinContent(i,0); if(i<=3)hupdown->SetBinContent(i,0); } }; void Finalize(COMET::ICOMETOutput* output) { std::cout << "saw " << nwordsseen << " words" << std::endl; for (int i=0; iDraw(); gPad->Print("ECALAllprimitivesFired.C"); hprimitivesP0D->Draw(); gPad->Print("P0DAllprimitivesFired.C"); hprimtrigECAL->Draw(); gPad->Print("ECALprimitivesFiredInGlobal.C"); hprimtrigP0D->Draw(); gPad->Print("P0DprimitivesFiredInGlobal.C"); hprimnotECAL->Draw(); gPad->Print("ECALprimitivesFiredOther.C"); hprimnotP0D->Draw(); gPad->Print("P0DprimitivesFiredOther.C"); htrigtype->Draw(); gPad->Print("GlobalTriggerTypes.C"); hupdown->Draw(); gPad->Print("UpDown.C"); std::cout << "Number of cosmic triggers generated = " << ntriggers << std::endl; }; private: TH1F *hprimitivesECAL; TH1F *hprimitivesP0D; TH1F *hprimtrigECAL; TH1F *hprimtrigP0D; TH1F *hprimnotECAL; TH1F *hprimnotP0D; TH1F *htrigtype; TH1F *hupdown; }; int main(int argc, char **argv) { IRunCosmicTriggerLoop userCode; cometEventLoop(argc,argv,userCode); }