#include "tpc/TpcGem.h" #include "tpc/TpcPadPlane.h" #include "tpc/TpcPadShapePool.h" #include "tpc/TpcDigi.h" #include "TCanvas.h" #include "TFile.h" #include "TClonesArray.h" #include "TTree.h" #include "TH2D.h" #include "TStyle.h" #include "algorithm" #include "sstream" #include "tpc/TpcDigiAge.h" #include "TSystem.h" void plotDigis(TString datafile, TString padplane, TString padshapes, bool movie=false){ gStyle->SetFillColor(kWhite); TCanvas* c=new TCanvas("c1","Tpc Digis",0,0,600,600); //TODO: Get these things from Database!!! TpcGem* _gem=new TpcGem(5000, // Gain 0.02); // Spread TpcPadShapePool* _padShapes = new TpcPadShapePool(padshapes.Data(), *_gem, 0.5, // lookup range 0.02, // Lookup Step 0.01); // LookupIntegrationStep TpcPadPlane* _padPlane= new TpcPadPlane(padplane.Data(),_padShapes); TFile* file = new TFile(datafile); if(!file)return; //TGeoManager *geoMan = (TGeoManager*) file->Get("CBMGeom"); TTree *t=(TTree*)file->Get("cbmsim") ; TClonesArray *sa=new TClonesArray("TpcDigi"); t->SetBranchAddress("TpcDigi",&sa); TH2D* ma=new TH2D("map","Hit pads",420,-42,42,420,-42,42); for (Int_t j=0; j< t->GetEntriesFast(); j++) { t->GetEntry(j); for (Int_t i=0; iGetEntriesFast(); i++) { TpcDigi *sig=(TpcDigi*)sa->At(i); double x,y; _padPlane->GetPadXY(sig->padId(),x,y); ma->Fill(x,y,sig->amp()); } } ma->Draw("LEGO"); //c->SaveAs("allDigis.eps"); if(movie){ // Produce movie ma->Reset(); ma->SetDrawOption("COL"); // get first event std::vector vd; Int_t ndig=0; Int_t evt=0; while(ndig<1){ t->GetEntry(evt++); ndig=sa->GetEntriesFast(); } for (Int_t i=0; iAt(i); vd.push_back(sig); } //sort in time; sort(vd.begin(),vd.end(),TpcDigiAge()); // make frames Int_t t1=0; int counter=0; for(Int_t i=0; it()-t1>20){ t1=sig->t(); // print frame std::ostringstream file; file<<"frames/digi"; if(counter<100)file<<"0"; if(counter<10)file<<"0"; file<Draw("COL"); c->SaveAs(file.str().c_str()); ma->Reset(); } double x,y; _padPlane->GetPadXY(sig->padId(),x,y); ma->Fill(x,y,sig->amp()); } gSystem->Exec("gifsicle --delay=10 --loop=5 frames/digi*.gif > anim.gif"); } }