Changeset 861 for trunk/MagicSoft
- Timestamp:
- 07/10/01 12:41:13 (23 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/macros/getThreshold.C
r855 r861 1 void getThreshold( char* filename = " data/oscar_protons.root")1 void getThreshold( char* filename = "/hdb1/users/jlopez/temp_loop.root") 2 2 { 3 3 // 4 // This macro fill the container M McEnerThreusing the task5 // MMc EnerThreCalc and shows the results.4 // This macro fill the container MHMcEnergies using the task 5 // MMcThresholdCalc and shows the results. 6 6 // 7 7 MParList parlist; … … 12 12 // 13 13 // Setup the parameter list 14 // - You need create the container M McEnerThre.14 // - You need create the container MHMcEnergies. 15 15 // + You need to put the number of trigger conditions when 16 16 // you declarete the MHMcEnergies … … 18 18 // taking only the trigger information from MMcTrig 19 19 // 20 const UInt_t numtriggerconditions = 1;20 const UInt_t numtriggerconditions = 5; 21 21 22 22 MHMcEnergies *hists = new MHMcEnergies(numtriggerconditions); … … 49 49 // Now you can display the results 50 50 // 51 for (UInt_t i=0; i<numtriggerconditions; i++) 51 for (UInt_t i=0; i<numtriggerconditions; i++) { 52 52 ((*hists)[i]).Draw(); 53 if (getchar()=='q') break; 54 } 53 55 } -
trunk/MagicSoft/Mars/mhist/MHMcEnergies.cc
r859 r861 23 23 \* ======================================================================== */ 24 24 25 ///////////////////////////////////////////////////////////////////////////// 26 // 27 // MHMcEnergies 28 // 29 // This class holds and array of MHMcEnergy objects in order to be able 30 // to compute the threshold for each of the different trigger conditions 31 // in a root file. 32 // 33 //////////////////////////////////////////////////////////////////////////// 25 34 #include "MHMcEnergies.h" 26 35 … … 30 39 ClassImp(MHMcEnergies); 31 40 41 // -------------------------------------------------------------------------- 42 // 43 // Default Constructor. 44 // 32 45 MHMcEnergies::MHMcEnergies(const UInt_t count, const char *name, const char *title) 33 46 : fNum(count) 34 47 { 35 //36 // default constructor37 //38 48 char aux[25]="MHMcEnergies"; 39 49 sprintf(aux+12, "[%i]", fNum); … … 48 58 } 49 59 60 // -------------------------------------------------------------------------- 61 // 62 // Default Destructor. 63 // 50 64 MHMcEnergies::~MHMcEnergies() 51 65 { 52 66 delete fHists; 53 67 } 54 68 // -------------------------------------------------------------------------- 69 // 70 // Add to the parameter list all the MHMcEnergy objects contained in the array. 71 // 55 72 void MHMcEnergies::AddEntriesToList(MParList *plist) 56 73 { -
trunk/MagicSoft/Mars/mhist/MHMcEnergies.h
r855 r861 20 20 { 21 21 private: 22 UInt_t fNum; 23 TClonesArray *fHists; // histograms22 UInt_t fNum; // Num of histograms 23 TClonesArray *fHists; // Array with the energy histograms 24 24 25 25 public: … … 36 36 37 37 #endif 38 -
trunk/MagicSoft/Mars/mhist/MHMcEnergy.cc
r859 r861 23 23 \* ======================================================================== */ 24 24 25 ///////////////////////////////////////////////////////////////////////////// 26 // 27 // MHMcEnergy 28 // 29 // This class holds the information ( histogram and fit function ) 30 // about the energy threshold for a particular trigger condition. 31 // 32 //////////////////////////////////////////////////////////////////////////// 25 33 #include "MHMcEnergy.h" 26 34 … … 34 42 ClassImp(MHMcEnergy); 35 43 44 // ------------------------------------------------------------------------- 45 // 46 // Default Constructor. 47 // 36 48 MHMcEnergy::MHMcEnergy(const UInt_t idx, const char *name, const char *title) 37 49 { 38 //39 // default constructor40 //41 50 char aux[15]="MHMcEnergy"; 42 51 … … 58 67 if (idx>0) 59 68 sprintf(aux+10, ";%i", idx); 60 hLogEner = new TH1F(aux, "", 100, 0.5, 4.5);69 hLogEner = new TH1F(aux, "", 40, 0.5, 4.5); 61 70 hLogEner->SetXTitle("log(E) [GeV]"); 62 71 hLogEner->SetYTitle("dN/dE"); 63 //hLogEner->SetBins(60);64 72 } 65 73 74 //------------------------------------------------------------------------- 75 // 76 // Defualt Destructor 77 // 66 78 MHMcEnergy::~MHMcEnergy() 67 79 { … … 70 82 } 71 83 84 //-------------------------------------------------------------------------- 85 // 86 // Fill the histogram with the log10 of the energy for triggered events. 87 // 72 88 void MHMcEnergy::Fill(Float_t log10E, Float_t w) 73 89 { … … 75 91 } 76 92 93 // ------------------------------------------------------------------------- 94 // 95 // Fitting function 96 // 77 97 void MHMcEnergy::Fit(Axis_t xxmin, Axis_t xxmax) 78 98 { 79 99 // 80 100 // 0: don't draw the function (it is drawn together with the histogram) 81 // +: add these function to the list of fits. Don't delete the last fit.101 // Q: quiet mode 82 102 // 83 // FIXME: R means: use the range specified in the function (xxmin, xxmax are ignored!) 84 // Q means: quiet (why?) 85 // 86 // 87 hLogEner->Fit(fLogEner->GetName(), "Q0+", "", xxmin, xxmax); 103 hLogEner->Fit(fLogEner->GetName(), "Q0", "", xxmin, xxmax); 88 104 } 89 105 106 // ------------------------------------------------------------------------ 107 // 108 // Drawing function. It creates its own canvas. 109 // 90 110 void MHMcEnergy::Draw(Option_t *option) 91 111 { … … 111 131 } 112 132 133 // -------------------------------------------------------------------------- 134 // 135 // Set the number of bins in the histogran. 136 // 137 void MHMcEnergy::SetBins(Int_t nbins) 138 { 139 hLogEner->SetBins(nbins,0.5,4.5); 140 } 141 // -------------------------------------------------------------------------- 142 // 143 // Write the threshold and its error in the standard output 144 // 113 145 void MHMcEnergy::Print(Option_t*) 114 146 { … … 116 148 } 117 149 150 // ------------------------------------------------------------------------- 151 // 152 // Return the threshold 153 // 118 154 Float_t MHMcEnergy::GetThreshold() const 119 155 { … … 123 159 } 124 160 161 // ------------------------------------------------------------------------- 162 // 163 // Return the error of the threshold. 164 // 125 165 Float_t MHMcEnergy::GetThresholdErr() const 126 166 { … … 129 169 const Float_t p1err = fLogEner->GetParError(1); 130 170 171 // The error has into accuont the error in the fit 131 172 return pow(10, p1) * p1err * lg10; 132 173 } 133 174 175 // ------------------------------------------------------------------------- 176 // 177 // Return the peak of the fitted gaussan function. 178 // 134 179 Float_t MHMcEnergy::GetGaussPeak() const 135 180 { … … 137 182 } 138 183 184 // ------------------------------------------------------------------------- 185 // 186 // Return the sigma of the fitted gaussan function. 187 // 139 188 Float_t MHMcEnergy::GetGaussSigma() const 140 189 { … … 142 191 } 143 192 193 194 195 -
trunk/MagicSoft/Mars/mhist/MHMcEnergy.h
r851 r861 32 32 void Fill(Float_t log10E, Float_t w); 33 33 void Fit(Axis_t xxmin, Axis_t xxmax); 34 void SetBins(Int_t nbins = 100); 34 35 35 36 void Draw(Option_t* option = ""); 36 37 void Print(Option_t* option = NULL); 37 38 38 ClassDef(MHMcEnergy, 1) // Histogram container for montecarlo energy 39 ClassDef(MHMcEnergy, 1) // Histogram container for montecarlo energy threshold 39 40 }; 40 41 -
trunk/MagicSoft/Mars/mmontecarlo/MMcThresholdCalc.cc
r859 r861 24 24 \* ======================================================================== */ 25 25 26 /////////////////////////////////////////////////////////////////////////// //27 // //28 // MMcThresholdCalc //29 // //30 // Input Containers: //31 // MMcEvt //32 // //33 // Output Containers: //34 // M McTrig;*, MHMcEnergy;* //35 // //26 /////////////////////////////////////////////////////////////////////////// 27 // 28 // MMcThresholdCalc 29 // 30 // Input Containers: 31 // MMcEvt, MMcTrig;* 32 // 33 // Output Containers: 34 // MHMcEnergies 35 // 36 36 ///////////////////////////////////////////////////////////////////////////// 37 37 … … 52 52 ClassImp(MMcThresholdCalc) 53 53 54 // -------------------------------------------------------------------------- 55 // 56 // Default Constructor. 57 // 54 58 MMcThresholdCalc::MMcThresholdCalc(const UInt_t dim, const char* name, 55 59 const char* title) : fDimension(dim) … … 58 62 *fTitle = title ? title : "Task to calculate the energy threshold from Monte Carlo"; 59 63 64 // Arrays of MMcTrig* and MHMcEnergy* are created in order to be 65 // able to work with root files with several trigger conditions. 60 66 fMcTrig = new MMcTrig*[fDimension]; 61 67 fHMcEnergy = new MHMcEnergy*[fDimension]; … … 66 72 } 67 73 74 // ------------------------------------------------------------------------- 75 // 76 // Default Destructor. 77 // 68 78 MMcThresholdCalc::~MMcThresholdCalc() 69 79 { … … 81 91 // connect Monte Carlo data with this task 82 92 93 // This task has into accout if the root file has one trigger 94 // condition (MMcTrig) or severl of them (MMcTrig;#.) 95 83 96 fMcEvt = (MMcEvt*)pList->FindObject("MMcEvt"); 84 97 if (!fMcEvt) … … 93 106 { 94 107 if (fDimension>1) 95 sprintf(auxname+7, ";%i ", i+1);108 sprintf(auxname+7, ";%i.", i+1); 96 109 97 110 fMcTrig[i] = (MMcTrig*)pList->FindObject(auxname); … … 110 123 for (unsigned int i=0; i<fDimension; i++) 111 124 { 112 if (fDimension>1 )113 sprintf(auxname+10, ";%i", i +1);125 if (fDimension>1&&i!=0) 126 sprintf(auxname+10, ";%i", i); 114 127 115 128 fHMcEnergy[i] = (MHMcEnergy*)pList->FindObject(auxname); … … 119 132 *fLog << dbginf << "'" << auxname << "' not found in list... creating." << endl; 120 133 121 fHMcEnergy[i] = new MHMcEnergy(fDimension>1 ? i+1: 0);134 fHMcEnergy[i] = new MHMcEnergy(fDimension>1&&i!=0 ? i : 0); 122 135 fMustDelete[i] = kTRUE; 123 136 pList->AddToList(fHMcEnergy[i]); … … 129 142 Bool_t MMcThresholdCalc::Process() 130 143 { 144 145 // The histograms are filled with log10 of the energy for triggered 146 // events and weighted with 1/E because it is needed the dN/dE vs. logE 147 // distribution to get the energy threshold. 148 131 149 const Float_t energy = fMcEvt->GetEnergy(); 132 150 const Float_t lg10 = log10(energy); … … 147 165 { 148 166 // fit the energy distribution to get the threshold 167 // Some iterations are done to be sure the fit parameters converge. 149 168 150 169 const Float_t sqrt2 = sqrt(2); … … 152 171 for (unsigned int i=0; i<fDimension; i++) 153 172 { 154 MHMcEnergy &h = *fHMcEnergy[i]; 173 Float_t peak; 174 Float_t sigma; 155 175 156 const Float_t peak = h.GetGaussPeak(); 157 const Float_t sigma = h.GetGaussSigma(); 158 159 h.Fit(1, 3); 160 h.Fit(peak - 2. *sigma, peak + 2. *sigma); 161 h.Fit(peak - sqrt2*sigma, peak + sqrt2*sigma); 176 fHMcEnergy[i]->Fit(1, 3); 177 178 peak = fHMcEnergy[i]->GetGaussPeak(); 179 sigma = fHMcEnergy[i]->GetGaussSigma(); 180 fHMcEnergy[i]->Fit(peak - 2. *sigma, peak + 2. *sigma); 181 182 peak = fHMcEnergy[i]->GetGaussPeak(); 183 sigma = fHMcEnergy[i]->GetGaussSigma(); 184 fHMcEnergy[i]->Fit(peak - sqrt2*sigma, peak + sqrt2*sigma); 162 185 } 163 186 return kTRUE; -
trunk/MagicSoft/Mars/mmontecarlo/MMcThresholdCalc.h
r859 r861 39 39 Bool_t PostProcess(); 40 40 41 ClassDef(MMcThresholdCalc, 0) // Task to fill the energy threshold information41 ClassDef(MMcThresholdCalc, 0) // Task to compute the energy threshold 42 42 }; 43 43
Note:
See TracChangeset
for help on using the changeset viewer.