| 49 |
* Date 16 June 2006 - Malvezzi |
* Date 16 June 2006 - Malvezzi |
| 50 |
* |
* |
| 51 |
* Description of changes: |
* Description of changes: |
| 52 |
* Implementation of case: numebr of events are <= 0. |
* Implementation of the case: numebr of events <= 0. |
| 53 |
* Remove of the graph "grPcktId1"; see PacketScan for the same information. |
* Remove graph "grPcktId1"; see PacketScan for the same information. |
| 54 |
* Fixed bugs: for a large namber of events is not possible to have vectors, so all graphs have been converted in histograms |
* Fixed bugs: for a large namber of events is not possible to have vectors, so I have subsituted graphs with histograms |
| 55 |
|
* or divided the graphs in more than one canvas. |
| 56 |
* |
* |
| 57 |
*/ |
*/ |
| 58 |
|
|
| 84 |
{ |
{ |
| 85 |
|
|
| 86 |
//------------------- Variables initilization -------------------------// |
//------------------- Variables initilization -------------------------// |
| 87 |
|
Long64_t nevents=0; |
| 88 |
TList *list = new TList; |
ULong_t lastime, firstime,obt; |
|
Int_t numkey; |
|
|
TObject *key = new TObject; |
|
|
const char *name; |
|
|
//TTree* tr = new TTree; |
|
|
//TTree* tr1 = new TTree; |
|
|
Long64_t nevents=0; // ev=0, events=0; |
|
|
ULong_t lastime, firstime; |
|
| 89 |
double obmin=0.; |
double obmin=0.; |
| 90 |
double obmax=0.; |
double obmax=0.; |
| 91 |
double obt; |
Float_t maxoffset, minoffset; |
|
ULong_t maxoffset, minoffset; |
|
|
Float_t pcktLenght =0., pcktCounter=0., offset=0., allCounter=0.; |
|
| 92 |
stringstream oss, oss1, oss2, oss3, noentries; |
stringstream oss, oss1, oss2, oss3, noentries; |
| 93 |
//------- load root file -------------- |
//------- load root file -------------- |
| 94 |
TFile *file = new TFile(base.Data()); |
TFile *file = new TFile(base.Data()); |
| 96 |
printf("No such file in the directory has been found"); |
printf("No such file in the directory has been found"); |
| 97 |
return; |
return; |
| 98 |
} |
} |
|
if (outDir == "" ) outDir = "."; |
|
|
list = file->GetListOfKeys(); //get list of trees in the file |
|
|
numkey = file->GetNkeys(); //get number of trees in the file |
|
| 99 |
|
|
| 100 |
TTree *PhysicsTr = (TTree*)file->Get("Physics"); |
TTree *PhysicsTr = (TTree*)file->Get("Physics"); |
| 101 |
TBranch *headBr = PhysicsTr->GetBranch("Header"); |
TBranch *headBr = PhysicsTr->GetBranch("Header"); |
| 106 |
PhysicsTr->SetBranchAddress("Header", &eh); |
PhysicsTr->SetBranchAddress("Header", &eh); |
| 107 |
|
|
| 108 |
nevents = headBr->GetEntries(); |
nevents = headBr->GetEntries(); |
|
const Int_t sizetot = nevents; |
|
| 109 |
|
|
| 110 |
TString filename = ((TObjString*)base.Tokenize('/')->Last())->GetString(); |
TString filename = ((TObjString*)base.Tokenize('/')->Last())->GetString(); |
| 111 |
filename = ((TObjString*)filename.Tokenize('.')->First())->GetString(); |
filename = ((TObjString*)filename.Tokenize('.')->First())->GetString(); |
| 144 |
return; |
return; |
| 145 |
} |
} |
| 146 |
|
|
| 147 |
|
//-------------- to know the max and min OBT ----------------------------// |
| 148 |
///-------------- to know the max and min File Offset ----------------------------// |
for (Int_t i = 0; i < nevents; i++){ |
| 149 |
/*for (Int_t i=0; i<numkey; i++){ |
headBr->GetEntry(i); |
| 150 |
key = list->At(i); |
ph = eh->GetPscuHeader(); |
| 151 |
name=(key->GetName()); |
obt = ph->GetOrbitalTime(); |
| 152 |
tr = (TTree*)file->Get(name); |
if(obt <= firstime) firstime=obt; |
| 153 |
if (tr->IsZombie()) continue; |
if(obt >= lastime) lastime=obt; |
| 154 |
events = tr->GetEntries(); |
} |
|
tr->SetBranchAddress("Header", &eh); |
|
|
for (Int_t j = 0; j < events; j++){ |
|
|
tr->GetEntry(j); |
|
|
ph = eh->GetPscuHeader(); |
|
|
ph->GetFileOffset(); |
|
|
if(ph->GetFileOffset() <= minoffset) minoffset=ph->GetFileOffset(); |
|
|
if(ph->GetFileOffset() >= maxoffset) maxoffset=ph->GetFileOffset(); |
|
|
} |
|
|
}*/ |
|
| 155 |
//*************************** Histograms ************************************************************// |
//*************************** Histograms ************************************************************// |
| 156 |
//------------------------ First histogram -----------------------------------// |
//------------------------ First histogram -----------------------------------// |
|
headBr->GetEntry(0); |
|
|
ph = eh->GetPscuHeader(); |
|
|
firstime = ph->GetOrbitalTime(); |
|
|
headBr->GetEntry(nevents-1); |
|
|
ph = eh->GetPscuHeader(); |
|
|
lastime = ph->GetOrbitalTime(); |
|
| 157 |
obmin=firstime; |
obmin=firstime; |
| 158 |
obmax=lastime; |
obmax=lastime; |
| 159 |
oss1.str(""); |
oss1.str(""); |
| 160 |
oss1 << filename.Data() << ": Physics Packet per minute;" <<" start @ " << firstime << ", end @ "<< lastime <<"ms"; |
oss1 <<"File name= "<< filename.Data() <<". Start time= " << obmin << ", end time= "<< obmax <<" ms"<<". Physics Packet per minute"; |
| 161 |
Int_t nbin = (lastime-firstime)/60000; |
Int_t nbin = (lastime-firstime)/60000; |
| 162 |
TH1F *h1 = new TH1F ("histo1", oss1.str().c_str(), nbin, obmin, obmax); |
TH1F *h1 = new TH1F ("histo1", oss1.str().c_str(), nbin, obmin, obmax); |
| 163 |
|
|
| 164 |
//------------------------ Second histogram -----------------------------------// |
//------------------------ Second histogram -----------------------------------// |
| 165 |
oss2.str(""); |
oss2.str(""); |
| 166 |
oss2 << filename.Data() << ": Lenght of Physic packets;"; |
oss2 << " Lenght of Physic packets;"; |
| 167 |
Int_t nint = (lastime-firstime); |
Int_t nint = (lastime-firstime); |
| 168 |
TH1F *PcktLenght = new TH1F ("histo2", oss2.str().c_str(), nint, obmin, obmax); |
TH1F *PcktLenght = new TH1F ("histo2", oss2.str().c_str(), nint, obmin, obmax); |
| 169 |
|
|
| 170 |
//------------------------ Third histogram -----------------------------------// |
//------------------------ Third histogram -----------------------------------// |
| 171 |
oss3.str(""); |
oss3.str(""); |
| 172 |
oss3 << filename.Data() << ": Physics Counter"; |
oss3 << " Physics Counter"; |
| 173 |
TH1F *PcktCounter = new TH1F ("histo3", oss3.str().c_str(), nint, obmin, obmax); |
TH1F *PcktCounter = new TH1F ("histo3", oss3.str().c_str(), nint, obmin, obmax); |
| 174 |
|
|
|
//------------------------ Fourth histogram -----------------------------------// |
|
|
/*oss3.str(""); |
|
|
oss3 << filename.Data() << ": Packet Counter"; |
|
|
Int_t nintoffset = (maxoffset-minoffset)/10; |
|
|
TH1F *FileOffset = new TH1F ("histo4", oss3.str().c_str(), nintoffset, minoffset, maxoffset); |
|
|
*/ |
|
| 175 |
//**************************************************************************************************// |
//**************************************************************************************************// |
| 176 |
//------- fill histograms ---------// |
//------- fill histograms ---------// |
| 177 |
|
|
| 178 |
for (Int_t i = 0; i < nevents; i++){ |
for (Int_t i = 0; i < nevents; i++){ |
| 179 |
headBr->GetEntry(i); |
headBr->GetEntry(i); |
| 180 |
ph = eh->GetPscuHeader(); |
ph = eh->GetPscuHeader(); |
| 181 |
obt = ph->GetOrbitalTime(); |
h1->Fill(ph->GetOrbitalTime()); |
| 182 |
pcktLenght=ph->GetPacketLenght(); |
PcktLenght->Fill(ph->GetOrbitalTime(),ph->GetPacketLenght()); |
| 183 |
pcktCounter=ph->GetCounter(); |
PcktCounter->Fill(ph->GetOrbitalTime(),ph->GetCounter()); |
|
h1->Fill(obt); |
|
|
PcktLenght->Fill(obt,pcktLenght); |
|
|
PcktCounter->Fill(obt,pcktCounter); |
|
| 184 |
} |
} |
| 185 |
|
|
|
/*for (Int_t i=0; i<numkey; i++){ |
|
|
key = list->At(i); |
|
|
name=(char *)(key->GetName()); |
|
|
tr1 = (TTree*)file->Get(name); |
|
|
if (tr1->IsZombie()) continue; |
|
|
tr1->SetBranchAddress("Header", &eh); |
|
|
ev = tr1->GetEntries(); |
|
|
for (Int_t j = 0; j < ev; j++){ |
|
|
tr1->GetEntry(j); |
|
|
ph = eh->GetPscuHeader(); |
|
|
offset=ph->GetFileOffset(); |
|
|
allCounter= ph->GetCounter(); |
|
|
FileOffset->Fill(offset,allCounter); |
|
|
} |
|
|
}*/ |
|
|
|
|
| 186 |
//****************************** Canvases *******************************// |
//****************************** Canvases *******************************// |
| 187 |
//TGaxis::SetMaxDigits(4); |
//TGaxis::SetMaxDigits(4); |
| 188 |
//------------------- First Canvas --------------------------------// |
//------------------- First Canvas --------------------------------// |
| 232 |
PcktCounter->SetMarkerSize(.5); |
PcktCounter->SetMarkerSize(.5); |
| 233 |
PcktCounter->SetMarkerStyle(21); |
PcktCounter->SetMarkerStyle(21); |
| 234 |
PcktCounter->Draw("9p"); |
PcktCounter->Draw("9p"); |
|
//--------- Second Canvas -----------------------------// |
|
|
/*TCanvas *finalCanv2 = new TCanvas("Header_2", base, 1280, 1024); |
|
|
finalCanv2->Divide(1,2); |
|
|
finalCanv2->SetFillColor(10); |
|
| 235 |
|
|
|
finalCanv2->cd(1); |
|
|
PcktCounter->SetStats(kFALSE); |
|
|
PcktCounter->GetXaxis()->SetTitle("OBT (ms)"); |
|
|
PcktCounter->GetXaxis()->SetTitleSize(0.05); |
|
|
PcktCounter->GetXaxis()->CenterTitle(); |
|
|
PcktCounter->GetXaxis()->SetLabelSize(0.04); |
|
|
PcktCounter->GetYaxis()->SetTitle("Counter"); |
|
|
PcktCounter->GetYaxis()->SetTitleSize(0.05); |
|
|
PcktCounter->GetYaxis()->CenterTitle(); |
|
|
PcktCounter->GetYaxis()->SetLabelSize(0.04); |
|
|
PcktCounter->SetMarkerColor(4); |
|
|
PcktCounter->SetMarkerSize(.5); |
|
|
PcktCounter->SetMarkerStyle(21); |
|
|
PcktCounter->Draw("9p"); |
|
|
|
|
|
finalCanv2->cd(2); |
|
|
FileOffset->SetStats(kFALSE); |
|
|
FileOffset->GetXaxis()->SetTitle("File Offset"); |
|
|
FileOffset->GetXaxis()->CenterTitle(); |
|
|
FileOffset->GetXaxis()->SetTitleSize(0.05); |
|
|
FileOffset->GetXaxis()->SetLabelSize(0.04); |
|
|
FileOffset->GetYaxis()->SetTitle("Counter"); |
|
|
FileOffset->GetYaxis()->CenterTitle(); |
|
|
FileOffset->GetYaxis()->SetTitleSize(0.05); |
|
|
FileOffset->GetYaxis()->SetLabelSize(0.04); |
|
|
FileOffset->SetMarkerColor(3); |
|
|
FileOffset->SetMarkerSize(.5); |
|
|
FileOffset->SetMarkerStyle(21); |
|
|
FileOffset->Draw("9p");*/ |
|
|
|
|
|
//-------to save---------------------------/// |
|
| 236 |
oss.str(""); |
oss.str(""); |
|
oss1.str(""); |
|
|
|
|
| 237 |
oss << outDir.Data() << filename.Data(); |
oss << outDir.Data() << filename.Data(); |
|
oss1 << outDir.Data() << filename.Data(); |
|
|
|
|
| 238 |
oss << "_HeaderScan_1." << format.Data(); |
oss << "_HeaderScan_1." << format.Data(); |
|
oss1 << "_HeaderScan_2." << format.Data(); |
|
|
|
|
| 239 |
finalCanv1->SaveAs(oss.str().c_str()); |
finalCanv1->SaveAs(oss.str().c_str()); |
| 240 |
//finalCanv2->SaveAs(oss1.str().c_str()); |
//------------- Graph PscuCounter vs FileOffset --------------------------------- |
| 241 |
|
const Int_t size = 100000; |
| 242 |
|
Int_t ev=0; |
| 243 |
|
Double_t PscuCounter[size], FileOffset[size]; |
| 244 |
|
Int_t m=0; |
| 245 |
|
Int_t pag= (nevents/100000)+1; |
| 246 |
|
|
| 247 |
|
TCanvas *finalCanv2 = new TCanvas("Header_2", base, 1280, 1024); |
| 248 |
|
finalCanv2->SetFillColor(10); |
| 249 |
|
|
| 250 |
|
/////ciclo sulle pagine//////////////////// |
| 251 |
|
for (Int_t interval=0; interval<pag; interval++){ |
| 252 |
|
|
| 253 |
|
for (Int_t l = 0; l < size; l++){ //ciclo su un sottogruppo |
| 254 |
|
headBr->GetEntry(ev+l); |
| 255 |
|
ph = eh->GetPscuHeader(); |
| 256 |
|
PscuCounter[l]= ph->GetCounter(); |
| 257 |
|
FileOffset[l]=ph->GetFileOffset(); |
| 258 |
|
m=l; |
| 259 |
|
} |
| 260 |
|
|
| 261 |
|
oss1.str(""); |
| 262 |
|
oss1 << filename.Data() <<": PscuCounter vs FileOffset. Canvas n."<< (interval+1); |
| 263 |
|
TGraph *graph= new TGraph(m, FileOffset, PscuCounter); |
| 264 |
|
|
| 265 |
|
finalCanv2->cd(); |
| 266 |
|
graph->SetTitle(oss1.str().c_str()); |
| 267 |
|
graph->GetXaxis()->SetTitle("File Offset"); |
| 268 |
|
graph->GetXaxis()->CenterTitle(); |
| 269 |
|
graph->GetXaxis()->SetTitleSize(0.04); |
| 270 |
|
graph->GetXaxis()->SetLabelSize(0.02); |
| 271 |
|
graph->GetYaxis()->SetTitle("Counter"); |
| 272 |
|
graph->GetYaxis()->CenterTitle(); |
| 273 |
|
graph->GetYaxis()->SetTitleSize(0.04); |
| 274 |
|
graph->GetYaxis()->SetLabelSize(0.02); |
| 275 |
|
graph->SetMarkerColor(3); |
| 276 |
|
graph->SetMarkerSize(.5); |
| 277 |
|
graph->SetMarkerStyle(21); |
| 278 |
|
graph->Draw("AP"); |
| 279 |
|
|
| 280 |
|
oss1.str(""); |
| 281 |
|
oss1 << outDir.Data() << filename.Data(); |
| 282 |
|
oss1 << "_HeaderScan_2_"<<(interval+1)<<"." << format.Data(); |
| 283 |
|
|
| 284 |
|
finalCanv2->SaveAs(oss1.str().c_str()); |
| 285 |
|
finalCanv2->Clear(); |
| 286 |
|
|
| 287 |
|
ev=ev+100000; |
| 288 |
|
} |
| 289 |
|
|
| 290 |
file->Close(); |
file->Close(); |
| 291 |
|
|
| 292 |
} |
} |
| 293 |
|
|
|
|
|
|
|
|
| 294 |
int main(int argc, char* argv[]){ |
int main(int argc, char* argv[]){ |
| 295 |
TString path; |
TString path; |
| 296 |
TString outDir = "./"; |
TString outDir = "./"; |