using namespace std;
#include "hmdclowlevelqa.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 "hcategory.h"
#include "hlocation.h"
#include "hmdccal1.h"
#include "hmdcraw.h"
#include "hmdclookupgeom.h"
#include "hmdclookupraw.h"
#include "hmdctimecut.h"
#include "hmdccalparraw.h"
#include "hmessagemgr.h"
#include "htool.h"
#include <iostream>
#include <iomanip>
#include <stdlib.h>
#include "TH2.h"
#include "TH1.h"
#include "TDirectory.h"
#include "TStopwatch.h"
#include "TMath.h"
Int_t HMdcLowLevelQA::colorsSector[6]={2,4,6,8,38,46};
Int_t HMdcLowLevelQA::colorsModule[4]={2,4,6,8};
Int_t HMdcLowLevelQA::colorsCuts[3]={3,5,4};
Int_t HMdcLowLevelQA::cutResults[4]={0,0,0,0};
ClassImp(HMdcLowLevelQA)
HMdcLowLevelQA::HMdcLowLevelQA(void) {
initVariables();
}
HMdcLowLevelQA::HMdcLowLevelQA(const Text_t* name,const Text_t* title)
: HReconstructor(name,title) {
initVariables();
}
HMdcLowLevelQA::~HMdcLowLevelQA(void) {
if (itercal1) delete itercal1;
if (iterraw) delete iterraw;
itercal1=0;
iterraw=0;
}
void HMdcLowLevelQA::initVariables()
{
fNameRootHists=0;
calCat=0;
rawCat=0;
itercal1=0;
iterraw=0;
lookup=0;
lookupRaw=0;
Eventcounter=0;
isInitialized = kFALSE;
for(Int_t i=0; i<6; i++){ for(Int_t j=0; j<4; j++){ cnt123[i][j]=0; }}
for(Int_t s=0; s<6; s++){ for(Int_t m=0; m<4; m++){ for(Int_t mb=0; mb<16; mb++){ NhitsPERmbo[s][m][mb]=0;} }}
sm_old[0]=-1, sm_old[1]=-1;
step_trend_meantime1_counter=1;
stepsize_trend_meantime1=5000;
resetCounters();
}
void HMdcLowLevelQA::printStatus(){
SEPERATOR_msg("*",30);
INFO_msg(10,HMessageMgr::DET_MDC,"HMdcLowLevelQA");
if(fNameRootHists){
gHades->getMsg()->info(10,HMessageMgr::DET_MDC,GetName(),"FileName : %s",fNameRootHists);
}else{
INFO_msg(10,HMessageMgr::DET_MDC,"File name: IS NOT SET!!!");
}
gHades->getMsg()->info(10,HMessageMgr::DET_MDC,GetName(),"Step size for trend Histo.= %d events",stepsize_trend_meantime1);
SEPERATOR_msg("*",30);
}
void HMdcLowLevelQA::setParContainers() {
lookup =(HMdcLookupGeom*)gHades->getRuntimeDb()->getContainer("MdcLookupGeom");
lookupRaw=(HMdcLookupRaw*) gHades->getRuntimeDb()->getContainer("MdcLookupRaw");
timecut =(HMdcTimeCut*) gHades->getRuntimeDb()->getContainer("MdcTimeCut");
}
void HMdcLowLevelQA::setOutputRoot(const Char_t *c)
{
if (fNameRootHists) delete fNameRootHists;
fNameRootHists = new Char_t[strlen(c)+1];
strcpy(fNameRootHists, c);
}
Bool_t HMdcLowLevelQA::init(void) {
Bool_t test=kFALSE;
setParContainers();
test=getCategories();
getSetup();
printStatus();
fActive=kTRUE;
return test;
}
Bool_t HMdcLowLevelQA::reinit(void)
{
if(!isInitialized)
{
nReqEvents = gHades->getNumberOfRequestedEvents();
isInitialized = kTRUE;
createHistograms();
}
return kTRUE;
}
Bool_t HMdcLowLevelQA::getCategories()
{
calCat=gHades->getCurrentEvent()->getCategory(catMdcCal1);
if (!calCat) {
Error("HMdcLowLevelQA:init()","Category HMdcCal1 is not filled! Sorry Guy, will quit.");
exit(1);
calCat=gHades->getSetup()->getDetector("Mdc")->buildCategory(catMdcCal1);
if (!calCat) return kFALSE;
else gHades->getCurrentEvent()->addCategory(catMdcCal1,calCat,"Mdc");
}
rawCat=gHades->getCurrentEvent()->getCategory(catMdcRaw);
if (!rawCat) {
Error("HMdcLowLevelQA:init()","Category HMdcRaw is not filled! Sorry Guy, will quit.");
exit(1);
rawCat=gHades->getSetup()->getDetector("Mdc")->buildCategory(catMdcRaw);
if (!rawCat) return kFALSE;
else gHades->getCurrentEvent()->addCategory(catMdcRaw,rawCat,"Mdc");
}
itercal1=(HIterator *)calCat->MakeIterator("native");
iterraw =(HIterator *)rawCat->MakeIterator("native");
loccal1.set(4,0,0,0,0);
locraw.set(4,0,0,0,0);
return kTRUE;
}
void HMdcLowLevelQA::writeTimeCuts(){
Int_t s=0;
for(Int_t p=0; p<4; p++){
hmdc_summ_tCuts_info[p]->SetBinContent(1, (Double_t)timecut->getCutT1L( s,p) );
hmdc_summ_tCuts_info[p]->SetBinContent(2, (Double_t)timecut->getCutT1R( s,p) );
hmdc_summ_tCuts_info[p]->SetBinContent(3, (Double_t)timecut->getCutT2L( s,p) );
hmdc_summ_tCuts_info[p]->SetBinContent(4, (Double_t)timecut->getCutT2R( s,p) );
hmdc_summ_tCuts_info[p]->SetBinContent(5, (Double_t)timecut->getCutDTime21L( s,p) );
hmdc_summ_tCuts_info[p]->SetBinContent(6, (Double_t)timecut->getCutDTime21R( s,p) );
hmdc_summ_tCuts_info[p]->Write();
}
}
void HMdcLowLevelQA::lookupSlopes(Int_t s, Int_t m){
}
void HMdcLowLevelQA::testTimeCuts(Int_t s,Int_t m,Float_t t1,Float_t t2)
{
hmdc_summ_t2mt1_vs_t1[s][m]->Fill(t1, t2-t1);
if(timecut->cutTime1(s,m,t1))
{
cutResults[0]=1;
}
else
{
cutResults[0]=0;
}
if(timecut->cutTime2(s,m,t2))
{
cutResults[1]=1;
}
else
{
cutResults[1]=0;
}
if(timecut->cutTimesDif(s,m,t1,t2))
{
cutResults[2]=1;
}
else
{
cutResults[2]=0;
}
if(cutResults[0]==1&&cutResults[1]==1&&cutResults[2]==1)
{
cutResults[3]=1;
}
else
{
cutResults[3]=0;
}
}
void HMdcLowLevelQA::createHistograms()
{
Char_t name [100];
Char_t axistitle[200];
sprintf(name,"%s","a_thisFileName");
a_thisFileName=new TH1F(name,name,1,0,1);
a_thisFileName->SetXTitle(fNameRootHists);
nBinsTrendX = (Int_t)TMath::Floor(nReqEvents / stepsize_trend_meantime1);
for(Int_t s=0;s<6;s++)
{
for(Int_t m=0;m<4;m++)
{
sprintf(name,"%s%i%s%i%s","hmdc_trend_meanSlope[",s,"][",m,"]");
hmdc_trend_meanSlope[s][m]=new TH1F(name,name,nBinsTrendX,0,nBinsTrendX);
hmdc_trend_meanSlope[s][m]->SetLineColor(colorsSector[s]);
hmdc_trend_meanSlope[s][m]->SetMarkerColor(colorsSector[s]);
hmdc_trend_meanSlope[s][m]->SetMarkerStyle(29);
hmdc_trend_meanSlope[s][m]->SetMarkerSize(.8);
sprintf(axistitle,"%s%i%s","step in file [",stepsize_trend_meantime1," counts]");
hmdc_trend_meanSlope[s][m]->SetXTitle(axistitle);
hmdc_trend_meanSlope[s][m]->SetYTitle("Mean Slope [1/ns]");
hmdc_trend_meanSlope[s][m]->SetOption("PL");
sprintf(name,"%s%i%s%i%s","hmdc_trend_meantime1[",s,"][",m,"]");
hmdc_trend_meantime1[s][m]=new TH1F(name,name,nBinsTrendX,0,nBinsTrendX);
hmdc_trend_meantime1[s][m]->SetLineColor(colorsSector[s]);
hmdc_trend_meantime1[s][m]->SetMarkerColor(colorsSector[s]);
hmdc_trend_meantime1[s][m]->SetMarkerStyle(29);
hmdc_trend_meantime1[s][m]->SetMarkerSize(.8);
sprintf(axistitle,"%s%i%s","step in file [",stepsize_trend_meantime1," events]");
hmdc_trend_meantime1[s][m]->SetXTitle(axistitle);
hmdc_trend_meantime1[s][m]->SetYTitle("Mean time1 [ns]");
hmdc_trend_meantime1[s][m]->SetOption("PL");
sprintf(name,"%s%i%s%i%s","hmdc_trend_meantime1not_t1[",s,"][",m,"]");
hmdc_trend_meantime1not_t1[s][m]=new TH1F(name,name,nBinsTrendX,0,nBinsTrendX);
hmdc_trend_meantime1not_t1[s][m]->SetLineColor(colorsSector[s]);
hmdc_trend_meantime1not_t1[s][m]->SetMarkerColor(colorsSector[s]);
hmdc_trend_meantime1not_t1[s][m]->SetMarkerStyle(29);
hmdc_trend_meantime1not_t1[s][m]->SetMarkerSize(.8);
sprintf(axistitle,"%s%i%s","step in file [",stepsize_trend_meantime1," events]");
hmdc_trend_meantime1not_t1[s][m]->SetXTitle(axistitle);
hmdc_trend_meantime1not_t1[s][m]->SetYTitle("Mean time1 [ns]");
hmdc_trend_meantime1not_t1[s][m]->SetOption("PL");
sprintf(name,"%s%i%s%i%s","hmdc_trend_meantime1not_t2[",s,"][",m,"]");
hmdc_trend_meantime1not_t2[s][m]=new TH1F(name,name,nBinsTrendX,0,nBinsTrendX);
hmdc_trend_meantime1not_t2[s][m]->SetLineColor(colorsSector[s]);
hmdc_trend_meantime1not_t2[s][m]->SetMarkerColor(colorsSector[s]);
hmdc_trend_meantime1not_t2[s][m]->SetMarkerStyle(29);
hmdc_trend_meantime1not_t2[s][m]->SetMarkerSize(.8);
sprintf(axistitle,"%s%i%s","step in file [",stepsize_trend_meantime1," events]");
hmdc_trend_meantime1not_t2[s][m]->SetXTitle(axistitle);
hmdc_trend_meantime1not_t2[s][m]->SetYTitle("Mean time1 [ns]");
hmdc_trend_meantime1not_t2[s][m]->SetOption("PL");
sprintf(name,"%s%i%s%i%s","hmdc_trend_meantime1not_t12[",s,"][",m,"]");
hmdc_trend_meantime1not_t12[s][m]=new TH1F(name,name,nBinsTrendX,0,nBinsTrendX);
hmdc_trend_meantime1not_t12[s][m]->SetLineColor(colorsSector[s]);
hmdc_trend_meantime1not_t12[s][m]->SetMarkerColor(colorsSector[s]);
hmdc_trend_meantime1not_t12[s][m]->SetMarkerStyle(29);
hmdc_trend_meantime1not_t12[s][m]->SetMarkerSize(.8);
sprintf(axistitle,"%s%i%s","step in file [",stepsize_trend_meantime1," events]");
hmdc_trend_meantime1not_t12[s][m]->SetXTitle(axistitle);
hmdc_trend_meantime1not_t12[s][m]->SetYTitle("Mean time1 [ns]");
hmdc_trend_meantime1not_t12[s][m]->SetOption("PL");
sprintf(name,"%s%i%s%i%s","hmdc_Slope[",s,"][",m,"]");
hmdc_Slope[s][m]=new TH1F(name,name,500,-100,900);
sprintf(name,"%s%i%s%i%s","hmdc_time1[",s,"][",m,"]");
hmdc_time1[s][m]=new TH1F(name,name,500,-100,900);
sprintf(name,"%s%i%s%i%s","hmdc_time1_everithing_summ[",s,"][",m,"]");
hmdc_time1_everithing_summ[s][m]=new TH1F(name,name,500,-100,900);
sprintf(name,"%s%i%s%i%s","hmdc_time1_good_t1_summ[",s,"][",m,"]");
hmdc_time1_good_t1_summ[s][m]=new TH1F(name,name,500,-100,900);
sprintf(name,"%s%i%s%i%s","hmdc_time1_not_t1_summ[",s,"][",m,"]");
hmdc_time1_not_t1_summ[s][m]=new TH1F(name,name,500,-100,900);
sprintf(name,"%s%i%s%i%s","hmdc_time1not_t1[",s,"][",m,"]");
hmdc_time1not_t1[s][m]=new TH1F(name,name,500,-100,900);
sprintf(name,"%s%i%s%i%s","hmdc_time1not_t2[",s,"][",m,"]");
hmdc_time1not_t2[s][m]=new TH1F(name,name,500,-100,900);
sprintf(name,"%s%i%s%i%s","hmdc_time1not_t12[",s,"][",m,"]");
hmdc_time1not_t12[s][m]=new TH1F(name,name,500,-100,900);
sprintf(name,"%s%i%s%i%s","hmdc_trend_neighbors[",s,"][",m,"]");
hmdc_trend_neighbors[s][m]=new TH1F(name,name,nBinsTrendX,0,nBinsTrendX);
hmdc_trend_neighbors[s][m]->SetLineColor(colorsSector[s]);
hmdc_trend_neighbors[s][m]->SetMarkerColor(colorsSector[s]);
hmdc_trend_neighbors[s][m]->SetMarkerStyle(29);
hmdc_trend_neighbors[s][m]->SetMarkerSize(.8);
sprintf(axistitle,"%s%i%s","step in file [",stepsize_trend_meantime1," events]");
hmdc_trend_neighbors[s][m]->SetXTitle(axistitle);
hmdc_trend_neighbors[s][m]->SetYTitle("Ratio Double/All cells");
hmdc_trend_neighbors[s][m]->SetOption("PL");
sprintf(name,"%s%i%s%i%s","hmdc_trend_123ratio[",s,"][",m,"]");
hmdc_trend_123ratio[s][m]=new TH1F(name,name,nBinsTrendX,0,nBinsTrendX);
hmdc_trend_123ratio[s][m]->SetLineColor(colorsSector[s]);
hmdc_trend_123ratio[s][m]->SetMarkerColor(colorsSector[s]);
hmdc_trend_123ratio[s][m]->SetMarkerStyle(29);
hmdc_trend_123ratio[s][m]->SetMarkerSize(.8);
sprintf(axistitle,"%s%i%s","step in file [",stepsize_trend_meantime1," events]");
hmdc_trend_123ratio[s][m]->SetXTitle(axistitle);
hmdc_trend_123ratio[s][m]->SetYTitle("Ratio Events_with(123 f. wires)/StepSize");
hmdc_trend_123ratio[s][m]->SetOption("PL");
for(Int_t mb=0; mb<16; mb++)
{
Char_t mbo_name[300];
sprintf(mbo_name,"%s%i%s%i%s%i%s","hmdc_trend_NhitsPERmbo[",s,"][",m,"][",mb,"]");
hmdc_trend_NhitsPERmbo[s][m][mb]=new TH1F(mbo_name,mbo_name,nBinsTrendX,0,nBinsTrendX);
hmdc_trend_NhitsPERmbo[s][m][mb]->SetLineColor(colorsSector[s]);
hmdc_trend_NhitsPERmbo[s][m][mb]->SetMarkerColor(colorsSector[s]);
hmdc_trend_NhitsPERmbo[s][m][mb]->SetMarkerStyle(29);
hmdc_trend_NhitsPERmbo[s][m][mb]->SetMarkerSize(.8);
sprintf(axistitle,"%s%i%s","step in file [",stepsize_trend_meantime1," events]");
hmdc_trend_NhitsPERmbo[s][m][mb]->SetXTitle(axistitle);
hmdc_trend_NhitsPERmbo[s][m][mb]->SetYTitle("hits/mbo");
hmdc_trend_NhitsPERmbo[s][m][mb]->SetOption("PL");
}
sprintf(name,"%s%i%s%i%s","hmdc_trend_multiplicity[",s,"][",m,"]");
hmdc_trend_multiplicity[s][m]=new TH1F(name,name,nBinsTrendX,0,nBinsTrendX);
hmdc_trend_multiplicity[s][m]->SetLineColor(colorsSector[s]);
hmdc_trend_multiplicity[s][m]->SetMarkerColor(colorsSector[s]);
hmdc_trend_multiplicity[s][m]->SetMarkerStyle(29);
hmdc_trend_multiplicity[s][m]->SetMarkerSize(.8);
sprintf(axistitle,"%s%i%s","step in file [",stepsize_trend_meantime1," events]");
hmdc_trend_multiplicity[s][m]->SetXTitle(axistitle);
hmdc_trend_multiplicity[s][m]->SetYTitle("Hits Multiplicity Mean Value");
hmdc_trend_multiplicity[s][m]->SetOption("PL");
sprintf(name,"%s%i%s%i%s","hmdc_multiplicity[",s,"][",m,"]");
hmdc_multiplicity[s][m]=new TH1F(name,name,500,-0,500);
sprintf(name,"%s%i%s%i%s","hmdc_summ_MBOvsTDC[",s,"][",m,"]");
hmdc_summ_MBOvsTDC[s][m]=new TH2F(name,name,96,0.5,96.5, 16,0.5,16.5);
hmdc_summ_MBOvsTDC[s][m]->SetXTitle("TDC channel number");
hmdc_summ_MBOvsTDC[s][m]->SetYTitle("MBO number");
hmdc_summ_MBOvsTDC[s][m]->SetOption("COLZ");
sprintf(name,"%s%i%s%i%s","hmdc_summ_dNdNhits[",s,"][",m,"]");
hmdc_summ_dNdNhits[s][m]=new TH1F(name,name,50,0.,50. );
hmdc_summ_dNdNhits[s][m]->SetXTitle("N of hits");
hmdc_summ_dNdNhits[s][m]->SetYTitle("dN/dNhits");
hmdc_summ_dNdNhits[s][m]->SetOption("");
sprintf(name,"%s%i%s%i%s","hmdc_summ_t2mt1_vs_t1[",s,"][",m,"]");
hmdc_summ_t2mt1_vs_t1[s][m]=new TH2F(name,name, 250,0.,500., 250, 0., 500.);
hmdc_summ_t2mt1_vs_t1[s][m]->SetXTitle("t1 [ns]");
hmdc_summ_t2mt1_vs_t1[s][m]->SetYTitle("t2-t1 [ns]");
hmdc_summ_t2mt1_vs_t1[s][m]->SetOption("COLZ");
Int_t colorsSector[4]={4,2,8,6};
for(Int_t cut=0; cut<3; cut++){
for(Int_t l=0; l<6; l++){
sprintf(name,"%s%i%s%i%s%i%s%i%s","hmdc_summ_dNdWire[",s,"][",m,"][",l,"][",cut,"]");
hmdc_summ_dNdWire[s][m][l][cut]=new TH1F(name,name,191,-0.5,190.5 );
hmdc_summ_dNdWire[s][m][l][cut]->SetXTitle("N of Wire");
hmdc_summ_dNdWire[s][m][l][cut]->SetYTitle("dN/dWire");
hmdc_summ_dNdWire[s][m][l][cut]->SetOption("");
hmdc_summ_dNdWire[s][m][l][cut]->SetLineColor(colorsSector[cut]);
hmdc_summ_dNdWire[s][m][l][cut]->SetFillColor(colorsSector[cut]);
}
}
}
}
for(Int_t p=0; p<4; p++){
sprintf(name,"%s%i","hmdc_summ_tCuts_info",p);
hmdc_summ_tCuts_info[p] = new TH1F(name,name,6,0.,6.);
hmdc_summ_tCuts_info[p]->SetXTitle("t1CutL,t1CutR,t2CutL,t2CutR,t2-t1CutL,t2-t1CutR");
}
sprintf(name,"%s","hmdc_summ_trend_meantime1_plane");
hmdc_summ_trend_meantime1_plane=new TH1F(name,name,4,0,4);
hmdc_summ_trend_meantime1_plane->SetMarkerStyle(29);
hmdc_summ_trend_meantime1_plane->SetMarkerSize(.8);
hmdc_summ_trend_meantime1_plane->SetXTitle("Plane Number");
hmdc_summ_trend_meantime1_plane->SetYTitle("Mean Value");
hmdc_summ_trend_meantime1_plane->SetOption("PL");
sprintf(name,"%s","hmdc_summ_trend_meantime1");
hmdc_summ_trend_meantime1=new TH1F(name,name,24,0,24);
hmdc_summ_trend_meantime1->SetMarkerStyle(29);
hmdc_summ_trend_meantime1->SetMarkerSize(.8);
hmdc_summ_trend_meantime1->SetXTitle("for(m=0;m<4;m++){for(s=0;s<6;s++){ ms }}");
hmdc_summ_trend_meantime1->SetYTitle("Mean Value");
hmdc_summ_trend_meantime1->SetOption("PL");
sprintf(name,"%s","hmdc_summ_trend_meantime1not_t1");
hmdc_summ_trend_meantime1not_t1=new TH1F(name,name,24,0,24);
hmdc_summ_trend_meantime1not_t1->SetMarkerStyle(29);
hmdc_summ_trend_meantime1not_t1->SetMarkerSize(.8);
hmdc_summ_trend_meantime1not_t1->SetXTitle("for(m=0;m<4;m++){for(s=0;s<6;s++){ mc }}");
hmdc_summ_trend_meantime1not_t1->SetYTitle("Mean Value");
hmdc_summ_trend_meantime1not_t1->SetOption("PL");
sprintf(name,"%s","hmdc_summ_trend_meantime1not_t2");
hmdc_summ_trend_meantime1not_t2=new TH1F(name,name,24,0,24);
hmdc_summ_trend_meantime1not_t2->SetMarkerStyle(29);
hmdc_summ_trend_meantime1not_t2->SetMarkerSize(.8);
hmdc_summ_trend_meantime1not_t2->SetXTitle("for(m=0;m<4;m++){for(s=0;s<6;s++){ mc }}");
hmdc_summ_trend_meantime1not_t2->SetYTitle("Mean Value");
hmdc_summ_trend_meantime1not_t2->SetOption("PL");
sprintf(name,"%s","hmdc_summ_trend_meantime1not_t12");
hmdc_summ_trend_meantime1not_t12=new TH1F(name,name,24,0,24);
hmdc_summ_trend_meantime1not_t12->SetMarkerStyle(29);
hmdc_summ_trend_meantime1not_t12->SetMarkerSize(.8);
hmdc_summ_trend_meantime1not_t12->SetXTitle("for(m=0;m<4;m++){for(s=0;s<6;s++){ mc }}");
hmdc_summ_trend_meantime1not_t12->SetYTitle("Mean Value");
hmdc_summ_trend_meantime1not_t12->SetOption("PL");
sprintf(name,"%s","hmdc_summ_trend_neighbors");
hmdc_summ_trend_neighbors=new TH1F(name,name,24,0,24);
hmdc_summ_trend_neighbors->SetMarkerStyle(29);
hmdc_summ_trend_neighbors->SetMarkerSize(.8);
hmdc_summ_trend_neighbors->SetXTitle("for(m=0;m<4;m++){for(s=0;s<6;s++){ mc }}");
hmdc_summ_trend_neighbors->SetYTitle("Mean Value");
hmdc_summ_trend_neighbors->SetOption("PL");
sprintf(name,"%s","hmdc_summ_trend_123ratio");
hmdc_summ_trend_123ratio=new TH1F(name,name,24,0,24);
hmdc_summ_trend_123ratio->SetMarkerStyle(29);
hmdc_summ_trend_123ratio->SetMarkerSize(.8);
hmdc_summ_trend_123ratio->SetXTitle("for(m=0;m<4;m++){for(s=0;s<6;s++){ mc }}");
hmdc_summ_trend_123ratio->SetYTitle("Mean Value");
hmdc_summ_trend_123ratio->SetOption("PL");
sprintf(name,"%s","hmdc_summ_trend_multiplicity");
hmdc_summ_trend_multiplicity=new TH1F(name,name,24,0,24);
hmdc_summ_trend_multiplicity->SetMarkerStyle(29);
hmdc_summ_trend_multiplicity->SetMarkerSize(.8);
hmdc_summ_trend_multiplicity->SetXTitle("for(m=0;m<4;m++){for(s=0;s<6;s++){ mc }}");
hmdc_summ_trend_multiplicity->SetYTitle("Mean Value");
hmdc_summ_trend_multiplicity->SetOption("PL");
for(Int_t m=0;m<4;m++)
{
sprintf(name,"%s%i%s","hmdc_trend_meantime1_plane[",m,"]");
hmdc_trend_meantime1_plane[m]=new TH1F(name,name,nBinsTrendX,0,nBinsTrendX);
hmdc_trend_meantime1_plane[m]->SetLineColor(colorsModule[m]);
hmdc_trend_meantime1_plane[m]->SetMarkerColor(colorsModule[m]);
hmdc_trend_meantime1_plane[m]->SetMarkerStyle(29);
hmdc_trend_meantime1_plane[m]->SetMarkerSize(.8);
sprintf(axistitle,"%s%i%s","step in file [",stepsize_trend_meantime1," events]");
hmdc_trend_meantime1_plane[m]->SetXTitle(axistitle);
hmdc_trend_meantime1_plane[m]->SetYTitle("Mean time1 [ns]");
hmdc_trend_meantime1_plane[m]->SetOption("P");
sprintf(name,"%s%i%s","hmdc_time1_plane[",m,"]");
hmdc_time1_plane[m]=new TH1F(name,name,500,-100,900);
}
}
void HMdcLowLevelQA::writeHistograms(Int_t s,Int_t mo,Int_t l,Int_t c,Int_t level,Int_t main)
{
TH1 *tmp;
TString name;
Int_t bins;
bins = (Int_t)TMath::Floor(Eventcounter / stepsize_trend_meantime1);
if(level==0)
{
if(main==1)
{
a_thisFileName->Write();
TString uFile(fNameRootHists);
TNamed *s1=new TNamed("thisFileName",uFile.Data());
s1->Write();
for(Int_t is=0; is<6 ; is++)
{
for(Int_t im=0; im<4; im++)
{
hmdc_summ_MBOvsTDC[ is][im]->Write();
hmdc_summ_dNdNhits[ is][im]->Write();
}
}
for(Int_t b=1; b<= 4; b++)
{
hmdc_summ_trend_meantime1_plane->SetBinContent(b, hmdc_summ_trend_meantime1_plane->GetBinContent(b)/Double_t(step_trend_meantime1_counter) );
}
for(Int_t b=1; b<=24; b++)
{
hmdc_summ_trend_meantime1->SetBinContent(b, hmdc_summ_trend_meantime1->GetBinContent(b)/Double_t(step_trend_meantime1_counter) );
hmdc_summ_trend_meantime1not_t1->SetBinContent(b,hmdc_summ_trend_meantime1not_t1->GetBinContent(b)/Double_t(step_trend_meantime1_counter) );
hmdc_summ_trend_meantime1not_t2->SetBinContent(b,hmdc_summ_trend_meantime1not_t2->GetBinContent(b)/Double_t(step_trend_meantime1_counter) );
hmdc_summ_trend_meantime1not_t12->SetBinContent(b,hmdc_summ_trend_meantime1not_t12->GetBinContent(b)/Double_t(step_trend_meantime1_counter) );
hmdc_summ_trend_neighbors->SetBinContent(b,hmdc_summ_trend_neighbors->GetBinContent(b)/Double_t(step_trend_meantime1_counter) );
hmdc_summ_trend_123ratio->SetBinContent(b,hmdc_summ_trend_123ratio->GetBinContent(b)/Double_t(step_trend_meantime1_counter) );
hmdc_summ_trend_multiplicity->SetBinContent(b,hmdc_summ_trend_multiplicity->GetBinContent(b)/Double_t(step_trend_meantime1_counter) );
}
tmp = hmdc_summ_trend_meantime1_plane;
name = (Char_t *)tmp->GetName();
tmp->SetName("tmp");
hmdc_summ_trend_meantime1_plane = (TH1F *)HTool::copyHistRange(tmp,name,0,-99,0,bins);
delete tmp;
tmp = hmdc_summ_trend_meantime1;
name = (Char_t *)tmp->GetName();
tmp->SetName("tmp");
hmdc_summ_trend_meantime1 = (TH1F *)HTool::copyHistRange(tmp,name,0,-99,0,bins);
delete tmp;
tmp = hmdc_summ_trend_meantime1not_t1;
name = (Char_t *)tmp->GetName();
tmp->SetName("tmp");
hmdc_summ_trend_meantime1not_t1 = (TH1F *)HTool::copyHistRange(tmp,name,0,-99,0,bins);
delete tmp;
tmp = hmdc_summ_trend_meantime1not_t2;
name = (Char_t *)tmp->GetName();
tmp->SetName("tmp");
hmdc_summ_trend_meantime1not_t2 = (TH1F *)HTool::copyHistRange(tmp,name,0,-99,0,bins);
delete tmp;
tmp = hmdc_summ_trend_meantime1not_t12;
name = (Char_t *)tmp->GetName();
tmp->SetName("tmp");
hmdc_summ_trend_meantime1not_t12 = (TH1F *)HTool::copyHistRange(tmp,name,0,-99,0,bins);
delete tmp;
tmp = hmdc_summ_trend_neighbors;
name = (Char_t *)tmp->GetName();
tmp->SetName("tmp");
hmdc_summ_trend_neighbors = (TH1F *)HTool::copyHistRange(tmp,name,0,-99,0,bins);
delete tmp;
tmp = hmdc_summ_trend_123ratio;
name = (Char_t *)tmp->GetName();
tmp->SetName("tmp");
hmdc_summ_trend_123ratio = (TH1F *)HTool::copyHistRange(tmp,name,0,-99,0,bins);
delete tmp;
tmp = hmdc_summ_trend_multiplicity;
name = (Char_t *)tmp->GetName();
tmp->SetName("tmp");
hmdc_summ_trend_multiplicity = (TH1F *)HTool::copyHistRange(tmp,name,0,-99,0,bins);
delete tmp;
hmdc_summ_trend_meantime1_plane->Write();
hmdc_summ_trend_meantime1->Write();
hmdc_summ_trend_meantime1not_t1->Write();
hmdc_summ_trend_meantime1not_t2->Write();
hmdc_summ_trend_meantime1not_t12->Write();
hmdc_summ_trend_neighbors->Write();
hmdc_summ_trend_123ratio->Write();
hmdc_summ_trend_multiplicity->Write();
}
else if(main==2)
{
}
else if(s!=-99&&mo==-99&&l==-99&&c==-99&&main==-99)
{
}
else if(s!=-99&&mo!=-99&&l==-99&&c==-99&&main==-99)
{
}
else if(s!=-99&&mo!=-99&&l!=-99&&c==-99&&main==-99)
{
tmp = hmdc_trend_NhitsPERmbo[s][mo][l];
name = (Char_t *)tmp->GetName();
tmp->SetName("tmp");
hmdc_trend_NhitsPERmbo[s][mo][l] = (TH1F *)HTool::copyHistRange(tmp,name,0,-99,0,bins);
delete tmp;
hmdc_trend_NhitsPERmbo[s][mo][l]->Write();
}
else if(s!=-99&&mo!=-99&&l!=-99&&c!=-99&&main==-99)
{
}
}
else
{
if(main==1)
{
for(Int_t is=0; is<6 ; is++)
{
for(Int_t im=0; im<4; im++)
{
hmdc_summ_t2mt1_vs_t1[is][im]->Write();
for(Int_t il=0; il<6; il++)
{
for(Int_t cut=0; cut<3; cut++)
{
hmdc_summ_dNdWire[is][im][il][cut]->Write();
}
}
}
}
}
else if(main==2)
{
hmdc_trend_meantime1_plane[mo]->Write();
}
else if(s!=-99&&mo==-99&&l==-99&&c==-99&&main==-99)
{
}
else if(s!=-99&&mo!=-99&&l==-99&&c==-99&&main==-99)
{
tmp = hmdc_trend_meantime1[s][mo];
name = (Char_t *)tmp->GetName();
tmp->SetName("tmp");
hmdc_trend_meantime1[s][mo] = (TH1F *)HTool::copyHistRange(tmp,name,0,-99,0,bins);
delete tmp;
tmp = hmdc_trend_meantime1not_t1[s][mo];
name = (Char_t *)tmp->GetName();
tmp->SetName("tmp");
hmdc_trend_meantime1not_t1[s][mo] = (TH1F *)HTool::copyHistRange(tmp,name,0,-99,0,bins);
delete tmp;
tmp = hmdc_trend_meantime1not_t2[s][mo];
name = (Char_t *)tmp->GetName();
tmp->SetName("tmp");
hmdc_trend_meantime1not_t2[s][mo] = (TH1F *)HTool::copyHistRange(tmp,name,0,-99,0,bins);
delete tmp;
tmp = hmdc_trend_meantime1not_t12[s][mo];
name = (Char_t *)tmp->GetName();
tmp->SetName("tmp");
hmdc_trend_meantime1not_t12[s][mo] = (TH1F *)HTool::copyHistRange(tmp,name,0,-99,0,bins);
delete tmp;
tmp = hmdc_trend_neighbors[s][mo];
name = (Char_t *)tmp->GetName();
tmp->SetName("tmp");
hmdc_trend_neighbors[s][mo] = (TH1F *)HTool::copyHistRange(tmp,name,0,-99,0,bins);
delete tmp;
tmp = hmdc_trend_123ratio[s][mo];
name = (Char_t *)tmp->GetName();
tmp->SetName("tmp");
hmdc_trend_123ratio[s][mo] = (TH1F *)HTool::copyHistRange(tmp,name,0,-99,0,bins);
delete tmp;
tmp = hmdc_trend_multiplicity[s][mo];
name = (Char_t *)tmp->GetName();
tmp->SetName("tmp");
hmdc_trend_multiplicity[s][mo] = (TH1F *)HTool::copyHistRange(tmp,name,0,-99,0,bins);
delete tmp;
tmp = hmdc_trend_meanSlope[s][mo];
name = (Char_t *)tmp->GetName();
tmp->SetName("tmp");
hmdc_trend_meanSlope[s][mo] = (TH1F *)HTool::copyHistRange(tmp,name,0,-99,0,bins);
delete tmp;
hmdc_trend_meantime1[ s][mo]->Write();
hmdc_trend_meantime1not_t1[ s][mo]->Write();
hmdc_trend_meantime1not_t2[ s][mo]->Write();
hmdc_trend_meantime1not_t12[s][mo]->Write();
hmdc_trend_neighbors[ s][mo]->Write();
hmdc_trend_123ratio[ s][mo]->Write();
hmdc_trend_multiplicity[ s][mo]->Write();
hmdc_trend_meanSlope[ s][mo]->Write();
hmdc_Slope[ s][mo]->Write();
hmdc_time1_everithing_summ[ s][mo]->Write();
hmdc_time1_good_t1_summ[ s][mo]->Write();
hmdc_time1_not_t1_summ[ s][mo]->Write();
}
else if(s!=-99&&mo!=-99&&l!=-99&&c==-99&&main==-99)
{
}
else if(s!=-99&&mo!=-99&&l!=-99&&c!=-99&&main==-99)
{
}
}
}
void HMdcLowLevelQA::fillHistogramsCal(Int_t s,Int_t m,Int_t l,Int_t c,Float_t time1,Float_t time2)
{
hmdc_time1_everithing_summ[s][m]->Fill(time1);
if(cutResults[3]==1)
{
hmdc_time1[s][m] ->Fill(time1);
hmdc_time1_plane[m]->Fill(time1);
hmdc_time1_good_t1_summ[s][m]->Fill(time1);
}
else if(cutResults[0]==0)
{
hmdc_time1not_t1[s][m]->Fill(time1);
hmdc_time1_not_t1_summ[s][m]->Fill(time1);
}
else if(cutResults[1]==0)
{
hmdc_time1not_t2[s][m]->Fill(time1);
}
else if(cutResults[2]==0)
{
hmdc_time1not_t12[s][m]->Fill(time1);
}
}
void HMdcLowLevelQA::fillHistogramsRaw(Int_t s,Int_t m,Int_t mb,Int_t ch,Float_t time1,Float_t time2)
{
hmdc_summ_MBOvsTDC[s][m]->Fill(ch+1, mb+1);
}
TDirectory *HMdcLowLevelQA::Mkdir(TDirectory *dirOld,const Char_t *c, Int_t i, Int_t p)
{
static Char_t sDir[255];
static Char_t sFmt[10];
if(i!=-99)
{
sprintf(sFmt, "%%s %%0%1ii", p);
sprintf(sDir, sFmt, c, i);
}
else
{
sprintf(sDir,"%s", c);
}
TDirectory *dirNew = dirOld->mkdir(sDir);
dirOld->cd(sDir);
return dirNew;
}
void HMdcLowLevelQA::getSetup()
{
HDetector *mdcDet = gHades->getSetup()->getDetector("Mdc");
for(Int_t m=0; m<4; m++)
{
numberOfSectorsPerModule[m]=0;
}
for(Int_t s=0; s<6; s++)
{
for(Int_t m=0; m<4; m++)
{
if (!mdcDet->getModule(s, m))
{
mySetup[s][m]=0;
}
else
{
mySetup[s][m]=1;
numberOfSectorsPerModule[m]++;
}
}
}
}
Bool_t HMdcLowLevelQA::finalize(void)
{
TFile *file = NULL;
if (fNameRootHists)
{
file = new TFile(fNameRootHists,"RECREATE");
file->cd();
HDetector *mdcDet = gHades->getSetup()->getDetector("Mdc");
if (!mdcDet){
ERROR_msg(HMessageMgr::DET_MDC,"HMdcOffsetCheck::finalize: Mdc-Detector setup (gHades->getSetup()->getDetector(\"Mdc\")) missing.");
}
else
for(Int_t s=0; s<6; s++)
{
TDirectory *dirSec=NULL;
if (file) dirSec=Mkdir(file, "sector", s);
writeHistograms(s,-99,-99,-99,1,-99);
for(Int_t mo=0; mo<4; mo++)
{
if (!mdcDet->getModule(s, mo)) continue;
TDirectory *dirMod=NULL;
if (dirSec) dirMod=Mkdir(dirSec, "module", mo);
writeHistograms(s,mo,-99,-99,1,-99);
for(Int_t mb=0; mb<16; mb++){
writeHistograms(s,mo,mb,-99,0,-99);
}
if (dirMod) dirMod->TDirectory::Cd("..");
}
if (dirSec) dirSec->TDirectory::Cd("..");
}
TDirectory *dirPlane=NULL;
if (file) dirPlane=Mkdir(file, "Plane", -99);
for(Int_t m=0; m<4; m++)
{
writeHistograms(-99,m,-99,-99,1,2);
}
if (dirPlane) dirPlane->TDirectory::Cd("..");
TDirectory *dirSummary=NULL;
if (file) dirSummary=Mkdir(file, "Summary", -99);
writeHistograms(-99,-99,-99,-99,0,1);
writeHistograms(-99,-99,-99,-99,1,1);
writeTimeCuts();
if (dirSummary) dirSummary->TDirectory::Cd("..");
file->Save();
file->Close();
}
else
{
Error("HMdcLowLevelQA:finalize()","NO OUTPUT DEFINED!");
}
return kTRUE;
}
Int_t HMdcLowLevelQA::execute()
{
Eventcounter++;
if(Eventcounter%stepsize_trend_meantime1==0)
{
if(step_trend_meantime1_counter<=200)
{
for(Int_t i=0;i<6;i++)
{
for(Int_t j=0;j<4;j++)
{
if(hmdc_time1[i][j]->Integral()>0)
{
hmdc_trend_meanSlope[i][j]->SetBinContent(step_trend_meantime1_counter,hmdc_time1[i][j]->GetMean());
hmdc_trend_meantime1[i][j]->SetBinContent(step_trend_meantime1_counter,hmdc_time1[i][j]->GetMean());
hmdc_trend_meantime1[i][j]->SetBinError( step_trend_meantime1_counter,stepsize_trend_meantime1/hmdc_time1[i][j]->Integral());
hmdc_summ_trend_meantime1->Fill(Double_t(j*6+i+0.5),Double_t(hmdc_time1[i][j]->GetMean()) );
}
hmdc_time1[i][j]->Reset();
if(hmdc_time1not_t1[i][j]->Integral()>0)
{
hmdc_trend_meantime1not_t1[i][j]->SetBinContent(step_trend_meantime1_counter,hmdc_time1not_t1[i][j]->GetMean());
hmdc_trend_meantime1not_t1[i][j]->SetBinError( step_trend_meantime1_counter,stepsize_trend_meantime1/hmdc_time1not_t1[i][j]->Integral());
hmdc_summ_trend_meantime1not_t1->Fill(Double_t(j*6+i+0.5),Double_t(hmdc_time1not_t1[i][j]->GetMean()) );
}
hmdc_time1not_t1[i][j]->Reset();
if(hmdc_time1not_t2[i][j]->Integral()>0)
{
hmdc_trend_meantime1not_t2[i][j]->SetBinContent(step_trend_meantime1_counter,hmdc_time1not_t2[i][j]->GetMean());
hmdc_trend_meantime1not_t2[i][j]->SetBinError( step_trend_meantime1_counter,stepsize_trend_meantime1/hmdc_time1not_t2[i][j]->Integral());
hmdc_summ_trend_meantime1not_t2->Fill(Double_t(j*6+i+0.5),Double_t(hmdc_time1not_t2[i][j]->GetMean()) );
}
hmdc_time1not_t2[i][j]->Reset();
if(hmdc_time1not_t12[i][j]->Integral()>0)
{
hmdc_trend_meantime1not_t12[i][j]->SetBinContent(step_trend_meantime1_counter,hmdc_time1not_t12[i][j]->GetMean());
hmdc_trend_meantime1not_t12[i][j]->SetBinError( step_trend_meantime1_counter,stepsize_trend_meantime1/hmdc_time1not_t12[i][j]->Integral());
hmdc_summ_trend_meantime1not_t12->Fill(Double_t(j*6+i+0.5),Double_t(hmdc_time1not_t12[i][j]->GetMean()) );
}
hmdc_time1not_t12[i][j]->Reset();
if(double_all[i][j][1]!=0)
{
hmdc_trend_neighbors[i][j]->SetBinContent(step_trend_meantime1_counter,(Float_t)double_all[i][j][0]/(Float_t)double_all[i][j][1]);
hmdc_summ_trend_neighbors->Fill( Double_t(j*6+i+0.5) , Double_t(double_all[i][j][0])/Double_t(double_all[i][j][1]) );
}
else
{
hmdc_trend_neighbors[i][j]->SetBinContent(step_trend_meantime1_counter,0);
}
if(stepsize_trend_meantime1>0)
{
hmdc_trend_123ratio[i][j]->SetBinContent(step_trend_meantime1_counter,(Float_t(cnt123[i][j])/Float_t(stepsize_trend_meantime1)) );
hmdc_summ_trend_123ratio->Fill(Double_t(j*6+i+0.5),(Double_t(cnt123[i][j])/Double_t(stepsize_trend_meantime1)) );
}
cnt123[i][j]=0;
for(Int_t mb=0; mb<16; mb++){
if(stepsize_trend_meantime1>0)
{
hmdc_trend_NhitsPERmbo[i][j][mb]->SetBinContent(step_trend_meantime1_counter,Float_t(NhitsPERmbo[i][j][mb])/Float_t(stepsize_trend_meantime1));
}
NhitsPERmbo[i][j][mb]=0;
}
if(hmdc_multiplicity[i][j]->Integral()>0)
{
hmdc_trend_multiplicity[i][j]->SetBinContent(step_trend_meantime1_counter,hmdc_multiplicity[i][j]->GetMean());
hmdc_trend_multiplicity[i][j]->SetBinError( step_trend_meantime1_counter,hmdc_multiplicity[i][j]->GetRMS()/hmdc_multiplicity[i][j]->Integral());
hmdc_summ_trend_multiplicity->Fill(Double_t(j*6+i+0.5),Double_t(hmdc_multiplicity[i][j]->GetMean()) );
}
hmdc_multiplicity[i][j]->Reset();
}
}
for(Int_t j=0;j<4;j++)
{
if(hmdc_time1_plane[j]->Integral()>0)
{
hmdc_trend_meantime1_plane[j]->SetBinContent(step_trend_meantime1_counter,hmdc_time1_plane[j]->GetMean());
hmdc_trend_meantime1_plane[j]->SetBinError(step_trend_meantime1_counter,(stepsize_trend_meantime1*numberOfSectorsPerModule[j])/hmdc_time1_plane[j]->Integral());
hmdc_summ_trend_meantime1_plane->Fill(Double_t(j), Double_t(hmdc_time1_plane[j]->GetMean()));
}
hmdc_time1_plane[j]->Reset();
}
step_trend_meantime1_counter++;
resetCounters();
}
else
{
Error("HMdcLOwLevelQA:execute()","Maximum number of steps in trend histograms exceeded!");
}
}
HMdcCal1* cal=0;
HMdcRaw* raw=0;
Int_t mb, ch;
Int_t l, c;
Int_t s,m;
Float_t time1=-99;
Float_t time2=-99;
itercal1->Reset();
iterraw->Reset();
while ((raw=(HMdcRaw *)iterraw->Next())!=0) {
raw->getAddress(s,m,mb,ch);
time1=raw->getTime(1);
time2=raw->getTime(2);
time1=-99;
time2=-99;
{
if(s==smmb_old[0] && m==smmb_old[1] && mb==smmb_old[2]){
}else{
smmb_old[0]=s, smmb_old[1]=m, smmb_old[2]=mb;
}
NhitsPERmbo[s][m][mb]++;
}
fillHistogramsRaw(s, m, mb, ch, time1, time2);
}
while ((cal=(HMdcCal1 *)itercal1->Next())!=0) {
cal->getAddress(s,m,l,c);
{
if(s==sm_old[0] && m==sm_old[1])
{
}
else
{
if(sect_module_NumberOfHits[sm_old[0]][sm_old[1]]>0 &&
sect_module_NumberOfHits[sm_old[0]][sm_old[1]]<4 )
{
cnt123[sm_old[0]][sm_old[1]]++;
}
hmdc_multiplicity[ s][m]->Fill(sect_module_NumberOfHits[s][m]);
hmdc_summ_dNdNhits[s][m]->Fill(sect_module_NumberOfHits[s][m]);
sect_module_NumberOfHits[s][m]=0;
sm_old[0]=s, sm_old[1]=m;
}
sect_module_NumberOfHits[s][m]++;
}
HMdcLookupCell& cell=(*lookupRaw)[s][m][l][c];
mb=cell.getNMoth();
ch=cell.getNChan();
time1=cal->getTime1();
time2=cal->getTime2();
testTimeCuts(s,m,time1,time2);
lookupSlopes(s,m);
if(cutResults[3]==1)checkNeighboringCells(s,m,c);
fillHistogramsCal(s,m,l,c,time1,time2);
hmdc_summ_dNdWire[s][m][l][0]->Fill(Double_t(c-0.5),1.);
if(cutResults[0]==1){
hmdc_summ_dNdWire[s][m][l][1]->Fill(Double_t(c-0.5),1.);
}
if(cutResults[3]==1){
hmdc_summ_dNdWire[s][m][l][2]->Fill(Double_t(c-0.5),1.);
}
time1=-99;
time2=-99;
}
return 0;
}
Last change: Sat May 22 13:02:51 2010
Last generated: 2010-05-22 13:02
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.