diff --git a/config/eventdisplay.xml b/config/eventdisplay.xml index e3a794e717e648c516b10af3084b33826d85adb4..79695167a3e1db55b8fb45a7040c98bef4a3252c 100644 --- a/config/eventdisplay.xml +++ b/config/eventdisplay.xml @@ -1,23 +1,25 @@ - <!-- // COLOR SET: + <!-- // you can set color name in 'color="color_name"' from predefined: white, black, gray, blue, azure (темно-синий), cyan (морской волны), teal (бирюзовый), green, spring (светло-зеленый), green+2 (темно-зеленый), spring+2 (темно-зеленый), khaki yellow, orange (желтый с оттенком), orange+2 (оранжевый кор.), orange+1 (светло-оранжевый кор.), orange+7 (выделенно-оранжевый) - red, violet, magenta (бардовый), magenta-6 (светло-бардовый), pink (темно-розовый) + red, violet, magenta (бардовый), magenta-6 (светло-бардовый), pink (темно-розовый). + or set rgb as decimal triple: 'color="RGB(r,g,b)"' or hex triple: 'color="RGB(#rgb_hex)"' --> <coloring type="detector"> - <subdetector name="ms01yokebarrel" color="blue" transparency="30" isRecursiveColoring="true"/> - <subdetector name="ms01cryostat" color="gray" transparency="15" isRecursiveColoring="true"/> - <subdetector name="ms01yokeendeii" color="blue" transparency="30" isRecursiveColoring="true"/> - <subdetector name="ms01yokeendeio" color="blue" transparency="30" isRecursiveColoring="true"/> - <subdetector name="ms01yokeendeim" color="blue" transparency="30" isRecursiveColoring="true"/> - <subdetector name="ms01yokeendeoi" color="blue" transparency="30" isRecursiveColoring="true"/> - <subdetector name="ms01yokeendeom" color="blue" transparency="30" isRecursiveColoring="true"/> - <subdetector name="ms01yokeendeoo" color="blue" transparency="30" isRecursiveColoring="true"/> - <subdetector name="pipe1" color="orange" transparency="0" isRecursiveColoring="true"/> - <subdetector name="tpcChamber1" color="cyan" transparency="0" isRecursiveColoring="true"/> - <subdetector name="tof1" color="spring" transparency="0" isRecursiveColoring="true"/> - <subdetector name="emc1Chamber1" color="violet" transparency="0" isRecursiveColoring="true"/> - <subdetector name="zdc01" color="green" transparency="0" isRecursiveColoring="true"/> + <subdetector name="ms01yokebarrel" color="gray" transparency="0" isRecursiveColoring="true"/> + <subdetector name="ms01cryostat" color="RGB(51,63,73)" transparency="15" isRecursiveColoring="true"/> <!--gray--> + <subdetector name="ms01yokeendeii" color="gray" transparency="0" isRecursiveColoring="true"/> + <subdetector name="ms01yokeendeio" color="gray" transparency="0" isRecursiveColoring="true"/> + <subdetector name="ms01yokeendeim" color="gray" transparency="0" isRecursiveColoring="true"/> + <subdetector name="ms01yokeendeoi" color="gray" transparency="0" isRecursiveColoring="true"/> + <subdetector name="ms01yokeendeom" color="gray" transparency="0" isRecursiveColoring="true"/> + <subdetector name="ms01yokeendeoo" color="gray" transparency="0" isRecursiveColoring="true"/> + <subdetector name="pipe1" color="RGB(225,55,0)" transparency="0" isRecursiveColoring="true"/> <!--orange--> + <subdetector name="tpcChamber1" color="RGB(0,170,225)" transparency="0" isRecursiveColoring="true"/> <!--cyan--> + <subdetector name="tof1" color="RGB(167,0,225)" transparency="0" isRecursiveColoring="true"/> <!--violet--> + <subdetector name="emc1Chamber1" color="RGB(170,225,0)" transparency="0" isRecursiveColoring="true"/> <!--yellow--> + <subdetector name="emc1EmptyChamber1" color="RGB(170,225,0)" transparency="0" isRecursiveColoring="true"/> <!--yellow--> + <subdetector name="zdc01" color="RGB(58,255,0)" transparency="0" isRecursiveColoring="true"/> <!--green--> </coloring> diff --git a/eventdisplay/FairEventManager.cxx b/eventdisplay/FairEventManager.cxx index 6256ff130ad38c35eab88e38b2497b953819fab2..a38b05588f8b09b22733a9a00dd078c88b6ba008 100644 --- a/eventdisplay/FairEventManager.cxx +++ b/eventdisplay/FairEventManager.cxx @@ -34,6 +34,7 @@ #include <unistd.h> #include <cerrno> #include <iostream> +#include <sstream> using namespace std; ClassImp(FairEventManager) @@ -80,7 +81,8 @@ FairEventManager::FairEventManager() fEntryCount(0), isZDCModule(NULL), fgShowRecoPointsIsShow(false), - fgRedrawRecoPointsReqired(false) + fgRedrawRecoPointsReqired(false), + fLastUsedColor(2001) { fgRinstance = this; @@ -105,7 +107,7 @@ void FairEventManager::InitColorStructure() cntSelectedColoring = 0; cntLevelColoring = 0; - if(ValidateXml(coloring_xml_path.Data(),coloring_xsd_path.Data())==true) + if (ValidateXml(coloring_xml_path.Data(),coloring_xsd_path.Data()) == true) { xmlNode* root_element = NULL; xmlSchemaPtr schema = NULL; @@ -145,7 +147,8 @@ void FairEventManager::InitColorStructure() int i=0; while (cur_node) { - if (strcmp((char*)cur_node->name, "text") != 0)//skipping elements with no attributes + if ((strcmp((char*)cur_node->name, "text") != 0) //skipping elements with no attributes + && (cur_node->type != XML_COMMENT_NODE)) { xmlAttr* attribute = cur_node->properties; while(attribute) @@ -523,6 +526,16 @@ void FairEventManager::LevelChangeNodeProperty(TGeoNode* node, int level) } } +// convert string with hexadecimal presentation without "0x" to integer +int hex_string_to_int(string hex_string) +{ + int x; + stringstream stream; + stream<<std::hex<<hex_string; + stream>>x; + return x; +} + //returns true if successful or false if validation failed bool FairEventManager::ValidateXml(const char *XMLFileName, const char *XSDFileName) { @@ -583,8 +596,63 @@ bool FairEventManager::ValidateXml(const char *XMLFileName, const char *XSDFileN // yellow, orange Int_t FairEventManager::GetColor(TString colorName) { + colorName = colorName.ReplaceAll(" ", ""); colorName.ToLower(); + // check if instead of color name we have an RGB triple + if (colorName.BeginsWith("rgb")) + { + // parse rgb triple + if (colorName < 6) + { + cout<<colorName<<" - RGB triple isn't correct. Color set to default blue"<<endl; + return 600; + } + TString triple = colorName(3, colorName.Length() - 3); + triple.Remove(TString::kLeading, '('); + triple.Remove(TString::kTrailing, ')'); + + int red_rgb = -1, green_rgb = -1, blue_rgb = -1; + if (triple[0] == '#') + { + if (triple < 7) + { + cout<<triple<<" - hex triple size after '#' isn't correct (should have 6 symbols). Color set to default blue"<<endl; + return 600; + } + + TString str_red = triple(1,2); + TString str_green = triple(3,2); + TString str_blue = triple(5,2); + if ((!str_red.IsHex()) || (!str_green.IsHex()) || (!str_blue.IsHex())) + { + cout<<triple<<" - hex triple after '#' has not hex format. Color set to default blue"<<endl; + return 600; + } + + red_rgb = hex_string_to_int(str_red.Data()); + green_rgb = hex_string_to_int(str_green.Data()); + blue_rgb = hex_string_to_int(str_blue.Data()); + } + else + { + TObjArray* pRGB = triple.Tokenize(","); + if (pRGB->GetEntriesFast() < 3) + { + cout<<triple<<" - RGB string doesn't include color triple. Color set to default blue"<<endl; + return 600; + } + red_rgb = ((TObjString*)pRGB->At(0))->GetString().Atoi(); + green_rgb = ((TObjString*)pRGB->At(1))->GetString().Atoi(); + blue_rgb = ((TObjString*)pRGB->At(2))->GetString().Atoi(); + delete pRGB; + } + + Int_t ci = fLastUsedColor++; + new TColor(ci, red_rgb/255.0F, green_rgb/255.0F, blue_rgb/255.0F); + return ci; + } + if (colorName == "white") return 0; else if (colorName == "black") return 1; else if (colorName == "gray") return 920; @@ -610,7 +678,7 @@ Int_t FairEventManager::GetColor(TString colorName) else if (colorName == "khaki") return 403; else { - std::cout<<colorName<<" not found. Color set to default blue" << std::endl; + cout<<colorName<<" not found. Color set to default blue"<<endl; return 600; } } diff --git a/eventdisplay/FairEventManager.h b/eventdisplay/FairEventManager.h index 83e3684f2119c757856eaa24e73ad0576c46d497..996c5bfbda3bb7841932d7ece5aa6ffb2114c6a7 100644 --- a/eventdisplay/FairEventManager.h +++ b/eventdisplay/FairEventManager.h @@ -176,6 +176,9 @@ class FairEventManager : public TEveEventManager // maximum energy to cut particles by energy in selected event Float_t fEvtMaxEnergy; //! + // the last color indice of Color Creating from rgb triple + Int_t fLastUsedColor; //! + // skeleton Singleton Instance static FairEventManager* fgRinstance; //! diff --git a/macro/eventdisplay/eventdisplay.C b/macro/eventdisplay/eventdisplay.C index 2b841c40c892603f196983fd45e3b1162c2cd618..124b4105c9fcada89235248a79f64d65819252a4 100644 --- a/macro/eventdisplay/eventdisplay.C +++ b/macro/eventdisplay/eventdisplay.C @@ -1,103 +1,89 @@ -// sim_file - file with simulation data, dst_file - file with DST data, out_file - output file -void eventdisplay (char* sim_file = 0, char* dst_file = 0, char* out_file = 0) +// EVENT DISPLAY macro for MPD simulated data +// +// sim_file - path to the file with MC data and detector geometry +// reco_file - file with reconstructed data for simulated events +// is_online: false - use Offline Mode (manual switching of events), default; true - use Online Mode (continious view events) +void eventdisplay(char* sim_file = "$VMCWORKDIR/macro/mpd/evetest.root", char* reco_file = "$VMCWORKDIR/macro/mpd/mpddst.root", bool is_online = false) { - TStopwatch timer; - timer.Start(); - gDebug = 0; - - - // load main and detectors libraries - gROOT->LoadMacro("$VMCWORKDIR/macro/mpd/mpdloadlibs.C"); - // load main and detectors libraries - mpdloadlibs(1,1); - - // load TEve libraries - gSystem->Load("libEve"); - gSystem->Load("libEventDisplay"); - - - // Define simulation file - TString simFile = "$VMCWORKDIR/macro/mpd/evetest.root"; - if (sim_file) - simFile = sim_file; - - // define parameter file - TString parFile = simFile; - - // define reconstructed file - TString dstFile = "$VMCWORKDIR/macro/mpd/mpddst.root"; - if (dst_file) - dstFile = dst_file; - - // define output file - TString outFile = "tmp.root"; - if (out_file) - outFile = out_file; - - // Create FairRunAna - FairRunAna *fRun = new FairRunAna(); - - // set input file - if (CheckFileExist(simFile)) - fRun->SetInputFile(simFile); - else - cout<<endl<<"ERROR: Input file wasn't found!"<<endl; - - // add friend file with reconstruction data - if (CheckFileExist(dstFile)) - fRun->AddFriend(dstFile); - else - cout<<endl<<"Warning: File with reconstructed data wasn't found!"<<endl; - - // set parameter file - if (CheckFileExist(parFile)) - { - FairRuntimeDb *rtdb = fRun->GetRuntimeDb(); - FairParRootFileIo *parIo1 = new FairParRootFileIo(); - parIo1->open(parFile.Data()); + gDebug = 0; + + // load main and detectors libraries + gROOT->LoadMacro("$VMCWORKDIR/macro/mpd/mpdloadlibs.C"); + mpdloadlibs(1,1); + + // load TEve libraries + gSystem->Load("libEve"); + gSystem->Load("libEventDisplay"); + + // CREATE FairRunAna + FairRunAna* fRun = new FairRunAna(); + + // check file existence with MC data and detector geometry + if (!CheckFileExist(sim_file)) + { + cout<<endl<<"ERROR: Simulation file with detector geometry wasn't found!"<<endl; + return; + } + + // set source of events to display and addtiional parameters + FairSource* fFileSource = new FairFileSource(sim_file); + + // set parameter file with MC data and detector geometry + FairRuntimeDb* rtdb = fRun->GetRuntimeDb(); + FairParRootFileIo* parIo1 = new FairParRootFileIo(); + parIo1->open(sim_file); rtdb->setFirstInput(parIo1); rtdb->setOutput(parIo1); rtdb->saveOutput(); - } - else - cout<<endl<<"ERROR: Parameter file wasn't found!"<<endl; - // set output file - fRun->SetOutputFile(outFile); + // add file with reconstructed data as a friend + if (CheckFileExist(reco_file)) + ((FairFileSource*)fFileSource)->AddFriend(reco_file); + else + cout<<endl<<"Warning: File with reconstructed data wasn't found!"<<endl; + + fRun->SetSource(fFileSource); + // Create Event Manager + FairEventManager* fMan = new FairEventManager(); + fMan->isOnline = is_online; - // Create event manager - FairEventManager *fMan= new FairEventManager(); + // set output file + fRun->SetOutputFile("ed_out.root"); - // draw MC points - FairMCPointDraw *TpcPoint = new FairMCPointDraw("TpcPoint", kOrange, kDot); - fMan->AddTask(TpcPoint); - FairMCPointDraw *TofPoint = new FairMCPointDraw("TOFPoint", kOrange, kDot); - fMan->AddTask(TofPoint); - FairMCPointDraw *ZdcPoint = new FairMCPointDraw("ZdcPoint", kOrange, kFullSquare); - fMan->AddTask(ZdcPoint); - FairMCPointDraw *EmcPoint = new FairMCPointDraw("EmcPoint", kOrange, kDot); - fMan->AddTask(EmcPoint); + // set FairRunAna drawing tasks + Style_t pointMarker = kFullDotSmall; + Color_t mcPointColor = kOrange, recoPointColor = kBlack; - // draw MC geometry tracks - FairMCTracks* GeoTrack = new FairMCTracks("GeoTracks"); - fMan->AddTask(GeoTrack); + // draw MC points + FairMCPointDraw *TpcPoint = new FairMCPointDraw("TpcPoint", mcPointColor, kDot); + fMan->AddTask(TpcPoint); + FairMCPointDraw *TofPoint = new FairMCPointDraw("TOFPoint", mcPointColor, kDot); + fMan->AddTask(TofPoint); + FairMCPointDraw *ZdcPoint = new FairMCPointDraw("ZdcPoint", mcPointColor, kFullSquare); + fMan->AddTask(ZdcPoint); + FairMCPointDraw *EmcPoint = new FairMCPointDraw("EmcPoint", mcPointColor, kDot); + fMan->AddTask(EmcPoint); - // draw MC tracks - //FairMCStack* MCTrack = new FairMCStack("MCTrack"); - //fMan->AddTask(MCTrack); + // draw MC geometry tracks + FairMCTracks* GeoTrack = new FairMCTracks("GeoTracks"); + fMan->AddTask(GeoTrack); - // DST hits - FairHitPointSetDraw *MpdTpcHit = new FairHitPointSetDraw("MpdTpcHit", kOrange, kDot); - fMan->AddTask(MpdTpcHit); + // draw MC tracks + //FairMCStack* MCTrack = new FairMCStack("MCTrack"); + //fMan->AddTask(MCTrack); - // DST hits (box view) - //FairHitDraw *MpdTpcHit = new FairHitDraw("MpdTpcHit", 1); - //fMan->AddTask(MpdTpcHit); + // DST hits + FairHitPointSetDraw *MpdTpcHit = new FairHitPointSetDraw("MpdTpcHit", mcPointColor, kDot); + fMan->AddTask(MpdTpcHit); - // DST tracks - MpdGlobalTrackDraw *MpdGlobalTrack = new MpdGlobalTrackDraw("GlobalTracks"); - fMan->AddTask(MpdGlobalTrack); + // DST hits (box view) + //FairHitDraw *MpdTpcHit = new FairHitDraw("MpdTpcHit", 1); + //fMan->AddTask(MpdTpcHit); + + // DST tracks + MpdGlobalTrackDraw *MpdGlobalTrack = new MpdGlobalTrackDraw("GlobalTracks"); + fMan->AddTask(MpdGlobalTrack); // draw EMC towers : MpdEmcTowerDraw(TaskName, emcEnergyThreshold in GeV, 2) MpdEmcTowerDraw *MpdEmcTower= new MpdEmcTowerDraw("MpdEmcTower", 0.0075, 2); @@ -107,23 +93,24 @@ void eventdisplay (char* sim_file = 0, char* dst_file = 0, char* out_file = 0) MpdZdcTowerDraw *MpdZdcTower= new MpdZdcTowerDraw("MpdZdcTower", 0.0001, kFALSE, 2); fMan->AddTask(MpdZdcTower); - if (gGeoManager) - gGeoManager->SetVisLevel(3); + // save EventDisplay Screenshot + //FairWebScreenshots* WebScreenshots = new FairWebScreenshots("WebScreenshots", "/var/www/html/events"); // for WEB-page + //FairWebScreenshots* WebScreenshots = new FairWebScreenshots("WebScreenshots","screenshots"); // folder to save the screenshots + //WebScreenshots->SetFormatFiles(0); // 0 -.png, 1 -.jpg, 2 -.jpg and .png + //WebScreenshots->SetMultiFiles(0); //0 - the same file (event.png), 1 - multiple files (event_nnn.png) + //WebScreenshots->SetPort(8016); // 8016 by default + //fMan->AddTask(WebScreenshots); + - //fMan->background_color = 17; + //if (gGeoManager) + // gGeoManager->SetVisLevel(3); - //FairEventManager::Init(Int_t visopt = 1, Int_t vislvl = 3, Int_t maxvisnds = 10000); - fMan->Init(); + // FairEventManager::Init(Int_t visopt = 1, Int_t vislvl = 3, Int_t maxvisnds = 10000) + fMan->Init(); // ----- Finish ------------------------------------------------------- - timer.Stop(); - Double_t rtime = timer.RealTime(); - Double_t ctime = timer.CpuTime(); cout << endl << endl; cout << "Event Display was initialized successfully." << endl; - cout << "Output file is " << outFile << endl; - cout << "Parameter file is " << parFile << endl; - cout << "Initialization: Real time " << rtime << " s, CPU time " << ctime << " s" << endl; cout << endl; // ------------------------------------------------------------------------ } diff --git a/macro/mpd_scheduler b/macro/mpd_scheduler index 359776e24be261ff7b620c0b6b04214308a5ef7e..b125ce9650e775cbf59582e14301757c01ec0209 160000 --- a/macro/mpd_scheduler +++ b/macro/mpd_scheduler @@ -1 +1 @@ -Subproject commit 359776e24be261ff7b620c0b6b04214308a5ef7e +Subproject commit b125ce9650e775cbf59582e14301757c01ec0209