// This codes is for counting the tracks passing through the detector by using the MC point information of detector //Total flux of particles per unit area in one year (fluence)= (Totntracks*2*10^7)*365*24*3600*dutycycle/(Events*area) particles/cm^2 // Some times one track can create more than one MC point on the detector (if detector has more than one plane), I have taken care of that. // Shyam Kumar #include //#include "/home/shyam/pandaroot/start/PndStartPoint.h" void startfluxnew() { Int_t Events=0; Int_t l=0; Int_t p=0; Int_t temp,j,ntracks, Totntracks; Double_t flux,Evtyear; Double_t dutycycle=0.5; //50% Double_t eventrate=2*1E7; //2*10^7 /seconds //----------------------------Reading the root file------------------------------- TFile* f = new TFile("../sim_complete.root"); // the sim file you want to analyse TTree *t=(TTree *) f->Get("cbmsim") ; TClonesArray *start_array=new TClonesArray("PndStartPoint"); t->SetBranchAddress("STARTPoint",&start_array);//Branch name Int_t nEntries = t->GetEntriesFast(); Totntracks = 0; for (Int_t j=0; j< nEntries; j++) { std::vector a, b; t->GetEntry(j); cout<<"Event="<GetEntriesFast(); k++) { PndStartPoint* startpoint = (PndStartPoint*)start_array->At(k); //m++; a.push_back(startpoint->GetTrackID()); } //---------------Sorting the array of MC points on Detector for each event---------- Int_t n=a.size(); ntracks = 0; for(Int_t i=0;ia[p+1]) { temp=a[p]; a[p]=a[p+1]; a[p+1]=temp; } } //----------------------Sorted array of MC points----------------- for(Int_t i=0;i