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, offset, lastoffset, firstoffset; |
|
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.; |
|
double obt; |
|
|
ULong_t maxoffset, minoffset; |
|
|
Float_t pcktLenght =0., pcktCounter=0., offset=0., allCounter=0.; |
|
91 |
stringstream oss, oss1, oss2, oss3, noentries; |
stringstream oss, oss1, oss2, oss3, noentries; |
92 |
//------- load root file -------------- |
//------- load root file -------------- |
93 |
TFile *file = new TFile(base.Data()); |
TFile *file = new TFile(base.Data()); |
95 |
printf("No such file in the directory has been found"); |
printf("No such file in the directory has been found"); |
96 |
return; |
return; |
97 |
} |
} |
|
if (outDir == "" ) outDir = "."; |
|
|
list = file->GetListOfKeys(); //get list of trees in the file |
|
|
numkey = file->GetNkeys(); //get number of trees in the file |
|
98 |
|
|
99 |
TTree *PhysicsTr = (TTree*)file->Get("Physics"); |
TTree *PhysicsTr = (TTree*)file->Get("Physics"); |
100 |
TBranch *headBr = PhysicsTr->GetBranch("Header"); |
TBranch *headBr = PhysicsTr->GetBranch("Header"); |
105 |
PhysicsTr->SetBranchAddress("Header", &eh); |
PhysicsTr->SetBranchAddress("Header", &eh); |
106 |
|
|
107 |
nevents = headBr->GetEntries(); |
nevents = headBr->GetEntries(); |
|
const Int_t sizetot = nevents; |
|
108 |
|
|
109 |
TString filename = ((TObjString*)base.Tokenize('/')->Last())->GetString(); |
TString filename = ((TObjString*)base.Tokenize('/')->Last())->GetString(); |
110 |
filename = ((TObjString*)filename.Tokenize('.')->First())->GetString(); |
filename = ((TObjString*)filename.Tokenize('.')->First())->GetString(); |
143 |
return; |
return; |
144 |
} |
} |
145 |
|
|
146 |
|
//-------------- to know the max and min OBT ----------------------------// |
147 |
///-------------- to know the max and min File Offset ----------------------------// |
for (Int_t i = 0; i < nevents; i++){ |
148 |
/*for (Int_t i=0; i<numkey; i++){ |
headBr->GetEntry(i); |
149 |
key = list->At(i); |
ph = eh->GetPscuHeader(); |
150 |
name=(key->GetName()); |
obt = ph->GetOrbitalTime(); |
151 |
tr = (TTree*)file->Get(name); |
offset=ph->GetFileOffset(); |
152 |
if (tr->IsZombie()) continue; |
if(obt <= firstime) firstime=obt; |
153 |
events = tr->GetEntries(); |
if(obt >= lastime) lastime=obt; |
154 |
tr->SetBranchAddress("Header", &eh); |
} |
155 |
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(); |
|
|
} |
|
|
}*/ |
|
156 |
//*************************** Histograms ************************************************************// |
//*************************** Histograms ************************************************************// |
157 |
//------------------------ First histogram -----------------------------------// |
//------------------------ First histogram -----------------------------------// |
|
headBr->GetEntry(0); |
|
|
ph = eh->GetPscuHeader(); |
|
|
firstime = ph->GetOrbitalTime(); |
|
|
headBr->GetEntry(nevents-1); |
|
|
ph = eh->GetPscuHeader(); |
|
|
lastime = ph->GetOrbitalTime(); |
|
158 |
obmin=firstime; |
obmin=firstime; |
159 |
obmax=lastime; |
obmax=lastime; |
160 |
oss1.str(""); |
oss1.str(""); |
161 |
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"; |
162 |
Int_t nbin = (lastime-firstime)/60000; |
Int_t nbin = (lastime-firstime)/60000; |
163 |
TH1F *h1 = new TH1F ("histo1", oss1.str().c_str(), nbin, obmin, obmax); |
TH1F *h1 = new TH1F ("histo1", oss1.str().c_str(), nbin, obmin, obmax); |
164 |
|
|
165 |
//------------------------ Second histogram -----------------------------------// |
//------------------------ Second histogram -----------------------------------// |
166 |
oss2.str(""); |
oss2.str(""); |
167 |
oss2 << filename.Data() << ": Lenght of Physic packets;"; |
oss2 << " Lenght of Physic packets;"; |
168 |
Int_t nint = (lastime-firstime); |
Int_t nint = (lastime-firstime); |
169 |
TH1F *PcktLenght = new TH1F ("histo2", oss2.str().c_str(), nint, obmin, obmax); |
TH1F *PcktLenght = new TH1F ("histo2", oss2.str().c_str(), nint, obmin, obmax); |
170 |
|
|
171 |
//------------------------ Third histogram -----------------------------------// |
//------------------------ Third histogram -----------------------------------// |
172 |
oss3.str(""); |
oss3.str(""); |
173 |
oss3 << filename.Data() << ": Physics Counter"; |
oss3 << " Physics Counter"; |
174 |
TH1F *PcktCounter = new TH1F ("histo3", oss3.str().c_str(), nint, obmin, obmax); |
TH1F *PcktCounter = new TH1F ("histo3", oss3.str().c_str(), nint, obmin, obmax); |
175 |
|
|
|
//------------------------ 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); |
|
|
*/ |
|
176 |
//**************************************************************************************************// |
//**************************************************************************************************// |
177 |
//------- fill histograms ---------// |
//------- fill histograms ---------// |
178 |
|
Int_t l=0; |
179 |
for (Int_t i = 0; i < nevents; i++){ |
for (Int_t i = 0; i < nevents; i++){ |
180 |
headBr->GetEntry(i); |
headBr->GetEntry(i); |
181 |
ph = eh->GetPscuHeader(); |
ph = eh->GetPscuHeader(); |
182 |
obt = ph->GetOrbitalTime(); |
h1->Fill(ph->GetOrbitalTime()); |
183 |
pcktLenght=ph->GetPacketLenght(); |
PcktLenght->Fill(ph->GetOrbitalTime(),ph->GetPacketLenght()); |
184 |
pcktCounter=ph->GetCounter(); |
PcktCounter->Fill(ph->GetOrbitalTime(),ph->GetCounter()); |
|
h1->Fill(obt); |
|
|
PcktLenght->Fill(obt,pcktLenght); |
|
|
PcktCounter->Fill(obt,pcktCounter); |
|
185 |
} |
} |
186 |
|
|
|
/*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); |
|
|
} |
|
|
}*/ |
|
|
|
|
187 |
//****************************** Canvases *******************************// |
//****************************** Canvases *******************************// |
188 |
//TGaxis::SetMaxDigits(4); |
//TGaxis::SetMaxDigits(4); |
189 |
//------------------- First Canvas --------------------------------// |
//------------------- First Canvas --------------------------------// |
233 |
PcktCounter->SetMarkerSize(.5); |
PcktCounter->SetMarkerSize(.5); |
234 |
PcktCounter->SetMarkerStyle(21); |
PcktCounter->SetMarkerStyle(21); |
235 |
PcktCounter->Draw("9p"); |
PcktCounter->Draw("9p"); |
|
//--------- Second Canvas -----------------------------// |
|
|
/*TCanvas *finalCanv2 = new TCanvas("Header_2", base, 1280, 1024); |
|
|
finalCanv2->Divide(1,2); |
|
|
finalCanv2->SetFillColor(10); |
|
236 |
|
|
|
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---------------------------/// |
|
237 |
oss.str(""); |
oss.str(""); |
|
oss1.str(""); |
|
|
|
|
238 |
oss << outDir.Data() << filename.Data(); |
oss << outDir.Data() << filename.Data(); |
|
oss1 << outDir.Data() << filename.Data(); |
|
|
|
|
239 |
oss << "_HeaderScan_1." << format.Data(); |
oss << "_HeaderScan_1." << format.Data(); |
|
oss1 << "_HeaderScan_2." << format.Data(); |
|
|
|
|
240 |
finalCanv1->SaveAs(oss.str().c_str()); |
finalCanv1->SaveAs(oss.str().c_str()); |
|
//finalCanv2->SaveAs(oss1.str().c_str()); |
|
|
|
|
|
file->Close(); |
|
|
|
|
|
} |
|
241 |
|
|
242 |
|
//------------- Graph PscuCounter vs FileOffset --------------------------------- |
243 |
|
const Int_t size = 100000; |
244 |
|
Int_t ev=0; |
245 |
|
Double_t PscuCounter[size], FileOffset[size]; |
246 |
|
Int_t m=0; |
247 |
|
Int_t pag= (nevents/100000)+1; |
248 |
|
|
249 |
|
TMultiGraph *mg1 = new TMultiGraph(); |
250 |
|
oss1.str(""); |
251 |
|
oss1 << filename.Data() <<": PscuCounter vs FileOffset."; |
252 |
|
mg1->SetTitle(oss1.str().c_str()); |
253 |
|
|
254 |
|
TCanvas *finalCanv2 = new TCanvas("Header_2", base, 1280, 1024); |
255 |
|
finalCanv2->SetFillColor(10); |
256 |
|
|
257 |
|
/////ciclo sulle pagine//////////////////// |
258 |
|
for (Int_t interval=0; interval<pag; interval++){ |
259 |
|
|
260 |
|
for (Int_t l = 0; l < size; l++){ //ciclo su un sottogruppo |
261 |
|
headBr->GetEntry(ev+l); |
262 |
|
ph = eh->GetPscuHeader(); |
263 |
|
PscuCounter[l]= ph->GetCounter(); |
264 |
|
FileOffset[l]=ph->GetFileOffset(); |
265 |
|
m=l; |
266 |
|
} |
267 |
|
|
268 |
|
TGraph *graph= new TGraph(m, FileOffset, PscuCounter); |
269 |
|
graph->SetMarkerColor(3); |
270 |
|
graph->SetMarkerSize(.5); |
271 |
|
graph->SetMarkerStyle(21); |
272 |
|
mg1->Add(graph); |
273 |
|
|
274 |
|
ev=ev+100000; |
275 |
|
} |
276 |
|
finalCanv2->cd(); |
277 |
|
mg1->Draw("AP"); |
278 |
|
mg1->SetTitle(oss1.str().c_str()); |
279 |
|
mg1->GetXaxis()->SetTitle("File Offset"); |
280 |
|
mg1->GetXaxis()->CenterTitle(); |
281 |
|
mg1->GetXaxis()->SetTitleSize(0.04); |
282 |
|
mg1->GetXaxis()->SetLabelSize(0.02); |
283 |
|
mg1->GetYaxis()->SetTitle("Counter"); |
284 |
|
mg1->GetYaxis()->CenterTitle(); |
285 |
|
mg1->GetYaxis()->SetTitleSize(0.04); |
286 |
|
mg1->GetYaxis()->SetLabelSize(0.02); |
287 |
|
|
288 |
|
|
289 |
|
finalCanv2->Update(); |
290 |
|
|
291 |
|
oss1.str(""); |
292 |
|
oss1 << outDir.Data() << filename.Data(); |
293 |
|
oss1 << "_HeaderScan_2"<<"." << format.Data(); |
294 |
|
|
295 |
|
finalCanv2->SaveAs(oss1.str().c_str()); |
296 |
|
|
297 |
|
file->Close(); |
298 |
|
|
299 |
|
} |
300 |
|
|
301 |
int main(int argc, char* argv[]){ |
int main(int argc, char* argv[]){ |
302 |
TString path; |
TString path; |