// selecting infos #include void zipZ(std::string einFile,Int_t slim) { // ----- Load libraries ------------------------------------------------ gROOT->Macro("$VMCWORKDIR/gconfig/rootlogon.C"); // ----- Timer -------------------------------------------------------- TStopwatch timer; timer.Start(); // ------------------------------------------------------------------------ ifstream text(einFile.c_str()); string nome; text >> nome; // std::string path("/hiskp1/bianco/mvd/THOMAS/HV/B1/CABLES/"); // std::string inFile = path + nome; std::string inFile = nome; cout << "-----------\nreading: " << nome <<"\n-------------" << endl; TVector3 in,out,dist; Double_t effradl,effradlsum,radlen; Double_t z,phi; Int_t size,sizebase; size = nome.length(); sizebase = size - 5; std::string base; strncpy(base.c_str(),nome.c_str(),sizebase); base[sizebase]='\0'; std::string outfileStr = Form("%s%s", base.c_str(), "ZIP.root"); cout << "BASE: " << base.c_str() << endl; cout << "OUTPUT: "<< outfileStr.c_str() << endl; TFile* f = new TFile(inFile.c_str()); // the sim file you want to analyse TFile* outfile = new TFile(outfileStr.c_str(),"RECREATE"); TTree *t=(TTree *) f->Get("cbmsim") ; t->SetDirectory(f); TClonesArray* mc_array=new TClonesArray("PndMCTrack"); t->SetBranchAddress("MCTrack",&mc_array);//Branch names TClonesArray* rad_array=new TClonesArray("FairRadLenPoint"); t->SetBranchAddress("RadLen",&rad_array); TNtuple* tuple = new TNtuple("ntp1", "gtrack tuple", "radlengths:zeta:phi"); tuple->SetDirectory(outfile); std::cout<< " there are "<< t->GetEntries() <<" events in the input file!"<< std::endl; int nEvents = t->GetEntries(); for (Int_t j=0; jGetEntry(j); effradl=0.; effradlsum=0.; if (j%1000==0) cout << "Event n. " << j << endl; //print the radlen informations: for( Int_t k = 0; k < rad_array->GetEntriesFast(); k++){ FairRadLenPoint* radpoint = (FairRadLenPoint*)rad_array->At(k); PndMCTrack *mc = (PndMCTrack*)mc_array->At(radpoint->GetTrackID()); radlen = radpoint->GetRadLength(); in = radpoint->GetPosition(); out = radpoint->GetPositionOut(); dist = in - out; effradl = dist.Mag()/radlen; effradlsum += effradl; } // end of loop on radlen points in one event z = (mc->GetStartVertex()).Z(); phi = (mc->GetMomentum()).Phi(); tuple->Fill(effradlsum,z,phi); }// end of loop on events tuple->Write(); outfile->Close(); if (slim == 1) { //inFile string del; del=Form("rm %s",inFile.c_str()); cout << del << endl; system(del.c_str()); } // ----- Finish ------------------------------------------------------- timer.Stop(); Double_t rtime = timer.RealTime(); Double_t ctime = timer.CpuTime(); cout << endl << endl; cout << "Macro finished succesfully." << endl; //cout << "Output file is " << outFile << endl; //cout << "Parameter file is " << parFile << endl; cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl; cout << endl; // ------------------------------------------------------------------------ }