/** * 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 UnpackerKrattaVisualisatorWithPulseShapes(){ gSystem->Load("libFairTools"); gSystem->Load("libGeoBase"); gSystem->Load("libParBase"); gSystem->Load("libBase"); gSystem->Load("libMbs"); gSystem->Load("libMbsAPI"); gSystem->Load("libTCHIEvent"); gSystem->Load("libTLANDEvent"); gSystem->Load("libTKRATEvent"); gSystem->Load("libTRootEvent"); gSystem->Load("libTCHIGridCsI"); gSystem->Load("libMBSUnpack"); gSystem->Load("libMerger"); gSystem->Load("libTMBALLEvent"); gSystem->Load("libAnaCHI"); ///Load libs for kratta analysis gSystem->Load("libTKratAnaStep1"); gSystem->Load("libTKratAnaStep2"); gSystem->Load("libKratMktreedst"); gSystem->Load("libTKRATEventParam"); 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); TCanvas *c1 = new TCanvas("c1","Kratta hits - pulse shapes",200,10,700,500); c1->Divide(7, 15); TH1I *hPhot[105]; for (Int_t ih = 0; ih < 35; ih++){ TString hName = Form("hPulse_%d", ih ); hPhot[ih] = new TH1I(hName, hName, 512, 0 , 512); hPhot[ih] -> SetLineColor( 2 ); } for (Int_t ih = 35; ih < 70; ih++){ TString hName = Form("hPulse_%d", ih ); hPhot[ih] = new TH1I(hName, hName, 1024, 0 , 1024); hPhot[ih] -> SetLineColor( 3 ); } for (Int_t ih = 70; ih < 105; ih++){ TString hName = Form("hPulse_%d", ih ); hPhot[ih] = new TH1I(hName, hName, 1024, 0 , 1024); hPhot[ih] -> SetLineColor( 4 ); } for (Int_t ih = 0; ih < 105; ih++) { c1->cd(1+ih); hPhot[ih]->Draw(); } 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 ); cout << "IM HERE 0 "<< endl; krakowFiredPhotodiodes = eKrattaRawEvent.ProcessCurrentEventMBS ( SubEventDataPtr, (*sebuflenght)/2-1, KrattaMapping); cout << "IM HERE 1 "<< endl; h3detector->Reset(); cout << "IM HERE 2 "<< endl; for (Int_t ih = 0; ih < 105; ih++) { hPhot[ih]->Reset(); } Int_t sleepTime = 100*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(col, phot, row ); Int_t * ArrayPtr = eKrattaRawEvent.GetSignalArray( kratChann ); for(Int_t iph = 0; iph < eKrattaRawEvent.GetSignalArraySize( kratChann ); iph++) { hPhot[ kratChann ]->Fill(iph, ArrayPtr[iph] ); } hPhot[ kratChann ]->SaveAs(Form("Pulse_Ev_%d_Chan_%d.root",i, kratChann)); } } if ( krakowFiredPhotodiodes > 0 ) { TString label = TString( InFile ) + Form( ", Event No=%d", i ) ; title->SetLabel( label ); padRefresh(c1); 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(); }