Changeset 1914
- Timestamp:
- 04/07/03 17:28:54 (22 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r1912 r1914 31 31 * macros/dohtml.C: 32 32 - added testenv.C 33 34 * readraw.cc: 35 - simplified 36 37 * mraw/MRawEvtData.cc: 38 - fixed a bug in the draw function (the drawn pixel has not been the 39 one with the given Id, but simply the i-th entry in the array) 33 40 34 41 -
trunk/MagicSoft/Mars/mraw/MRawEvtData.cc
r1082 r1914 62 62 #include "MArrayB.h" 63 63 #include "MRawRunHeader.h" 64 #include "MRawEvtPixelIter.h" 64 65 65 66 ClassImp(MRawEvtData); … … 217 218 TString str(opt); 218 219 219 UInt_t num= 0;220 UInt_t id = 0; 220 221 221 222 if (str.BeginsWith("GRAPH", TString::kIgnoreCase)) 222 {223 223 if (str.Length()>5) 224 sscanf(&str[5], "%d", &num); 225 226 if (num>=GetNumPixels()) 227 num= GetNumPixels(); 228 229 *fLog << inf << "Drawing Graph: Pixel #" << num << " of " << (int)GetNumPixels() << endl; 230 231 const Int_t n = GetNumHiGainSamples(); 232 233 Float_t *x = new Float_t[n]; 234 Float_t *y = new Float_t[n]; 224 sscanf(&str[5], "%d", &id); 225 if (str.BeginsWith("HIST", TString::kIgnoreCase)) 226 if (str.Length()>4) 227 sscanf(&str[4], "%d", &id); 228 229 MRawEvtPixelIter pix(this); 230 if (!pix.Jump(id)) 231 { 232 *fLog << warn << "Pixel Id #" << id << " doesn't exist!" << endl; 233 return; 234 } 235 236 const Byte_t *higains = pix.GetHiGainSamples(); 237 238 const Int_t n = GetNumHiGainSamples(); 239 240 TString name = "Pixel No."; 241 name += pix.GetPixelId(); 242 243 if (str.BeginsWith("GRAPH", TString::kIgnoreCase)) 244 { 245 *fLog << inf << "Drawing Graph: Pixel Id #" << pix.GetPixelId(); 246 *fLog << " of " << (int)GetNumPixels() << "Pixels" << endl; 247 248 TGraph *graph = new TGraph; 235 249 236 250 for (int i=0; i<n; i++) 237 { 238 x[i] = i; 239 y[i] = (*fHiGainFadcSamples)[i + num*GetNumHiGainSamples()]; 240 } 241 242 TGraph *graph = new TGraph(n, x, y); 251 graph->SetPoint(graph->GetN(), i, higains[i]); 252 243 253 graph->SetMaximum(256); 244 254 graph->SetMinimum(0); … … 257 267 if (str.BeginsWith("HIST", TString::kIgnoreCase)) 258 268 { 259 *fLog << "Length: " << str.Length() << endl; 260 261 if (str.Length()>4) 262 sscanf(&str[4], "%d", &num); 263 264 if (num>=GetNumPixels()) 265 num= GetNumPixels(); 266 267 *fLog << "Drawing Histogram of Pixel " << num << endl; 268 269 const Int_t n = GetNumHiGainSamples(); 270 271 char *name = new char[16]; 272 273 sprintf(name, "Pixel No.%d", (*fHiGainPixId)[num]); 269 *fLog << "Drawing Histogram of Pixel with Id " << pix.GetPixelId() << endl; 274 270 275 271 TH1F *hist = new TH1F(name, "Hi Gain Samples FADC", n, 0, n); … … 278 274 279 275 for (int i=0; i<n; i++) 280 hist->Fill(0.5+i, (*fHiGainFadcSamples)[i + num*GetNumHiGainSamples()]);276 hist->Fill(0.5+i, higains[i]); 281 277 282 278 hist->SetBit(kCanDelete); -
trunk/MagicSoft/Mars/readraw.cc
r993 r1914 25 25 // 26 26 ///////////////////////////////////////////////////////////////////////////// 27 28 void EnableBranch(TTree *t, TString name, void *ptr) 29 { 30 if (!t->GetBranch(name+".")) 31 return; 32 33 t->GetBranch(name+".")->SetAddress(ptr); 34 gLog << " Found '" << name << "'" << endl; 35 } 27 36 28 37 int main(const int argc, const char **argv) … … 59 68 } 60 69 61 MRawRunHeader *runheader = new MRawRunHeader();62 MRawEvtHeader *evtheader = new MRawEvtHeader();63 MTime *evttime = new MTime();64 MRawEvtData *evtdata = new MRawEvtData();65 MRawCrateArray *evtcrate = new MRawCrateArray();66 67 MMcEvt *evtmc = new MMcEvt() ;68 MMcTrig *trigmc = new MMcTrig() ;69 70 70 // 71 71 // open the file 72 72 // 73 gLog << " Open the file " << endl ;73 gLog << " Open the file '" << argv[1] << "'" << endl; 74 74 TFile input(argv[1], "READ"); 75 75 … … 77 77 // open the Run Header and read in 78 78 // 79 gLog << " Check the RunHeader " << endl ; 80 TTree *runtree = (TTree*) input.Get("RunHeaders") ; 81 79 gLog << " Check for Tree 'RunHeaders'" << endl; 80 TTree *runtree = (TTree*)input.Get("RunHeaders"); 82 81 if (!runtree) 83 { 84 gLog << endl 85 << " WARNING: This file has NO RunHeader " 86 << endl << endl ; 87 } 82 gLog << " WARNING: This file has NO Tree 'RunHeaders'" << endl << endl; 88 83 else 89 84 { 90 gLog << " Entries in Tree RunHeaders: " << dec << runtree->GetEntries() << endl 85 gLog << " Entries in Tree RunHeaders: " << dec << runtree->GetEntries() << endl; 91 86 87 MRawRunHeader *runheader = NULL; 92 88 runtree->GetBranch("MRawRunHeader")->SetAddress(&runheader); 93 89 runtree->GetEvent(0); 94 95 90 runheader->Print(); 96 91 } … … 99 94 // open the DataTree and read in 100 95 // 101 gLog << " Check the Event Tree " << endl ; 102 TTree *evttree = (TTree*) input.Get("Events") ; 103 gLog << " Check all the Branches in the Tree " << endl ; 104 96 gLog << " Check the Tree 'Events'" << endl ; 97 TTree *evttree = (TTree*)input.Get("Events") ; 98 if (!evttree) 99 { 100 gLog << "Tree 'Events' not found in file... exit!" << endl; 101 return -1; 102 } 103 105 104 // 106 105 // check the branches in the Tree 107 106 // 108 TIter Next(evttree->GetListOfBranches()); 109 TBranch *branch=NULL; 110 111 while ((branch=(TBranch*)Next())) 112 { 113 // 114 // Get Name of Branch 115 // 116 const char *name = branch->GetName(); 117 118 if (!strcmp(name, "MRawEvtHeader")) 119 evttree->GetBranch("MRawEvtHeader")->SetAddress(&evtheader); 107 gLog << " Check all the Branches in the Tree." << endl; 108 gLog << endl; 120 109 121 if (!strcmp(name, "MTime")) 122 evttree->GetBranch("MTime")->SetAddress(&evttime); 110 MRawEvtHeader *evtheader = NULL; 111 MTime *evttime = NULL; 112 MRawEvtData *evtdata = NULL; 113 MRawCrateArray *evtcrate = NULL; 114 MMcEvt *evtmc = NULL; 115 MMcTrig *trigmc = NULL; 123 116 124 if (!strcmp(name, "MRawEvtData")) 125 evttree->GetBranch("MRawEvtData")->SetAddress(&evtdata); 126 127 if (!strcmp(name, "MRawCrateArray")) 128 evttree->GetBranch("MRawCrateArray")->SetAddress(&evtcrate); 129 130 if (!strcmp(name, "MMcTrig")) 131 evttree->GetBranch("MMcTrig")->SetAddress(&trigmc); 132 133 if (!strcmp(name, "MMcEvt")) 134 evttree->GetBranch("MMcEvt")->SetAddress(&evtmc); 135 } 117 EnableBranch(evttree, "MRawEvtHeader", &evtheader); 118 EnableBranch(evttree, "MTime", &evttime); 119 EnableBranch(evttree, "MRawEvtData", &evtdata); 120 EnableBranch(evttree, "MRawCrateArray", &evtcrate); 121 EnableBranch(evttree, "MMcEvt", &evtmc); 122 EnableBranch(evttree, "MMcTrig", &trigmc); 136 123 137 124 // … … 140 127 Int_t nent = (Int_t)evttree->GetEntries(); 141 128 142 gLog << endl << endl;129 gLog << endl; 143 130 gLog << " Entries in Tree Data: " << dec << nent << endl; 131 gLog << endl; 144 132 145 133 for (Int_t i = 0; i<nent; i++) … … 152 140 evttree->GetEvent(i); 153 141 154 evtmc->Print(); 155 156 evtheader->Print(); 157 evttime->Print(); 158 evtcrate->Print(); 159 evtdata->Print(); 142 if (evtmc) 143 evtmc->Print(); 144 if (trigmc) 145 trigmc->Print(); 146 if (evtheader) 147 evtheader->Print(); 148 if (evttime) 149 evttime->Print(); 150 if (evtcrate) 151 evtcrate->Print(); 152 if (evtdata) 153 evtdata->Print(); 160 154 } 161 155
Note:
See TracChangeset
for help on using the changeset viewer.