| 1 | /* ======================================================================== *\
|
|---|
| 2 | !
|
|---|
| 3 | ! *
|
|---|
| 4 | ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
|
|---|
| 5 | ! * Software. It is distributed to you in the hope that it can be a useful
|
|---|
| 6 | ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
|
|---|
| 7 | ! * It is distributed WITHOUT ANY WARRANTY.
|
|---|
| 8 | ! *
|
|---|
| 9 | ! * Permission to use, copy, modify and distribute this software and its
|
|---|
| 10 | ! * documentation for any purpose is hereby granted without fee,
|
|---|
| 11 | ! * provided that the above copyright notice appear in all copies and
|
|---|
| 12 | ! * that both that copyright notice and this permission notice appear
|
|---|
| 13 | ! * in supporting documentation. It is provided "as is" without express
|
|---|
| 14 | ! * or implied warranty.
|
|---|
| 15 | ! *
|
|---|
| 16 | !
|
|---|
| 17 | !
|
|---|
| 18 | ! Author(s): Thomas Bretz, 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
|
|---|
| 19 | !
|
|---|
| 20 | ! Copyright: MAGIC Software Development, 2000-2007
|
|---|
| 21 | !
|
|---|
| 22 | !
|
|---|
| 23 | \* ======================================================================== */
|
|---|
| 24 |
|
|---|
| 25 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 26 | //
|
|---|
| 27 | // MRawEvtData
|
|---|
| 28 | //
|
|---|
| 29 | // Storage container to store the raw FADC values.
|
|---|
| 30 | //
|
|---|
| 31 | // MArrayS fHiGainPixId
|
|---|
| 32 | // ---------------------
|
|---|
| 33 | // Array of Pixel Numbers for their high voltage channel in the order the
|
|---|
| 34 | // FADC values are stored in fHiGainFadcSamples
|
|---|
| 35 | //
|
|---|
| 36 | // MArrayB fHiGainFadcSaples
|
|---|
| 37 | // -------------------------
|
|---|
| 38 | // FADC samples (hi gain) of all pixels
|
|---|
| 39 | //
|
|---|
| 40 | // MArrayS fLoGainPixId
|
|---|
| 41 | // --------------------
|
|---|
| 42 | // see fHiGainPixId
|
|---|
| 43 | //
|
|---|
| 44 | // MArrayB fLoGainFadcSamples
|
|---|
| 45 | // --------------------------
|
|---|
| 46 | // see fHiGainFadcSaples
|
|---|
| 47 | //
|
|---|
| 48 | //
|
|---|
| 49 | // Version 6
|
|---|
| 50 | // ------------------
|
|---|
| 51 | // - The data can now be stoe in a single array keeping he full
|
|---|
| 52 | // compatibility
|
|---|
| 53 | //
|
|---|
| 54 | // Version 5 (0.8.5):
|
|---|
| 55 | // ------------------
|
|---|
| 56 | // - Changed type of ABFlags from TArrayC to MArrayB
|
|---|
| 57 | //
|
|---|
| 58 | // Version 4 (0.8.4):
|
|---|
| 59 | // ------------------
|
|---|
| 60 | // - Changed derivement from MCamEvent to MParContainer and MCamEvent
|
|---|
| 61 | //
|
|---|
| 62 | // Version 3 (0.8.4):
|
|---|
| 63 | // ------------------
|
|---|
| 64 | // - Added fABFlags
|
|---|
| 65 | //
|
|---|
| 66 | // Version 2:
|
|---|
| 67 | // ----------
|
|---|
| 68 | // - Derives from MCamEvent now
|
|---|
| 69 | //
|
|---|
| 70 | // Version 1:
|
|---|
| 71 | // ----------
|
|---|
| 72 | // - First implementation
|
|---|
| 73 | //
|
|---|
| 74 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 75 | #include "MRawEvtData.h"
|
|---|
| 76 |
|
|---|
| 77 | #include <fstream>
|
|---|
| 78 |
|
|---|
| 79 | #include <TH1.h>
|
|---|
| 80 | #include <TGraph.h>
|
|---|
| 81 | #include <TArrayC.h>
|
|---|
| 82 | #include <TVirtualPad.h>
|
|---|
| 83 |
|
|---|
| 84 | #include "MLog.h"
|
|---|
| 85 | #include "MLogManip.h"
|
|---|
| 86 |
|
|---|
| 87 | #include "MArrayS.h"
|
|---|
| 88 | #include "MArrayB.h"
|
|---|
| 89 | #include "MGeomCam.h"
|
|---|
| 90 |
|
|---|
| 91 | #include "MRawCrateArray.h"
|
|---|
| 92 | #include "MRawCrateData.h"
|
|---|
| 93 |
|
|---|
| 94 | #include "MRawRunHeader.h"
|
|---|
| 95 | #include "MRawEvtPixelIter.h"
|
|---|
| 96 |
|
|---|
| 97 | ClassImp(MRawEvtData);
|
|---|
| 98 |
|
|---|
| 99 | using namespace std;
|
|---|
| 100 |
|
|---|
| 101 | // --------------------------------------------------------------------------
|
|---|
| 102 | //
|
|---|
| 103 | // Default constructor. It initializes all arrays with zero size.
|
|---|
| 104 | //
|
|---|
| 105 | MRawEvtData::MRawEvtData(const char *name, const char *title)
|
|---|
| 106 | : fRunHeader(0)
|
|---|
| 107 | {
|
|---|
| 108 | fName = name ? name : "MRawEvtData";
|
|---|
| 109 | fTitle = title ? title : "Raw Event Data Information";
|
|---|
| 110 |
|
|---|
| 111 | InitArrays();
|
|---|
| 112 | }
|
|---|
| 113 |
|
|---|
| 114 | // --------------------------------------------------------------------------
|
|---|
| 115 | //
|
|---|
| 116 | // Destructor. Deletes all the arrays.
|
|---|
| 117 | //
|
|---|
| 118 | MRawEvtData::~MRawEvtData()
|
|---|
| 119 | {
|
|---|
| 120 | DeleteArrays();
|
|---|
| 121 | }
|
|---|
| 122 |
|
|---|
| 123 | // --------------------------------------------------------------------------
|
|---|
| 124 | //
|
|---|
| 125 | // reset all arrays
|
|---|
| 126 | //
|
|---|
| 127 | void MRawEvtData::Clear(Option_t *)
|
|---|
| 128 | {
|
|---|
| 129 | /*
|
|---|
| 130 | FIXME:
|
|---|
| 131 | Is Reset (set all entries to zero) what you want to do
|
|---|
| 132 | or Set(0) (delete the array)
|
|---|
| 133 | */
|
|---|
| 134 | fHiGainPixId->Reset();
|
|---|
| 135 | fLoGainPixId->Reset();
|
|---|
| 136 | fHiGainFadcSamples->Reset();
|
|---|
| 137 | fLoGainFadcSamples->Reset();
|
|---|
| 138 | fABFlags->Reset();
|
|---|
| 139 | }
|
|---|
| 140 |
|
|---|
| 141 | // --------------------------------------------------------------------------
|
|---|
| 142 | //
|
|---|
| 143 | // return the number of hi gain samples per pixel
|
|---|
| 144 | //
|
|---|
| 145 | UShort_t MRawEvtData::GetNumHiGainSamples() const
|
|---|
| 146 | {
|
|---|
| 147 | // If value<0 we are reading old MC files which don't have the
|
|---|
| 148 | // value set so far. So we use the old methid to determin the
|
|---|
| 149 | // numbers and calculate them from the length of the arrays.
|
|---|
| 150 | return fHiGainPixId->GetSize() ? fHiGainFadcSamples->GetSize()/fHiGainPixId->GetSize() : 0;
|
|---|
| 151 | }
|
|---|
| 152 |
|
|---|
| 153 | // --------------------------------------------------------------------------
|
|---|
| 154 | //
|
|---|
| 155 | // return the number of lo gain samples per pixel
|
|---|
| 156 | //
|
|---|
| 157 | UShort_t MRawEvtData::GetNumLoGainSamples() const
|
|---|
| 158 | {
|
|---|
| 159 | // If value<0 we are reading old MC files which don't have the
|
|---|
| 160 | // value set so far. So we use the old methid to determin the
|
|---|
| 161 | // numbers and calculate them from the length of the arrays.
|
|---|
| 162 | return fLoGainPixId->GetSize() ? fLoGainFadcSamples->GetSize()/fLoGainPixId->GetSize() : 0;
|
|---|
| 163 | }
|
|---|
| 164 |
|
|---|
| 165 | // --------------------------------------------------------------------------
|
|---|
| 166 | //
|
|---|
| 167 | // return the number of stored pixel
|
|---|
| 168 | //
|
|---|
| 169 | UShort_t MRawEvtData::GetNumPixels() const
|
|---|
| 170 | {
|
|---|
| 171 | return fHiGainPixId ? fHiGainPixId->GetSize() : 0;
|
|---|
| 172 | }
|
|---|
| 173 |
|
|---|
| 174 | // --------------------------------------------------------------------------
|
|---|
| 175 | //
|
|---|
| 176 | // Print out the onformation to *fLog.
|
|---|
| 177 | // Options:
|
|---|
| 178 | // "hex" Prints the time slices hexadecimal (default)
|
|---|
| 179 | // "dec" Prints the time slices decimal
|
|---|
| 180 | //
|
|---|
| 181 | void MRawEvtData::Print(Option_t *opt) const
|
|---|
| 182 | {
|
|---|
| 183 | //
|
|---|
| 184 | // print fadc inforation to screen
|
|---|
| 185 | // Possible Options:
|
|---|
| 186 | // - DEC: Print values decimal instead of hexadecimal (default)
|
|---|
| 187 | //
|
|---|
| 188 | const UShort_t nHiSamp = GetNumHiGainSamples();
|
|---|
| 189 | const UShort_t nLoSamp = GetNumLoGainSamples();
|
|---|
| 190 |
|
|---|
| 191 | fLog->unsetf(ios::showbase);
|
|---|
| 192 |
|
|---|
| 193 | *fLog << dec << all;
|
|---|
| 194 | *fLog << GetDescriptor() << ": " << endl;
|
|---|
| 195 | *fLog << GetNumPixels() << " Pixels with " << (Int_t)nHiSamp << "/" << (Int_t)nLoSamp << " samples" << endl;
|
|---|
| 196 |
|
|---|
| 197 | TString str(opt);
|
|---|
| 198 | Int_t manip = str.Contains("dec", TString::kIgnoreCase);
|
|---|
| 199 |
|
|---|
| 200 | MRawEvtPixelIter pixel(const_cast<MRawEvtData*>(this));
|
|---|
| 201 | Int_t i = 0;
|
|---|
| 202 | while (pixel.Next())
|
|---|
| 203 | {
|
|---|
| 204 | const UShort_t idx = pixel.GetPixelId();
|
|---|
| 205 |
|
|---|
| 206 | *fLog << endl << dec << setfill(' ');
|
|---|
| 207 | *fLog << " " << setw(3) << i++ << " - " << setw(3) << idx << " ";
|
|---|
| 208 |
|
|---|
| 209 | if (pixel.IsABFlagValid())
|
|---|
| 210 | *fLog << "<" << (pixel.HasABFlag()?"B":"A") << "> ";
|
|---|
| 211 |
|
|---|
| 212 | *fLog << (manip?dec:hex) << setfill(manip?' ':'0');
|
|---|
| 213 |
|
|---|
| 214 | const Byte_t *hi = pixel.GetHiGainSamples();
|
|---|
| 215 | const Byte_t *lo = pixel.GetLoGainSamples();
|
|---|
| 216 |
|
|---|
| 217 | for (int j=0; j<nHiSamp; j++)
|
|---|
| 218 | {
|
|---|
| 219 | *fLog << setw(manip?3:2);
|
|---|
| 220 | *fLog << ((UShort_t)hi[j]&0xff);
|
|---|
| 221 | if (manip)
|
|---|
| 222 | *fLog << ' ';
|
|---|
| 223 | }
|
|---|
| 224 |
|
|---|
| 225 | for (int j=0; j<nLoSamp; j++)
|
|---|
| 226 | {
|
|---|
| 227 | *fLog << setw(manip?3:2);
|
|---|
| 228 | *fLog << ((UShort_t)lo[j]&0xff);
|
|---|
| 229 | if (manip)
|
|---|
| 230 | *fLog << ' ';
|
|---|
| 231 | }
|
|---|
| 232 | }
|
|---|
| 233 | *fLog << dec << endl;
|
|---|
| 234 | }
|
|---|
| 235 |
|
|---|
| 236 | // --------------------------------------------------------------------------
|
|---|
| 237 | //
|
|---|
| 238 | // Draw a pixel. A Histogram or Graph is created and it's draw function is
|
|---|
| 239 | // called.
|
|---|
| 240 | // Options:
|
|---|
| 241 | // "GRAPH" A graph is drawn
|
|---|
| 242 | // "HIST" A histogram is drawn
|
|---|
| 243 | // <index> The pixel with the given index is drawn
|
|---|
| 244 | //
|
|---|
| 245 | void MRawEvtData::Draw(Option_t *opt)
|
|---|
| 246 | {
|
|---|
| 247 | if (GetNumPixels()==0)
|
|---|
| 248 | {
|
|---|
| 249 | *fLog << warn << "Sorry, no pixel to draw!" << endl;
|
|---|
| 250 | return;
|
|---|
| 251 | }
|
|---|
| 252 |
|
|---|
| 253 | TString str(opt);
|
|---|
| 254 | str.ToLower();
|
|---|
| 255 |
|
|---|
| 256 | UInt_t id = 0;
|
|---|
| 257 |
|
|---|
| 258 | if (str.BeginsWith("graph"))
|
|---|
| 259 | if (str.Length()>5)
|
|---|
| 260 | sscanf(&str[5], "%d", &id);
|
|---|
| 261 | if (str.BeginsWith("hist"))
|
|---|
| 262 | if (str.Length()>4)
|
|---|
| 263 | sscanf(&str[4], "%d", &id);
|
|---|
| 264 |
|
|---|
| 265 | MRawEvtPixelIter pix(this);
|
|---|
| 266 | if (!pix.Jump(id))
|
|---|
| 267 | {
|
|---|
| 268 | *fLog << warn << dec << "Pixel Idx #" << id << " doesn't exist!" << endl;
|
|---|
| 269 | return;
|
|---|
| 270 | }
|
|---|
| 271 |
|
|---|
| 272 | const Byte_t *higains = pix.GetHiGainSamples();
|
|---|
| 273 | const Byte_t *logains = pix.GetLoGainSamples();
|
|---|
| 274 |
|
|---|
| 275 | const Int_t nh = GetNumHiGainSamples();
|
|---|
| 276 | const Int_t nl = GetNumLoGainSamples();
|
|---|
| 277 |
|
|---|
| 278 | TString name = "Pixel Idx.";
|
|---|
| 279 | name += pix.GetPixelId();
|
|---|
| 280 |
|
|---|
| 281 | Bool_t same = str.Contains("same");
|
|---|
| 282 |
|
|---|
| 283 | if (str.BeginsWith("graph"))
|
|---|
| 284 | {
|
|---|
| 285 | *fLog << inf << "Drawing Graph: Pixel Idx #" << dec << pix.GetPixelId();
|
|---|
| 286 | *fLog << " of " << (int)GetNumPixels() << "Pixels" << endl;
|
|---|
| 287 |
|
|---|
| 288 | TGraph *graphhi = new TGraph;
|
|---|
| 289 |
|
|---|
| 290 | for (int i=0; i<nh; i++)
|
|---|
| 291 | graphhi->SetPoint(graphhi->GetN(), i, higains[i]);
|
|---|
| 292 | for (int i=0; i<nl; i++)
|
|---|
| 293 | graphhi->SetPoint(graphhi->GetN(), i+nh, logains[i]);
|
|---|
| 294 |
|
|---|
| 295 | graphhi->SetMaximum(256);
|
|---|
| 296 | graphhi->SetMinimum(0);
|
|---|
| 297 |
|
|---|
| 298 | graphhi->SetBit(kCanDelete);
|
|---|
| 299 | graphhi->Draw(same ? "C*" : "AC*");
|
|---|
| 300 |
|
|---|
| 301 | TH1F *histhi = graphhi->GetHistogram();
|
|---|
| 302 | histhi->SetMinimum(0);
|
|---|
| 303 | histhi->SetMaximum(255);
|
|---|
| 304 |
|
|---|
| 305 | histhi->SetXTitle("Time/FADC Slices");
|
|---|
| 306 | histhi->SetYTitle("Signal/FADC Units");
|
|---|
| 307 |
|
|---|
| 308 | return;
|
|---|
| 309 | }
|
|---|
| 310 |
|
|---|
| 311 | if (str.BeginsWith("hist"))
|
|---|
| 312 | {
|
|---|
| 313 | // FIXME: Add Legend
|
|---|
| 314 | *fLog << inf << "Drawing Histogram of Pixel with Idx #" << dec << pix.GetPixelId() << " to " << gPad << endl;
|
|---|
| 315 |
|
|---|
| 316 | TH1F *histh = new TH1F(name, "FADC Samples", nh, -0.5, nh-.5);
|
|---|
| 317 | histh->SetMinimum(0);
|
|---|
| 318 | histh->SetMaximum(255);
|
|---|
| 319 | histh->SetXTitle("Time [FADC Slices]");
|
|---|
| 320 | histh->SetYTitle("Signal [FADC Units]");
|
|---|
| 321 | histh->SetDirectory(NULL);
|
|---|
| 322 | for (int i=0; i<nh; i++)
|
|---|
| 323 | histh->Fill(i, higains[i]);
|
|---|
| 324 | for (int i=0; i<nl; i++)
|
|---|
| 325 | histh->Fill(i, logains[i]);
|
|---|
| 326 | histh->SetBit(kCanDelete);
|
|---|
| 327 | histh->Draw(same ? "same" : "");
|
|---|
| 328 |
|
|---|
| 329 | return;
|
|---|
| 330 | }
|
|---|
| 331 |
|
|---|
| 332 | *fLog << warn << dbginf << "Warning - You must specify either 'GRAPH' or 'HIST'" << endl;
|
|---|
| 333 | }
|
|---|
| 334 |
|
|---|
| 335 | // --------------------------------------------------------------------------
|
|---|
| 336 | //
|
|---|
| 337 | // Deletes all the arrays
|
|---|
| 338 | // The flag is for future usage.
|
|---|
| 339 | //
|
|---|
| 340 | void MRawEvtData::InitArrays(UShort_t numconnected, UShort_t maxid)
|
|---|
| 341 | {
|
|---|
| 342 | // fRunHeader should not be set only in the constructor!
|
|---|
| 343 | const Int_t numhi = fRunHeader ? fRunHeader->GetNumSamplesHiGain() : -1;
|
|---|
| 344 | const Int_t numlo = fRunHeader ? fRunHeader->GetNumSamplesLoGain() : -1;
|
|---|
| 345 |
|
|---|
| 346 | fHiGainPixId = new MArrayS(numconnected);
|
|---|
| 347 | fLoGainPixId = new MArrayS(0);
|
|---|
| 348 | fHiGainFadcSamples = new MArrayB(numconnected*(numhi+numlo));
|
|---|
| 349 | fLoGainFadcSamples = new MArrayB(0);
|
|---|
| 350 |
|
|---|
| 351 | fABFlags = new MArrayB(maxid==0 ? 0 : maxid/8+1);
|
|---|
| 352 |
|
|---|
| 353 | fConnectedPixels = 0;
|
|---|
| 354 | }
|
|---|
| 355 |
|
|---|
| 356 | // --------------------------------------------------------------------------
|
|---|
| 357 | //
|
|---|
| 358 | // Deletes all the arrays
|
|---|
| 359 | //
|
|---|
| 360 | void MRawEvtData::DeleteArrays()
|
|---|
| 361 | {
|
|---|
| 362 | delete fHiGainPixId;
|
|---|
| 363 | delete fLoGainPixId;
|
|---|
| 364 | delete fHiGainFadcSamples;
|
|---|
| 365 | delete fLoGainFadcSamples;
|
|---|
| 366 | delete fABFlags;
|
|---|
| 367 | }
|
|---|
| 368 |
|
|---|
| 369 | // --------------------------------------------------------------------------
|
|---|
| 370 | //
|
|---|
| 371 | // Deletes all arrays describing the pixel Id and Samples in pixels.
|
|---|
| 372 | // The flag is for future usage.
|
|---|
| 373 | //
|
|---|
| 374 | void MRawEvtData::ResetPixels(UShort_t numconnected, UShort_t maxid)
|
|---|
| 375 | {
|
|---|
| 376 | //const int npix = fRunHeader->GetNumCrates()*fRunHeader->GetNumPixInCrate();
|
|---|
| 377 | if (fHiGainPixId && fHiGainPixId->GetSize()==numconnected && (UShort_t)fABFlags->GetSize()==(maxid/8+1))
|
|---|
| 378 | {
|
|---|
| 379 | fConnectedPixels = 0;
|
|---|
| 380 | return;
|
|---|
| 381 | }
|
|---|
| 382 |
|
|---|
| 383 | DeleteArrays();
|
|---|
| 384 | InitArrays(numconnected, maxid);
|
|---|
| 385 | }
|
|---|
| 386 |
|
|---|
| 387 | // --------------------------------------------------------------------------
|
|---|
| 388 | //
|
|---|
| 389 | // This is to fill the data of one pixel to the MRawEvtHeader Class.
|
|---|
| 390 | // The parameters are the pixelnumber and the FADC_SLICES values of ADCs
|
|---|
| 391 | //
|
|---|
| 392 | void MRawEvtData::AddPixel(UShort_t nOfPixel, TArrayC *data)
|
|---|
| 393 | {
|
|---|
| 394 | const Int_t n = fRunHeader->GetNumSamples();
|
|---|
| 395 | if (data->GetSize()!=n)
|
|---|
| 396 | {
|
|---|
| 397 | *fLog << err << "RawEvtData::AddPixel: Error, number of samples in ";
|
|---|
| 398 | *fLog << "TArrayC " << data->GetSize() << " doesn't match current number " << n << endl;
|
|---|
| 399 | return;
|
|---|
| 400 | }
|
|---|
| 401 |
|
|---|
| 402 | //
|
|---|
| 403 | // enhance pixel array by one
|
|---|
| 404 | //
|
|---|
| 405 | fHiGainPixId->Set(fHiGainPixId->GetSize()+1);
|
|---|
| 406 |
|
|---|
| 407 | //
|
|---|
| 408 | // add the number of the new pixel to the array as last entry
|
|---|
| 409 | //
|
|---|
| 410 | fHiGainPixId->AddAt(nOfPixel, fHiGainPixId->GetSize()-1);
|
|---|
| 411 |
|
|---|
| 412 | //
|
|---|
| 413 | // enhance the array by the number of new samples
|
|---|
| 414 | //
|
|---|
| 415 | fHiGainFadcSamples->Set(fHiGainFadcSamples->GetSize()+n);
|
|---|
| 416 |
|
|---|
| 417 | //
|
|---|
| 418 | // add the new slices as last entries to array
|
|---|
| 419 | //
|
|---|
| 420 | fHiGainFadcSamples->AddAt((Byte_t*)data->GetArray(), fHiGainFadcSamples->GetSize()-n, n);
|
|---|
| 421 | }
|
|---|
| 422 | /*
|
|---|
| 423 | void MRawEvtData::AddPixel(UShort_t nOfPixel, TArrayC *data, Bool_t lflag)
|
|---|
| 424 | {
|
|---|
| 425 | MArrayS *arrpix = lflag ? fLoGainPixId : fHiGainPixId;
|
|---|
| 426 | MArrayB *arrsam = lflag ? fLoGainFadcSamples : fHiGainFadcSamples;
|
|---|
| 427 |
|
|---|
| 428 | //
|
|---|
| 429 | // check whether we got the right number of new samples
|
|---|
| 430 | // if there are no samples already stored: this is the new number of samples
|
|---|
| 431 | //
|
|---|
| 432 | const UShort_t ns = data->GetSize();
|
|---|
| 433 | const UShort_t nSamp = lflag ? GetNumLoGainSamples() : GetNumHiGainSamples();
|
|---|
| 434 | if (nSamp && ns!=nSamp)
|
|---|
| 435 | {
|
|---|
| 436 | *fLog << err << "RawEvtData::AddPixel: Error, number of samples in ";
|
|---|
| 437 | *fLog << "TArrayC " << ns << " doesn't match current number " << nSamp << endl;
|
|---|
| 438 | return;
|
|---|
| 439 | }
|
|---|
| 440 |
|
|---|
| 441 | //
|
|---|
| 442 | // enhance pixel array by one
|
|---|
| 443 | //
|
|---|
| 444 | arrpix->Set(arrpix->GetSize()+1);
|
|---|
| 445 |
|
|---|
| 446 | //
|
|---|
| 447 | // add the number of the new pixel to the array as last entry
|
|---|
| 448 | //
|
|---|
| 449 | arrpix->AddAt(nOfPixel, arrpix->GetSize()-1);
|
|---|
| 450 |
|
|---|
| 451 | //
|
|---|
| 452 | // enhance the array by the number of new samples
|
|---|
| 453 | //
|
|---|
| 454 | arrsam->Set(arrsam->GetSize()+ns);
|
|---|
| 455 |
|
|---|
| 456 | //
|
|---|
| 457 | // add the new slices as last entries to array
|
|---|
| 458 | //
|
|---|
| 459 | arrsam->AddAt((Byte_t*)data->GetArray(), arrsam->GetSize()-ns, ns);
|
|---|
| 460 | }
|
|---|
| 461 | */
|
|---|
| 462 |
|
|---|
| 463 | void MRawEvtData::ReadPixel(istream &fin, Int_t npix)
|
|---|
| 464 | {
|
|---|
| 465 | // number of samples
|
|---|
| 466 | const UInt_t ns = fRunHeader->GetNumSamples();
|
|---|
| 467 |
|
|---|
| 468 | // position in higain array
|
|---|
| 469 | Byte_t *pos = fHiGainFadcSamples->GetArray() + fConnectedPixels*ns;
|
|---|
| 470 |
|
|---|
| 471 | // bytes per sample
|
|---|
| 472 | const Int_t bps = fRunHeader->GetNumBytesPerSample();
|
|---|
| 473 |
|
|---|
| 474 | // Number of bytes
|
|---|
| 475 | const Int_t nb = ns*bps;
|
|---|
| 476 |
|
|---|
| 477 | // Set pixel index
|
|---|
| 478 | fHiGainPixId->AddAt(npix, fConnectedPixels++);
|
|---|
| 479 |
|
|---|
| 480 | // Read data for one pixel
|
|---|
| 481 | if (bps==1)
|
|---|
| 482 | {
|
|---|
| 483 | fin.read((char*)pos, nb);
|
|---|
| 484 | return;
|
|---|
| 485 | }
|
|---|
| 486 |
|
|---|
| 487 | // Read data for one pixel
|
|---|
| 488 | Byte_t arr[nb];
|
|---|
| 489 | fin.read((char*)arr, nb);
|
|---|
| 490 |
|
|---|
| 491 | for (Byte_t *p=arr+bps-1; p<arr+nb; p+=bps)
|
|---|
| 492 | *pos++ = *p;
|
|---|
| 493 | }
|
|---|
| 494 |
|
|---|
| 495 | void MRawEvtData::SetABFlag(Int_t npix, Bool_t ab)
|
|---|
| 496 | {
|
|---|
| 497 | if (ab)
|
|---|
| 498 | SETBIT((*fABFlags)[npix/8], npix%8);
|
|---|
| 499 | else
|
|---|
| 500 | CLRBIT((*fABFlags)[npix/8], npix%8);
|
|---|
| 501 | }
|
|---|
| 502 |
|
|---|
| 503 | // --------------------------------------------------------------------------
|
|---|
| 504 | //
|
|---|
| 505 | // Fills members with information from a magic binary file.
|
|---|
| 506 | // WARNING: you have to use Init() before you can do this
|
|---|
| 507 | //
|
|---|
| 508 | /*
|
|---|
| 509 | void MRawEvtData::ReadEvt(istream &fin, Int_t posinarray)
|
|---|
| 510 | {
|
|---|
| 511 |
|
|---|
| 512 | const UShort_t npic = fRunHeader->GetNumPixInCrate();
|
|---|
| 513 |
|
|---|
| 514 | const UShort_t npos = npic*posinarray;
|
|---|
| 515 |
|
|---|
| 516 | //const Byte_t ab = fCrateArray->GetEntry(posinarray)->GetABFlags();
|
|---|
| 517 |
|
|---|
| 518 | for (int i=npos; i<npic+npos; i++)
|
|---|
| 519 | {
|
|---|
| 520 | // calc the spiral hardware pixel number
|
|---|
| 521 | const UShort_t ipos = i;
|
|---|
| 522 |
|
|---|
| 523 | // Get Hardware Id
|
|---|
| 524 | const Short_t hwid = fRunHeader->GetPixAssignment(ipos);
|
|---|
| 525 |
|
|---|
| 526 | // Check whether the pixel is connected or not
|
|---|
| 527 | if (hwid==0)
|
|---|
| 528 | {
|
|---|
| 529 | const UShort_t n = fRunHeader->GetNumSamplesLoGain()+fRunHeader->GetNumSamplesHiGain();
|
|---|
| 530 | fin.seekg(n, ios::cur);
|
|---|
| 531 | return;
|
|---|
| 532 | }
|
|---|
| 533 |
|
|---|
| 534 | // -1 converts the hardware pixel Id into the software pixel index
|
|---|
| 535 | const Int_t npix = (Int_t)hwid-1;
|
|---|
| 536 |
|
|---|
| 537 | const Byte_t ab = fCrateArray->GetEntry(posinarray)->GetABFlags();
|
|---|
| 538 | AddPixel(fin, npix, TESTBIT(ab, i-npos));
|
|---|
| 539 | }
|
|---|
| 540 | }
|
|---|
| 541 | */
|
|---|
| 542 |
|
|---|
| 543 | // --------------------------------------------------------------------------
|
|---|
| 544 | //
|
|---|
| 545 | // Return the size in bytes of one event data block
|
|---|
| 546 | //
|
|---|
| 547 | Int_t MRawEvtData::GetNumBytes() const
|
|---|
| 548 | {
|
|---|
| 549 | const UShort_t nlo = fRunHeader->GetNumSamplesLoGain();
|
|---|
| 550 | const UShort_t nhi = fRunHeader->GetNumSamplesHiGain();
|
|---|
| 551 | const UShort_t npic = fRunHeader->GetNumPixInCrate();
|
|---|
| 552 | const UShort_t nbps = fRunHeader->GetNumBytesPerSample();
|
|---|
| 553 |
|
|---|
| 554 | return (nhi+nlo)*npic*nbps;
|
|---|
| 555 | }
|
|---|
| 556 |
|
|---|
| 557 | // --------------------------------------------------------------------------
|
|---|
| 558 | //
|
|---|
| 559 | // Make sure, that you skip the whole event. This function only skips a part
|
|---|
| 560 | // of the event - see MRawRead::SkipEvent
|
|---|
| 561 | //
|
|---|
| 562 | void MRawEvtData::SkipEvt(istream &fin)
|
|---|
| 563 | {
|
|---|
| 564 | fin.seekg(GetNumBytes(), ios::cur);
|
|---|
| 565 | }
|
|---|
| 566 |
|
|---|
| 567 | Bool_t MRawEvtData::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
|
|---|
| 568 | {
|
|---|
| 569 | *fLog << warn << "WARNING - The use of MRawEvtData::GetPixelContent is deprecated!" << endl;
|
|---|
| 570 |
|
|---|
| 571 | /*
|
|---|
| 572 | MRawEvtPixelIter Next(const_cast<MRawEvtData*>(this));
|
|---|
| 573 | if (!Next.Jump(idx))
|
|---|
| 574 | return kFALSE;
|
|---|
| 575 |
|
|---|
| 576 | switch (type)
|
|---|
| 577 | {
|
|---|
| 578 | case 0:
|
|---|
| 579 | val = Next.GetSumHiGainSamples()-(float)GetNumHiGainSamples()*fHiGainFadcSamples->GetArray()[0];
|
|---|
| 580 | val*= cam.GetPixRatio(idx);
|
|---|
| 581 | break;
|
|---|
| 582 | case 1:
|
|---|
| 583 | val = Next.GetMaxHiGainSample();
|
|---|
| 584 | break;
|
|---|
| 585 | case 2:
|
|---|
| 586 | val = Next.GetMaxLoGainSample();
|
|---|
| 587 | break;
|
|---|
| 588 | case 3:
|
|---|
| 589 | val = Next.GetIdxMaxHiGainSample();
|
|---|
| 590 | break;
|
|---|
| 591 | case 4:
|
|---|
| 592 | val = Next.GetIdxMaxLoGainSample();
|
|---|
| 593 | break;
|
|---|
| 594 | case 5:
|
|---|
| 595 | val = Next.GetIdxMaxHiLoGainSample();
|
|---|
| 596 | return val >= 0;
|
|---|
| 597 | }
|
|---|
| 598 | */
|
|---|
| 599 | return kTRUE;
|
|---|
| 600 | }
|
|---|
| 601 |
|
|---|
| 602 | void MRawEvtData::Copy(TObject &named)
|
|---|
| 603 | #if ROOT_VERSION_CODE > ROOT_VERSION(3,04,01)
|
|---|
| 604 | const
|
|---|
| 605 | #endif
|
|---|
| 606 | {
|
|---|
| 607 | MRawEvtData &evt = (MRawEvtData &)named;
|
|---|
| 608 |
|
|---|
| 609 | *evt.fHiGainPixId = *fHiGainPixId;
|
|---|
| 610 | *evt.fLoGainPixId = *fLoGainPixId;
|
|---|
| 611 |
|
|---|
| 612 | *evt.fHiGainFadcSamples = *fHiGainFadcSamples;
|
|---|
| 613 | *evt.fLoGainFadcSamples = *fLoGainFadcSamples;
|
|---|
| 614 |
|
|---|
| 615 | *evt.fABFlags = *fABFlags;
|
|---|
| 616 |
|
|---|
| 617 | evt.fConnectedPixels = fConnectedPixels;
|
|---|
| 618 | }
|
|---|