#include "honlinemonhist.h" #include "honlinehistarray.h" #include "honlinetrendhist.h" #include "hcategory.h" #include "rpcdef.h" #include "hrpcraw.h" //#include "hcategory.h" #include "fwdetdef.h" #include "hstsraw.h" #include "hstscal.h" #include "hstsgeompar.h" #include "hfrpcraw.h" #include "hfrpccal.h" #include "hfrpchit.h" #include "hforwardcand.h" //#include "tofdef.h" //#include "htofraw.h" //#include "htofhit.h" #include "helpers.h" #include "TList.h" #include "TString.h" #include #include using namespace std; map < TString , HOnlineMonHistAddon* > stsMap; //---------------------------------------------------------------------------------------------- // Initialize histograms //---------------------------------------------------------------------------------------------- struct stsP { // 2D histograms tables (straw_module:straw_layer) HOnlineMonHistAddon* h_Sts_straw_cnts = 0; HOnlineMonHistAddon* h_Sts_straw_tot = 0; HOnlineMonHistAddon* h_Sts_straw_tlead = 0; // 1D histograms tables (straw_module) HOnlineMonHistAddon* h_Sts_straws_tot_m1 = 0; HOnlineMonHistAddon* h_Sts_straws_tot_m2 = 0; HOnlineMonHistAddon* h_Sts_straws_tlead_m1 = 0; HOnlineMonHistAddon* h_Sts_straws_tlead_m2 = 0; // 1D histograms table (straw_module) - number of entries per event (multiplicity) HOnlineMonHistAddon* h_Sts_multiplicity = 0; }; stsP* pSts; //---------------------------------------------------------------------------------------------- // Create histograms //---------------------------------------------------------------------------------------------- // Array of indices for short straws Bool_t createHistSts(TList& histpool) { mapHolder::setMap(stsMap); // make stsMap currentMap // const size_t straw_mods = 2; // const size_t straw_layers = 4; //---------------------------------------------------------------------------------------------- // Defining histogram parameters //---------------------------------------------------------------------------------------------- const Char_t* hists[] = { // 2D histograms tables (straw_module:straw_layer) "FORMAT#array TYPE#2F NAME#h_Sts_straw_cnts TITLE#Straw_Counts ACTIVE#1 RESET#1 REFRESH#50000 BIN#224:0.0:224.0:3:-1.0:1.0 SIZE#2:4 AXIS#Straw:Shape:no DIR#no OPT#colz STATS#0 LOG#0:0:0 GRID#1:1 LINE#1:0 FILL#0:0 MARKER#0:0:0 RANGE#-99:-99" ,"FORMAT#array TYPE#2F NAME#h_Sts_straw_tot TITLE#Straw_ToT ACTIVE#1 RESET#1 REFRESH#50000 BIN#448:0.0:448.0:99:5.0:500.0 SIZE#2:4 AXIS#Straw:ToT_[ns]:no DIR#no OPT#colz STATS#0 LOG#0:0:0 GRID#1:1 LINE#1:0 FILL#0:0 MARKER#0:0:0 RANGE#-99:-99" ,"FORMAT#array TYPE#2F NAME#h_Sts_straw_tlead TITLE#Straw_Drift_Time ACTIVE#1 RESET#1 REFRESH#50000 BIN#448:0.0:448.0:100:0.0:800.0 SIZE#2:4 AXIS#Straw:Drift_Time_[ns]:no DIR#no OPT#colz STATS#0 LOG#0:0:0 GRID#1:1 LINE#1:0 FILL#0:0 MARKER#0:0:0 RANGE#-99:-99" // // 1D histograms tables (straw_module) ,"FORMAT#array TYPE#1F NAME#h_Sts_straws_tot_m1 TITLE#ToT_m1 ACTIVE#1 RESET#1 REFRESH#50000 BIN#100:0.0:500.0:0:0.0:0.0 SIZE#1:4 AXIS#ToT_[ns]:counts:no DIR#no OPT#no STATS#0 LOG#0:0:0 GRID#1:1 LINE#1:0 FILL#38:0 MARKER#0:0:0 RANGE#-99:-99" ,"FORMAT#array TYPE#1F NAME#h_Sts_straws_tot_m2 TITLE#ToT_m2 ACTIVE#1 RESET#1 REFRESH#50000 BIN#100:0.0:500.0:0:0.0:0.0 SIZE#1:4 AXIS#ToT_[ns]:counts:no DIR#no OPT#no STATS#0 LOG#0:0:0 GRID#1:1 LINE#1:0 FILL#38:0 MARKER#0:0:0 RANGE#-99:-99" ,"FORMAT#array TYPE#1F NAME#h_Sts_straws_tlead_m1 TITLE#Drift_Time_m1 ACTIVE#1 RESET#1 REFRESH#50000 BIN#100:0.0:800.0:0:0.0:0.0 SIZE#1:4 AXIS#Drift_Time_[ns]:counts:no DIR#no OPT#no STATS#0 LOG#0:0:0 GRID#1:1 LINE#1:0 FILL#38:0 MARKER#0:0:0 RANGE#-99:-99" ,"FORMAT#array TYPE#1F NAME#h_Sts_straws_tlead_m2 TITLE#Drift_Time_m2 ACTIVE#1 RESET#1 REFRESH#50000 BIN#100:0.0:800.0:0:0.0:0.0 SIZE#1:4 AXIS#Drift_Time_[ns]:counts:no DIR#no OPT#no STATS#0 LOG#0:0:0 GRID#1:1 LINE#1:0 FILL#38:0 MARKER#0:0:0 RANGE#-99:-99" // 1D histograms table (straw_module) - number of entries per event (multiplicity) , "FORMAT#array TYPE#1F NAME#h_Sts_multiplicity TITLE#Multiplicity ACTIVE#1 RESET#1 REFRESH#50000 BIN#50:0.0:50.0:0:0.0:0.0 SIZE#1:3 AXIS#Multiplicity:counts:no DIR#no OPT#no STATS#0 LOG#0:0:0 GRID#1:1 LINE#1:0 FILL#46:0 MARKER#0:0:0 RANGE#-99:-99" //"FORMAT#array TYPE#1F NAME#hMdcFiredWiresChambertemp2 TITLE#fired_wires_distribution ACTIVE#1 RESET#1 REFRESH#5000 BIN#200:0:200:0:0:0 SIZE#6:4 AXIS#fired_wires_per_event:counts:no DIR#no OPT#no STATS#0 LOG#0:1:0 GRID#1:1 LINE#0:0 FILL#0:0 MARKER#0:0:0 RANGE#-99:-99 LEGEND#-1:-1:-1:-1:no" }; // Create histograms and add them to the pool mapHolder::createHists(sizeof(hists)/sizeof(Char_t*),hists,histpool); // ??? pSts = new stsP(); // 2D histograms tables (straw_module:straw_layer) pSts->h_Sts_straw_cnts = get("h_Sts_straw_cnts"); pSts->h_Sts_straw_tot = get("h_Sts_straw_tot"); pSts->h_Sts_straw_tlead = get("h_Sts_straw_tlead"); // 1D histograms tables (straw_module) pSts->h_Sts_straws_tot_m1 = get("h_Sts_straws_tot_m1"); pSts->h_Sts_straws_tot_m2 = get("h_Sts_straws_tot_m2"); pSts->h_Sts_straws_tlead_m1 = get("h_Sts_straws_tlead_m1"); pSts->h_Sts_straws_tlead_m2 = get("h_Sts_straws_tlead_m2"); // 1D histogram - number of entries per event pSts->h_Sts_multiplicity = get("h_Sts_multiplicity"); //---------------------------------------------------------------------------------------------- // Setting colors for histogram arrays //---------------------------------------------------------------------------------------------- // Colors Int_t colorsSector[6] = {2, 4, 6, 8, 38, 46}; HOnlineMonHistAddon* addon = 0; if( (addon = pSts->h_Sts_multiplicity )) { for(Int_t s = 0; s < 3; s ++) { addon->getP(0,s)->SetLineColor(colorsSector[s]); } } /* HOnlineMonHistAddon* addon = 0; if( (addon = pSts->hTofhits_raw )) { for(Int_t s = 0; s < 6; s ++) { addon->getP(0,s)->SetLineColor(colorsSector[s]); } } if( (addon = pSts->hTofmult_trend_raw )) { for(Int_t s = 0; s < 6; s ++) { addon->getP(0,s)->SetLineColor(colorsSector[s]); addon->getP(0,s)->SetMarkerColor(colorsSector[s]); } } if((addon = pSts->hTof_RpcTMultiplicity)) { for(Int_t i = 0; i < 4; i++) { addon->getP(0,i)->SetLineColor(colorsSector[i]); addon->getP(0,i)->SetLineWidth(2); } } if((addon = pSts->hTofMultiplicity)) { for(Int_t i = 0; i < 4; i++) { addon->getP(0,i)->SetLineColor(colorsSector[i]); addon->getP(0,i)->SetLineWidth(2); } } if((addon = pSts->hTof_RpcTofMultiplicity)) {for(Int_t i = 0; i < 4; i++) { addon->getP(0,i)->SetLineColor(colorsSector[i]); addon->getP(0,i)->SetLineWidth(2); } } */ if(pSts->h_Sts_straws_tot_m1) { for(Int_t i = 0; i < 4; i ++) { pSts->h_Sts_straws_tot_m1->getP(0,i)->SetLineColor(i+1); pSts->h_Sts_straws_tot_m1->getP(0,i)->SetLineWidth(2); pSts->h_Sts_straws_tot_m1->getP(0,i)->SetFillStyle(0); } auto* leg_Sts_straws_tot_m1 = new TLegend(0.68, 0.68, .88, .88); leg_Sts_straws_tot_m1->AddEntry(pSts->h_Sts_straws_tot_m1->getP(0,0), "Layer_1", "l"); leg_Sts_straws_tot_m1->AddEntry(pSts->h_Sts_straws_tot_m1->getP(0,1), "Layer_2", "l"); leg_Sts_straws_tot_m1->AddEntry(pSts->h_Sts_straws_tot_m1->getP(0,2), "Layer_3", "l"); leg_Sts_straws_tot_m1->AddEntry(pSts->h_Sts_straws_tot_m1->getP(0,3), "Layer_4", "l"); pSts->h_Sts_straws_tot_m1->setLegend(leg_Sts_straws_tot_m1); } if(pSts->h_Sts_straws_tot_m2) { for(Int_t i = 0; i < 4; i ++) { pSts->h_Sts_straws_tot_m2->getP(0,i)->SetLineColor(i+1); pSts->h_Sts_straws_tot_m2->getP(0,i)->SetLineWidth(2); pSts->h_Sts_straws_tot_m2->getP(0,i)->SetFillStyle(0); } auto* leg_Sts_straws_tot_m2 = new TLegend(0.68, 0.68, .88, .88); leg_Sts_straws_tot_m2->AddEntry(pSts->h_Sts_straws_tot_m2->getP(0,0), "Layer_1", "l"); leg_Sts_straws_tot_m2->AddEntry(pSts->h_Sts_straws_tot_m2->getP(0,1), "Layer_2", "l"); leg_Sts_straws_tot_m2->AddEntry(pSts->h_Sts_straws_tot_m2->getP(0,2), "Layer_3", "l"); leg_Sts_straws_tot_m2->AddEntry(pSts->h_Sts_straws_tot_m2->getP(0,3), "Layer_4", "l"); pSts->h_Sts_straws_tot_m2->setLegend(leg_Sts_straws_tot_m2); } if(pSts->h_Sts_straws_tlead_m1) { for(Int_t i = 0; i < 4; i ++) { pSts->h_Sts_straws_tlead_m1->getP(0,i)->SetLineColor(i+1); pSts->h_Sts_straws_tlead_m1->getP(0,i)->SetLineWidth(2); pSts->h_Sts_straws_tlead_m1->getP(0,i)->SetFillStyle(0); } auto* leg_Sts_straws_tlead_m1 = new TLegend(0.12, 0.68, .32, .88); leg_Sts_straws_tlead_m1->AddEntry(pSts->h_Sts_straws_tlead_m1->getP(0,0), "Layer_1", "l"); leg_Sts_straws_tlead_m1->AddEntry(pSts->h_Sts_straws_tlead_m1->getP(0,1), "Layer_2", "l"); leg_Sts_straws_tlead_m1->AddEntry(pSts->h_Sts_straws_tlead_m1->getP(0,2), "Layer_3", "l"); leg_Sts_straws_tlead_m1->AddEntry(pSts->h_Sts_straws_tlead_m1->getP(0,3), "Layer_4", "l"); pSts->h_Sts_straws_tlead_m1->setLegend(leg_Sts_straws_tlead_m1); } if(pSts->h_Sts_straws_tlead_m2) { for(Int_t i = 0; i < 4; i ++) { pSts->h_Sts_straws_tlead_m2->getP(0,i)->SetLineColor(i+1); pSts->h_Sts_straws_tlead_m2->getP(0,i)->SetLineWidth(2); pSts->h_Sts_straws_tlead_m2->getP(0,i)->SetFillStyle(0); } auto* leg_Sts_straws_tlead_m2 = new TLegend(0.12, 0.68, .32, .88); leg_Sts_straws_tlead_m2->AddEntry(pSts->h_Sts_straws_tlead_m2->getP(0,0), "Layer_1", "l"); leg_Sts_straws_tlead_m2->AddEntry(pSts->h_Sts_straws_tlead_m2->getP(0,1), "Layer_2", "l"); leg_Sts_straws_tlead_m2->AddEntry(pSts->h_Sts_straws_tlead_m2->getP(0,2), "Layer_3", "l"); leg_Sts_straws_tlead_m2->AddEntry(pSts->h_Sts_straws_tlead_m2->getP(0,3), "Layer_4", "l"); pSts->h_Sts_straws_tlead_m2->setLegend(leg_Sts_straws_tlead_m2); } //---------------------------------------------------------------------------------------------- // Accessing geometry container //---------------------------------------------------------------------------------------------- HRuntimeDb *rtdb = HRuntimeDb::instance();//myHades -> getRuntimeDb(); HStsGeomPar* pStrawGeomPar = (HStsGeomPar *)gHades->getRuntimeDb()->getContainer("StsGeomPar"); // Checking if parameters container for geometry was created properly if (!pStrawGeomPar) { Error("HStsDigitizer::init()","Parameter container for geometry not created"); return kFALSE; } rtdb->initContainers(1); rtdb->print(); // Print detector parameters on screen //pStrawGeomPar->printParams(); //Float_t sina[FWDET_STRAW_MAX_MODULES][FWDET_STRAW_MAX_LAYERS]; //Float_t cosa[FWDET_STRAW_MAX_MODULES][FWDET_STRAW_MAX_LAYERS]; for (Int_t m = 0; m < STS_MAX_MODULES; ++m) { /* for (Int_t l = 0; l < FWDET_STRAW_MAX_LAYERS; ++l) { Float_t a = pStrawGeomPar->getLayerRotation(m, l) * TMath::DegToRad(); cosa[m][l] = TMath::Cos(a); sina[m][l] = TMath::Sin(a); } */ } return kTRUE; } //---------------------------------------------------------------------------------------------- // Main part of the program //---------------------------------------------------------------------------------------------- Bool_t fillHistSts(Int_t evtCt) { mapHolder::setMap(stsMap); // make stsMap currentMap //---------------------------------------------------------------------------------------------- // Categories to access //---------------------------------------------------------------------------------------------- HCategory* fStsRaw = gHades->getCurrentEvent()->getCategory(catStsRaw); // HCategory* fStsCal = gHades->getCurrentEvent()->getCategory(catStsCal); // HCategory* fStsetCand = gHades->getCurrentEvent()->getCategory(catStsetCand); //---------------------------------------------------------------------------------------------- // fStsRaw category - accessing, loop over entries and filling histograms //---------------------------------------------------------------------------------------------- if(fStsRaw) { HStsRaw * stsstraw; // Initializing HStsRaw pointer Int_t multiplicity_ALL = fStsRaw->getEntries(); // Get number of entries (number of signals registered by straws) in one event Int_t multiplicity_STS1 = 0; Int_t multiplicity_STS2 = 0; for(Int_t i = 0; i < fStsRaw->getEntries(); i ++) // Loop over entries inside each event { stsstraw = (HStsRaw*)fStsRaw->getObject(i); // Get fStsRaw object if(stsstraw) // Check if "stsstraw" object was accessed properly { // Initializing extracted variables Char_t mod, lay, ud; // mod - Module, lay - Layer, ud - upper/lower (short) or long straw Int_t straw; // Straw index Float_t time, width; // time - time of first registration of signal (crossing threshold), width - Time over Threshold // Getting values of each variable in this entry stsstraw->getAddress(mod, lay, straw, ud); stsstraw->getTimeAndWidth(time, width); // Defining structure to account for presence of long and short straws in detector float side = 2; switch (ud) { case 0b01: side = -0.5; break; // Lower short straw case 0b10: side = +0.5; break; // Upper short straw case 0b11: side = 0; break; // Long straw default: break; } // Filling multiplicity for STS1 and STS2 if ( mod == 0 ) multiplicity_STS1 = multiplicity_STS1 + 1; if ( mod == 1 ) multiplicity_STS2 = multiplicity_STS2 + 1; // Filling counts per straw histograms if (side == 2) continue; // Skip if no hit registered in straws if (side == 0) // If hit in long straw { if(pSts->h_Sts_straw_cnts) pSts->h_Sts_straw_cnts->getP((Int_t)mod,(Int_t)lay)->Fill(straw, -0.5); if(pSts->h_Sts_straw_cnts) pSts->h_Sts_straw_cnts->getP((Int_t)mod,(Int_t)lay)->Fill(straw, 0); if(pSts->h_Sts_straw_cnts) pSts->h_Sts_straw_cnts->getP((Int_t)mod,(Int_t)lay)->Fill(straw, +0.5); } else // If hit in short straw { if(pSts->h_Sts_straw_cnts) pSts->h_Sts_straw_cnts->getP((Int_t)mod,(Int_t)lay)->Fill(straw, side); } Int_t straw_index = HStsCal::calcStrawIndex(straw, ud); // Filling ToT and TLead per straw histograms if (side == -0.5) // If hit in lower short straw { if(pSts->h_Sts_straw_tot) pSts->h_Sts_straw_tot->getP((Int_t)mod,(Int_t)lay)->Fill(straw_index, width); if(pSts->h_Sts_straw_tlead) pSts->h_Sts_straw_tlead->getP((Int_t)mod,(Int_t)lay)->Fill(straw_index, time); } else { if(pSts->h_Sts_straw_tot) pSts->h_Sts_straw_tot->getP((Int_t)mod,(Int_t)lay)->Fill(straw_index, width); if(pSts->h_Sts_straw_tlead) pSts->h_Sts_straw_tlead->getP((Int_t)mod,(Int_t)lay)->Fill(straw_index, time); } // Filling ToT and TLead histograms if (mod == 0) { if(pSts->h_Sts_straws_tot_m1) pSts->h_Sts_straws_tot_m1->getP(0,(Int_t)lay)->Fill(width); if(pSts->h_Sts_straws_tlead_m1) pSts->h_Sts_straws_tlead_m1->getP(0,(Int_t)lay)->Fill(time); } else if (mod == 1) { if(pSts->h_Sts_straws_tot_m2) pSts->h_Sts_straws_tot_m2->getP(0,(Int_t)lay)->Fill(width); if(pSts->h_Sts_straws_tlead_m2) pSts->h_Sts_straws_tlead_m2->getP(0,(Int_t)lay)->Fill(time); } } } // Filling multiplicity histograms if(pSts->h_Sts_multiplicity) pSts->h_Sts_multiplicity->getP(0,0)->Fill(multiplicity_ALL); if(pSts->h_Sts_multiplicity) pSts->h_Sts_multiplicity->getP(0,1)->Fill(multiplicity_STS1); if(pSts->h_Sts_multiplicity) pSts->h_Sts_multiplicity->getP(0,2)->Fill(multiplicity_STS2); } //---------------------------------------------------------------------------------------------- // Reset if needed //---------------------------------------------------------------------------------------------- mapHolder::resetHists(evtCt); return kTRUE; }