/** * For the ASY-EOS experiment * Kratta hit visualisator * 2012-03 * Sebastian.Kupny@uj.edu.pl * Based on examples UnpackerBasic.C and from examples in root tutorial * - fillrandom3D.C (histogram in OpenGL) * - hksimple.C (padRefresh function) * * [2013-02-13] This macro has to be updated, because Kratta data structures has been changed in last time. */ #include #include void padRefresh(TPad *pad,int flag=0); void UnpackerKrattaVisualisator(){ gSystem->Load("libMbs"); gSystem->Load("libMbsAPI"); gSystem->Load("libTCHIEvent"); gSystem->Load("libTMBALLEvent"); gSystem->Load("libTLANDEvent"); gSystem->Load("libTSTELEvent"); gSystem->Load("libTKRAKOWEvent"); gSystem->Load("libTKRATEvent"); gSystem->Load("libTRootEvent"); int Nruns; TString InFile ; ifstream inputfile; inputfile.open("runlist-local.dat"); inputfile >> Nruns; cout <<"Nruns ="<< Nruns << endl; MbsFile* myMbs=0; Int_t *status=new Int_t; Int_t* sebuflenght=new Int_t; Short_t* setype=new Short_t; Short_t* sesubtype=new Short_t; Char_t* sesubcrate=new Char_t; Int_t* SubEventDataPtr=new Int_t; string dir = getenv("VMCWORKDIR"); TKRATRawEvent eKrattaRawEvent; TKRATMapping KrattaMapping; KrattaMapping.Init( dir + "/calfiles/KRATTA/Asyeos_Kratta_Mapping.conf"); KrattaMapping.PrintMapping(); TFile f("dataKrattaRawEvents.root","recreate"); ///f.SetCompressionLevel(1); //try level 2 also TTree T("KRE","Kratta raw event"); T.Branch("KrattaRawEvent",&eKrattaRawEvent,10000); //T.Branch("TArray",&tempArray,10000); //T.Branch("KrattaPhotodiode",&eKrattaPhotodiode,10000); //T.Branch("KrattaRawEventNonEmpty",&eventNonEmpty,10000); //T.Branch("KrattaRawEventNo",&eventNo,10000); gStyle->SetCanvasPreferGL(kTRUE); TCanvas *c2 = new TCanvas("c2","Kratta hit visualisator (OpenGL)",200,10,700,500); c2->SetFillColor(18); pad1 = new TPad("pad1","Detector",0.05,0.05,0.95,0.95,21); pad1->Draw(); pad1->cd(); pad1->SetGridx(); pad1->SetGridy(); pad1->GetFrame()->SetFillColor(42); pad1->GetFrame()->SetBorderMode(-1); pad1->GetFrame()->SetBorderSize(5); h3detector = new TH3F("h3detector","Detector energy deposition",7,0,7,3,0,3,5,0,5); h3detector->SetXTitle("Column No"); h3detector->SetYTitle("Photodiode No"); h3detector->SetZTitle("Row No"); h3detector->SetFillColor(2); h3detector->Draw("glbox"); TPaveLabel * title = new TPaveLabel(-0.98,0.85,0.98,0.98, "" ); title->SetFillColor(16); title->SetTextFont(42); title->Draw(); Int_t krakowFiredPhotodiodes = 0; /// end of Kratta event/root/file for(int irun=0;irun>InFile; myMbs= new MbsFile(InFile,status); cout << "Next file" << endl; cout << irun<<" "<< InFile << endl; if(!(*status)){ myMbs->PrintFileHeader(); Int_t lastevent=0; Int_t i=0; ///Int_t chievt=0; ///Int_t mbsevt=0; while(!lastevent && lastevent !=3 ){ //lastevent = 3 means it is lastevent in file cout << "\r\r\r\r\r\rProced event i = "<< i << flush; lastevent = myMbs->GetEvent(); Int_t nrSubEvts=myMbs->GetNrSubEvent(); eKrattaRawEvent.Clear(); for(Int_t j=1;j<=nrSubEvts;j++){ SubEventDataPtr = myMbs->GetSubEvent(j,sebuflenght,setype,sesubtype,sesubcrate); if((*setype==10) && (*sesubtype==1) && (*SubEventDataPtr==256)){} if((*setype==10) && (*sesubtype==1) && (*SubEventDataPtr==512)){} if((*setype==36) && (*sesubtype==2700) ){} if((*setype==36) && (*sesubtype==9494) ){} if((*setype==32) && (*sesubtype==1130) ){} if((*setype==36) && (*sesubtype==2800) ){} if((*setype==34) && (*sesubtype==1) ){} if((*setype == 36) && (*sesubtype == 1) ) ///Kratta { eKrattaRawEvent.SetId( i ); krakowFiredPhotodiodes = eKrattaRawEvent.ProcessCurrentEventMBS ( SubEventDataPtr, *sebuflenght, KrattaMapping); h3detector->Reset(); Int_t sleepTime = 10*krakowFiredPhotodiodes; cout << "\t Fired photodiodes: " << krakowFiredPhotodiodes <<", sleep time[ms]: "<GetColumn_Int(); Int_t row = eKrattaRawEvent.GetPhotodiode( kratChann )->GetRow_Int(); Int_t phot = eKrattaRawEvent.GetPhotodiode( kratChann )->GetPhotodiode_Int(); h3detector->Fill(6-col, phot, row ); } } if ( krakowFiredPhotodiodes > 0 ) { TString label = TString( InFile ) + Form( ", Event No=%d", i ) ; title->SetLabel( label ); padRefresh(c2); gSystem->Sleep (sleepTime); } } } /// END LOOP OVER SUBEVENTS for(Int_t j=1;j<=nrSubEvts;j++) i++; T.Fill(); ///Filling the roottree } /// END LOOP OVER EVENTS while(!lastevent) myMbs->CloseFile(); } /// END CONDITION if(!(*status)) delete myMbs; } /// END LOOP OVER FILES for(int irun=0;irun Exit(0); } void padRefresh(TPad *pad,int flag) { if (!pad) return; pad->Modified(); pad->Update(); TList *tl = pad->GetListOfPrimitives(); if (!tl) return; TListIter next(tl); TObject *to; while ((to=next())) { if (to->InheritsFrom(TPad::Class())) padRefresh((TPad*)to,1);} if (flag) return; gSystem->ProcessEvents(); }