//*-- AUTHOR : j.Markert //_HADES_CLASS_DESCRIPTION /////////////////////////////////////////////////////////////////////////////// // // HMdcTrigger // // /////////////////////////////////////////////////////////////////////////////// using namespace std; #include "hmdctrigger.h" #include "hmdcdef.h" #include "hdebug.h" #include "hades.h" #include "hiterator.h" #include "hruntimedb.h" #include "hspectrometer.h" #include "hdetector.h" #include "hevent.h" #include "heventheader.h" #include "hcategory.h" #include "hlinearcategory.h" #include "hstartcal.h" #include #include #include #include "TH1.h" #include "TH2.h" #include "TFile.h" ClassImp(HMdcTrigger) HMdcTrigger::HMdcTrigger(void) { calStartCat=NULL; iter_start=NULL; dotimecut = kFALSE; startbit=kFALSE; tofbit=kFALSE; tofinobit=kFALSE; fillcontrolhists=kFALSE; binnum0 =1; binnum1 =1; binnum2 =1; binnum3 =1; binnum4 =1; binnum5 =1; binnum6 =1; binnum7 =1; binnum8 =1; binnum9 =1; binnum10 =1; binnum11 =1; binnum12 =1; binnum13 =1; binnum14 =1; binnum15 =1; bin0 =1; bin1 =1; bin2 =1; bin3 =1; bin4 =1; bin5 =1; bin6 =1; bin7 =1; bin8 =1; bin9 =1; bin10 =1; bin11 =1; bin12 =1; bin13 =1; bin14 =1; bin15 =1; countnocut=0; countmultiplicityStartcut=0; counttimewindowStartcut=0; countskipedevents=0; maxbinnum=10000; maxX=9999; setDefaultTimeWindow(); setStartMultiplicityCut(1,2); setVetoMultiplicityCut(0,1); setTofMultiplicityCut(1,2); setTofinoMultiplicityCut(1,2); } HMdcTrigger::HMdcTrigger(Text_t* name,Text_t* title) : HReconstructor(name,title) { calStartCat=NULL; iter_start=NULL; dotimecut = kFALSE; startbit=kFALSE; tofbit=kFALSE; tofinobit=kFALSE; fillcontrolhists=kFALSE; binnum0 =1; binnum1 =1; binnum2 =1; binnum3 =1; binnum4 =1; binnum5 =1; binnum6 =1; binnum7 =1; binnum8 =1; binnum9 =1; binnum10 =1; binnum11 =1; binnum12 =1; binnum13 =1; binnum14 =1; binnum15 =1; bin0 =1; bin1 =1; bin2 =1; bin3 =1; bin4 =1; bin5 =1; bin6 =1; bin7 =1; bin8 =1; bin9 =1; bin10 =1; bin11 =1; bin12 =1; bin13 =1; bin14 =1; bin15 =1; countnocut=0; countmultiplicityStartcut=0; counttimewindowStartcut=0; countskipedevents=0; maxbinnum=10000; maxX=9999; setDefaultTimeWindow(); setStartMultiplicityCut(0,10); setVetoMultiplicityCut(0,10); setTofMultiplicityCut(0,10); setTofinoMultiplicityCut(0,10); } HMdcTrigger::~HMdcTrigger(void) { // destructor deletes the iterator if (iter_start) delete iter_start; iter_start=0; if(file && fillcontrolhists) writeHist(file); if (fNameRootTrigger) delete fNameRootTrigger; } void HMdcTrigger::setDefaultTimeWindow() { // Sets the the default values for the cut in starttime for each single strip //setTimeWindowStart(37.2,38.2,36.3,37.5,37.3,38.5,36.5,37.7,0,1000,0,1000,0,1000,0,1000); setTimeWindowStart(-1000.,1000.,-1000.,1000.,-1000.,1000.,-1000.,1000.,-1000.,1000.,-1000.,1000.,-1000.,1000.,-1000.,1000.); setTimeWindowVeto (-1000.,1000.,-1000.,1000.,-1000.,1000.,-1000.,1000.,-1000.,1000.,-1000.,1000.,-1000.,1000.,-1000.,1000.); } void HMdcTrigger::setOutputRoot(Char_t *c) { // Sets rootfile output of HMdcTrigger where all created histograms were written. // if (fNameRootTrigger) delete fNameRootTrigger; fNameRootTrigger = new Char_t[strlen(c)+1]; strcpy(fNameRootTrigger, c); } Bool_t HMdcTrigger::init(void) { cout<<"init hmdctrigger"<getCurrentEvent()->getCategory(catStartCal); //???? if (!calStartCat) { calStartCat=gHades->getSetup()->getDetector("Start")->buildCategory(catStartCal); if (!calStartCat) return kFALSE; else gHades->getCurrentEvent()->addCategory(catStartCal,calStartCat,"Start"); } iter_start=(HIterator *)calStartCat->MakeIterator("native"); //TFile *file = NULL; if (fNameRootTrigger && fillcontrolhists) {file = new TFile(fNameRootTrigger,"RECREATE");} if (file && fillcontrolhists) createHist(file); cout<<"****************************************************************************"<cd(); hstartcutstat->Write(); hstart_time_s0to7->Write(); hstart_time_s0to7_clean->Write(); hstart_time_s8to15->Write(); hstart_time_s8to15_clean->Write(); hstartvetodistribution->Write(); hstartvetodistribution_clean->Write(); for(Int_t i=0;i<8;i++){ hstart_time[i]->Write(); hstart_time_clean[i]->Write();; // hstart_time_history[i]->Write(); // hstart_time_history_clean[i]->Write(); hveto_time[i]->Write(); hveto_time_clean[i]->Write();; // hveto_time_history[i]->Write(); // hveto_time_history_clean[i]->Write(); } // close root file file->Save(); file->Close(); delete file; } void HMdcTrigger::createHist(TFile* file) { file->cd(); cout<<"creating histograms"<SetXTitle("start multiplicity"); hstartvetodistribution->SetYTitle("veto multiplicity"); hstartvetodistribution_clean= new TH2F("start_veto_distribution_clean","start veto distribution clean",100,0,10,100,0,10); hstartvetodistribution_clean->SetXTitle("start multiplicity"); hstartvetodistribution_clean->SetYTitle("veto multiplicity"); for(Int_t i=0;i<8;i++){ Char_t title[60], tmp[60]; sprintf(title,"%s%i","start time strip",i); sprintf(tmp, "%s%i", "hstart_time_s",i); hstart_time[i] = new TH1F(tmp, title,400 ,-20,20); sprintf(title,"%s%i%s","start time strip",i," clean"); sprintf(tmp, "%s%i%s", "hstart_time_s",i,"_clean"); hstart_time_clean[i] = new TH1F(tmp, title,400 ,-20,20); sprintf(title,"%s%i","start time history strip",i); sprintf(tmp, "%s%i", "hstart_time_history_s",i); // hstart_time_history[i] = new TH1F(tmp, title,maxbinnum ,0,maxbinnum); sprintf(title,"%s%i%s","start time history strip",i," clean"); sprintf(tmp, "%s%i%s", "hstart_time_history_s",i,"_clean"); // hstart_time_history_clean[i] = new TH1F(tmp, title,maxbinnum ,0,maxbinnum); } for(Int_t i=0;i<8;i++){ Char_t title[60], tmp[60]; sprintf(title,"%s%i","veto time strip",i); sprintf(tmp, "%s%i", "hveto_time_s",i); hveto_time[i] = new TH1F(tmp, title,400 ,-20,20); sprintf(title,"%s%i%s","veto time strip",i," clean"); sprintf(tmp, "%s%i%s", "hveto_time_s",i,"_clean"); hveto_time_clean[i] = new TH1F(tmp, title,400 ,-20,20); sprintf(title,"%s%i","veto time history strip",i); sprintf(tmp, "%s%i", "hveto_time_history_s",i); // hveto_time_history[i] = new TH1F(tmp, title,maxbinnum ,0,maxbinnum); sprintf(title,"%s%i%s","veto time history strip",i," clean"); sprintf(tmp, "%s%i%s", "hveto_time_history_s",i,"_clean"); // hveto_time_history_clean[i] = new TH1F(tmp, title,maxbinnum ,0,maxbinnum); } } Int_t HMdcTrigger::execute(void) { countnocut++; // counts all events if(fillcontrolhists)hstartcutstat->SetBinContent(1,countnocut); HStartCal *startcal=NULL; Int_t startmod; Int_t sstrip; Float_t stime; Int_t strip0=0; Int_t strip1=0; Int_t strip2=0; Int_t strip3=0; Int_t strip4=0; Int_t strip5=0; Int_t strip6=0; Int_t strip7=0; Int_t strip8=0; Int_t strip9=0; Int_t strip10=0; Int_t strip11=0; Int_t strip12=0; Int_t strip13=0; Int_t strip14=0; Int_t strip15=0; // Float_t start_time=0; Int_t count_start=0; Int_t count_start_check=0; Int_t mul_start=0; Int_t mul_veto=0; // I have one start time for all hits in this event but if more start times that I skip iter_start ->Reset(); while ((startcal=(HStartCal*)iter_start->Next())!= 0) { //first I count hits in Start if count>1 than I skip such event for the moment if(startcal->getStrip()<8 && (startcal->getModule()==0)) mul_start++; if(startcal->getStrip()<8 && (startcal->getModule()==1)) mul_veto++; count_start++; } if(fillcontrolhists) hstartvetodistribution->Fill(mul_start,mul_veto); // fill histogram for start distribution (no cuts) iter_start ->Reset(); // now I know number of hits in Start and for the moment I choose only those where there is only one //**************************************************************************************************** //**************************************************************************************************** // trigger conditions: // // Int_t getTBit(void) - return the integer value // Bool_t IsTBit(Int_t i) - check bit i of the pattern // Bool_t IsTofBit(void) - check TOF bit of the pattern (TOF&START) // Bool_t IsStartBit(void) - check START bit of the pattern (START&!VETO) // Bool_t IsTofinoBit(void) - check TOFINO bit of the pattern (TOFINO) // // //**************************************************************************************************** //**************************************************************************************************** //if(count_start==1) { /* This part does not work anylonger, because of missing Tofbit if( ((startbit) && gHades->getCurrentEvent()->getHeader()->IsStartBit())|| // startbit set ((tofbit) && gHades->getCurrentEvent()->getHeader()->IsTofBit())|| // tofbit set ((tofinobit)&& gHades->getCurrentEvent()->getHeader()->IsTofinoBit())|| // tofinobit set ((!startbit)&&(!tofbit)&&(!tofinobit)) ) // no bit set { */ tofbit=kTRUE; if( ((startbit)&&((mul_start>=startmultmin&&mul_start=vetomultmin&&mul_veto=startmultmin&&mul_start=vetomultmin&&mul_veto=startmultmin&&mul_start=vetomultmin&&mul_vetoFill(mul_start,mul_veto); hstartcutstat->SetBinContent(2,countmultiplicityStartcut); } // fill histogram for start distribution with the cut conditions iter_start ->Reset(); while ((startcal=(HStartCal*) iter_start->Next())!= 0) { count_start_check++; // if( count_start_check>1) printf("I have a problem check>1!\n"); startmod=startcal->getModule(); if(startmod==0){ sstrip =startcal->getStrip(); }else { sstrip =startcal->getStrip()+8; } stime =startcal->getTime(); //printf("strip,time%i %f\n",sstrip,stime); // cout<<"test "<cd(); //start if(dotimecut){ if(sstrip==0) { strip0=1; if(file){ if(fillcontrolhists){ hstart_time[0]->Fill(stime); hstart_time_s0to7->Fill(stime); // if (bin0SetBinContent(bin0,stime); bin0++;}}} if(sstrip==1) { strip1=1; if(file){ if(fillcontrolhists){ hstart_time[1]->Fill(stime); hstart_time_s0to7->Fill(stime); //if(bin1SetBinContent(bin1,stime); bin1++;}}} if(sstrip==2) { strip2=1; if(file){ if(fillcontrolhists){ hstart_time[2]->Fill(stime); hstart_time_s0to7->Fill(stime); // hstart_time_history[2]->SetBinContent(bin2,stime); bin2++;}}} if(sstrip==3) { strip3=1; if(file){ if(fillcontrolhists){ hstart_time[3]->Fill(stime); hstart_time_s0to7->Fill(stime); // if(bin3SetBinContent(bin3,stime); bin3++;}}} // if(sstrip==4) { strip4=1; if(file){ if(fillcontrolhists){ hstart_time[4]->Fill(stime); hstart_time_s0to7->Fill(stime); // if(bin4SetBinContent(bin4,stime); bin4++;}}} if(sstrip==5) { strip5=1; if(file){ if(fillcontrolhists){ hstart_time[5]->Fill(stime); hstart_time_s0to7->Fill(stime); // if(bin5SetBinContent(bin5,stime); bin5++;}}} if(sstrip==6) { strip6=1; if(file){ if(fillcontrolhists){ hstart_time[6]->Fill(stime); hstart_time_s0to7->Fill(stime); // if(bin6SetBinContent(bin6,stime); bin6++;}}} if(sstrip==7) { strip7=1; if(file){ if(fillcontrolhists){ hstart_time[7]->Fill(stime); hstart_time_s0to7->Fill(stime); // if(bin7SetBinContent(bin7,stime); bin7++;}}} //veto if(sstrip==8) { strip8=1; if(file){ if(fillcontrolhists){ hveto_time[0]->Fill(stime); hstart_time_s8to15->Fill(stime); // if(bin8SetBinContent(bin8,stime); bin8++;}}} if(sstrip==9) { strip9=1; if(file){ if(fillcontrolhists){ hveto_time[1]->Fill(stime); hstart_time_s8to15->Fill(stime); // if(bin9SetBinContent(bin9,stime); bin9++;}}} if(sstrip==10) { strip10=1; if(file){ if(fillcontrolhists){ hveto_time[2]->Fill(stime); hstart_time_s8to15->Fill(stime); // if(bin10SetBinContent(bin10,stime); bin10++;}}} if(sstrip==11) { strip11=1; if(file){ if(fillcontrolhists){ hveto_time[3]->Fill(stime); hstart_time_s8to15->Fill(stime); // if(bin11SetBinContent(bin11,stime); bin11++;}}} // if(sstrip==12) { strip12=1; if(file){ if(fillcontrolhists){ hveto_time[4]->Fill(stime); hstart_time_s8to15->Fill(stime); // if(bin12SetBinContent(bin12,stime); bin12++;}}} if(sstrip==13) { strip13=1; if(file){ if(fillcontrolhists){ hveto_time[5]->Fill(stime); hstart_time_s8to15->Fill(stime); // if(bin13SetBinContent(bin13,stime); bin13++;}}} if(sstrip==14) { strip14=1; if(file){ if(fillcontrolhists){ hveto_time[6]->Fill(stime); hstart_time_s8to15->Fill(stime); //if(bin14SetBinContent(bin14,stime); bin14++;}}} if(sstrip==15) { strip15=1; if(file){ if(fillcontrolhists){ hveto_time[7]->Fill(stime); hstart_time_s8to15->Fill(stime); //if(bin15SetBinContent(bin15,stime); bin15++;}}} } if(dotimecut){ //start if(sstrip==0&&((stime>minstrip0)&&(stimeFill(stime); hstart_time_s0to7_clean->Fill(stime); //if(binnum0SetBinContent(binnum0,stime); binnum0++;}}} if(sstrip==1&&((stime>minstrip1)&&(stimeFill(stime); hstart_time_s0to7_clean->Fill(stime); // if(binnum1SetBinContent(binnum1,stime); binnum1++;}}} if(sstrip==2&&((stime>minstrip2)&&(stimeFill(stime); hstart_time_s0to7_clean->Fill(stime); // if(binnum2SetBinContent(binnum2,stime); binnum2++;}}} if(sstrip==3&&((stime>minstrip3)&&(stimeFill(stime); hstart_time_s0to7_clean->Fill(stime); // if(binnum3SetBinContent(binnum3,stime); binnum3++;}}} if(sstrip==4&&((stime>minstrip4)&&(stimeFill(stime); hstart_time_s0to7_clean->Fill(stime); //if(binnum4SetBinContent(binnum4,stime); binnum4++;}}} if(sstrip==5&&((stime>minstrip5)&&(stimeFill(stime); hstart_time_s0to7_clean->Fill(stime); // if(binnum5SetBinContent(binnum5,stime); binnum5++;}}} if(sstrip==6&&((stime>minstrip6)&&(stimeFill(stime); hstart_time_s0to7_clean->Fill(stime); // if(binnum6SetBinContent(binnum6,stime); binnum6++;}}} if(sstrip==7&&((stime>minstrip7)&&(stimeFill(stime); hstart_time_s0to7_clean->Fill(stime); // if(binnum7SetBinContent(binnum7,stime); binnum7++;}}} //veto if(sstrip==8&&((stime>minstrip8)&&(stimeFill(stime); hstart_time_s8to15_clean->Fill(stime); // if(binnum8SetBinContent(binnum8,stime); binnum8++;}}} if(sstrip==9&&((stime>minstrip9)&&(stimeFill(stime); hstart_time_s8to15_clean->Fill(stime); // if(binnum9SetBinContent(binnum9,stime); binnum9++;}}} if(sstrip==10&&((stime>minstrip10)&&(stimeFill(stime); hstart_time_s8to15_clean->Fill(stime); // if(binnum10SetBinContent(binnum10,stime); binnum10++;}}} if(sstrip==11&&((stime>minstrip11)&&(stimeFill(stime); hstart_time_s8to15_clean->Fill(stime); // if(binnum11SetBinContent(binnum11,stime); binnum11++;}}} if(sstrip==12&&((stime>minstrip12)&&(stimeFill(stime); hstart_time_s8to15_clean->Fill(stime); // if(binnum12SetBinContent(binnum12,stime); binnum12++;}}} if(sstrip==13&&((stime>minstrip13)&&(stimeFill(stime); hstart_time_s8to15_clean->Fill(stime); // if(binnum13SetBinContent(binnum13,stime); binnum13++;}}} if(sstrip==14&&((stime>minstrip14)&&(stimeFill(stime); hstart_time_s8to15_clean->Fill(stime); // if(binnum14SetBinContent(binnum14,stime); binnum14++;}}} if(sstrip==15&&((stime>minstrip15)&&(stimeFill(stime); hstart_time_s8to15_clean->Fill(stime); // if(binnum15SetBinContent(binnum15,stime); binnum15++;}}} } } } // }// if ((strip0||strip1)||(strip2||strip3)||(strip4||strip5)||(strip6||strip7)) { counttimewindowStartcut++; // counts events after time window cut if one is applied if(fillcontrolhists)hstartcutstat->SetBinContent(3,counttimewindowStartcut); return 0; } else { countskipedevents++; // counts skiped events if(fillcontrolhists)hstartcutstat->SetBinContent(4,countskipedevents); return kSkipEvent;} }